summaryrefslogtreecommitdiff
path: root/Kernel/init.cpp
AgeCommit message (Collapse)Author
2021-05-19Kernel+LibC: Add support for filtering profiling eventsGunnar Beutner
This adds the -t command-line argument for the profile tool. Using this argument you can filter which event types you want in your profile.
2021-05-17Kernel: Implement a PCI Serial Device driverIdan Horowitz
This simple driver simply finds a device in a device definitions list and then sets up a SerialDevice instance based on the definition. The driver currently only supports "WCH CH382 2S" pci serial boards, as that is the only device available for me to test with, but most other pci serial devices should be as easily addable as adding a board_definitions entry.
2021-05-17Kernel: Use IOAddress instead of direct IO calls in SerialDeviceIdan Horowitz
2021-05-17Kernel: Initialize the PCI Bus earlier in the boot sequenceIdan Horowitz
We now initialize the PCI Bus as early as possible, to allow for early boot (PCI based) serial logging.
2021-05-16Kernel: Move ConsoleDevice initialization just after kmalloc initLiav A
This will ensure we will get all the kernel log on the second tty.
2021-05-16Kernel: Allow the user to specify the virtual console when bootingLiav A
2021-05-16Kernel/Graphics + SystemServer: Support text mode properlyLiav A
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-16Kernel: Expand the kernel memory slot from 16 MiB to 32 MiBLiav A
Like in 8cd5477e54a19d5476e9a31d0677e58c9a4ce12d, we need to expand the kernel slot again to be able to boot again.
2021-05-16Kernel: Rename Console => ConsoleDeviceLiav A
This change will help to distinguish between the console device and the Console abstraction layer in the Graphics subsystem later.
2021-05-16Kernel: Introduce a new graphics subsystemLiav A
This new subsystem is replacing the old code that was used to create device nodes of framebuffer devices in /dev. This subsystem includes for now 3 roles: 1. GraphicsManagement singleton object that is used in the boot process to enumerate and initialize display devices. 2. GraphicsDevice(s) that are used to control the display adapter. 3. FramebufferDevice(s) that are used to control the device node in /dev. For now, we support the Bochs display adapter and any other generic VGA compatible adapter that was configured by the boot loader to a known and fixed resolution. Two improvements in the Bochs display adapter code are that we can support native bochs-display device (this device doesn't expose any VGA capabilities) and also that we use the MMIO region, to configure the device, instead of setting IO ports for such tasks.
2021-04-29Kernel: Enable building the kernel with -fltoGunnar Beutner
GCC with -flto is more aggressive when it comes to inlining and discarding functions which is why we must mark some of the functions as NEVER_INLINE (because they contain asm labels which would be duplicated in the object files if the compiler decides to inline the function elsewhere) and __attribute__((used)) for others so that GCC doesn't discard them.
2021-04-22Everything: Move to SPDX license identifiers in all files.Brian Gianforcaro
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-17Kernel: Add base support for VirtIO devicesIdan Horowitz
Based on pull #3236 by tomuta, this adds helper methods for generic device initialization, and partily-broken virtqueue helper methods Co-authored-by: Tom <tomut@yahoo.com> Co-authored-by: Sahan <sahan.h.fernando@gmail.com>
2021-04-07Kernel: Remove unused UHCI_ENABLED flagAndreas Kling
2021-04-03Kernel: Introduce a new HID subsystemLiav A
The end goal of this commit is to allow to boot on bare metal with no PS/2 device connected to the system. It turned out that the original code relied on the existence of the PS/2 keyboard, so VirtualConsole called it even though ACPI indicated the there's no i8042 controller on my real machine because I didn't plug any PS/2 device. The code is much more flexible, so adding HID support for other type of hardware (e.g. USB HID) could be much simpler. Briefly describing the change, we have a new singleton called HIDManagement, which is responsible to initialize the i8042 controller if exists, and to enumerate its devices. I also abstracted a bit things, so now every Human interface device is represented with the HIDDevice class. Then, there are 2 types of it - the MouseDevice and KeyboardDevice classes; both are responsible to handle the interface in the DevFS. PS2KeyboardDevice, PS2MouseDevice and VMWareMouseDevice classes are responsible for handling the hardware-specific interface they are assigned to. Therefore, they are inheriting from the IRQHandler class.
2021-03-21Kernel: Add simplistic work queuesTom
We can't use deferred functions for anything that may require preemption, such as copying from/to user or accessing the disk. For those purposes we should use a work queue, which is essentially a kernel thread that may be preempted or blocked.
2021-03-21Kernel::CPU: Move headers into common directoryHendiadyoin1
Alot of code is shared between i386/i686/x86 and x86_64 and a lot probably will be used for compatability modes. So we start by moving the headers into one Directory. We will probalby be able to move some cpp files aswell.
2021-03-21Kernel: Renable UHCIController on 64-bit processorsHendiadyoin1
2021-03-12Everywhere: Remove klog(), dbg() and purge all LogStream usage :^)Andreas Kling
Good-bye LogStream. Long live AK::Format!
2021-03-09Kernel: Convert klog() => dmesgln() in init()Andreas Kling
2021-03-04Kernel: Make the kernel compile & link for x86_64Andreas Kling
It's now possible to build the whole kernel with an x86_64 toolchain. There's no bootstrap code so it doesn't work yet (obviously.)
2021-03-03Kernel: init: Make comment clearerMarco
2021-03-03Kernel: Add 'boot_prof' option to enable full system profiling on bootBrian Gianforcaro
The full system profiling functionality is useful for profiling the boot performance of the system. Add a new kernel boot option to start the system with profiling enabled. This lets you disable and view a profile once the system is booted. You can use it by running: ``` $ run.sh qcmd boot_prof ```
2021-03-03Kernel: Move Kernel CommandLine parsing to strongly typed API.Brian Gianforcaro
Previously all of the CommandLine parsing was spread out around the Kernel. Instead move it all into the Kernel CommandLine class, and expose a strongly typed API for querying the state of options.
2021-02-28Kernel: Add self-test boot mode, an alias for text modeAndrew Kaster
Add a special boot mode for running tests, rather than using the system as a general purpose OS. We'll use this in SystemServer to specify only services needed to run tests and exit.
2021-02-24Kernel: Panic early if the kernel gets too big for its memory slotAndreas Kling
Let's help our future selves find this problem sooner next time it happens. Hopefully we'll come up with a nicer loader before then, but who knows. :^)
2021-02-23Everywhere: Rename ASSERT => VERIFYAndreas Kling
(...and ASSERT_NOT_REACHED => VERIFY_NOT_REACHED) Since all of these checks are done in release builds as well, let's rename them to VERIFY to prevent confusion, as everyone is used to assertions being compiled out in release. We can introduce a new ASSERT macro that is specifically for debug checks, but I'm doing this wholesale conversion first since we've accumulated thousands of these already, and it's not immediately obvious which ones are suitable for ASSERT.
2021-02-23Kernel: Copy the kernel command line to a good location at bootAndreas Kling
When building the kernel with -O2, we somehow ended up with the kernel command line outside of the lower 8MB of physical memory. Since we don't map that area in our initial page table setup, we would triple fault when trying to parse the command line. This patch sidesteps the issue by copying the (first 4KB of) the kernel command line to a buffer in a known safe location at boot.
2021-02-19Kernel: Slap UNMAP_AFTER_INIT on a whole bunch of functionsAndreas Kling
There's no real system here, I just added it to various functions that I don't believe we ever want to call after initialization has finished. With these changes, we're able to unmap 60 KiB of kernel text after init. :^)
2021-02-19Kernel: Add .unmap_after_init section for code we don't need after initAndreas Kling
You can now declare functions with UNMAP_AFTER_INIT and they'll get segregated into a separate kernel section that gets completely unmapped at the end of initialization. This can be used for anything we don't need to call once we've booted into userspace. There are two nice things about this mechanism: - It allows us to free up entire pages of memory for other use. (Note that this patch does not actually make use of the freed pages yet, but in the future we totally could!) - It allows us to get rid of obviously dangerous gadgets like write-to-CR0 and write-to-CR4 which are very useful for an attacker trying to disable SMAP/SMEP/etc. I've also made sure to include a helpful panic message in case you hit a kernel crash because of this protection. :^)
2021-02-14Kernel: Mark a handful of things in init.cpp as READONLY_AFTER_INITAndreas Kling
2021-02-14Kernel: Add mechanism to make some memory read-only after init finishesAndreas Kling
You can now use the READONLY_AFTER_INIT macro when declaring a variable and we will put it in a special ".ro_after_init" section in the kernel. Data in that section remains writable during the boot and init process, and is then marked read-only just before launching the SystemServer. This is based on an idea from the Linux kernel. :^)
2021-02-14Kernel: Use PANIC() in a bunch of places :^)Andreas Kling
2021-02-12Kernel: Merge split function and data sections into one during linkingOwen Smith
Also add an assertion to make sure the safemem sections are never discarded by the linker.
2021-02-05Kernel: Add NE2000 network card driverJean-Baptiste Boric
Remember, friends don't let friends use NE2000 network cards :^)
2021-02-05Kernel: Try to detect Sound Blaster 16 before creating an instanceLiav A
We shouldn't create a SB16 instance without checking if the Sound Blaster 16 card is actually installed in the system.
2021-02-01Kernel: Introduce the MemoryDeviceLiav A
This is a character device that is being used by the dmidecode utility. We only allow to map the BIOS ROM area to userspace with this device.
2021-02-01Kernel: Expose SMBIOS blobs in ProcFSLiav A
2021-01-28Kernel: Retire SchedulerData and add Thread lookup tableTom
This allows us to get rid of the thread lists in SchedulerData. Also, instead of iterating over all threads to find a thread by id, just use a lookup table. In the rare case of having to iterate over all threads, just iterate the lookup table.
2021-01-26Kernel: Ensure that HPET is initialized before using random the first timeMaciej Zygmanowski
2021-01-23Kernel: Allow "serial_debug" everywhere on the command lineJean-Baptiste Boric
2021-01-22Kernel: Parse boot modules from Multiboot specificationJean-Baptiste Boric
2021-01-09Everywhere: Replace a bundle of dbg with dbgln.asynts
These changes are arbitrarily divided into multiple commits to make it easier to find potentially introduced bugs with git bisect.
2021-01-09Kernel/USB: Implement test transferJesse Buhagiar
We can now test a _very_ basic transaction via `do_debug_transfer()`. This function merely attaches some TDs to the LSCTRL queue head and points some input and output buffers. We then sense an interrupt with USBSTS value of 1, meaning Interrupt On Completion (of the transaction). At this point, the input buffer is filled with some data.
2021-01-09Kernel/USB: Add basic root port detection/managementJesse Buhagiar
We can now read/write to the two root ports exposed to the UHCI controller, and detect when a device is plugged in or out via a kernel process that constantly scans the port for any changes. This is very basic, but is a bit of fun to see the kernel detecting hardware on the fly :^)
2021-01-09Kernel/USB: Move USB classes into `USB` namespaceJesse Buhagiar
The entire USB spec involves more than just UHCI, so let's put everything into it's own nice namespace :^)
2021-01-09Kernel/USB: Move USB related files to into specific directoryJesse Buhagiar
As the USB/UHCI driver grows in size, it'll be much cleaner to have all of the USB related files in one folder where they can be easily accessed :^)
2020-12-27Kernel: Introduce a new partitioning subsystemLiav A
The partitioning code was very outdated, and required a full refactor. The new subsystem removes duplicated code and uses more AK containers. The most important change is that all implementations of the PartitionTable class conform to one interface, which made it possible to remove unnecessary code in the EBRPartitionTable class. Finding partitions is now done in the StorageManagement singleton, instead of doing so in init.cpp. Also, now we don't try to find partitions on demand - the kernel will try to detect if a StorageDevice is partitioned, and if so, will check what is the partition table, which could be MBR, GUID or EBR. Then, it will create DiskPartitionMetadata object for each partition that is available in the partition table. This object will be used by the partition enumeration code to create a DiskPartition with the correct minor number.
2020-12-27Kernel: Move Partition code files to the Storage folderLiav A
This folder is more appropriate for these files.
2020-12-21Kernel: Introduce the StorageManagement classLiav A
The StorageManagement class has 2 roles: 1. During boot, it should find all storage controllers in the machine, and then determine what is the boot device. 2. Later on boot, it is a registrar of all storage controllers and storage devices. Thus, it could be used to show information about these devices when implemented. This change allows the user to specify a boot driver other than /dev/hda and if it's connected in the machine - it will boot.