Commit Graph

160 Commits

Author SHA1 Message Date
Timothy Flynn
c911781c21 Everywhere: Remove needless trailing semi-colons after functions
This is a new option in clang-format-16.
2023-07-08 10:32:56 +01:00
Liav A
336fb4f313 Kernel: Move InterruptDisabler to the Interrupts subdirectory 2023-06-04 21:32:34 +02:00
Liav A
927926b924 Kernel: Move Performance-measurement code to the Tasks subdirectory 2023-06-04 21:32:34 +02:00
Liav A
b88c1d90e1 Kernel: Move TimerQueue code to the Time subdirectory 2023-06-04 21:32:34 +02:00
Liav A
8f21420a1d Kernel: Move all boot-related code to the new Boot subdirectory 2023-06-04 21:32:34 +02:00
Liav A
1b04726c85 Kernel: Move all tasks-related code to the Tasks subdirectory 2023-06-04 21:32:34 +02:00
Daniel Bertalan
906abbdf53 Kernel/aarch64: Fix build after #17842 2023-05-25 08:26:07 -07:00
kleines Filmröllchen
fc5cab5c21 Everywhere: Use MonotonicTime instead of Duration
This is easily identifiable by anyone who uses Duration::now_monotonic,
and any downstream users of that data.
2023-05-24 23:18:07 +02:00
kleines Filmröllchen
939600d2d4 Kernel: Use UnixDateTime wherever applicable
"Wherever applicable" = most places, actually :^), especially for
networking and filesystem timestamps.

This includes changes to unzip, which uses DOSPackedTime, since that is
changed for the FAT file systems.
2023-05-24 23:18:07 +02:00
kleines Filmröllchen
213025f210 AK: Rename Time to Duration
That's what this class really is; in fact that's what the first line of
the comment says it is.

This commit does not rename the main files, since those will contain
other time-related classes in a little bit.
2023-05-24 23:18:07 +02:00
Pankaj Raghav
8944ca830f Kernel: Remove is_sharing_with_others API from GenericInterruptHandler
is_sharing_with_others API was never really put to use properly since
it was introduced. The only place where it is used in Interrupts.cpp is
in conjuction with is_shared_handler() which is only true for
SharedIRQHandler and is_sharing_with_others will always return false.

Remove that API.
2023-04-25 10:18:39 +02:00
Timon Kruiper
188a52db01 Kernel: Implement TimeManagement::boot_time() for aarch64
For now just return 0 as we have no RTC support on aarch64 yet, and add
a FIXME to return the correct value.
2023-04-06 21:19:58 +03:00
Marco Cutecchia
f61e65a609 Kernel: Add missing include that broke the AARCH64 build 2023-03-08 14:20:29 +01:00
Andreas Kling
7369d0ab5f Kernel: Stop using NonnullLockRefPtrVector 2023-03-06 23:46:36 +01:00
Humberto Alves
f6eb155167 Kernel: Support more clocks in sys$clock_getres()
Support all the available clocks in clock_getres(). Also, fix this
function to use the actual ticks per second value, not the constant
`_SC_CLK_TCK` (which is always equal to 8) and move the resolution
computation logic to TimeManagement.
2023-02-21 01:00:06 +01:00
Sam Atkins
3cbc0fdbb0 Kernel: Remove declarations for non-existent methods 2023-01-27 20:33:18 +00:00
Liav A
91db482ad3 Kernel: Reorganize Arch/x86 directory to Arch/x86_64 after i686 removal
No functional change.
2022-12-28 11:53:41 +01:00
Liav A
5ff318cf3a Kernel: Remove i686 support 2022-12-28 11:53:41 +01:00
Andreas Kling
10fa72d451 Kernel: Use AK::Time for InodeMetadata timestamps instead of time_t
Before this change, we were truncating the nanosecond part of file
timestamps in many different places.
2022-11-24 16:56:27 +01:00
Timon Kruiper
01a14ac7af Kernel: Implement TimeManagement for aarch64
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-17 20:11:31 +02:00
Timon Kruiper
83b95c135e Kernel/aarch64: Implement HardwareTimer for RPi::Timer
This makes the RPi::Timer suitable for use in the TimeManagement code.
2022-10-17 20:11:31 +02:00
Timon Kruiper
9827c11d8b Kernel: Move InterruptDisabler out of Arch directory
The code in this file is not architecture specific, so it can be moved
to the base Kernel directory.
2022-10-17 20:11:31 +02:00
Liav A
7520acd4eb Kernel: Move Scheduler current time method to the TimeManagement code 2022-10-14 14:13:51 +02:00
Liav A
fe2bd8e3dd Kernel: Move x86-specific timer code handling to Arch/x86/Time directory
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-23 17:22:15 +01:00
Liav A
1b7b360ca1 Kernel: Move x86-specific IRQ controller code to Arch/x86 directory
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-20 18:43:05 +01:00
Liav A
d5ee03ef5b Kernel/x86: Move RTC and CMOS code to x86 arch-specific subdirectory
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-09-20 18:43:05 +01:00
Andreas Kling
11eee67b85 Kernel: Make self-contained locking smart pointers their own classes
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-20 17:20:43 +02:00
Andreas Kling
e475263113 AK+Kernel: Add AK::AtomicRefCounted and use everywhere in the kernel
Instead of having two separate implementations of AK::RefCounted, one
for userspace and one for kernelspace, there is now RefCounted and
AtomicRefCounted.
2022-08-20 17:15:52 +02:00
Undefine
97cc33ca47 Everywhere: Make the codebase more architecture aware 2022-07-27 21:46:42 +00:00
sin-ack
fbc771efe9 Everywhere: Use default StringView constructor over nullptr
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-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
Andreas Kling
adaaea4c9a Kernel: Make TimeManagement::boot_time() static 2022-06-15 17:15:04 +02:00
Timon Kruiper
f085903f62 Kernel: Move IRQController and InterruptManagement to Arch directory
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-02 13:14:12 +01:00
Timon Kruiper
a4534678f9 Kernel: Implement InterruptDisabler using generic Processor functions
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-02 13:14:12 +01:00
Timon Kruiper
ea9cf8b6ab Kernel: Separate NonMaskableInterruptDisabler into its own file
This is for the upcoming change to make InterruptDisabler class work for
the aarch64 build.
2022-06-02 13:14:12 +01:00
Idan Horowitz
086969277e Everywhere: Run clang-format 2022-04-01 21:24:45 +01:00
Brian Gianforcaro
d05fa14e52 Kernel: Use TRY() when validating clock_id in TimeManagement
Gets rid of a bit of code duplication, and makes the API more consistent
with the style we are moving towards.
2022-02-21 15:47:51 -08:00
Idan Horowitz
57ba67ed2a Kernel: Create the time page region before initializing the timers
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-18 21:00:46 +02:00
Idan Horowitz
fb3e46e930 Kernel: Make map_typed() & map_typed_writable() fallible using ErrorOr
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.
2022-01-13 22:40:25 +01:00
Andreas Kling
ac7ce12123 Kernel: Remove the kmalloc_eternal heap :^)
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-28 21:02:38 +01:00
Pankaj Raghav
1a27220bca Kernel: Encapsulate APIC initialization inside InterruptManagement
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-26 16:22:09 +02:00
Hendiadyoin1
e34eb3e36d Kernel: Remove unused String.h includes
This makes searching for not yet OOM safe interfaces a bit easier.
2021-12-11 13:15:26 -08:00
Andreas Kling
63117f826b Kernel: Simplify 64-bit HPET reads on x86_64
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-12-11 20:13:25 +01:00
Andreas Kling
79fa9765ca Kernel: Replace KResult and KResultOr<T> with Error and ErrorOr<T>
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-11-08 01:10:53 +01:00
Andreas Kling
0592f80186 Kernel: Add TimeManagement::is_initialized()
This allows clients to check whether TimeManagement is available before
trying to ask it about time related things.
2021-10-26 01:00:54 +02:00
James Mintram
dfe4810c3a Kernel: Add cross platform RegisterState header and Aarch64 version
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-15 21:48:45 +01:00
Brian Gianforcaro
3a945051fc Kernel: Use operator ""sv in all purpose() implementations
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-03 13:36:10 +02:00
Liav A
4974727dbb Kernel: Move x86 IO instructions code into the x86 specific folder 2021-10-01 12:27:20 +02:00
Liav A
3e9dfd2e74 Kernel: Remove IO.h include from a bunch of places 2021-10-01 12:27:20 +02:00
Liav A
9132596b8e Kernel: Move ACPI and BIOS code into the new Firmware directory
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-12 11:52:16 +02:00