summaryrefslogtreecommitdiff
path: root/Kernel/init.cpp
AgeCommit message (Collapse)Author
2020-02-17Kernel: Replace "current" with Thread::current and Process::currentAndreas Kling
Suggested by Sergey. The currently running Thread and Process are now Thread::current and Process::current respectively. :^)
2020-02-16Kernel: Move all code into the Kernel namespaceAndreas Kling
2020-02-10AK: Remove bitrotted Traits::dump() mechanismAndreas Kling
This was only used by HashTable::dump() which I used when doing the first HashTable implementation. Removing this allows us to also remove most includes of <AK/kstdio.h>.
2020-02-09Kernel: Apply changes to use LibBareMetal definitionsLiav A
2020-02-08Kernel: Merge unnecessary DiskDevice class into BlockDeviceAndreas Kling
2020-02-05Kernel Commandline: Change nopci_mmio to be pci_mmioLiav A
Instead of having nopci_mmio, the boot argument now is pci_mmio='on|off'.
2020-02-05Kernel Commandline: Change no_vmmouse boot argument to be vmmouseLiav A
Instead of having no_vmmouse, the boot argument now is vmmouse='on|off'.
2020-02-05Kernel Commandline: Remove noacpi & noacpi_aml boot argumentsLiav A
Instead of having boot arguments like noacpi & noacpi_aml, we have one boot argument - acpi='on|off|limited'.
2020-02-04Kernel: Add support for vmmouseLiav A
We add this feature together with the VMWareBackdoor class. VMWareBackdoor class is responsible for enabling the vmmouse, and then controlling it from the PS2 mouse IRQ handler.
2020-02-02Kernel: Detect devices when enumerating the PCI busLiav A
Instead of making each driver to enumerate the PCI bus itself, PCI::Initializer will call detect_devices() to do one enumeration of the bus.
2020-02-02Partition Table: Add support for Extended partitionsLiav A
Now also MBR configurations with extended partitions are supported.
2020-02-01Partition Table: Allow to boot with a partition number higher than 4Liav A
This is true currently only to GUID partitions, Booting with an MBR partition is still limited to partition numbers 1-4.
2020-02-01Kernel: Finalizer should not go back to sleep if there's more to doAndreas Kling
Before putting itself back on the wait queue, the finalizer task will now check if there's more work to do, and if so, do it first. :^) This patch also puts a bunch of process/thread debug logging behind PROCESS_DEBUG and THREAD_DEBUG since it was unbearable to debug this stuff with all the spam.
2020-01-22Revert "Kernel: Replace IRQHandler with the new InterruptHandler class"Andreas Kling
This reverts commit 6c72736b26a81a8f03d8dd47989bfffe26bb1c95. I am unable to boot on my home machine with this change in the tree.
2020-01-22Kernel: Replace IRQHandler with the new InterruptHandler classLiav A
System components that need an IRQ handling are now inheriting the InterruptHandler class. In addition to that, the initialization process of PATAChannel was changed to fit the changes. PATAChannel, E1000NetworkAdapter and RTL8139NetworkAdapter are now inheriting from PCI::Device instead of InterruptHandler directly.
2020-01-21Kernel: Remove map_for_kernel() in MemoryManagerLiav A
We don't need to have this method anymore. It was a hack that was used in many components in the system but currently we use better methods to create virtual memory mappings. To prevent any further use of this method it's best to just remove it completely. Also, the APIC code is disabled for now since it doesn't help booting the system, and is broken since it relies on identity mapping to exist in the first 1MB. Any call to the APIC code will result in assertion failed. In addition to that, the name of the method which is responsible to create an identity mapping between 1MB to 2MB was changed, to be more precise about its purpose.
2020-01-18Kernel: Clean up and reorganize init.cppAndreas Kling
This is where we first enter into the kernel, so we should make at least some effort to keep things nice and understandable.
2020-01-18Kernel: Move all CPU feature initialization into cpu_setup()Andreas Kling
..and do it very very early in boot.
2020-01-18ACPI: Re-enable ACPI initialization after paging changesAndreas Kling
2020-01-18Meta: Add license header to source filesAndreas Kling
As suggested by Joshua, this commit adds the 2-clause BSD license as a comment block to the top of every source file. For the first pass, I've just added myself for simplicity. I encourage everyone to add themselves as copyright holders of any file they've added or modified in some significant way. If I've added myself in error somewhere, feel free to replace it with the appropriate copyright holder instead. Going forward, all new source files should include a license header.
2020-01-17Kernel: Move kernel above the 3GB virtual address markAndreas Kling
The kernel and its static data structures are no longer identity-mapped in the bottom 8MB of the address space, but instead move above 3GB. The first 8MB above 3GB are pseudo-identity-mapped to the bottom 8MB of the physical address space. But things don't have to stay this way! Thanks to Jesse who made an earlier attempt at this, it was really easy to get device drivers working once the page tables were in place! :^) Fixes #734.
2020-01-17Kernel: Misc tweaksSergey Bugaev
2020-01-14Kernel: Move DMI decoder initialization method to init_stage2Liav A
Also, PCI Initializer dismiss() now deletes the object correctly, and the PCI initialization process no longer use the DMI decoder to determine if PCI is supported. grub configuration files include an entry to boot the OS without ACPI support.
2020-01-10Kernel: Add a basic chroot() syscall :^)Andreas Kling
The chroot() syscall now allows the superuser to isolate a process into a specific subtree of the filesystem. This is not strictly permanent, as it is also possible for a superuser to break *out* of a chroot, but it is a useful mechanism for isolating unprivileged processes. The VFS now uses the current process's root_directory() as the root for path resolution purposes. The root directory is stored as an uncached Custody in the Process object.
2020-01-06Kernel: Randomize the stack canary on startupAndreas Kling
2020-01-03Kernel: Add a more expressive API for getting random bytesAndreas Kling
We now have these API's in <Kernel/Random.h>: - get_fast_random_bytes(u8* buffer, size_t buffer_size) - get_good_random_bytes(u8* buffer, size_t buffer_size) - get_fast_random<T>() - get_good_random<T>() Internally they both use x86 RDRAND if available, otherwise they fall back to the same LCG we had in RandomDevice all along. The main purpose of this patch is to give kernel code a way to better express its needs for random data. Randomness is something that will require a lot more work, but this is hopefully a step in the right direction.
2020-01-02Kernel: Create support for PCI ECAMLiav A
The new PCI subsystem is initialized during runtime. PCI::Initializer is supposed to be called during early boot, to perform a few tests, and initialize the proper configuration space access mechanism. Kernel boot parameters can be specified by a user to determine what tests will occur, to aid debugging on problematic machines. After that, PCI::Initializer should be dismissed. PCI::IOAccess is a class that is derived from PCI::Access class and implements PCI configuration space access mechanism via x86 IO ports. PCI::MMIOAccess is a class that is derived from PCI::Access and implements PCI configurtaion space access mechanism via memory access. The new PCI subsystem also supports determination of IO/MMIO space needed by a device by checking a given BAR. In addition, Every device or component that use the PCI subsystem has changed to match the last changes.
2020-01-01Kernel: Disable x86 RDTSC instruction in userspaceAndreas Kling
It's still possible to read the TSC via the read_tsc() syscall, but we will now clear some of the bottom bits for unprivileged users.
2020-01-01Kernel: Enable x86 UMIP (User Mode Instruction Prevention) if supportedAndreas Kling
This prevents code running outside of kernel mode from using the following instructions: * SGDT - Store Global Descriptor Table * SIDT - Store Interrupt Descriptor Table * SLDT - Store Local Descriptor Table * SMSW - Store Machine Status Word * STR - Store Task Register There's no need for userspace to be able to use these instructions so let's just disable them to prevent information leakage.
2020-01-01Kernel: Move CPU feature detection to Arch/x86/CPU.{cpp.h}Andreas Kling
We now refuse to boot on machines that don't support PAE since all of our paging code depends on it. Also let's only enable SSE and PGE support if the CPU advertises it.
2019-12-30Kernel: Refactor scheduler to use dynamic thread prioritiesAndreas Kling
Threads now have numeric priorities with a base priority in the 1-99 range. Whenever a runnable thread is *not* scheduled, its effective priority is incremented by 1. This is tracked in Thread::m_extra_priority. The effective priority of a thread is m_priority + m_extra_priority. When a runnable thread *is* scheduled, its m_extra_priority is reset to zero and the effective priority returns to base. This means that lower-priority threads will always eventually get scheduled to run, once its effective priority becomes high enough to exceed the base priority of threads "above" it. The previous values for ThreadPriority (Low, Normal and High) are now replaced as follows: Low -> 10 Normal -> 30 High -> 50 In other words, it will take 20 ticks for a "Low" priority thread to get to "Normal" effective priority, and another 20 to reach "High". This is not perfect, and I've used some quite naive data structures, but I think the mechanism will allow us to build various new and interesting optimizations, and we can figure out better data structures later on. :^)
2019-12-29Kernel: Embrace the SerenityOS nameAndreas Kling
2019-12-22Kernel: Get rid of "main thread" conceptAndreas Kling
The idea of all processes reliably having a main thread was nice in some ways, but cumbersome in others. More importantly, it didn't match up with POSIX thread semantics, so let's move away from it. This thread gets rid of Process::main_thread() and you now we just have a bunch of Thread objects floating around each Process. When the finalizer nukes the last Thread in a Process, it will also tear down the Process. There's a bunch of more things to fix around this, but this is where we get started :^)
2019-12-01Kernel: Use a WaitQueue to implement finalizer wakeupAndreas Kling
This gets rid of the special "Lurking" thread state and replaces it with a generic WaitQueue :^)
2019-11-17Kernel: Just hang if VFS::mount_root() failsAndreas Kling
2019-11-13Kernel: Add a kernel boot parameter to force PIO modesupercomputer7
Also added an option in the run script to force PIO operation mode with the IDE controller. In addition, we're no longer limited to PIIX3 and PIIX4 chipsets for DMA
2019-11-09Kernel: Use a lookup table for syscallsAndreas Kling
Instead of the big ugly switch statement, build a lookup table using the syscall enumeration macro. This greatly simplifies the syscall implementation. :^)
2019-11-08Kernel: Removing hardcoded offsets from Memory Managersupercomputer7
Now the kernel page directory and the page tables are located at a safe address, to prevent from paging data colliding with garbage.
2019-11-06Kernel: Rework Process::Priority into ThreadPriorityAndreas Kling
Scheduling priority is now set at the thread level instead of at the process level. This is a step towards allowing processes to set different priorities for threads. There's no userspace API for that yet, since only the main thread's priority is affected by sched_setparam().
2019-11-06Kernel: Remove unnecessary init_ksyms() functionAndreas Kling
2019-11-06Kernel: Don't instantiate and throw away ProcFS + DevPtsFS on bootAndreas Kling
Oops, we were creating these and then throwing them away. They will get instantiated a bit later, when we bring up the mounts in /etc/fstab from userspace.
2019-11-06Kernel: Use KParams::has() instead of !KParams::get().is_null()Andreas Kling
Also rename a local variable to be consistent with what it represents.
2019-11-06Kernel+SystemServer: Get rid of two virtual consolesAndreas Kling
Having four virtual (text) consoles by default seems really overkill for a system that can't even switch to them anyway (yet!)
2019-10-31Kernel: Add bare minimum for global constructors (#707)Andrew Kaster
Add text.startup to the .text block, add .ctors as well. Use them in init.cpp to call global constructors after gtd and idt init. That way any funky constructors should be ok. Also defines some Itanium C++ ABI methods that probably shouldn't be, but without them the linker gets very angry. If the code ever actually tries to use __dso_handle or call __cxa_atexit, there's bigger problems with the kernel. Bit of a hack would be an understatement but hey. It works :)
2019-10-29Kernel: Enabling Text mode debugging (#696)Liav A
Also added an option to start Serenity with text mode in QEMU in the run script.
2019-10-16APIC: Enable APIC and start APsTom
2019-10-07PartitionTable: Initial GPT Support, Adding Block Limitsupercomputer7
Also added a script to handle creation of GPT partitioned disk (with GRUB config file). Block limit will be used to disallow potential access to other partitions.
2019-09-16Kernel: Add a simple slab allocator for small allocationsAndreas Kling
This is a freelist allocator with static size classes that works as a complement to the generic kmalloc(). It's a lot faster than kmalloc() since allocation just means popping from the freelist. It's also significantly more compact when there are a lot of objects smaller than the minimum kmalloc chunk size (32 bytes.) This patch enables it for the Region and PhysicalPage classes. In the PhysicalPage (8 bytes) case, it's a huge improvement since we no longer waste 75% of the storage allocated. There are also a number of ways this can be improved, so let's keep working on it going forward.
2019-09-16Kernel: Move kmalloc() into a Kernel/Heap/ directoryAndreas Kling
2019-09-14Kernel: Stop idling after handling an IRQAndreas Kling
If we receive an IRQ while the idle task is running, prevent it from re-halting the CPU after the IRQ handler returns. Instead have the idle task yield to the scheduler, so we can see if the IRQ has unblocked something.