mirror of
https://github.com/RGBCube/serenity
synced 2025-07-23 09:07:41 +00:00
Kernel: Use global mechanism to determine minor number of Storage Device
This commit is contained in:
parent
566c10b8b8
commit
b59e45e65c
7 changed files with 31 additions and 8 deletions
|
@ -381,9 +381,9 @@ UNMAP_AFTER_INIT void IDEChannel::detect_disks()
|
||||||
dbgln("IDEChannel: {} {} device found: Type={}, Name={}, C/H/Spt={}/{}/{}, Capabilities=0x{:04x}", channel_type_string(), channel_string(i), interface_type == PATADiskDevice::InterfaceType::ATA ? "ATA" : "ATAPI", ((char*)bbuf.data() + 54), cyls, heads, spt, capabilities);
|
dbgln("IDEChannel: {} {} device found: Type={}, Name={}, C/H/Spt={}/{}/{}, Capabilities=0x{:04x}", channel_type_string(), channel_string(i), interface_type == PATADiskDevice::InterfaceType::ATA ? "ATA" : "ATAPI", ((char*)bbuf.data() + 54), cyls, heads, spt, capabilities);
|
||||||
|
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
m_master = PATADiskDevice::create(m_parent_controller, *this, PATADiskDevice::DriveType::Master, interface_type, cyls, heads, spt, capabilities, 3, (m_channel_type == ChannelType::Primary) ? 0 : 2);
|
m_master = PATADiskDevice::create(m_parent_controller, *this, PATADiskDevice::DriveType::Master, interface_type, cyls, heads, spt, capabilities);
|
||||||
} else {
|
} else {
|
||||||
m_slave = PATADiskDevice::create(m_parent_controller, *this, PATADiskDevice::DriveType::Slave, interface_type, cyls, heads, spt, capabilities, 3, (m_channel_type == ChannelType::Primary) ? 1 : 3);
|
m_slave = PATADiskDevice::create(m_parent_controller, *this, PATADiskDevice::DriveType::Slave, interface_type, cyls, heads, spt, capabilities);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,13 +33,13 @@
|
||||||
|
|
||||||
namespace Kernel {
|
namespace Kernel {
|
||||||
|
|
||||||
UNMAP_AFTER_INIT NonnullRefPtr<PATADiskDevice> PATADiskDevice::create(const IDEController& controller, IDEChannel& channel, DriveType type, InterfaceType interface_type, u16 cylinders, u16 heads, u16 spt, u16 capabilities, int major, int minor)
|
UNMAP_AFTER_INIT NonnullRefPtr<PATADiskDevice> PATADiskDevice::create(const IDEController& controller, IDEChannel& channel, DriveType type, InterfaceType interface_type, u16 cylinders, u16 heads, u16 spt, u16 capabilities)
|
||||||
{
|
{
|
||||||
return adopt(*new PATADiskDevice(controller, channel, type, interface_type, cylinders, heads, spt, capabilities, major, minor));
|
return adopt(*new PATADiskDevice(controller, channel, type, interface_type, cylinders, heads, spt, capabilities));
|
||||||
}
|
}
|
||||||
|
|
||||||
UNMAP_AFTER_INIT PATADiskDevice::PATADiskDevice(const IDEController& controller, IDEChannel& channel, DriveType type, InterfaceType interface_type, u16 cylinders, u16 heads, u16 spt, u16 capabilities, int major, int minor)
|
UNMAP_AFTER_INIT PATADiskDevice::PATADiskDevice(const IDEController& controller, IDEChannel& channel, DriveType type, InterfaceType interface_type, u16 cylinders, u16 heads, u16 spt, u16 capabilities)
|
||||||
: StorageDevice(controller, major, minor, 512, 0)
|
: StorageDevice(controller, 512, 0)
|
||||||
, m_cylinders(cylinders)
|
, m_cylinders(cylinders)
|
||||||
, m_heads(heads)
|
, m_heads(heads)
|
||||||
, m_sectors_per_track(spt)
|
, m_sectors_per_track(spt)
|
||||||
|
|
|
@ -57,7 +57,7 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static NonnullRefPtr<PATADiskDevice> create(const IDEController&, IDEChannel&, DriveType, InterfaceType, u16, u16, u16, u16, int major, int minor);
|
static NonnullRefPtr<PATADiskDevice> create(const IDEController&, IDEChannel&, DriveType, InterfaceType, u16, u16, u16, u16);
|
||||||
virtual ~PATADiskDevice() override;
|
virtual ~PATADiskDevice() override;
|
||||||
|
|
||||||
// ^StorageDevice
|
// ^StorageDevice
|
||||||
|
@ -69,7 +69,7 @@ public:
|
||||||
virtual String device_name() const override;
|
virtual String device_name() const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
PATADiskDevice(const IDEController&, IDEChannel&, DriveType, InterfaceType, u16, u16, u16, u16, int major, int minor);
|
PATADiskDevice(const IDEController&, IDEChannel&, DriveType, InterfaceType, u16, u16, u16, u16);
|
||||||
|
|
||||||
// ^DiskDevice
|
// ^DiskDevice
|
||||||
virtual const char* class_name() const override;
|
virtual const char* class_name() const override;
|
||||||
|
|
|
@ -29,9 +29,17 @@
|
||||||
#include <Kernel/Debug.h>
|
#include <Kernel/Debug.h>
|
||||||
#include <Kernel/FileSystem/FileDescription.h>
|
#include <Kernel/FileSystem/FileDescription.h>
|
||||||
#include <Kernel/Storage/StorageDevice.h>
|
#include <Kernel/Storage/StorageDevice.h>
|
||||||
|
#include <Kernel/Storage/StorageManagement.h>
|
||||||
|
|
||||||
namespace Kernel {
|
namespace Kernel {
|
||||||
|
|
||||||
|
StorageDevice::StorageDevice(const StorageController& controller, size_t sector_size, size_t max_addressable_block)
|
||||||
|
: BlockDevice(StorageManagement::major_number(), StorageManagement::minor_number(), sector_size)
|
||||||
|
, m_storage_controller(controller)
|
||||||
|
, m_max_addressable_block(max_addressable_block)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
StorageDevice::StorageDevice(const StorageController& controller, int major, int minor, size_t sector_size, size_t max_addressable_block)
|
StorageDevice::StorageDevice(const StorageController& controller, int major, int minor, size_t sector_size, size_t max_addressable_block)
|
||||||
: BlockDevice(major, minor, sector_size)
|
: BlockDevice(major, minor, sector_size)
|
||||||
, m_storage_controller(controller)
|
, m_storage_controller(controller)
|
||||||
|
|
|
@ -61,6 +61,7 @@ public:
|
||||||
virtual mode_t required_mode() const override { return 0600; }
|
virtual mode_t required_mode() const override { return 0600; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
StorageDevice(const StorageController&, size_t, size_t);
|
||||||
StorageDevice(const StorageController&, int, int, size_t, size_t);
|
StorageDevice(const StorageController&, int, int, size_t, size_t);
|
||||||
// ^DiskDevice
|
// ^DiskDevice
|
||||||
virtual const char* class_name() const override;
|
virtual const char* class_name() const override;
|
||||||
|
|
|
@ -40,6 +40,7 @@
|
||||||
namespace Kernel {
|
namespace Kernel {
|
||||||
|
|
||||||
static StorageManagement* s_the;
|
static StorageManagement* s_the;
|
||||||
|
static size_t s_device_minor_number;
|
||||||
|
|
||||||
UNMAP_AFTER_INIT StorageManagement::StorageManagement(String boot_argument, bool force_pio)
|
UNMAP_AFTER_INIT StorageManagement::StorageManagement(String boot_argument, bool force_pio)
|
||||||
: m_boot_argument(boot_argument)
|
: m_boot_argument(boot_argument)
|
||||||
|
@ -47,6 +48,7 @@ UNMAP_AFTER_INIT StorageManagement::StorageManagement(String boot_argument, bool
|
||||||
, m_storage_devices(enumerate_storage_devices())
|
, m_storage_devices(enumerate_storage_devices())
|
||||||
, m_disk_partitions(enumerate_disk_partitions())
|
, m_disk_partitions(enumerate_disk_partitions())
|
||||||
{
|
{
|
||||||
|
s_device_minor_number = 0;
|
||||||
if (!boot_argument_contains_partition_uuid()) {
|
if (!boot_argument_contains_partition_uuid()) {
|
||||||
determine_boot_device();
|
determine_boot_device();
|
||||||
return;
|
return;
|
||||||
|
@ -177,6 +179,15 @@ RefPtr<BlockDevice> StorageManagement::boot_block_device() const
|
||||||
return m_boot_block_device;
|
return m_boot_block_device;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int StorageManagement::major_number()
|
||||||
|
{
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
int StorageManagement::minor_number()
|
||||||
|
{
|
||||||
|
return s_device_minor_number++;
|
||||||
|
}
|
||||||
|
|
||||||
NonnullRefPtr<FS> StorageManagement::root_filesystem() const
|
NonnullRefPtr<FS> StorageManagement::root_filesystem() const
|
||||||
{
|
{
|
||||||
auto boot_device_description = boot_block_device();
|
auto boot_device_description = boot_block_device();
|
||||||
|
|
|
@ -48,6 +48,9 @@ public:
|
||||||
|
|
||||||
NonnullRefPtr<FS> root_filesystem() const;
|
NonnullRefPtr<FS> root_filesystem() const;
|
||||||
|
|
||||||
|
static int major_number();
|
||||||
|
static int minor_number();
|
||||||
|
|
||||||
NonnullRefPtrVector<StorageController> ide_controllers() const;
|
NonnullRefPtrVector<StorageController> ide_controllers() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue