1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 12:37:45 +00:00

Kernel: Don't use naked new statements in init process

Instead, try to create the device objects in separate static methods,
and if we fail for some odd reason to allocate memory for such devices,
just panic with that reason.
This commit is contained in:
Liav A 2021-06-18 11:37:26 +03:00 committed by Andreas Kling
parent fba3c77a04
commit 29f9a38f76
11 changed files with 74 additions and 18 deletions

View file

@ -11,15 +11,11 @@
namespace Kernel {
#define SERIAL_COM1_ADDR 0x3F8
#define SERIAL_COM2_ADDR 0x2F8
#define SERIAL_COM3_ADDR 0x3E8
#define SERIAL_COM4_ADDR 0x2E8
class SerialDevice final : public CharacterDevice {
AK_MAKE_ETERNAL
public:
SerialDevice(IOAddress base_addr, unsigned minor);
static NonnullRefPtr<SerialDevice> must_create(size_t com_number);
virtual ~SerialDevice() override;
// ^CharacterDevice
@ -113,6 +109,8 @@ public:
private:
friend class PCISerialDevice;
SerialDevice(IOAddress base_addr, unsigned minor);
// ^CharacterDevice
virtual const char* class_name() const override { return "SerialDevice"; }