summaryrefslogtreecommitdiff
path: root/Kernel/init.cpp
AgeCommit message (Collapse)Author
2020-08-13Kernel: Simplify the way we check for "serial_debug" on command lineAndreas Kling
2020-08-12Kernel: Tell compiler about invisible callsBen Wiederhake
This makes the Kernel build cleanly with -Wmissing-declarations.
2020-08-12Kernel: Group C++ ABI functions togetherBen Wiederhake
As suggested in #3096.
2020-08-10Kernel: Invoke heap constructors separately early onTom
By having a separate list of constructors for the kernel heap code, we can properly use constructors without re-running them after the heap was already initialized. This solves some problems where values were wiped out because they were overwritten by running their constructors later in the initialization process.
2020-08-10Kernel: More PID/TID typingBen Wiederhake
2020-07-30Kernel: Make BXVGA detection actually detect VBoxVGALuke
I decided to play around with trying to run Serenity in VirtualBox. It crashed WindowServer with a beautiful array of multi-color flashing letters :^) Skipping getting side-tracked seeing that it chose MBVGA in the serial debug and trying to debug why it caused such a display, I finally checked BXVGA. While find_framebuffer_address checks for VBoxVGA, init_stage2 didn't. Whoops!
2020-07-17Kernel: Ensure there are all VirtualConsoles properly initializedFlorian Angermeier
It is possible to switch to VirtualConsoles 1 to 4 via the shortcut ALT + [1-4]. Therefor the array of VirtualConsoles should be guaranteed to be initialized. Also add an constant for the maximum number of VirtualConsoles to guarantee consistency.
2020-07-09Kernel: Fix some flaws that caused crashes or hangs during bootTom
We need to halt the BSP briefly until all APs are ready for the first context switch, but we can't hold the same spinlock by all of them while doing so. So, while the APs are waiting on each other they need to release the scheduler lock, and then once signaled re-acquire it. Should solve some timing dependent hangs or crashes, most easily observed using qemu with kvm disabled.
2020-07-06Kernel: Add SMP IPI supportTom
We can now properly initialize all processors without crashing by sending SMP IPI messages to synchronize memory between processors. We now initialize the APs once we have the scheduler running. This is so that we can process IPI messages from the other cores. Also rework interrupt handling a bit so that it's more of a 1:1 mapping. We need to allocate non-sharable interrupts for IPIs. This also fixes the occasional hang/crash because all CPUs now synchronize memory with each other.
2020-07-03Kernel: Consolidate features into CPUFeature enumTom
This allows us to consolidate printing out all the CPU features into one log statement. Also expose them in /proc/cpuinfo
2020-07-03Kernel: Split initialization of Processor structureTom
We need to very early on initialize the Processor structure so that we can use RecursiveSpinLock early on.
2020-07-01Kernel: Boot all APS all the way into their own idle loopTom
2020-07-01Kernel: Add a quickmap region for each processorTom
Threads need to be able to concurrently quickmap things.
2020-07-01Kernel: Turn Thread::current and Process::current into functionsTom
This allows us to query the current thread and process on a per processor basis
2020-07-01Kernel: Implement software context switching and Processor structureTom
Moving certain globals into a new Processor structure for each CPU allows us to eventually run an instance of the scheduler on each CPU.
2020-06-27Kernel: Make Random work on CPUs without rdrandPeter Elliott
- If rdseed is not available, fallback to rdrand. - If rdrand is not available, block for entropy, or use insecure prng depending on if user wants fast or good random.
2020-06-20Kernel: Remove DMI decoder from the kernelAndreas Kling
As suggested by @supercomputer7, we can simply expose this as a blob and decode it in userspace instead. Fixes #2599.
2020-06-12AK: Make string-to-number conversion helpers return OptionalAndreas Kling
Get rid of the weird old signature: - int StringType::to_int(bool& ok) const And replace it with sensible new signature: - Optional<int> StringType::to_int() const
2020-06-04Kernel: Detect APs and boot them into protected modeTom
This isn't fully working, the APs pretend like they're fully initialized and are just halted permanently for now.
2020-05-27Kernel: Introduce "boot_mode" and "init" cmdline optionsSergey Bugaev
Together, they replace the old text_debug option. * boot_mode should be either "graphical" (the default) or "text". We could potentially support other values here in the future. * init specifies which userspace process the kernel should spawn to bootstrap userspace. By default, this is SystemServer, but you can specify e.g. init=/bin/Shell to run system diagnostics.
2020-05-27Kernel: Port VirtualConsole to LibVT :^)Sergey Bugaev
Unfortunately this drops the feature of preserving VGA buffer contents. Resolves https://github.com/SerenityOS/serenity/issues/2399
2020-05-04Kernel: Use Multiboot macros instead of magic constants (#2090)Nathan Lanza
MUTLIBOOT_FRAMEBUFFER_TYPE_{RGB,EGA_TEXT} are defined in the Multiboot.h header. Use those definitions instead of hard-coding 1 and 2.
2020-04-18Kernel: Remove CommandLine::get() in favor of lookup()Andreas Kling
lookup() returns an Optional<String> which allows us to implement easy default values using lookup(key).value_or(default_value);
2020-04-11Kernel: Instantiate network adapters in their own detect() methodsLiav A
This commit is one step forward for pluggable driver modules. Instead of creating instances of network adapter classes, we let their detect() methods to figure out if there are existing devices to initialize.
2020-04-11Kernel: Keep records of PCI::Address & PCI::ID pairs for enumerationLiav A
2020-04-09Kernel: Create BXVGA device if found in the PCI busLiav A
2020-04-09Kernel: Simplify the Time management initializationLiav A
2020-04-09Kernel: Run clang-format on init.cppLiav A
2020-04-09Kernel: Simplify the Interrupt management initializationLiav A
2020-04-09Kernel: Remove redundant "ACPI" from filenames in ACPI/Andreas Kling
2020-04-09Kernel: Merge ACPI::StaticParser into ACPI::ParserAndreas Kling
There's no need for StaticParser to be a separate thing from Parser.
2020-04-09Kernel: Remove "non-operational" ACPI parser stateAndreas Kling
If we don't support ACPI, just don't instantiate an ACPI parser. This is way less confusing than having a special parser class whose only purpose is to do nothing. We now search for the RSDP in ACPI::initialize() instead of letting the parser constructor do it. This allows us to defer the decision to create a parser until we're sure we can make a useful one.
2020-04-09Kernel: Move ACPI initialization from init.cpp to ACPI::initialize()Andreas Kling
2020-04-09Kernel: Move NetworkTask startup into NetworkTask::spawn()Andreas Kling
2020-04-08Kernel: Simplify PCI initialization logicAndreas Kling
- Get rid of the PCI::Initializer object which was not serving any real purpose or holding any data members. - Move command line parsing from init to PCI::initialize().
2020-04-08Kernel: Simplify VMWareBackdoor somewhatAndreas Kling
- If there is no VMWare backdoor, don't allocate memory for it. - Remove the "unsupported" state, instead just don't instantiate. - Move the command-line parsing from init to the driver. - Move mouse packet reception from PS2MouseDevice to VMWareBackdoor.
2020-04-08Kernel: Move global constructor invocation a bit earlierAndreas Kling
2020-04-08Kernel: Move sync and finalization tasks into their own filesAndreas Kling
Instead of clogging up the initialization sequence, put these tasks in their own files.
2020-04-08Kernel: Remove DebugLogDeviceAndreas Kling
This was a cute idea but ultimately it's just not useful since we already have the dbgputch() and dbgputstr() syscalls.
2020-04-08Kernel: Move more things from init() to init_stage2()Andreas Kling
The purpose of init() is to get multi-tasking up and running. We don't want to do anything in init() that doesn't advance that goal. This patch moves some things from init() to init_stage2(), and adds a comment block explaining the split.
2020-04-08Kernel: Rename KParams => Kernel::CommandLineAndreas Kling
Let's make this read more like English.
2020-04-08Kernel: Update cryptically-named functions related to symbolicationAndreas Kling
2020-04-06Kernel: Change Ext2FS to be backed by a file instead of a block deviceLiav A
In contrast to the previous patchset that was reverted, this time we use a "special" method to access a file with block size of 512 bytes (like a harddrive essentially).
2020-04-03Revert "Kernel: Change Ext2FS to be backed by a file instead of a block device"Andreas Kling
This reverts commit 6b59311d4bdc1447e085573f9bd2c42819e264dd. Reverting these changes since they broke things. Fixes #1608.
2020-04-02Kernel: Change Ext2FS to be backed by a file instead of a block deviceLiav A
This ensures that we can mount image files as virtual disks without the need of implementing gross hacks like loopback devices :)
2020-03-28Kernel: Remove the floppy driverAndreas Kling
Nobody was using this code, and it was not actively worked on, so let's just not have it. Press F.
2020-03-19Kernel: Introduce the new Time management subsystemLiav A
This new subsystem includes better abstractions of how time will be handled in the OS. We take advantage of the existing RTC timer to aid in keeping time synchronized. This is standing in contrast to how we handled time-keeping in the kernel, where the PIT was responsible for that function in addition to update the scheduler about ticks. With that new advantage, we can easily change the ticking dynamically and still keep the time synchronized. In the process context, we no longer use a fixed declaration of TICKS_PER_SECOND, but we call the TimeManagement singleton class to provide us the right value. This allows us to use dynamic ticking in the future, a feature known as tickless kernel. The scheduler no longer does by himself the calculation of real time (Unix time), and just calls the TimeManagment singleton class to provide the value. Also, we can use 2 new boot arguments: - the "time" boot argument accpets either the value "modern", or "legacy". If "modern" is specified, the time management subsystem will try to setup HPET. Otherwise, for "legacy" value, the time subsystem will revert to use the PIT & RTC, leaving HPET disabled. If this boot argument is not specified, the default pattern is to try to setup HPET. - the "hpet" boot argumet accepts either the value "periodic" or "nonperiodic". If "periodic" is specified, the HPET will scan for periodic timers, and will assert if none are found. If only one is found, that timer will be assigned for the time-keeping task. If more than one is found, both time-keeping task & scheduler-ticking task will be assigned to periodic timers. If this boot argument is not specified, the default pattern is to try to scan for HPET periodic timers. This boot argument has no effect if HPET is disabled. In hardware context, PIT & RealTimeClock classes are merely inheriting from the HardwareTimer class, and they allow to use the old i8254 (PIT) and RTC devices, managing them via IO ports. By default, the RTC will be programmed to a frequency of 1024Hz. The PIT will be programmed to a frequency close to 1000Hz. About HPET, depending if we need to scan for periodic timers or not, we try to set a frequency close to 1000Hz for the time-keeping timer and scheduler-ticking timer. Also, if possible, we try to enable the Legacy replacement feature of the HPET. This feature if exists, instructs the chipset to disconnect both i8254 (PIT) and RTC. This behavior is observable on QEMU, and was verified against the source code: https://github.com/qemu/qemu/commit/ce967e2f33861b0e17753f97fa4527b5943c94b6 The HPETComparator class is inheriting from HardwareTimer class, and is responsible for an individual HPET comparator, which is essentially a timer. Therefore, it needs to call the singleton HPET class to perform HPET-related operations. The new abstraction of Hardware timers brings an opportunity of more new features in the foreseeable future. For example, we can change the callback function of each hardware timer, thus it makes it possible to swap missions between hardware timers, or to allow to use a hardware timer for other temporary missions (e.g. calibrating the LAPIC timer, measuring the CPU frequency, etc).
2020-03-06Init Stage: Allow to boot with smp=onLiav A
One can now set the kernel boot argument smp to on, and therefore, to instruct the kernel to use the IOAPIC instead of the PIC.
2020-03-02Kernel: Use klog() instead of kprintf()Liav A
Also, duplicate data in dbg() and klog() calls were removed. In addition, leakage of virtual address to kernel log is prevented. This is done by replacing kprintf() calls to dbg() calls with the leaked data instead. Also, other kprintf() calls were replaced with klog().
2020-02-29Init Stage: Use latest changesLiav A
Now we setup interrupts before ACPI, and we don't use the ACPI parser to find the MADT table anymore.