Commit Graph

8668 Commits

Author SHA1 Message Date
Idan Horowitz
26cff62a0a Kernel: Rename Memory::PhysicalPage to Memory::PhysicalRAMPage
Since these are now only used to represent RAM pages, (and not MMIO
pages) rename them to make their purpose more obvious.
2024-05-17 15:38:28 -06:00
Idan Horowitz
827322c139 Kernel: Stop allocating physical pages for mapped MMIO regions
As MMIO is placed at fixed physical addressed, and does not need to be
backed by real RAM physical pages, there's no need to use PhysicalPage
instances to track their pages.
This results in slightly reduced allocations, but more importantly
makes MMIO addresses which end up after the normal RAM ranges work,
like 64-bit PCI BARs usually are.
2024-05-17 15:38:28 -06:00
Liav A.
5f3ef1aa9e Kernel: Remove includes of PCI API.h file
This file will be removed in a future commit, so let's get rid of what
we can right now.
2024-05-14 15:42:29 -06:00
Liav A.
e1d435d0b0 Kernel/x86_64: Rename PCI HostBridge => PIIX4HostBridge
This code is actually for the old PIIX4 PCI host bridge, which requires
to use legacy x86 IO instructions.
2024-05-14 15:42:29 -06:00
Liav A.
69a3602237 Kernel/GPU: Rename GenericGraphicsAdapter => GPUDevice
GenericGraphicsAdapter is mouthful. Also, the idea is to move towards a
more advanced subsystem that handles GPUs, not merely graphics adapters.
2024-05-14 15:42:29 -06:00
Liav A
6014ce0552 Kernel/PCI: Add small access spinlock to each HostController
Prepare to remove biglock on PCI::Access in a future commit, so we can
ensure we only lock a spinlock on a precise PCI HostController if needed
instead of the entire subsystem.
2024-05-14 15:42:29 -06:00
Liav A.
0bab9a9313 Kernel: Move VirtIO RNG implementation to the Security/Random directory 2024-05-14 15:42:29 -06:00
Liav A.
bbb749ab47 Kernel: Move VirtIO console code to the Devices/Serial/VirtIO directory 2024-05-14 15:42:29 -06:00
Liav A.
cb558f4459 Kernel/Devices: Remove SerialDevice::initialize method
We can just do the initialization sequence in the constructor.
2024-05-14 15:42:29 -06:00
Liav A.
b4c218168f Kernel/Storage: Remove StorageController reset and shutdown methods
We never used these virtual methods outside their own implementation,
so let's stop pretending that we should be able to utilize this for
unknown purpose.
2024-05-14 15:42:29 -06:00
Liav A.
eadf2bf29f Kernel/Devices: Remove UNMAP_AFTER_INIT from SerialDevice code 2024-05-14 15:42:29 -06:00
Liav A.
136d5b12d5 Kernel/VirtIO: Remove stale detect method 2024-05-14 15:42:29 -06:00
Liav A.
d73c82d746 Kernel: Remove UNMAP_AFTER_INIT from VGA text mode console 2024-05-14 15:42:29 -06:00
Liav A
d068af89d5 Kernel/x86: Bake the Prekernel and the Kernel into one image
The new baked image is a Prekernel and a Kernel baked together now, so
essentially we no longer need to pass the Prekernel as -kernel and the
actual kernel image as -initrd to QEMU, leaving the option to pass an
actual initrd or initramfs module later on with multiboot.
2024-05-14 23:37:38 +02:00
implicitfield
4574a8c334 Kernel+LibC+LibCore: Implement mknodat(2) 2024-05-14 22:30:39 +02:00
implicitfield
05cf1327ed Kernel: Make utimensat ignore the dirfd when given an absolute path 2024-05-14 22:30:39 +02:00
Sönke Holz
fe12a413a1 Kernel: Use AK::unwind_stack_from_frame_pointer 2024-05-14 14:02:06 -06:00
Liav A.
5194ab59b5 Kernel/Memory: Make has_been_{r,w,x} flags clearly being set
Before of this change, actually setting the m_access to contain the
HasBeen{Readeable,Writable,Executable} bits was done by the method of
Region set_access_bit which added ORing with (access << 4) when enabling
a certain access bit to achieve this.

Now this is changed and when calling set_{readeable,writable,executable}
methods, they will set an appropriate SetOnce flag that could be checked
later.
2024-05-14 12:41:51 -06:00
Liav A.
15ddc1f17a Kernel+Userland: Reject W->X prot region transition after a prctl call
We add a prctl option which would be called once after the dynamic
loader has finished to do text relocations before calling the actual
program entry point.

This change makes it much more obvious when we are allowed to change
a region protection access from being writable to executable.
The dynamic loader should be able to do this, but after a certain point
it is obvious that such mechanism should be disabled.
2024-05-14 12:41:51 -06:00
Liav A.
e756567341 Kernel+Userland: Convert process syscall region enforce flag to SetOnce
This flag is set only once, and should never reset once it has been set,
making it an ideal SetOnce use-case.
It also simplifies the expected conditions for the enabling prctl call,
as we don't expect a boolean flag, but rather the specific prctl option
will always set (enable) Process' AddressSpace syscall region enforcing.
2024-05-14 12:41:51 -06:00
Liav A.
2cb86c1309 Kernel/Storage: Remove ATA IDE support
Nobody uses this functionality. I used this code on my old 2007 ICH7
test machine about a year ago, but bare metal is a small aspect of the
project, so it's safe to assume that nobody really tests this piece of
code.
Therefore, let's drop this for good and focus on more modern hardware.
2024-05-14 12:38:05 -06:00
Matthew Olsson
4ae7bbda52 Lagom: Add ClangPlugins to the build system 2024-05-13 16:50:54 -06:00
Timothy Flynn
3ff1d7da59 Kernel: Run clang-format
The following command was used to clang-format these files:

    clang-format-18 -i $(find . \
        -not \( -path "./\.*" -prune \) \
        -not \( -path "./Base/*" -prune \) \
        -not \( -path "./Build/*" -prune \) \
        -not \( -path "./Toolchain/*" -prune \) \
        -not \( -path "./Ports/*" -prune \) \
        -type f -name "*.cpp" -o -name "*.mm" -o -name "*.h")

There was a recent release of clang-format version 18.1.5 which fixes
errant spaces around `->` in these files.
2024-05-12 15:44:27 -04:00
Isaac
3d2fcf4244 Kernel/net: Add tracking of dropped packets per adapter 2024-05-09 12:02:26 +02:00
Liav A.
f7a85401bb Kernel/Storage: Remove a stale StorageDevice constructor method
ramdisk devices are long gone by now, so this is a stale method.
2024-05-07 17:02:09 -06:00
implicitfield
a08d1637e2 Kernel: Add FUSE support
This adds both the fuse device (used for communication between the
kernel and the filesystem) and filesystem implementation itself.
2024-05-07 16:54:27 -06:00
Dan Klishch
cc5bacf886 Kernel: Allow annotating initially loaded executable segments
This allows marking regions as VirtualMemoryRangeFlags::SyscallCode in
static executables.
2024-05-07 16:36:38 -06:00
Hendiadyoin1
b17f080dcc Kernel/riscv: Use new DeviceTree helpers in PCI initializations
This also changes the PCI interface slightly to be a bit nicer to work
with.
2024-05-02 07:44:13 -06:00
Hendiadyoin1
8ea8b7a6e5 Kernel/MM: Parse /memreserve/ blocks in FDT based memory mapping mode
These seem to be actually used in the RPi FDTs
2024-05-02 07:44:13 -06:00
Hendiadyoin1
2b13769dd5 Kernel/MM: Skip non static reserved memory regions instead of crashing
Crashing seems a bit harsh, so let's just skip them instead, as they
actually show up in the device tree of RPis.
2024-05-02 07:44:13 -06:00
Sönke Holz
b363abb082 Kernel/aarch64: Explicitly allow float instrs in {load,store}_fpu_state
LLVM 18 otherwise throws errors, as we use '-mgeneral-regs-only' in the
kernel.
The functions had to be moved into a .S, as there is no
'-mno-general-regs-only' and also no nice way to remove
'-mgeneral-regs-only' for a single .cpp file.
2024-04-30 06:32:58 -06:00
Idan Horowitz
dfa2c98497 Kernel: Support the RISC-V PLIC
By supporting the RISC-V PLIC (Platform-Level Interrupt Controller)
we can now handle device (external) interrupts.
2024-04-30 06:01:26 -06:00
Idan Horowitz
0a2d520b15 Kernel: Handle CLINT interrupts separately from normal interrupts
Since CLINT interrupts are wired directly into the hart, instead of
going through an interrupt controller (the PLIC), trying to handle them
through the normal numbered-interrupt mechanism will just complicate it
for no reason.
Instead we now handle them directly in the trap handler.
2024-04-30 06:01:26 -06:00
Idan Horowitz
002bba4a97 Kernel: Configure PCI interrupt routing based on the FDT 2024-04-30 06:01:26 -06:00
Idan Horowitz
7102d90b2b Kernel: Verify we are running on hart 0
This is already an implicit assumption when we initialize our CPU id.
2024-04-30 06:01:26 -06:00
Idan Horowitz
d3e285c253 Kernel: Deduplicate HardwareTimerBase::frequency()/ticks_per_second() 2024-04-30 06:01:26 -06:00
Liav A.
b9df8deba2 Kernel/USB: Don't include UHCIController.h in USBPipe.h
The USB::Pipe is abstracted from the actual USB host controller
implementation, so don't include the UHCIController.h file.
Also, we missed an include to UserOrKernelBuffer.h, so this is added to
ensure the code can still compile.
2024-04-28 22:30:48 +02:00
Liav A.
2bba9411ca Kernel: Use the AK SetOnce container class in various cases
We have many places in the kernel code that we have boolean flags that
are only set once, and never reset again but are checked multiple times
before and after the time they're being set, which matches the purpose
of the SetOnce class.
2024-04-26 23:46:23 -06:00
Sönke Holz
01f1d2daaa Kernel/riscv64: Don't clobber the boot info argument in enable_paging
"register asm" variables don't preserve the register value, so the call
to calculate_physical_to_link_time_address_offset in the asm input
operands is allowed to clobber a0.
2024-04-26 15:01:31 -06:00
Timothy Flynn
ab602cfc2c Kernel: Colorize log message for capabilities that have not been pledged
The log message can be hard to spot in a sea of debug messages. Colorize
it to make the message more immediately pop out.
2024-04-26 09:29:02 -04:00
Idan Horowitz
7339409575 Kernel: Properly initialize NVMe admin queue depth
We were reading the value instead of setting it (as required by the
specification). This worked only when we booted with a bootloader which
initialized NVMe before us.
2024-04-26 09:52:56 +02:00
Idan Horowitz
a2b2209ea5 Kernel: Fix definition of CAP_TO_MASK
The default type for integer literals is signed int, so we were
accidentally smearing those bits to the upper 32 bit of the result.
This resulted in extremely unreasonable timeouts.
2024-04-26 09:52:56 +02:00
Idan Horowitz
543fc4d0fc Kernel: Support automatic configuration of PCI bridges based on the FDT
This let's us actually boot with RISC-V.
2024-04-26 09:52:56 +02:00
Idan Horowitz
08d4b231e1 Kernel: Take EnumerableDeviceIdentifier by const ref instead of by value
It's 48 bytes.
2024-04-26 09:52:56 +02:00
Idan Horowitz
f6ae9f8a6d Kernel: Reset enumerated buses bitmap before enumerating PCI devices
This allows this method to be used more than once.
2024-04-26 09:52:56 +02:00
Idan Horowitz
95aff1cf13 Kernel: Remove unused IterationDecision in enumerate_attached_devices 2024-04-26 09:52:56 +02:00
Idan Horowitz
e350d3b2c6 Kernel: Use PCI:Class:ID::Bridge instead of magic value 2024-04-26 09:52:56 +02:00
Idan Horowitz
519be6e626 Kernel: Use correctly-sized read when checking PCI host bridge function
We were accidentally doing a 16-bit read instead of an 8-bit read,
meaning we would also read the 'CACHE_LINE_SIZE' field immediately
following it, and never actually continue.
2024-04-26 09:52:56 +02:00
Timothy Flynn
fecd08ce64 Everywhere: Remove 'clang-format off' comments that are no longer needed 2024-04-24 16:50:01 -04:00
Timothy Flynn
ec492a1a08 Everywhere: Run clang-format
The following command was used to clang-format these files:

    clang-format-18 -i $(find . \
        -not \( -path "./\.*" -prune \) \
        -not \( -path "./Base/*" -prune \) \
        -not \( -path "./Build/*" -prune \) \
        -not \( -path "./Toolchain/*" -prune \) \
        -not \( -path "./Ports/*" -prune \) \
        -type f -name "*.cpp" -o -name "*.mm" -o -name "*.h")

There are a couple of weird cases where clang-format now thinks that a
pointer access in an initializer list, e.g. `m_member(ptr->foo)`, is a
lambda return statement, and it puts spaces around the `->`.
2024-04-24 16:50:01 -04:00