summaryrefslogtreecommitdiff
path: root/Kernel/Time
AgeCommit message (Collapse)Author
2022-10-17Kernel: Implement TimeManagement for aarch64Timon Kruiper
This sets up the RPi::Timer to trigger an interurpt every 4ms using one of the comparators. The actual time is calculated by looking at the main counter of the RPi::Timer using the Timer::update_time function. A stub for Scheduler::timer_tick is also added, since the TimeManagement code now calls the function.
2022-10-17Kernel/aarch64: Implement HardwareTimer for RPi::TimerTimon Kruiper
This makes the RPi::Timer suitable for use in the TimeManagement code.
2022-10-17Kernel: Move InterruptDisabler out of Arch directoryTimon Kruiper
The code in this file is not architecture specific, so it can be moved to the base Kernel directory.
2022-10-14Kernel: Move Scheduler current time method to the TimeManagement codeLiav A
2022-09-23Kernel: Move x86-specific timer code handling to Arch/x86/Time directoryLiav A
The APICTimer, HPET and RTC (the RTC timer is in the context of the PC RTC here) are timers that exist only in x86 platforms, therefore, we move the handling code and the initialization code to the Arch/x86/Time directory. Other related code patterns in the TimeManagement singleton and in the Random.cpp file are guarded with #ifdef to ensure they are only compiled for x86 builds.
2022-09-20Kernel: Move x86-specific IRQ controller code to Arch/x86 directoryLiav A
The PIC and APIC code are specific to x86 platforms, so move them out of the general Interrupts directory to Arch/x86/common/Interrupts directory instead.
2022-09-20Kernel/x86: Move RTC and CMOS code to x86 arch-specific subdirectoryLiav A
The RTC and CMOS are currently only supported for x86 platforms and use specific x86 instructions to produce only certain x86 plaform operations and results, therefore, we move them to the Arch/x86 specific directory.
2022-08-20Kernel: Make self-contained locking smart pointers their own classesAndreas Kling
Until now, our kernel has reimplemented a number of AK classes to provide automatic internal locking: - RefPtr - NonnullRefPtr - WeakPtr - Weakable This patch renames the Kernel classes so that they can coexist with the original AK classes: - RefPtr => LockRefPtr - NonnullRefPtr => NonnullLockRefPtr - WeakPtr => LockWeakPtr - Weakable => LockWeakable The goal here is to eventually get rid of the Lock* classes in favor of using external locking.
2022-08-20AK+Kernel: Add AK::AtomicRefCounted and use everywhere in the kernelAndreas Kling
Instead of having two separate implementations of AK::RefCounted, one for userspace and one for kernelspace, there is now RefCounted and AtomicRefCounted.
2022-07-27Everywhere: Make the codebase more architecture awareUndefine
2022-07-12Everywhere: Use default StringView constructor over nullptrsin-ack
While null StringViews are just as bad, these prevent the removal of StringView(char const*) as that constructor accepts a nullptr. No functional changes.
2022-07-12Everywhere: Add sv suffix to strings relying on StringView(char const*)sin-ack
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-06-15Kernel: Make TimeManagement::boot_time() staticAndreas Kling
2022-06-02Kernel: Move IRQController and InterruptManagement to Arch directoryTimon Kruiper
These 2 classes currently contain much code that is x86(_64) specific. Move them to the architecture specific directory. This also allows for a simpler implementation for aarch64.
2022-06-02Kernel: Implement InterruptDisabler using generic Processor functionsTimon Kruiper
Now that the code does not use architectural specific code, it is moved to the generic Arch directory and the paths are modified accordingly.
2022-06-02Kernel: Separate NonMaskableInterruptDisabler into its own fileTimon Kruiper
This is for the upcoming change to make InterruptDisabler class work for the aarch64 build.
2022-04-01Everywhere: Run clang-formatIdan Horowitz
2022-02-21Kernel: Use TRY() when validating clock_id in TimeManagementBrian Gianforcaro
Gets rid of a bit of code duplication, and makes the API more consistent with the style we are moving towards.
2022-01-18Kernel: Create the time page region before initializing the timersIdan Horowitz
We were unconditionally trying to update it in the interrupt, which would depend on the timer interrupt not being received too soon after the timers are initialized (before the time page was initialized), which was the case when using HPET timers via the ACPI tables, but not when using the PIT when ACPI was disabled.
2022-01-13Kernel: Make map_typed() & map_typed_writable() fallible using ErrorOrIdan Horowitz
This mostly just moved the problem, as a lot of the callers are not capable of propagating the errors themselves, but it's a step in the right direction.
2021-12-28Kernel: Remove the kmalloc_eternal heap :^)Andreas Kling
This was a premature optimization from the early days of SerenityOS. The eternal heap was a simple bump pointer allocator over a static byte array. My original idea was to avoid heap fragmentation and improve data locality, but both ideas were rooted in cargo culting, not data. We would reserve 4 MiB at boot and only ended up using ~256 KiB, wasting the rest. This patch replaces all kmalloc_eternal() usage by regular kmalloc().
2021-12-26Kernel: Encapsulate APIC initialization inside InterruptManagementPankaj Raghav
Currently the APIC class is constructed irrespective of whether it is used or not. So, move APIC initialization from init to the InterruptManagement class and construct the APIC class only when it is needed.
2021-12-11Kernel: Remove unused String.h includesHendiadyoin1
This makes searching for not yet OOM safe interfaces a bit easier.
2021-12-11Kernel: Simplify 64-bit HPET reads on x86_64Andreas Kling
We don't have to worry about racy 32-bit reads when we're reading the 64-bit HPET value using a 64-bit CPU. :^)
2021-11-08Kernel: Replace KResult and KResultOr<T> with Error and ErrorOr<T>Andreas Kling
We now use AK::Error and AK::ErrorOr<T> in both kernel and userspace! This was a slightly tedious refactoring that took a long time, so it's not unlikely that some bugs crept in. Nevertheless, it does pass basic functionality testing, and it's just real nice to finally see the same pattern in all contexts. :^)
2021-10-26Kernel: Add TimeManagement::is_initialized()Andreas Kling
This allows clients to check whether TimeManagement is available before trying to ask it about time related things.
2021-10-15Kernel: Add cross platform RegisterState header and Aarch64 versionJames Mintram
A new RegisterState header includes the platform specific RegisterState header based on the platform being compiled. The Aarch64 RegisterState header contains stubs for Debug
2021-10-03Kernel: Use `operator ""sv` in all purpose() implementationsBrian Gianforcaro
Previously there was a mix of returning plain strings and returning explicit string views using `operator ""sv`. This change switches them all to standardized on `operator ""sv` as it avoids a call to strlen.
2021-10-01Kernel: Move x86 IO instructions code into the x86 specific folderLiav A
2021-10-01Kernel: Remove IO.h include from a bunch of placesLiav A
2021-09-12Kernel: Move ACPI and BIOS code into the new Firmware directoryLiav A
This will somwhat help unify them also under the same SysFS directory in the commit. Also, it feels much more like this change reflects the reality that both ACPI and the BIOS are part of the firmware on x86 computers.
2021-09-08Kernel/ACPI: Return Optional container after table searchLiav A
This is a better pattern than returning a PhysicalAddress with a zero value, so the code is more understandable now.
2021-09-06Kernel: Make kernel region allocators return KResultOr<NOP<Region>>Andreas Kling
This expands the reach of error propagation greatly throughout the kernel. Sadly, it also exposes the fact that we're allocating (and doing other fallible things) in constructors all over the place. This patch doesn't attempt to address that of course. That's work for our future selves.
2021-09-05Kernel: Switch static_asserts of a type size to AK::AssertSizeBrian Gianforcaro
This will provide better debug ability when the size comparison fails.
2021-09-05AK+Kernel: Move KResult.h to Kernel/API for userspace accesssin-ack
This commit moves the KResult and KResultOr objects to Kernel/API to signify that they may now be freely used by userspace code at points where a syscall-related error result is to be expected. It also exposes KResult and KResultOr to the global namespace to make it nicer to use for userspace code.
2021-08-23Kernel: Convert Processor::in_irq() to static current_in_irq()Andreas Kling
This closes the race window between Processor::current() and a context switch happening before in_irq().
2021-08-10Kernel: Add CLOCK_MONOTONIC_COARSE to the kernel time pageAndreas Kling
This allows clock_gettime(CLOCK_MONOTONIC_COARSE) without syscalls. Core::EventLoop takes advantage of this automatically. :^)
2021-08-10Kernel: Only expose CLOCK_REALTIME_COARSE via the kernel time pageAndreas Kling
Non-COARSE clock sources may probably still require a syscall.
2021-08-10Kernel: Close race window in timestamp update mechanismAndreas Kling
As pointed out by 8infy, this mechanism is racy: WRITER: 1. ++update1; 2. write_data(); 3. ++update2; READER: 1. do { auto saved = update1; 2. read_data(); 3. } while (saved != update2); The following sequence can lead to a bogus/partial read: R1 R2 R3 W1 W2 W3 We close this race by incrementing the second update counter first: WRITER: 1. ++update2; 2. write_data(); 3. ++update1;
2021-08-10Kernel+LibC: Allow clock_gettime() to run without syscallsAndreas Kling
This patch adds a vDSO-like mechanism for exposing the current time as an array of per-clock-source timestamps. LibC's clock_gettime() calls sys$map_time_page() to map the kernel's "time page" into the process address space (at a random address, ofc.) This is only done on first call, and from then on the timestamps are fetched from the time page. This first patch only adds support for CLOCK_REALTIME, but eventually we should be able to support all clock sources this way and get rid of sys$clock_gettime() in the kernel entirely. :^) Accesses are synchronized using two atomic integers that are incremented at the start and finish of the kernel's time page update cycle.
2021-08-08Everywhere: Replace AK::Singleton => SingletonAndreas Kling
2021-08-06Kernel: Add convenience values to the Memory::Region::Access enumAndreas Kling
Instead of `Memory::Region::Access::Read | Memory::Region::AccessWrite` you can now say `Memory::Region::Access::ReadWrite`.
2021-08-06Kernel: Move Kernel/Memory/ code into Kernel::Memory namespaceAndreas Kling
2021-08-06Kernel: Rename Kernel/VM/ to Kernel/Memory/Andreas Kling
This directory isn't just about virtual memory, it's about all kinds of memory management.
2021-08-06Kernel: Make HardwareTimer::model() return StringViewAndreas Kling
2021-08-01Kernel: Remove unused header includesBrian Gianforcaro
2021-07-18Everywhere: Make tracking cpu usage independent from system ticksTom
This switches tracking CPU usage to more accurately measure time in user and kernel land using either the TSC or another time source. This will also come in handy when implementing a tickless kernel mode.
2021-07-17Kernel: Remove TimeManagement::initialized that wasn't implementedTom
2021-07-11Kernel: Remove unused header includes in Time subtreeBrian Gianforcaro
2021-07-11Kernel: Make various T::class_name() and similar return StringViewAndreas Kling
Instead of returning char const*, we can also give you a StringView.