Commit Graph

69 Commits

Author SHA1 Message Date
Liav A
d4bfb479fd Kernel/Commandline: Remove a remainder of the removed boot_mode flag 2022-08-14 01:03:23 +01:00
Liav A
6164729d06 Everywhere: Get rid of the fbdev kernel boot argument remainders 2022-08-14 01:03:23 +01:00
sin-ack
c8585b77d2 Everywhere: Replace single-char StringView op. arguments with chars
This prevents us from needing a sv suffix, and potentially reduces the
need to run generic code for a single character (as contains,
starts_with, ends_with etc. for a char will be just a length and
equality check).

No functional changes.
2022-07-12 23:11:35 +02:00
sin-ack
3f3f45580a Everywhere: Add sv suffix to strings relying on StringView(char const*)
Each of these strings would previously rely on StringView's char const*
constructor overload, which would call __builtin_strlen on the string.
Since we now have operator ""sv, we can replace these with much simpler
versions. This opens the door to being able to remove
StringView(char const*).

No functional changes.
2022-07-12 23:11:35 +02:00
sin-ack
c70f45ff44 Everywhere: Explicitly specify the size in StringView constructors
This commit moves the length calculations out to be directly on the
StringView users. This is an important step towards the goal of removing
StringView(char const*), as it moves the responsibility of calculating
the size of the string to the user of the StringView (which will prevent
naive uses causing OOB access).
2022-07-12 23:11:35 +02:00
Liav A
d49a35df31 Kernel/Graphics: Simplify the feature level of the Graphics subsystem
Instead of letting the user to determine whether framebuffer devices
will be created (which is useless because they are gone by now), let's
simplify the flow by allowing the user to choose between full, limited
or disabled functionality. The determination happens only once, so, if
the user decided to disable graphics support, the initialize method
exits immediately. If limited functionality is chosen, then a generic
DisplayConnector is initialized with the preset framebuffer resolution,
if present, and then the initialize method exits. As a default, the code
proceeds to initialize all drivers as usual.
2022-05-05 20:55:57 +02:00
Idan Horowitz
086969277e Everywhere: Run clang-format 2022-04-01 21:24:45 +01:00
Liav A
eca8f292a5 Kernel: Allow to disable early boot console
This aid debugging on bare metal when we suspect that the boot console
does something wrong that interferes with other kernel components.
2022-03-18 09:22:10 +00:00
Liav A
f6e635938f Kernel: Change PCI access commandline option to also represent no access
This change allow the user to request the kernel to not use any PCI
resources/devices at all.

Also, don't try to initialize devices that rely on PCI if disabled.
2022-03-02 18:41:54 +01:00
Pankaj Raghav
e5a6d12ff8 Kernel: Add nvme_poll command line parameters
As we don't currently support MSI(X) interrupts, it could be an issue
to boot on some newer hardware. NVMe devices support polling mode
where the driver actively polls for completion instead of waiting for
an interrupt.
2022-02-02 18:26:59 +01:00
Liav A
69f054616d Kernel: Add CommandLine option to disable or enable the PC speaker
By default, we disable the PC speaker as it's quite annoying when using
the text mode console.
2022-01-23 00:40:54 +00:00
Liav A
d67c70d043 Kernel: Ensure that CommandLine is initialized before choosing PanicMode
If the kernel commandline is not initialized, just halt everything.
2022-01-21 19:34:10 +02:00
Idan Horowitz
194d1c884b Kernel: Convert CommandLine to KString 2022-01-12 16:09:09 +02:00
Tom
785c10fda9 Kernel: Add option to force using only the bootloader framebuffer
This allows forcing the use of only the framebuffer set up by the
bootloader and skips instantiating devices for any other graphics
cards that may be present.
2022-01-06 22:34:11 +01:00
Brian Gianforcaro
8bcce82887 Kernel: Use MUST+ Vector::try_prepend instead of Vector::prepend
In preparation for disabling Vector::prepend from being available
during the compilation of the Kernel.
2022-01-05 14:04:18 +01:00
Hendiadyoin1
9346b9589f Kernel: Remove else-after-return statements in CommandLine.cpp 2021-12-30 14:32:17 +01:00
Hendiadyoin1
1db53400ce Kernel: Remove superfluous moves in CommandLine.cpp 2021-12-30 14:32:17 +01:00
Liav A
30659040ed Kernel: Ensure SMP mode is not enabled if IOAPIC mode is disabled
We need to use the IOAPIC in SMP mode, so if the user requested to
disable it, we can't enable SMP mode either.
2021-12-20 11:00:31 -08:00
Liav A
ac7953f945 Kernel: Allow switching to IOAPIC mode even without enabling SMP
This small change allows to use the IOAPIC by default without to enable
SMP mode, which emulates Uni-Processor setup with IOAPIC instead of
using the PIC.

This opens the opportunity to utilize other types of interrupts like MSI
and MSI-X interrupts.
2021-12-14 09:02:06 +01:00
Andreas Kling
8b1108e485 Everywhere: Pass AK::StringView by value 2021-11-11 01:27:46 +01:00
Ben Wiederhake
bf88adbcb6 Kernel: Avoid allocation when checking for vmmouse 2021-10-25 23:38:28 +02:00
Ben Wiederhake
8d13f6ddce Kernel+SystemServer: Change bootmode to system_mode
'bootmode' now only controls which set of services are started by
SystemServer, so it is more appropriate to rename it to system_mode, and
no longer validate it in the Kernel.
2021-10-25 23:38:28 +02:00
Ben Wiederhake
09432a8241 Kernel: Separate panic behavior from bootmode
Bootmode used to control panic behavior and SystemServer.
This patch factors panic behavior control into a separate flag.
2021-10-25 23:38:28 +02:00
Ben Wiederhake
542a88a7be Kernel: Separate framebuffers from bootmode
Bootmode used to control framebuffers, panic behavior, and SystemServer.
This patch factors framebuffer control into a separate flag.
Note that the combination 'bootmode=self-test fbdev=on' leads to
unexpected behavior, which can only be fixed in a later commit.
2021-10-25 23:38:28 +02:00
Nico Weber
1cdb12e920 Kernel: Fix -Wunreachable-code warnings from clang 2021-10-08 23:33:46 +02:00
Liav A
d0245b5e6b Kernel/CommandLine: Verify ACPI feature level cannot have invalid string
The allowed options are "on", "limited" and "off". Anything else is now
not allowed and will result in kernel panic.
2021-09-10 22:01:23 +02:00
Liav A
026f80a95b Kernel/ACPI: Simplify parser initialization
Let's remove the DynamicParser class, as it really did nothing yet in
the Kernel. Instead, when we add support for AML parsing, we can figure
out how to do it properly without the need of a derived class that just
complicates everything for no good reason.
2021-09-10 22:01:23 +02:00
Andreas Kling
dd82f68326 Kernel: Use KString all the way in sys$execve()
This patch converts all the usage of AK::String around sys$execve() to
using KString instead, allowing us to catch and propagate OOM errors.

It also required changing the kernel CommandLine helper class to return
a vector of KString for the userspace init program arguments.
2021-09-09 21:25:10 +02:00
Liav A
7bf8844499 Kernel/PCI: Turn on memory access by default
This will allow the Kernel to utilize memory access to the PCI
configuration space if such method is available.
2021-09-07 13:47:37 +02:00
Liav A
25ea7461a0 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 13:47:37 +02:00
Brian Gianforcaro
e9d8f158a1 AK+Kernel: StringView hash map Traits should not set peek type to String
This typo / bug in the Traits<T> implementation for StringView caused
AK::HashMap methods to return a `String` when looking up values out of
a hash map of type HashTable<StringView,StringView>.

This change fixes the typo, and fixes the only consumer, the kernel
Commandline class.
2021-08-18 10:21:19 +02:00
Luke
7a86a8df90 Kernel/USB: Create controller base class and introduce USBManagement
This removes Pipes dependency on the UHCIController by introducing a
controller base class. This will be used to implement other controllers
such as OHCI.

Additionally, there can be multiple instances of a UHCI controller.
For example, multiple UHCI instances can be required for systems with
EHCI controllers. EHCI relies on using multiple of either UHCI or OHCI
controllers to drive USB 1.x devices.

This means UHCIController can no longer be a singleton. Multiple
instances of it can now be created and passed to the device and then to
the pipe.

To handle finding and creating these instances, USBManagement has been
introduced. It has the same pattern as the other management classes
such as NetworkManagement.
2021-08-09 21:05:25 +02:00
Brian Gianforcaro
8e93815846 Kernel: Fix panic loop when encountering an unknown boot_mode
The kernel panic handler now parses the kernels boot_mode to decide how
to handle the panic. So the previous logic could end up in an panic loop
until we blew out the kernel stack.

Instead only validate the kernel's boot mode once per boot, after
initializing the kernel command line.
2021-08-08 23:11:50 +02:00
Ali Mohammad Pur
eb9c82a487 Kernel: Un-unmap-after-init CommandLine::boot_mode()
This function is now used when the kernel panics, so unmapping it would
make the kernel panic while in panic, which is not a good thing :P
2021-07-26 11:33:14 +02:00
Hendiadyoin1
62f9377656 Kernel: Move special sections into Sections.h
This also removes a lot of CPU.h includes infavor for Sections.h
2021-06-24 00:38:23 +02:00
Hendiadyoin1
7ca3d413f7 Kernel: Pull apart CPU.h
This does not add any functional changes
2021-06-24 00:38:23 +02:00
Liav A
2e2201e8e1 Kernel/CommandLine: Add option to disable physical networking hardware
This is useful for debugging sessions mostly.
2021-06-09 22:44:09 +04:30
Luke
01d7c1b722 Kernel: Fix "sv" being inside of "no-fbdev" instead of outside
It was previously "no-fbdevsv" when it should be "no-fbdev"sv.
2021-06-03 17:08:06 +02:00
Brian Gianforcaro
35a97884aa Kernel: Move CommandLine API to use AK::StringView instead of AK::String
The current CommandLine API unfortunately allocates Strings just to
query the presence of arguments on the command line. Switch the API
to use StringView instead to reduce the number of String allocations.
2021-05-31 14:04:00 +04:30
Liav A
d431e4cd01 Kernel/Storage: Remove the None option from AHCI reset policy
This was proved to be a problematic option. I tested this option on
bare metal AHCI controller, and if we didn't reset the controller, the
firmware (SeaBIOS) could leave the controller state not clean, so an
plugged device signature was in place although the specific port had no
plugged device after rebooting.
Therefore, we need to ensure we use the controller in a clean state
always.

In addition to that, the Complete option was renamed to Aggressive, as
it represents better the consequences of choosing this option.
2021-05-29 15:51:52 +02:00
Liav A
5e81464245 Kernel/Commandline: Allow the user to specify an embedded string
This is by default left empty, so people won't run the kernel in a mode
which they didn't want to. The embedded string will override the
supplied commandline from the bootloader, which is good for debugging
sessions.

This change seemed important for me, because I debug the kernel on bare
metal with iPXE, and every change to the commandline meant that I needed
rewrite a new iPXE USB image with a modified iPXE script.
2021-05-21 22:38:26 +01:00
Liav A
df84fdfd2c Kernel: Print commandline after initializing it 2021-05-21 22:38:26 +01:00
Liav A
ab52108982 Kernel: Allow the user to specify the virtual console when booting 2021-05-16 19:58:33 +02:00
Liav A
20743e8aed Kernel/Graphics + SystemServer: Support text mode properly
As we removed the support of VBE modesetting that was done by GRUB early
on boot, we need to determine if we can modeset the resolution with our
drivers, and if not, we should enable text mode and ensure that
SystemServer knows about it too.

Also, SystemServer should first check if there's a framebuffer device
node, which is an indication that text mode was not even if it was
requested. Then, if it doesn't find it, it should check what boot_mode
argument the user specified (in case it's self-test). This way if we
try to use bochs-display device (which is not VGA compatible) and
request a text mode, it will not honor the request and will continue
with graphical mode.

Also try to print critical messages with mininum memory allocations
possible.

In LibVT, We make the implementation flexible for kernel-specific
methods that are implemented in ConsoleImpl class.
2021-05-16 19:58:33 +02:00
Brian Gianforcaro
1682f0b760 Everything: Move to SPDX license identifiers in all files.
SPDX License Identifiers are a more compact / standardized
way of representing file license information.

See: https://spdx.dev/resources/use/#identifiers

This was done with the `ambr` search and replace tool.

 ambr --no-parent-ignore --key-from-file --rep-from-file key.txt rep.txt *
2021-04-22 11:22:27 +02:00
Idan Horowitz
aaf3d26dae Kernel: Add kernel command line flag to disable VirtIO support
This command line flag can be used to disable VirtIO support on
certain configurations (native windows) where interfacing with
virtio devices can cause qemu to freeze.
2021-04-18 22:06:42 +02:00
Luke
c84107a1ab Kernel: Add boot argument to disable the UHCI Controller
Helps with bare metal debugging, as we can't be sure our implementation
will work with a given machine.

As reported by someone on Discord, their machine hangs when we attempt
the dummy transfer.
2021-04-18 17:01:22 +02:00
Liav A
a0be30f655 Kernel: Introduce two new boot arguments to assist with bare metal debug
The first one is for disabling the PS2 controller, the other one is for
disabling physical storage enumeration.
We can't be sure any machine will work with our implementation,
therefore this will help us to test more machines.
2021-04-08 22:17:13 +02:00
Liav A
fc92a4b228 Kernel/PCI: Disable ECAM method by default
Until I figure out what's going wrong with it on bare-metal, disable it
unless explicitly enabled by the user.
2021-04-06 22:25:28 +02:00
Liav A
8abbb7e090 Kernel/PCI: Introduce a new ECAM access mechanism
Now the kernel supports 2 ECAM access methods.
MMIOAccess was renamed to WindowedMMIOAccess and is what we had until
now - each device that is detected on boot is assigned to a
memory-mapped window, so IO operations on multiple devices can occur
simultaneously due to creating multiple virtual mappings, hence the name
is a memory-mapped window.

This commit adds a new class called MMIOAccess (not to be confused with
the old MMIOAccess class). This class creates one memory-mapped window.
On each IO operation on a configuration space of a device, it maps the
requested PCI bus region to that window. Therefore it holds a SpinLock
during the operation to ensure that no other PCI bus region was mapped
during the call.

A user can choose to either use PCI ECAM with memory-mapped window
for each device, or for an entire bus. By default, the kernel prefers to
map the entire PCI bus region.
2021-04-03 19:34:52 +02:00