2020-12-19 16:25:06 +03:00
|
|
|
/*
|
2022-04-25 19:54:06 +03:00
|
|
|
* Copyright (c) 2020-2022, Liav A. <liavalb@hotmail.co.il>
|
2022-02-09 21:33:39 +03:00
|
|
|
* Copyright (c) 2022, the SerenityOS developers.
|
2020-12-19 16:25:06 +03:00
|
|
|
*
|
2021-04-22 11:24:48 +03:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-12-19 16:25:06 +03:00
|
|
|
*/
|
|
|
|
|
2022-02-04 23:11:50 +03:00
|
|
|
#include <AK/IterationDecision.h>
|
2021-08-27 08:08:43 +03:00
|
|
|
#include <AK/Singleton.h>
|
2021-10-03 01:11:01 +03:00
|
|
|
#include <AK/StringView.h>
|
2020-12-31 14:17:03 +03:00
|
|
|
#include <AK/UUID.h>
|
Kernel/PCI: Simplify the entire subsystem
A couple of things were changed:
1. Semantic changes - PCI segments are now called PCI domains, to better
match what they are really. It's also the name that Linux gave, and it
seems that Wikipedia also uses this name.
We also remove PCI::ChangeableAddress, because it was used in the past
but now it's no longer being used.
2. There are no WindowedMMIOAccess or MMIOAccess classes anymore, as
they made a bunch of unnecessary complexity. Instead, Windowed access is
removed entirely (this was tested, but never was benchmarked), so we are
left with IO access and memory access options. The memory access option
is essentially mapping the PCI bus (from the chosen PCI domain), to
virtual memory as-is. This means that unless needed, at any time, there
is only one PCI bus being mapped, and this is changed if access to
another PCI bus in the same PCI domain is needed. For now, we don't
support mapping of different PCI buses from different PCI domains at the
same time, because basically it's still a non-issue for most machines
out there.
2. OOM-safety is increased, especially when constructing the Access
object. It means that we pre-allocating any needed resources, and we try
to find PCI domains (if requested to initialize memory access) after we
attempt to construct the Access object, so it's possible to fail at this
point "gracefully".
3. All PCI API functions are now separated into a different header file,
which means only "clients" of the PCI subsystem API will need to include
that header file.
4. Functional changes - we only allow now to enumerate the bus after
a hardware scan. This means that the old method "enumerate_hardware"
is removed, so, when initializing an Access object, the initializing
function must call rescan on it to force it to find devices. This makes
it possible to fail rescan, and also to defer it after construction from
both OOM-safety terms and hotplug capabilities.
2021-09-07 12:08:38 +03:00
|
|
|
#include <Kernel/Bus/PCI/API.h>
|
2021-06-25 09:46:17 +03:00
|
|
|
#include <Kernel/Bus/PCI/Access.h>
|
2022-01-15 10:17:07 +03:00
|
|
|
#include <Kernel/Bus/PCI/Controller/VolumeManagementDevice.h>
|
2021-01-24 20:20:23 +03:00
|
|
|
#include <Kernel/CommandLine.h>
|
2020-12-19 16:25:06 +03:00
|
|
|
#include <Kernel/Devices/BlockDevice.h>
|
2020-12-26 17:53:30 +03:00
|
|
|
#include <Kernel/FileSystem/Ext2FileSystem.h>
|
2021-02-14 11:30:31 +03:00
|
|
|
#include <Kernel/Panic.h>
|
2021-11-19 12:52:07 +03:00
|
|
|
#include <Kernel/Storage/ATA/AHCI/Controller.h>
|
|
|
|
#include <Kernel/Storage/ATA/GenericIDE/Controller.h>
|
|
|
|
#include <Kernel/Storage/ATA/GenericIDE/ISAController.h>
|
|
|
|
#include <Kernel/Storage/ATA/GenericIDE/PCIController.h>
|
2021-12-16 18:07:54 +03:00
|
|
|
#include <Kernel/Storage/NVMe/NVMeController.h>
|
2020-12-26 17:53:30 +03:00
|
|
|
#include <Kernel/Storage/Partition/EBRPartitionTable.h>
|
|
|
|
#include <Kernel/Storage/Partition/GUIDPartitionTable.h>
|
2022-03-19 12:55:55 +03:00
|
|
|
#include <Kernel/Storage/Ramdisk/Controller.h>
|
2020-12-19 16:25:06 +03:00
|
|
|
#include <Kernel/Storage/StorageManagement.h>
|
2022-03-02 03:42:06 +03:00
|
|
|
#include <LibPartition/MBRPartitionTable.h>
|
2020-12-19 16:25:06 +03:00
|
|
|
|
|
|
|
namespace Kernel {
|
|
|
|
|
2021-08-27 08:08:43 +03:00
|
|
|
static Singleton<StorageManagement> s_the;
|
2021-12-23 21:08:18 +03:00
|
|
|
static Atomic<u32> s_device_minor_number;
|
Kernel/Storage: Add LUN address to each StorageDevice
LUN address is essentially how people used to address SCSI devices back
in the day we had these devices more in use. However, SCSI was taken as
an abstraction layer for many Unix and Unix-like systems, so it still
common to see LUN addresses in use. In Serenity, we don't really provide
such abstraction layer, and therefore until now, we didn't use LUNs too.
However (again), this changes, as we want to let users to address their
devices under SysFS easily. LUNs make sense in that regard, because they
can be easily adapted to different interfaces besides SCSI.
For example, for legacy ATA hard drive being connected to the first IDE
controller which was enumerated on the PCI bus, and then to the primary
channel as slave device, the LUN address would be 0:0:1.
To make this happen, we add unique ID number to each StorageController,
which increments by 1 for each new instance of StorageController. Then,
we adapt the ATA and NVMe devices to use these numbers and generate LUN
in the construction time.
2022-04-22 18:52:20 +03:00
|
|
|
static Atomic<u32> s_controller_id;
|
2020-12-19 16:25:06 +03:00
|
|
|
|
2022-01-25 21:29:34 +03:00
|
|
|
static constexpr StringView partition_uuid_prefix = "PARTUUID:"sv;
|
2021-10-03 01:11:01 +03:00
|
|
|
|
2021-08-27 08:08:43 +03:00
|
|
|
UNMAP_AFTER_INIT StorageManagement::StorageManagement()
|
2020-12-19 16:25:06 +03:00
|
|
|
{
|
2021-08-27 08:08:43 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void StorageManagement::remove_device(StorageDevice& device)
|
|
|
|
{
|
|
|
|
m_storage_devices.remove(device);
|
2020-12-31 14:17:03 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
bool StorageManagement::boot_argument_contains_partition_uuid()
|
|
|
|
{
|
2021-10-03 01:11:01 +03:00
|
|
|
return m_boot_argument.starts_with(partition_uuid_prefix);
|
2020-12-19 16:25:06 +03:00
|
|
|
}
|
|
|
|
|
2022-01-21 17:18:31 +03:00
|
|
|
UNMAP_AFTER_INIT void StorageManagement::enumerate_pci_controllers(bool force_pio, bool nvme_poll)
|
2020-12-26 17:53:30 +03:00
|
|
|
{
|
2021-08-27 08:08:43 +03:00
|
|
|
VERIFY(m_controllers.is_empty());
|
2022-01-03 14:39:33 +03:00
|
|
|
|
|
|
|
using SubclassID = PCI::MassStorage::SubclassID;
|
2021-04-08 21:18:48 +03:00
|
|
|
if (!kernel_command_line().disable_physical_storage()) {
|
2022-01-03 14:39:33 +03:00
|
|
|
|
2022-02-04 23:11:50 +03:00
|
|
|
MUST(PCI::enumerate([&](PCI::DeviceIdentifier const& device_identifier) -> void {
|
2022-01-03 14:39:33 +03:00
|
|
|
if (device_identifier.class_code().value() != to_underlying(PCI::ClassID::MassStorage)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-01-15 10:17:07 +03:00
|
|
|
{
|
2022-02-09 21:33:39 +03:00
|
|
|
constexpr PCI::HardwareID vmd_device = { 0x8086, 0x9a0b };
|
2022-01-15 10:17:07 +03:00
|
|
|
if (device_identifier.hardware_id() == vmd_device) {
|
|
|
|
auto controller = PCI::VolumeManagementDevice::must_create(device_identifier);
|
2022-02-04 20:48:13 +03:00
|
|
|
MUST(PCI::Access::the().add_host_controller_and_enumerate_attached_devices(move(controller), [this, nvme_poll](PCI::DeviceIdentifier const& device_identifier) -> void {
|
2022-01-15 10:17:07 +03:00
|
|
|
auto subclass_code = static_cast<SubclassID>(device_identifier.subclass_code().value());
|
|
|
|
if (subclass_code == SubclassID::NVMeController) {
|
2022-01-27 14:14:58 +03:00
|
|
|
auto controller = NVMeController::try_initialize(device_identifier, nvme_poll);
|
2022-01-15 10:17:07 +03:00
|
|
|
if (controller.is_error()) {
|
|
|
|
dmesgln("Unable to initialize NVMe controller: {}", controller.error());
|
|
|
|
} else {
|
|
|
|
m_controllers.append(controller.release_value());
|
|
|
|
}
|
|
|
|
}
|
2022-02-04 20:48:13 +03:00
|
|
|
}));
|
2022-01-15 10:17:07 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-03 14:39:33 +03:00
|
|
|
auto subclass_code = static_cast<SubclassID>(device_identifier.subclass_code().value());
|
|
|
|
if (subclass_code == SubclassID::IDEController && kernel_command_line().is_ide_enabled()) {
|
2022-01-21 17:18:31 +03:00
|
|
|
m_controllers.append(PCIIDEController::initialize(device_identifier, force_pio));
|
2022-01-03 14:39:33 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (subclass_code == SubclassID::SATAController
|
2021-09-28 20:18:51 +03:00
|
|
|
&& device_identifier.prog_if().value() == to_underlying(PCI::MassStorage::SATAProgIF::AHCI)) {
|
2021-09-23 10:20:54 +03:00
|
|
|
m_controllers.append(AHCIController::initialize(device_identifier));
|
2021-01-24 20:20:23 +03:00
|
|
|
}
|
2022-01-03 14:39:33 +03:00
|
|
|
if (subclass_code == SubclassID::NVMeController) {
|
2022-01-27 14:14:58 +03:00
|
|
|
auto controller = NVMeController::try_initialize(device_identifier, nvme_poll);
|
2021-12-16 18:07:54 +03:00
|
|
|
if (controller.is_error()) {
|
2022-01-03 14:39:33 +03:00
|
|
|
dmesgln("Unable to initialize NVMe controller: {}", controller.error());
|
2021-12-16 18:07:54 +03:00
|
|
|
} else {
|
|
|
|
m_controllers.append(controller.release_value());
|
|
|
|
}
|
|
|
|
}
|
2022-02-04 20:48:13 +03:00
|
|
|
}));
|
2021-01-24 20:20:23 +03:00
|
|
|
}
|
2020-12-26 17:53:30 +03:00
|
|
|
}
|
|
|
|
|
2021-08-27 08:08:43 +03:00
|
|
|
UNMAP_AFTER_INIT void StorageManagement::enumerate_storage_devices()
|
2020-12-26 17:53:30 +03:00
|
|
|
{
|
2021-02-23 22:42:32 +03:00
|
|
|
VERIFY(!m_controllers.is_empty());
|
2020-12-26 17:53:30 +03:00
|
|
|
for (auto& controller : m_controllers) {
|
|
|
|
for (size_t device_index = 0; device_index < controller.devices_count(); device_index++) {
|
|
|
|
auto device = controller.device(device_index);
|
|
|
|
if (device.is_null())
|
|
|
|
continue;
|
2021-08-27 08:08:43 +03:00
|
|
|
m_storage_devices.append(device.release_nonnull());
|
2020-12-26 17:53:30 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-26 22:47:30 +03:00
|
|
|
UNMAP_AFTER_INIT void StorageManagement::dump_storage_devices_and_partitions() const
|
|
|
|
{
|
|
|
|
dbgln("StorageManagement: Detected {} storage devices", m_storage_devices.size_slow());
|
|
|
|
for (auto const& storage_device : m_storage_devices) {
|
|
|
|
auto const& partitions = storage_device.partitions();
|
|
|
|
if (partitions.is_empty()) {
|
|
|
|
dbgln(" Device: {} (no partitions)", storage_device.early_storage_name());
|
|
|
|
} else {
|
|
|
|
dbgln(" Device: {} ({} partitions)", storage_device.early_storage_name(), partitions.size());
|
|
|
|
unsigned partition_number = 1;
|
|
|
|
for (auto const& partition : partitions) {
|
|
|
|
dbgln(" Partition: {} (UUID {})", partition_number, partition.metadata().unique_guid().to_string());
|
|
|
|
partition_number++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-02 02:09:46 +03:00
|
|
|
UNMAP_AFTER_INIT ErrorOr<NonnullOwnPtr<Partition::PartitionTable>> StorageManagement::try_to_initialize_partition_table(StorageDevice const& device) const
|
2020-12-26 17:53:30 +03:00
|
|
|
{
|
2022-03-02 03:42:06 +03:00
|
|
|
auto mbr_table_or_error = Partition::MBRPartitionTable::try_to_initialize(device);
|
2022-04-25 19:54:06 +03:00
|
|
|
if (!mbr_table_or_error.is_error())
|
|
|
|
return mbr_table_or_error.release_value();
|
|
|
|
auto ebr_table_or_error = EBRPartitionTable::try_to_initialize(device);
|
|
|
|
if (!ebr_table_or_error.is_error()) {
|
|
|
|
return ebr_table_or_error.release_value();
|
2020-12-26 17:53:30 +03:00
|
|
|
}
|
2022-04-25 19:54:06 +03:00
|
|
|
return TRY(GUIDPartitionTable::try_to_initialize(device));
|
2020-12-26 17:53:30 +03:00
|
|
|
}
|
|
|
|
|
2022-01-03 13:58:38 +03:00
|
|
|
UNMAP_AFTER_INIT void StorageManagement::enumerate_disk_partitions()
|
2020-12-26 17:53:30 +03:00
|
|
|
{
|
2021-02-23 22:42:32 +03:00
|
|
|
VERIFY(!m_storage_devices.is_empty());
|
2020-12-26 17:53:30 +03:00
|
|
|
size_t device_index = 0;
|
|
|
|
for (auto& device : m_storage_devices) {
|
2022-04-25 19:54:06 +03:00
|
|
|
auto partition_table_or_error = try_to_initialize_partition_table(device);
|
|
|
|
if (partition_table_or_error.is_error())
|
2020-12-26 17:53:30 +03:00
|
|
|
continue;
|
2022-04-25 19:54:06 +03:00
|
|
|
auto partition_table = partition_table_or_error.release_value();
|
2020-12-26 17:53:30 +03:00
|
|
|
for (size_t partition_index = 0; partition_index < partition_table->partitions_count(); partition_index++) {
|
|
|
|
auto partition_metadata = partition_table->partition(partition_index);
|
|
|
|
if (!partition_metadata.has_value())
|
|
|
|
continue;
|
|
|
|
// FIXME: Try to not hardcode a maximum of 16 partitions per drive!
|
2022-01-03 13:58:38 +03:00
|
|
|
auto disk_partition = DiskPartition::create(device, (partition_index + (16 * device_index)), partition_metadata.value());
|
|
|
|
device.add_partition(disk_partition);
|
2020-12-26 17:53:30 +03:00
|
|
|
}
|
|
|
|
device_index++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-03 11:54:36 +03:00
|
|
|
UNMAP_AFTER_INIT void StorageManagement::determine_boot_device()
|
2020-12-19 16:25:06 +03:00
|
|
|
{
|
2021-02-23 22:42:32 +03:00
|
|
|
VERIFY(!m_controllers.is_empty());
|
2021-10-03 01:11:01 +03:00
|
|
|
if (m_boot_argument.starts_with("/dev/"sv)) {
|
2021-08-14 07:01:19 +03:00
|
|
|
StringView storage_name = m_boot_argument.substring_view(5);
|
|
|
|
for (auto& storage_device : m_storage_devices) {
|
2021-08-27 17:13:03 +03:00
|
|
|
if (storage_device.early_storage_name() == storage_name) {
|
2021-08-14 07:01:19 +03:00
|
|
|
m_boot_block_device = storage_device;
|
2021-11-27 10:10:10 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2022-01-02 02:12:44 +03:00
|
|
|
// If the early storage name's last character is a digit (e.g. in the case of NVMe where the last
|
|
|
|
// number in the device name indicates the node, e.g. /dev/nvme0n1 we need to append a "p" character
|
|
|
|
// so that we can properly distinguish the partition index from the device itself
|
|
|
|
char storage_name_last_char = *(storage_device.early_storage_name().end() - 1);
|
2022-01-13 01:20:42 +03:00
|
|
|
OwnPtr<KString> normalized_name;
|
|
|
|
StringView early_storage_name;
|
|
|
|
if (storage_name_last_char >= '0' && storage_name_last_char <= '9') {
|
|
|
|
normalized_name = MUST(KString::formatted("{}p", storage_device.early_storage_name()));
|
|
|
|
early_storage_name = normalized_name->view();
|
|
|
|
} else {
|
2022-01-02 02:12:44 +03:00
|
|
|
early_storage_name = storage_device.early_storage_name();
|
2022-01-13 01:20:42 +03:00
|
|
|
}
|
2022-01-02 02:12:44 +03:00
|
|
|
|
|
|
|
auto start_storage_name = storage_name.substring_view(0, min(early_storage_name.length(), storage_name.length()));
|
|
|
|
|
|
|
|
if (early_storage_name.starts_with(start_storage_name)) {
|
2021-11-27 10:10:10 +03:00
|
|
|
StringView partition_sign = storage_name.substring_view(start_storage_name.length());
|
|
|
|
auto possible_partition_number = partition_sign.to_uint<size_t>();
|
|
|
|
if (!possible_partition_number.has_value())
|
|
|
|
break;
|
|
|
|
if (possible_partition_number.value() == 0)
|
|
|
|
break;
|
|
|
|
if (storage_device.partitions().size() < possible_partition_number.value())
|
|
|
|
break;
|
|
|
|
m_boot_block_device = storage_device.partitions()[possible_partition_number.value() - 1];
|
|
|
|
break;
|
2021-01-21 20:50:19 +03:00
|
|
|
}
|
2021-08-14 07:01:19 +03:00
|
|
|
}
|
2020-12-19 16:25:06 +03:00
|
|
|
}
|
|
|
|
|
2021-01-21 20:50:19 +03:00
|
|
|
if (m_boot_block_device.is_null()) {
|
2022-01-26 22:47:30 +03:00
|
|
|
dump_storage_devices_and_partitions();
|
2021-02-14 11:30:31 +03:00
|
|
|
PANIC("StorageManagement: boot device {} not found", m_boot_argument);
|
2020-12-19 16:25:06 +03:00
|
|
|
}
|
2020-12-31 14:17:03 +03:00
|
|
|
}
|
|
|
|
|
2021-03-03 11:54:36 +03:00
|
|
|
UNMAP_AFTER_INIT void StorageManagement::determine_boot_device_with_partition_uuid()
|
2020-12-31 14:17:03 +03:00
|
|
|
{
|
2021-08-27 08:08:43 +03:00
|
|
|
VERIFY(!m_storage_devices.is_empty());
|
2021-10-03 01:11:01 +03:00
|
|
|
VERIFY(m_boot_argument.starts_with(partition_uuid_prefix));
|
2020-12-31 14:17:03 +03:00
|
|
|
|
2022-01-28 21:21:40 +03:00
|
|
|
auto partition_uuid = UUID(m_boot_argument.substring_view(partition_uuid_prefix.length()), UUID::Endianness::Mixed);
|
2020-12-31 14:17:03 +03:00
|
|
|
|
2021-08-27 08:08:43 +03:00
|
|
|
for (auto& storage_device : m_storage_devices) {
|
|
|
|
for (auto& partition : storage_device.partitions()) {
|
|
|
|
if (partition.metadata().unique_guid().is_zero())
|
|
|
|
continue;
|
|
|
|
if (partition.metadata().unique_guid() == partition_uuid) {
|
|
|
|
m_boot_block_device = partition;
|
|
|
|
break;
|
|
|
|
}
|
2020-12-31 14:17:03 +03:00
|
|
|
}
|
|
|
|
}
|
2020-12-19 16:25:06 +03:00
|
|
|
}
|
|
|
|
|
2020-12-31 14:17:03 +03:00
|
|
|
RefPtr<BlockDevice> StorageManagement::boot_block_device() const
|
2020-12-19 16:25:06 +03:00
|
|
|
{
|
2021-08-27 08:08:43 +03:00
|
|
|
return m_boot_block_device.strong_ref();
|
2020-12-26 17:53:30 +03:00
|
|
|
}
|
|
|
|
|
2021-12-23 21:08:18 +03:00
|
|
|
MajorNumber StorageManagement::storage_type_major_number()
|
2021-02-25 20:36:49 +03:00
|
|
|
{
|
|
|
|
return 3;
|
|
|
|
}
|
2021-12-23 21:08:18 +03:00
|
|
|
MinorNumber StorageManagement::generate_storage_minor_number()
|
2021-02-25 20:36:49 +03:00
|
|
|
{
|
2021-08-27 08:08:43 +03:00
|
|
|
auto minor_number = s_device_minor_number.load();
|
|
|
|
s_device_minor_number++;
|
|
|
|
return minor_number;
|
2021-02-25 20:36:49 +03:00
|
|
|
}
|
|
|
|
|
Kernel/Storage: Add LUN address to each StorageDevice
LUN address is essentially how people used to address SCSI devices back
in the day we had these devices more in use. However, SCSI was taken as
an abstraction layer for many Unix and Unix-like systems, so it still
common to see LUN addresses in use. In Serenity, we don't really provide
such abstraction layer, and therefore until now, we didn't use LUNs too.
However (again), this changes, as we want to let users to address their
devices under SysFS easily. LUNs make sense in that regard, because they
can be easily adapted to different interfaces besides SCSI.
For example, for legacy ATA hard drive being connected to the first IDE
controller which was enumerated on the PCI bus, and then to the primary
channel as slave device, the LUN address would be 0:0:1.
To make this happen, we add unique ID number to each StorageController,
which increments by 1 for each new instance of StorageController. Then,
we adapt the ATA and NVMe devices to use these numbers and generate LUN
in the construction time.
2022-04-22 18:52:20 +03:00
|
|
|
u32 StorageManagement::generate_controller_id()
|
|
|
|
{
|
|
|
|
auto controller_id = s_controller_id.load();
|
|
|
|
s_controller_id++;
|
|
|
|
return controller_id;
|
|
|
|
}
|
|
|
|
|
2021-07-11 01:20:38 +03:00
|
|
|
NonnullRefPtr<FileSystem> StorageManagement::root_filesystem() const
|
2020-12-26 17:53:30 +03:00
|
|
|
{
|
2020-09-17 22:51:09 +03:00
|
|
|
auto boot_device_description = boot_block_device();
|
|
|
|
if (!boot_device_description) {
|
2022-01-26 22:47:30 +03:00
|
|
|
dump_storage_devices_and_partitions();
|
2021-02-14 11:30:31 +03:00
|
|
|
PANIC("StorageManagement: Couldn't find a suitable device to boot from");
|
2020-12-31 14:17:03 +03:00
|
|
|
}
|
2021-09-07 14:39:11 +03:00
|
|
|
auto description_or_error = OpenFileDescription::try_create(boot_device_description.release_nonnull());
|
2021-09-04 13:46:19 +03:00
|
|
|
VERIFY(!description_or_error.is_error());
|
|
|
|
|
2021-09-06 12:14:25 +03:00
|
|
|
auto file_system = Ext2FS::try_create(description_or_error.release_value()).release_value();
|
2021-09-04 13:46:19 +03:00
|
|
|
|
|
|
|
if (auto result = file_system->initialize(); result.is_error()) {
|
2022-01-26 22:47:30 +03:00
|
|
|
dump_storage_devices_and_partitions();
|
2021-11-08 02:51:39 +03:00
|
|
|
PANIC("StorageManagement: Couldn't open root filesystem: {}", result.error());
|
2020-12-19 16:25:06 +03:00
|
|
|
}
|
2021-09-04 13:46:19 +03:00
|
|
|
return file_system;
|
2020-12-19 16:25:06 +03:00
|
|
|
}
|
|
|
|
|
2022-01-27 14:14:58 +03:00
|
|
|
UNMAP_AFTER_INIT void StorageManagement::initialize(StringView root_device, bool force_pio, bool poll)
|
2020-12-19 16:25:06 +03:00
|
|
|
{
|
2021-08-27 08:08:43 +03:00
|
|
|
VERIFY(s_device_minor_number == 0);
|
|
|
|
m_boot_argument = root_device;
|
2022-01-21 17:18:31 +03:00
|
|
|
if (PCI::Access::is_disabled()) {
|
|
|
|
// Note: If PCI is disabled, we assume that at least we have an ISA IDE controller
|
|
|
|
// to probe and use
|
|
|
|
m_controllers.append(ISAIDEController::initialize());
|
|
|
|
} else {
|
|
|
|
enumerate_pci_controllers(force_pio, poll);
|
|
|
|
}
|
|
|
|
// Note: Whether PCI bus is present on the system or not, always try to attach
|
|
|
|
// a given ramdisk.
|
|
|
|
m_controllers.append(RamdiskController::initialize());
|
2021-08-27 08:08:43 +03:00
|
|
|
enumerate_storage_devices();
|
|
|
|
enumerate_disk_partitions();
|
|
|
|
if (!boot_argument_contains_partition_uuid()) {
|
|
|
|
determine_boot_device();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
determine_boot_device_with_partition_uuid();
|
2020-12-19 16:25:06 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
StorageManagement& StorageManagement::the()
|
|
|
|
{
|
|
|
|
return *s_the;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|