mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 20:57:35 +00:00
Kernel: Try 5 times to find the root boot drive
This gives us enough time to discover more devices, such as USB drives
This commit is contained in:
parent
a390adcf35
commit
8993c43598
3 changed files with 18 additions and 18 deletions
|
@ -420,7 +420,13 @@ void init_stage2(void*)
|
|||
for (auto* init_function = driver_init_table_start; init_function != driver_init_table_end; init_function++)
|
||||
(*init_function)();
|
||||
|
||||
StorageManagement::the().initialize(kernel_command_line().root_device(), kernel_command_line().is_force_pio(), kernel_command_line().is_nvme_polling_enabled());
|
||||
StorageManagement::the().initialize(kernel_command_line().is_force_pio(), kernel_command_line().is_nvme_polling_enabled());
|
||||
for (int i = 0; i < 5; ++i) {
|
||||
if (StorageManagement::the().determine_boot_device(kernel_command_line().root_device()))
|
||||
break;
|
||||
dbgln_if(STORAGE_DEVICE_DEBUG, "Boot device {} not found, sleeping 2 seconds", kernel_command_line().root_device());
|
||||
(void)Thread::current()->sleep(Duration::from_seconds(2));
|
||||
}
|
||||
if (VirtualFileSystem::the().mount_root(StorageManagement::the().root_filesystem()).is_error()) {
|
||||
PANIC("VirtualFileSystem::mount_root failed");
|
||||
}
|
||||
|
|
|
@ -376,38 +376,39 @@ UNMAP_AFTER_INIT void StorageManagement::determine_boot_device_with_logical_unit
|
|||
resolve_partition_from_boot_device_parameter(*chosen_storage_device, logical_unit_number_device_prefix);
|
||||
}
|
||||
|
||||
UNMAP_AFTER_INIT void StorageManagement::determine_boot_device()
|
||||
UNMAP_AFTER_INIT bool StorageManagement::determine_boot_device(StringView boot_argument)
|
||||
{
|
||||
VERIFY(!m_controllers.is_empty());
|
||||
m_boot_argument = boot_argument;
|
||||
|
||||
if (m_boot_argument.starts_with(block_device_prefix)) {
|
||||
determine_block_boot_device();
|
||||
return;
|
||||
return m_boot_block_device;
|
||||
}
|
||||
|
||||
if (m_boot_argument.starts_with(partition_uuid_prefix)) {
|
||||
determine_boot_device_with_partition_uuid();
|
||||
return;
|
||||
return m_boot_block_device;
|
||||
}
|
||||
|
||||
if (m_boot_argument.starts_with(logical_unit_number_device_prefix)) {
|
||||
determine_boot_device_with_logical_unit_number();
|
||||
return;
|
||||
return m_boot_block_device;
|
||||
}
|
||||
|
||||
if (m_boot_argument.starts_with(ata_device_prefix)) {
|
||||
determine_ata_boot_device();
|
||||
return;
|
||||
return m_boot_block_device;
|
||||
}
|
||||
|
||||
if (m_boot_argument.starts_with(nvme_device_prefix)) {
|
||||
determine_nvme_boot_device();
|
||||
return;
|
||||
return m_boot_block_device;
|
||||
}
|
||||
|
||||
if (m_boot_argument.starts_with(sd_device_prefix)) {
|
||||
determine_sd_boot_device();
|
||||
return;
|
||||
return m_boot_block_device;
|
||||
}
|
||||
PANIC("StorageManagement: Invalid root boot parameter.");
|
||||
}
|
||||
|
@ -476,10 +477,9 @@ NonnullRefPtr<FileSystem> StorageManagement::root_filesystem() const
|
|||
return file_system;
|
||||
}
|
||||
|
||||
UNMAP_AFTER_INIT void StorageManagement::initialize(StringView root_device, bool force_pio, bool poll)
|
||||
UNMAP_AFTER_INIT void StorageManagement::initialize(bool force_pio, bool poll)
|
||||
{
|
||||
VERIFY(s_storage_device_minor_number == 0);
|
||||
m_boot_argument = root_device;
|
||||
if (PCI::Access::is_disabled()) {
|
||||
#if ARCH(X86_64)
|
||||
// Note: If PCI is disabled, we assume that at least we have an ISA IDE controller
|
||||
|
@ -502,12 +502,6 @@ UNMAP_AFTER_INIT void StorageManagement::initialize(StringView root_device, bool
|
|||
|
||||
enumerate_storage_devices();
|
||||
enumerate_disk_partitions();
|
||||
|
||||
determine_boot_device();
|
||||
if (m_boot_block_device.is_null()) {
|
||||
dump_storage_devices_and_partitions();
|
||||
PANIC("StorageManagement: boot device {} not found", m_boot_argument);
|
||||
}
|
||||
}
|
||||
|
||||
StorageManagement& StorageManagement::the()
|
||||
|
|
|
@ -24,9 +24,10 @@ class StorageManagement {
|
|||
|
||||
public:
|
||||
StorageManagement();
|
||||
void initialize(StringView boot_argument, bool force_pio, bool nvme_poll);
|
||||
void initialize(bool force_pio, bool nvme_poll);
|
||||
static StorageManagement& the();
|
||||
|
||||
bool determine_boot_device(StringView boot_argument);
|
||||
NonnullRefPtr<FileSystem> root_filesystem() const;
|
||||
|
||||
static MajorNumber storage_type_major_number();
|
||||
|
@ -49,7 +50,6 @@ private:
|
|||
ErrorOr<void> enumerate_device_partitions(StorageDevice&);
|
||||
void enumerate_disk_partitions();
|
||||
|
||||
void determine_boot_device();
|
||||
void determine_boot_device_with_partition_uuid();
|
||||
|
||||
void resolve_partition_from_boot_device_parameter(StorageDevice const& chosen_storage_device, StringView boot_device_prefix);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue