2020-01-18 11:38:21 +03:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
|
|
|
*
|
2021-04-22 11:24:48 +03:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-01-18 11:38:21 +03:00
|
|
|
*/
|
|
|
|
|
2021-05-21 20:42:33 +03:00
|
|
|
#include <AK/StringBuilder.h>
|
2020-04-08 14:54:44 +03:00
|
|
|
#include <Kernel/CommandLine.h>
|
2021-03-03 11:51:55 +03:00
|
|
|
#include <Kernel/Panic.h>
|
2021-06-22 18:40:16 +03:00
|
|
|
#include <Kernel/Sections.h>
|
2020-08-25 04:35:27 +03:00
|
|
|
#include <Kernel/StdLib.h>
|
2019-06-04 13:54:27 +03:00
|
|
|
|
2020-04-08 14:54:44 +03:00
|
|
|
namespace Kernel {
|
2019-06-04 13:54:27 +03:00
|
|
|
|
2020-08-25 04:35:27 +03:00
|
|
|
static char s_cmd_line[1024];
|
2022-07-11 20:32:29 +03:00
|
|
|
static constexpr StringView s_embedded_cmd_line = ""sv;
|
2020-04-08 14:54:44 +03:00
|
|
|
static CommandLine* s_the;
|
|
|
|
|
2022-04-01 20:58:27 +03:00
|
|
|
UNMAP_AFTER_INIT void CommandLine::early_initialize(char const* cmd_line)
|
2020-08-25 04:35:27 +03:00
|
|
|
{
|
|
|
|
if (!cmd_line)
|
|
|
|
return;
|
|
|
|
size_t length = strlen(cmd_line);
|
|
|
|
if (length >= sizeof(s_cmd_line))
|
2020-09-18 10:49:51 +03:00
|
|
|
length = sizeof(s_cmd_line) - 1;
|
2020-08-25 04:35:27 +03:00
|
|
|
memcpy(s_cmd_line, cmd_line, length);
|
|
|
|
s_cmd_line[length] = '\0';
|
|
|
|
}
|
|
|
|
|
2022-01-21 12:36:32 +03:00
|
|
|
bool CommandLine::was_initialized()
|
|
|
|
{
|
|
|
|
return s_the != nullptr;
|
|
|
|
}
|
|
|
|
|
2022-04-01 20:58:27 +03:00
|
|
|
CommandLine const& kernel_command_line()
|
2019-06-04 13:54:27 +03:00
|
|
|
{
|
2021-02-23 22:42:32 +03:00
|
|
|
VERIFY(s_the);
|
2019-06-04 13:54:27 +03:00
|
|
|
return *s_the;
|
|
|
|
}
|
|
|
|
|
2021-02-19 23:29:46 +03:00
|
|
|
UNMAP_AFTER_INIT void CommandLine::initialize()
|
2020-04-08 14:54:44 +03:00
|
|
|
{
|
2021-02-23 22:42:32 +03:00
|
|
|
VERIFY(!s_the);
|
2022-07-11 22:53:29 +03:00
|
|
|
s_the = new CommandLine({ s_cmd_line, strlen(s_cmd_line) });
|
2021-05-21 20:12:29 +03:00
|
|
|
dmesgln("Kernel Commandline: {}", kernel_command_line().string());
|
2021-10-23 18:31:00 +03:00
|
|
|
// Validate the modes the user passed in.
|
|
|
|
(void)s_the->panic_mode(Validate::Yes);
|
2020-04-08 14:54:44 +03:00
|
|
|
}
|
|
|
|
|
2022-01-11 22:12:12 +03:00
|
|
|
UNMAP_AFTER_INIT NonnullOwnPtr<KString> CommandLine::build_commandline(StringView cmdline_from_bootloader)
|
2019-06-04 13:54:27 +03:00
|
|
|
{
|
2021-05-21 20:42:33 +03:00
|
|
|
StringBuilder builder;
|
|
|
|
builder.append(cmdline_from_bootloader);
|
2021-10-07 20:51:24 +03:00
|
|
|
if constexpr (!s_embedded_cmd_line.is_empty()) {
|
2022-07-11 23:10:18 +03:00
|
|
|
builder.append(' ');
|
2021-05-21 20:42:33 +03:00
|
|
|
builder.append(s_embedded_cmd_line);
|
|
|
|
}
|
2022-01-11 22:12:12 +03:00
|
|
|
return KString::must_create(builder.string_view());
|
2021-05-21 20:42:33 +03:00
|
|
|
}
|
2020-08-22 17:34:14 +03:00
|
|
|
|
2022-04-01 20:58:27 +03:00
|
|
|
UNMAP_AFTER_INIT void CommandLine::add_arguments(Vector<StringView> const& args)
|
2021-05-21 20:42:33 +03:00
|
|
|
{
|
2020-08-23 16:04:49 +03:00
|
|
|
for (auto&& str : args) {
|
2021-05-31 11:59:02 +03:00
|
|
|
if (str == ""sv) {
|
2019-06-04 14:55:52 +03:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2022-10-22 16:38:21 +03:00
|
|
|
auto pair = str.split_view('=');
|
2021-05-31 11:59:02 +03:00
|
|
|
VERIFY(pair.size() == 2 || pair.size() == 1);
|
2019-06-04 13:54:27 +03:00
|
|
|
|
|
|
|
if (pair.size() == 1) {
|
2021-12-29 02:42:39 +03:00
|
|
|
m_params.set(pair[0], ""sv);
|
2019-06-04 13:54:27 +03:00
|
|
|
} else {
|
2021-12-29 02:42:39 +03:00
|
|
|
m_params.set(pair[0], pair[1]);
|
2019-06-04 13:54:27 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-11 22:12:12 +03:00
|
|
|
UNMAP_AFTER_INIT CommandLine::CommandLine(StringView cmdline_from_bootloader)
|
|
|
|
: m_string(build_commandline(cmdline_from_bootloader))
|
2021-05-21 20:42:33 +03:00
|
|
|
{
|
|
|
|
s_the = this;
|
2022-04-01 20:58:27 +03:00
|
|
|
auto const& args = m_string->view().split_view(' ');
|
2022-12-06 09:15:46 +03:00
|
|
|
MUST(m_params.try_ensure_capacity(args.size()));
|
2021-05-21 20:42:33 +03:00
|
|
|
add_arguments(args);
|
|
|
|
}
|
|
|
|
|
2021-11-11 02:55:02 +03:00
|
|
|
Optional<StringView> CommandLine::lookup(StringView key) const
|
2020-04-08 17:35:00 +03:00
|
|
|
{
|
|
|
|
return m_params.get(key);
|
|
|
|
}
|
|
|
|
|
2021-11-11 02:55:02 +03:00
|
|
|
bool CommandLine::contains(StringView key) const
|
2019-06-04 13:54:27 +03:00
|
|
|
{
|
|
|
|
return m_params.contains(key);
|
|
|
|
}
|
2020-04-08 14:54:44 +03:00
|
|
|
|
2021-03-03 12:00:41 +03:00
|
|
|
UNMAP_AFTER_INIT bool CommandLine::is_boot_profiling_enabled() const
|
|
|
|
{
|
2021-05-31 11:59:02 +03:00
|
|
|
return contains("boot_prof"sv);
|
2021-03-03 12:00:41 +03:00
|
|
|
}
|
|
|
|
|
2021-03-03 11:51:55 +03:00
|
|
|
UNMAP_AFTER_INIT bool CommandLine::is_ide_enabled() const
|
|
|
|
{
|
2021-05-31 11:59:02 +03:00
|
|
|
return !contains("disable_ide"sv);
|
2021-03-03 11:51:55 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
UNMAP_AFTER_INIT bool CommandLine::is_smp_enabled() const
|
|
|
|
{
|
2021-12-19 22:30:36 +03:00
|
|
|
// Note: We can't enable SMP mode without enabling the IOAPIC.
|
|
|
|
if (!is_ioapic_enabled())
|
|
|
|
return false;
|
2021-05-31 11:59:02 +03:00
|
|
|
return lookup("smp"sv).value_or("off"sv) == "on"sv;
|
2021-03-03 11:51:55 +03:00
|
|
|
}
|
|
|
|
|
2021-12-19 22:30:36 +03:00
|
|
|
UNMAP_AFTER_INIT bool CommandLine::is_smp_enabled_without_ioapic_enabled() const
|
|
|
|
{
|
|
|
|
auto smp_enabled = lookup("smp"sv).value_or("off"sv) == "on"sv;
|
|
|
|
return smp_enabled && !is_ioapic_enabled();
|
|
|
|
}
|
|
|
|
|
2021-11-28 18:38:10 +03:00
|
|
|
UNMAP_AFTER_INIT bool CommandLine::is_ioapic_enabled() const
|
|
|
|
{
|
|
|
|
auto value = lookup("enable_ioapic"sv).value_or("on"sv);
|
|
|
|
if (value == "on"sv)
|
|
|
|
return true;
|
|
|
|
if (value == "off"sv)
|
|
|
|
return false;
|
|
|
|
PANIC("Unknown enable_ioapic setting: {}", value);
|
|
|
|
}
|
|
|
|
|
2022-03-15 23:04:12 +03:00
|
|
|
UNMAP_AFTER_INIT bool CommandLine::is_early_boot_console_disabled() const
|
|
|
|
{
|
|
|
|
auto value = lookup("early_boot_console"sv).value_or("on"sv);
|
|
|
|
if (value == "on"sv)
|
|
|
|
return false;
|
|
|
|
if (value == "off"sv)
|
|
|
|
return true;
|
|
|
|
PANIC("Unknown early_boot_console setting: {}", value);
|
|
|
|
}
|
|
|
|
|
2022-12-22 04:46:22 +03:00
|
|
|
UNMAP_AFTER_INIT I8042PresenceMode CommandLine::i8042_presence_mode() const
|
|
|
|
{
|
|
|
|
auto value = lookup("i8042_presence_mode"sv).value_or("auto"sv);
|
|
|
|
if (value == "auto"sv)
|
|
|
|
return I8042PresenceMode::Automatic;
|
|
|
|
if (value == "none"sv)
|
|
|
|
return I8042PresenceMode::None;
|
|
|
|
if (value == "force"sv)
|
|
|
|
return I8042PresenceMode::Force;
|
|
|
|
if (value == "aggressive-test"sv)
|
|
|
|
return I8042PresenceMode::AggressiveTest;
|
|
|
|
PANIC("Unknown i8042_presence_mode setting: {}", value);
|
|
|
|
}
|
|
|
|
|
2021-03-03 11:51:55 +03:00
|
|
|
UNMAP_AFTER_INIT bool CommandLine::is_vmmouse_enabled() const
|
|
|
|
{
|
2021-10-23 23:31:28 +03:00
|
|
|
return lookup("vmmouse"sv).value_or("on"sv) == "on"sv;
|
2021-03-03 11:51:55 +03:00
|
|
|
}
|
|
|
|
|
2021-04-03 16:46:04 +03:00
|
|
|
UNMAP_AFTER_INIT PCIAccessLevel CommandLine::pci_access_level() const
|
2021-03-03 11:51:55 +03:00
|
|
|
{
|
2022-01-21 17:09:05 +03:00
|
|
|
auto value = lookup("pci"sv).value_or("ecam"sv);
|
|
|
|
if (value == "ecam"sv)
|
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
|
|
|
return PCIAccessLevel::MemoryAddressing;
|
2022-10-04 03:05:54 +03:00
|
|
|
#if ARCH(X86_64)
|
2022-01-21 17:09:05 +03:00
|
|
|
if (value == "io"sv)
|
2021-04-03 16:46:04 +03:00
|
|
|
return PCIAccessLevel::IOAddressing;
|
2022-09-02 10:02:16 +03:00
|
|
|
#endif
|
2022-01-21 17:09:05 +03:00
|
|
|
if (value == "none"sv)
|
|
|
|
return PCIAccessLevel::None;
|
2021-04-03 13:29:07 +03:00
|
|
|
PANIC("Unknown PCI ECAM setting: {}", value);
|
2021-03-03 11:51:55 +03:00
|
|
|
}
|
|
|
|
|
2022-01-21 17:09:05 +03:00
|
|
|
UNMAP_AFTER_INIT bool CommandLine::is_pci_disabled() const
|
|
|
|
{
|
|
|
|
return lookup("pci"sv).value_or("ecam"sv) == "none"sv;
|
|
|
|
}
|
|
|
|
|
2021-03-03 11:51:55 +03:00
|
|
|
UNMAP_AFTER_INIT bool CommandLine::is_legacy_time_enabled() const
|
|
|
|
{
|
2021-05-31 11:59:02 +03:00
|
|
|
return lookup("time"sv).value_or("modern"sv) == "legacy"sv;
|
2021-03-03 11:51:55 +03:00
|
|
|
}
|
|
|
|
|
2022-01-22 13:29:55 +03:00
|
|
|
bool CommandLine::is_pc_speaker_enabled() const
|
|
|
|
{
|
|
|
|
auto value = lookup("pcspeaker"sv).value_or("off"sv);
|
|
|
|
if (value == "on"sv)
|
|
|
|
return true;
|
|
|
|
if (value == "off"sv)
|
|
|
|
return false;
|
|
|
|
PANIC("Unknown pcspeaker setting: {}", value);
|
|
|
|
}
|
|
|
|
|
2021-03-03 11:51:55 +03:00
|
|
|
UNMAP_AFTER_INIT bool CommandLine::is_force_pio() const
|
|
|
|
{
|
2021-05-31 11:59:02 +03:00
|
|
|
return contains("force_pio"sv);
|
2021-03-03 11:51:55 +03:00
|
|
|
}
|
|
|
|
|
2021-08-15 09:49:17 +03:00
|
|
|
UNMAP_AFTER_INIT StringView CommandLine::root_device() const
|
2021-03-03 11:51:55 +03:00
|
|
|
{
|
Kernel/Storage: Introduce new boot device addressing modes
Before of this patch, we supported two methods to address a boot device:
1. Specifying root=/dev/hdXY, where X is a-z letter which corresponds to
a boot device, and Y as number from 1 to 16, to indicate the partition
number, which can be omitted to instruct the kernel to use a raw device
rather than a partition on a raw device.
2. Specifying root=PARTUUID: with a GUID string of a GUID partition. In
case of existing storage device with GPT partitions, this is most likely
the safest option to ensure booting from persistent storage.
While option 2 is more advanced and reliable, the first option has 2
caveats:
1. The string prefix "/dev/hd" doesn't mean anything beside a convention
on Linux installations, that was taken into use in Serenity. In Serenity
we don't mount DevTmpFS before we mount the boot device on /, so the
kernel doesn't really access /dev anyway, so this convention is only a
big misleading relic that can easily make the user to assume we access
/dev early on boot.
2. This convention although resemble the simple linux convention, is
quite limited in specifying a correct boot device across hardware setup
changes, so option 2 was recommended to ensure the system is always
bootable.
With these caveats in mind, this commit tries to fix the problem with
adding more addressing options as well as to remove the first option
being mentioned above of addressing.
To sum it up, there are 4 addressing options:
1. Hardware relative address - Each instance of StorageController is
assigned with a index number relative to the type of hardware it handles
which makes it possible to address storage devices with a prefix of the
commandset ("ata" for ATA, "nvme" for NVMe, "ramdisk" for Plain memory),
and then the number for the parent controller relative hardware index,
another number LUN target_id, and a third number for LUN disk_id.
2. LUN address - Similar to the previous option, but instead we rely on
the parent controller absolute index for the first number.
3. Block device major and minor numbers - by specifying the major and
minor numbers, the kernel can simply try to get the corresponding block
device and use it as the boot device.
4. GUID string, in the same fashion like before, so the user use the
"PARTUUID:" string prefix and add the GUID of the GPT partition.
For the new address modes 1 and 2, the user can choose to also specify a
partition out of the selected boot device. To do that, the user needs to
append the semicolon character and then add the string "partX" where X
is to be changed for the partition number. We start counting from 0, and
therefore the first partition number is 0 and not 1 in the kernel boot
argument.
2022-08-05 20:32:26 +03:00
|
|
|
return lookup("root"sv).value_or("lun0:0:0"sv);
|
2021-03-03 11:51:55 +03:00
|
|
|
}
|
|
|
|
|
2022-01-27 13:55:39 +03:00
|
|
|
bool CommandLine::is_nvme_polling_enabled() const
|
|
|
|
{
|
|
|
|
return contains("nvme_poll"sv);
|
|
|
|
}
|
|
|
|
|
2021-03-03 11:51:55 +03:00
|
|
|
UNMAP_AFTER_INIT AcpiFeatureLevel CommandLine::acpi_feature_level() const
|
|
|
|
{
|
2021-09-10 16:45:12 +03:00
|
|
|
auto value = kernel_command_line().lookup("acpi"sv).value_or("limited"sv);
|
2021-05-31 11:59:02 +03:00
|
|
|
if (value == "limited"sv)
|
2021-03-03 11:51:55 +03:00
|
|
|
return AcpiFeatureLevel::Limited;
|
2021-05-31 11:59:02 +03:00
|
|
|
if (value == "off"sv)
|
2021-03-03 11:51:55 +03:00
|
|
|
return AcpiFeatureLevel::Disabled;
|
2021-09-10 18:06:26 +03:00
|
|
|
if (value == "on"sv)
|
|
|
|
return AcpiFeatureLevel::Enabled;
|
|
|
|
PANIC("Unknown ACPI feature level: {}", value);
|
2021-03-03 11:51:55 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
UNMAP_AFTER_INIT HPETMode CommandLine::hpet_mode() const
|
|
|
|
{
|
2021-05-31 11:59:02 +03:00
|
|
|
auto hpet_mode = lookup("hpet"sv).value_or("periodic"sv);
|
|
|
|
if (hpet_mode == "periodic"sv)
|
2021-03-03 11:51:55 +03:00
|
|
|
return HPETMode::Periodic;
|
2021-05-31 11:59:02 +03:00
|
|
|
if (hpet_mode == "nonperiodic"sv)
|
2021-03-03 11:51:55 +03:00
|
|
|
return HPETMode::NonPeriodic;
|
|
|
|
PANIC("Unknown HPETMode: {}", hpet_mode);
|
|
|
|
}
|
|
|
|
|
2021-06-04 08:02:14 +03:00
|
|
|
UNMAP_AFTER_INIT bool CommandLine::is_physical_networking_disabled() const
|
|
|
|
{
|
|
|
|
return contains("disable_physical_networking"sv);
|
|
|
|
}
|
|
|
|
|
2021-04-08 21:18:48 +03:00
|
|
|
UNMAP_AFTER_INIT bool CommandLine::disable_physical_storage() const
|
|
|
|
{
|
2021-05-31 11:59:02 +03:00
|
|
|
return contains("disable_physical_storage"sv);
|
2021-04-08 21:18:48 +03:00
|
|
|
}
|
|
|
|
|
2021-04-17 22:36:53 +03:00
|
|
|
UNMAP_AFTER_INIT bool CommandLine::disable_uhci_controller() const
|
|
|
|
{
|
2021-05-31 11:59:02 +03:00
|
|
|
return contains("disable_uhci_controller"sv);
|
2021-04-17 22:36:53 +03:00
|
|
|
}
|
|
|
|
|
2021-08-08 21:50:20 +03:00
|
|
|
UNMAP_AFTER_INIT bool CommandLine::disable_usb() const
|
|
|
|
{
|
|
|
|
return contains("disable_usb"sv);
|
|
|
|
}
|
|
|
|
|
2021-04-18 16:06:35 +03:00
|
|
|
UNMAP_AFTER_INIT bool CommandLine::disable_virtio() const
|
|
|
|
{
|
2021-05-31 11:59:02 +03:00
|
|
|
return contains("disable_virtio"sv);
|
2021-04-18 16:06:35 +03:00
|
|
|
}
|
|
|
|
|
2021-03-12 19:35:16 +03:00
|
|
|
UNMAP_AFTER_INIT AHCIResetMode CommandLine::ahci_reset_mode() const
|
|
|
|
{
|
2022-04-01 20:58:27 +03:00
|
|
|
auto const ahci_reset_mode = lookup("ahci_reset_mode"sv).value_or("controllers"sv);
|
2021-05-31 11:59:02 +03:00
|
|
|
if (ahci_reset_mode == "controllers"sv) {
|
2021-03-12 19:35:16 +03:00
|
|
|
return AHCIResetMode::ControllerOnly;
|
2021-12-29 02:44:39 +03:00
|
|
|
}
|
|
|
|
if (ahci_reset_mode == "aggressive"sv) {
|
2021-05-29 01:18:45 +03:00
|
|
|
return AHCIResetMode::Aggressive;
|
2021-03-12 19:35:16 +03:00
|
|
|
}
|
|
|
|
PANIC("Unknown AHCIResetMode: {}", ahci_reset_mode);
|
|
|
|
}
|
|
|
|
|
2021-10-23 19:26:50 +03:00
|
|
|
StringView CommandLine::system_mode() const
|
2021-03-03 11:51:55 +03:00
|
|
|
{
|
2021-10-23 19:26:50 +03:00
|
|
|
return lookup("system_mode"sv).value_or("graphical"sv);
|
2021-03-03 11:51:55 +03:00
|
|
|
}
|
|
|
|
|
2021-10-23 18:31:00 +03:00
|
|
|
PanicMode CommandLine::panic_mode(Validate should_validate) const
|
|
|
|
{
|
2022-04-01 20:58:27 +03:00
|
|
|
auto const panic_mode = lookup("panic"sv).value_or("halt"sv);
|
2021-10-23 18:31:00 +03:00
|
|
|
if (panic_mode == "halt"sv) {
|
|
|
|
return PanicMode::Halt;
|
2021-12-29 02:44:39 +03:00
|
|
|
}
|
|
|
|
if (panic_mode == "shutdown"sv) {
|
2021-10-23 18:31:00 +03:00
|
|
|
return PanicMode::Shutdown;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (should_validate == Validate::Yes)
|
|
|
|
PANIC("Unknown PanicMode: {}", panic_mode);
|
|
|
|
|
|
|
|
return PanicMode::Halt;
|
|
|
|
}
|
|
|
|
|
2022-04-30 15:53:02 +03:00
|
|
|
UNMAP_AFTER_INIT CommandLine::GraphicsSubsystemMode CommandLine::graphics_subsystem_mode() const
|
|
|
|
{
|
|
|
|
auto const graphics_subsystem_mode_value = lookup("graphics_subsystem_mode"sv).value_or("on"sv);
|
|
|
|
if (graphics_subsystem_mode_value == "on"sv)
|
|
|
|
return GraphicsSubsystemMode::Enabled;
|
|
|
|
if (graphics_subsystem_mode_value == "limited"sv)
|
|
|
|
return GraphicsSubsystemMode::Limited;
|
|
|
|
if (graphics_subsystem_mode_value == "off"sv)
|
|
|
|
return GraphicsSubsystemMode::Disabled;
|
|
|
|
PANIC("Invalid graphics_subsystem_mode value: {}", graphics_subsystem_mode_value);
|
2021-03-03 11:51:55 +03:00
|
|
|
}
|
|
|
|
|
2021-08-15 09:49:17 +03:00
|
|
|
StringView CommandLine::userspace_init() const
|
2021-03-03 11:51:55 +03:00
|
|
|
{
|
2021-05-31 11:59:02 +03:00
|
|
|
return lookup("init"sv).value_or("/bin/SystemServer"sv);
|
2021-03-03 11:51:55 +03:00
|
|
|
}
|
|
|
|
|
2021-09-09 12:36:40 +03:00
|
|
|
NonnullOwnPtrVector<KString> CommandLine::userspace_init_args() const
|
2021-03-03 11:51:55 +03:00
|
|
|
{
|
2021-09-09 12:36:40 +03:00
|
|
|
NonnullOwnPtrVector<KString> args;
|
2021-03-03 11:51:55 +03:00
|
|
|
|
2021-09-09 12:36:40 +03:00
|
|
|
auto init_args = lookup("init_args"sv).value_or(""sv).split_view(';');
|
|
|
|
if (!init_args.is_empty())
|
2022-09-16 14:43:07 +03:00
|
|
|
MUST(args.try_prepend(MUST(KString::try_create(userspace_init()))));
|
2021-09-09 12:36:40 +03:00
|
|
|
for (auto& init_arg : init_args)
|
2022-09-16 14:43:07 +03:00
|
|
|
args.append(MUST(KString::try_create(init_arg)));
|
2021-09-09 12:36:40 +03:00
|
|
|
return args;
|
2021-03-03 11:51:55 +03:00
|
|
|
}
|
|
|
|
|
2021-05-14 00:22:02 +03:00
|
|
|
UNMAP_AFTER_INIT size_t CommandLine::switch_to_tty() const
|
|
|
|
{
|
2022-04-01 20:58:27 +03:00
|
|
|
auto const default_tty = lookup("switch_to_tty"sv).value_or("1"sv);
|
2021-05-14 00:22:02 +03:00
|
|
|
auto switch_tty_number = default_tty.to_uint();
|
|
|
|
if (switch_tty_number.has_value() && switch_tty_number.value() >= 1) {
|
|
|
|
return switch_tty_number.value() - 1;
|
|
|
|
}
|
|
|
|
PANIC("Invalid default tty value: {}", default_tty);
|
|
|
|
}
|
2020-04-08 14:54:44 +03:00
|
|
|
}
|