mirror of
https://github.com/RGBCube/serenity
synced 2025-06-01 08:28:11 +00:00
Kernel/Devices: Ensure appropriate locking on the Device map singleton
Devices might be removed and inserted at anytime, so let's ensure we always do these kind of operations with a good known state of the HashMap. The VirtIO code was modified to create devices outside the IRQ handler, so now it works with the new locking of the devices singleton, but a better approach might be needed later on.
This commit is contained in:
parent
21b6d84ff0
commit
009feefee0
5 changed files with 57 additions and 37 deletions
|
@ -7,6 +7,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/Badge.h>
|
||||
#include <Kernel/Bus/VirtIO/Device.h>
|
||||
#include <Kernel/Devices/CharacterDevice.h>
|
||||
#include <Kernel/FileSystem/OpenFileDescription.h>
|
||||
|
@ -29,6 +30,8 @@ public:
|
|||
void set_open(Badge<VirtIO::Console>, bool state) { m_open = state; }
|
||||
bool is_open() const { return m_open; }
|
||||
|
||||
void init_receive_buffer(Badge<Console>);
|
||||
|
||||
private:
|
||||
constexpr static size_t RINGBUFFER_SIZE = 2 * PAGE_SIZE;
|
||||
|
||||
|
@ -40,8 +43,6 @@ private:
|
|||
virtual KResultOr<size_t> write(OpenFileDescription&, u64, const UserOrKernelBuffer&, size_t) override;
|
||||
virtual KResultOr<NonnullRefPtr<OpenFileDescription>> open(int options) override;
|
||||
|
||||
void init_receive_buffer();
|
||||
|
||||
static unsigned next_device_id;
|
||||
u16 m_receive_queue {};
|
||||
u16 m_transmit_queue {};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue