diff options
author | Idan Horowitz <idan.horowitz@gmail.com> | 2022-01-26 22:03:48 +0200 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2022-01-26 22:07:01 +0000 |
commit | ac4583660b2c7da33ac13b4733f993767bb08644 (patch) | |
tree | 0571cdcdb26b1ca5987339616be32425b24d500f /Kernel/Bus/VirtIO/ConsolePort.h | |
parent | 94a39db31d94bb60e257a5649b6cf2a873c820fc (diff) | |
download | serenity-ac4583660b2c7da33ac13b4733f993767bb08644.zip |
Kernel: Make VirtIO::ConsolePort construction OOM-fallible
Diffstat (limited to 'Kernel/Bus/VirtIO/ConsolePort.h')
-rw-r--r-- | Kernel/Bus/VirtIO/ConsolePort.h | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/Kernel/Bus/VirtIO/ConsolePort.h b/Kernel/Bus/VirtIO/ConsolePort.h index 40797ab397..beed06e1a2 100644 --- a/Kernel/Bus/VirtIO/ConsolePort.h +++ b/Kernel/Bus/VirtIO/ConsolePort.h @@ -24,7 +24,8 @@ class Console; class ConsolePort : public CharacterDevice { public: - explicit ConsolePort(unsigned port, VirtIO::Console&); + static ErrorOr<NonnullRefPtr<ConsolePort>> try_create(unsigned port, VirtIO::Console&); + void handle_queue_update(Badge<VirtIO::Console>, u16 queue_index); void set_open(Badge<VirtIO::Console>, bool state) { m_open = state; } @@ -35,6 +36,8 @@ public: private: constexpr static size_t RINGBUFFER_SIZE = 2 * PAGE_SIZE; + ConsolePort(unsigned port, VirtIO::Console& console, NonnullOwnPtr<Memory::RingBuffer> receive_buffer, NonnullOwnPtr<Memory::RingBuffer> transmit_buffer); + virtual StringView class_name() const override { return "VirtIOConsolePort"sv; } virtual bool can_read(const OpenFileDescription&, u64) const override; @@ -47,8 +50,8 @@ private: u16 m_receive_queue {}; u16 m_transmit_queue {}; - OwnPtr<Memory::RingBuffer> m_receive_buffer; - OwnPtr<Memory::RingBuffer> m_transmit_buffer; + NonnullOwnPtr<Memory::RingBuffer> m_receive_buffer; + NonnullOwnPtr<Memory::RingBuffer> m_transmit_buffer; VirtIO::Console& m_console; unsigned m_port; |