diff options
author | Liav A <liavalb@gmail.com> | 2021-06-04 08:02:14 +0300 |
---|---|---|
committer | Ali Mohammad Pur <Ali.mpfard@gmail.com> | 2021-06-09 22:44:09 +0430 |
commit | 2e2201e8e1c2cc7e67ae6e8be2907c69b832900a (patch) | |
tree | e9908de79d41bc1983d0a310b029646743a8e7e1 /Kernel | |
parent | 1c94b5e8eb9723149a76ef54d38224c995c1a765 (diff) | |
download | serenity-2e2201e8e1c2cc7e67ae6e8be2907c69b832900a.zip |
Kernel/CommandLine: Add option to disable physical networking hardware
This is useful for debugging sessions mostly.
Diffstat (limited to 'Kernel')
-rw-r--r-- | Kernel/CommandLine.cpp | 5 | ||||
-rw-r--r-- | Kernel/CommandLine.h | 1 | ||||
-rw-r--r-- | Kernel/Net/NetworkingManagement.cpp | 16 |
3 files changed, 15 insertions, 7 deletions
diff --git a/Kernel/CommandLine.cpp b/Kernel/CommandLine.cpp index 0391f93939..058fb5b4af 100644 --- a/Kernel/CommandLine.cpp +++ b/Kernel/CommandLine.cpp @@ -154,6 +154,11 @@ UNMAP_AFTER_INIT HPETMode CommandLine::hpet_mode() const PANIC("Unknown HPETMode: {}", hpet_mode); } +UNMAP_AFTER_INIT bool CommandLine::is_physical_networking_disabled() const +{ + return contains("disable_physical_networking"sv); +} + UNMAP_AFTER_INIT bool CommandLine::disable_ps2_controller() const { return contains("disable_ps2_controller"sv); diff --git a/Kernel/CommandLine.h b/Kernel/CommandLine.h index 9a963131d1..20aaa6b9cc 100644 --- a/Kernel/CommandLine.h +++ b/Kernel/CommandLine.h @@ -55,6 +55,7 @@ public: [[nodiscard]] bool is_boot_profiling_enabled() const; [[nodiscard]] bool is_ide_enabled() const; [[nodiscard]] bool is_smp_enabled() const; + [[nodiscard]] bool is_physical_networking_disabled() const; [[nodiscard]] bool is_vmmouse_enabled() const; [[nodiscard]] PCIAccessLevel pci_access_level() const; [[nodiscard]] bool is_legacy_time_enabled() const; diff --git a/Kernel/Net/NetworkingManagement.cpp b/Kernel/Net/NetworkingManagement.cpp index c2bb229b14..af961ec069 100644 --- a/Kernel/Net/NetworkingManagement.cpp +++ b/Kernel/Net/NetworkingManagement.cpp @@ -85,13 +85,15 @@ UNMAP_AFTER_INIT RefPtr<NetworkAdapter> NetworkingManagement::determine_network_ bool NetworkingManagement::initialize() { - PCI::enumerate([&](const PCI::Address& address, PCI::ID) { - // Note: PCI class 2 is the class of Network devices - if (PCI::get_class(address) != 0x02) - return; - if (auto adapter = determine_network_device(address); !adapter.is_null()) - m_adapters.append(adapter.release_nonnull()); - }); + if (!kernel_command_line().is_physical_networking_disabled()) { + PCI::enumerate([&](const PCI::Address& address, PCI::ID) { + // Note: PCI class 2 is the class of Network devices + if (PCI::get_class(address) != 0x02) + return; + if (auto adapter = determine_network_device(address); !adapter.is_null()) + m_adapters.append(adapter.release_nonnull()); + }); + } auto loopback = LoopbackAdapter::create(); m_adapters.append(loopback); m_loopback_adapter = loopback; |