Kernel/Devices: Remove the DeviceManagement singleton

This change has many improvements:
- We don't use `LockRefPtr` to hold instances of many base devices as
  with the DeviceManagement class. Instead, we have a saner pattern of
  holding them in a `NonnullRefPtr<T> const`, in a small-text footprint
  class definition in the `Device.cpp` file.
- The awkwardness of using `::the()` each time we need to get references
  to mostly-static objects (like the Event queue) in runtime is now gone
  in the migration to using the `Device` class.
- Acquiring a device feel more obvious because we use now the Device
  class for this method. The method name is improved as well.
This commit is contained in:
Liav A.
2024-07-12 22:17:17 +03:00
committed by Tim Schumacher
parent b1f470f7fe
commit 96e1391c23
97 changed files with 327 additions and 389 deletions

View File

@@ -5,7 +5,7 @@
*/
#include <Kernel/API/DeviceFileTypes.h>
#include <Kernel/Devices/DeviceManagement.h>
#include <Kernel/Devices/Device.h>
#include <Kernel/Devices/Loop/LoopDevice.h>
#include <Kernel/FileSystem/DevLoopFS/FileSystem.h>
#include <Kernel/FileSystem/DevLoopFS/Inode.h>
@@ -58,7 +58,7 @@ ErrorOr<NonnullRefPtr<Inode>> DevLoopFS::get_inode(InodeIdentifier inode_id) con
return *m_root_inode;
unsigned loop_index = inode_index_to_loop_index(inode_id.index());
auto device = DeviceManagement::the().get_device(DeviceNodeType::Block, 20, loop_index);
auto device = Device::acquire_by_type_and_major_minor_numbers(DeviceNodeType::Block, 20, loop_index);
VERIFY(device);
auto& loop_device = static_cast<LoopDevice&>(*device);