Commit graph

8868 commits

Author SHA1 Message Date
Sönke Holz
61244cdad5 Kernel/EFI: Add header for the RISC-V EFI boot protocol
These definitions are adapted from the UEFI spec to match our code
style.
2024-11-15 01:18:04 +01:00
Sönke Holz
5772348b99 Kernel/EFI: Add header for the "Media Access" protocols
These definitions are adapted from the UEFI spec to match our code
style.
2024-11-15 01:18:04 +01:00
Sönke Holz
05b4e38ed0 Kernel/EFI: Add header for the "Loaded Image" protocols
These definitions are adapted from the UEFI spec to match our code
style.
2024-11-15 01:18:04 +01:00
Sönke Holz
83adb406a5 Kernel/EFI: Add header for the "Device Path" protocols
These definitions are adapted from the UEFI spec to match our code
style.
2024-11-15 01:18:04 +01:00
Sönke Holz
7cd62197da Kernel/EFI: Add header for the System Table
These definitions are adapted from the UEFI spec to match our code
style.
2024-11-15 01:18:04 +01:00
Sönke Holz
4a9480e7a9 Kernel/EFI: Add header for the Boot Services
These definitions are adapted from the UEFI spec to match our code
style.
2024-11-15 01:18:04 +01:00
Sönke Holz
fbce9ec8cc Kernel/EFI: Add header for the "Console Support" protocols
These definitions are adapted from the UEFI spec to match our code
style.
2024-11-15 01:18:04 +01:00
Sönke Holz
1ac9aaa6ac Kernel/EFI: Add header for basic EFI data types
These definitions are adapted from the UEFI spec to match our code
style.
2024-11-15 01:18:04 +01:00
Sönke Holz
7c710805ec Kernel: VERIFY that the SafeMem sections are not empty on all arches 2024-11-07 09:32:54 -05:00
Sönke Holz
9e9148dead Kernel/aarch64: Add .{ro,unmap}_after_init sections to linker script 2024-11-07 09:32:54 -05:00
Sönke Holz
859fceeb07 Kernel/aarch64: Correctly set {start,end}_of_kernel_{data,text}
MemoryManager::protect_kernel_image uses these symbols.
2024-11-07 09:32:54 -05:00
Sönke Holz
93cc7d213f Kernel/x86: Fix indentation in linker script 2024-11-07 09:32:54 -05:00
Sönke Holz
3f3f7a4440 Kernel/aarch64: Fix indentation in linker script
Also remove some trailing whitespace.
2024-11-07 09:32:54 -05:00
Sönke Holz
1d9301d845 Kernel/aarch64: Don't use the memory before .text as the initial stack
This new stack has the same size as the initial stack on riscv64 and
x86_64.
2024-11-07 09:32:54 -05:00
implicitfield
54bfc3d294 Kernel/Ext2FS: Cache blocks less aggressively
With this patch, we now only cache at most 2^14 blocks, which greatly
relieves memory pressure when working with large files.
2024-11-05 20:14:21 +01:00
implicitfield
54b8fe1fa4 Kernel/Ext2FS: Add a helper to free every block an inode holds 2024-11-05 20:14:21 +01:00
implicitfield
a32b9c903b Kernel/Ext2FS: Make block allocation properly fallible
For some context, write_bytes_locked used to simply bail out before
writing any data if there weren't enough blocks to cover the entire size
of an inode before 1bf7f99a.

We're not actually restoring that behavior here, since computing the
amount of blocks to be allocated would get exceedingly complex,
considering that there could always be holes in between already
allocated blocks.

Instead, this simply makes allocate_blocks() bail out properly if there
aren't any free blocks left.

Fixes #24980
2024-11-05 20:14:21 +01:00
implicitfield
dca1a755c2 Kernel/FATFS: Make lookups case-insensitive 2024-11-02 15:54:29 -04:00
implicitfield
a9083f9be7 Kernel/FATFS: Avoid creating LFN entries when an SFN will suffice 2024-11-02 15:54:29 -04:00
implicitfield
0ba7a03869 Kernel/FATFS: Implement the specced LFN -> SFN conversion algorithm 2024-11-02 15:54:29 -04:00
implicitfield
3a585fa5a2 Kernel/FATFS: Keep all FATs up to date
There are almost always at least two FATs, so let's make sure to keep
all of them up to date.
2024-11-02 15:54:29 -04:00
implicitfield
b8828c7629 Kernel/FATFS: Cap reads at the respective file size 2024-11-02 15:54:29 -04:00
Sönke Holz
d6a3500973 Kernel/aarch64: Make RPi::Timer a DeviceTree::Driver
This driver doesn't actually get any info (like the physical address)
from the devicetree node for now.
2024-11-02 13:53:10 -04:00
Sönke Holz
ed6202601b Kernel/aarch64: Make RPi::InterruptController a DeviceTree::Driver
This driver doesn't actually get any info (like the physical address)
from the devicetree node for now.
2024-11-02 13:53:10 -04:00
Sönke Holz
9f47b4b490 Kernel: Introduce a new model for writing devicetree drivers
Devicetree drivers are created by using the `DEVICETREE_DRIVER` macro.
That macro creates a new class deriving from `DeviceTree::Driver` and
inserts it into the driver init section.
The driver code then has to implement the `probe` member function, which
will be called if `DeviceTree::Management` finds a node with a
compatible property entry that was in the array passed as the second
argument to the `DEVICETREE_DRIVER` macro.
The `probe` function then will check if it supports the given node and
if so, registers a `DeviceTree::DeviceRecipe` at the appropriate
subsystem, which will then create a device from that recipe once it is
initialized.
The driver can store the necessary info it got from the devicetree,
such as the physical address and interrupt numbers, in the capture
list of the callback lambda stored in `DeviceRecipe::create_device`.

The `DeviceTree::DeviceRecipe`s are necessary, as the `probe` functions
might not be able to create an instance of the actual device class,
since doing so can depend on some subsystems being initialized first.
2024-11-02 13:53:10 -04:00
Sönke Holz
19258d8980 Kernel/USB: Let register_driver work before USBManagement initialization
This will be needed in the next commit, which moves the driver init
functions calling code earlier into the boot process.
2024-11-02 13:53:10 -04:00
Sönke Holz
eacfb94256 Kernel: Rename pre_init arguments to fit the new BootInfo definition 2024-10-30 18:51:35 -04:00
Sönke Holz
4f8490b5ff Kernel: Move boot info variables into a shared struct
This commit reorganizes the BootInfo struct definition so it can be
shared for all architectures.

The existing free extern "C" boot info variables have been removed and
replaced with a global BootInfo struct, 'g_boot_info'.

On x86-64, the BootInfo is directly copied from the Prekernel-provided
struct.
On AArch64 and RISC-V, BootInfo is populated during pre_init.
2024-10-30 18:51:35 -04:00
Sönke Holz
8c1e0ae059 Kernel/GPU: Move boot framebuffer checks into 2 bools 2024-10-30 18:51:35 -04:00
Sönke Holz
21946f8343 Kernel: Make PhysicalAddress constructors constexpr 2024-10-30 18:51:35 -04:00
Hendiadyoin1
92e2e309d3 Kernel/USB: Add and use a shared function to set a device's interface 2024-10-30 18:47:50 -04:00
Hendiadyoin1
66cfe47ed8 Kernel/USBMS: Add a basic UAS driver
For now we only support USB <3.0 devices, as we don't support streams.
We also don't leverage the benefits of UAS, as we pretend to have a
queue depth of 1, ie are single threaded.

To test this driver, you can use the following command:
```
SERENITY_BOOT_DRIVE=usb-uas Meta/serenity.sh run x86_64 Clang
```
2024-10-30 18:47:50 -04:00
Hendiadyoin1
1db4da93eb Kernel/USB: Save all USB descriptors and allow iterating over them
This makes it easier to access class specific descriptors, which
are sometimes dependent on the descriptors immediately before them.
2024-10-30 18:47:50 -04:00
Hendiadyoin1
435d78c575 Kernel/USBMS: Move the BOT/BBB driver to its own directory 2024-10-30 18:47:50 -04:00
Sönke Holz
d033add27f Kernel: Share __assertion_failed() implementation between architectures
I put the generic implementation in Assertions.cpp, since the
declaration is in Assertions.h.

The only change needed to make the x86-64 implementation generic was
replacing the cli with a Processor::disable_interrupts().
2024-10-30 18:42:21 -04:00
Sönke Holz
44c016eb47 Kernel/x86: Remove _abort()
This function is unused.
2024-10-30 18:42:21 -04:00
Sönke Holz
098612fffd Kernel/riscv64: Use '.option arch' instead of '.option norvc'
'.option norvc' is scheduled for deprecation:
3b06fa93fd/src/asm-manual.adoc (rvcnorvc)
2024-10-30 18:41:16 -04:00
Sönke Holz
69166b5c5b Kernel/riscv64: Add a note why we can always use the PAUSE HINT 2024-10-30 18:41:16 -04:00
Sönke Holz
cf377af04c Kernel/riscv64: Use '.option arch' instead of manually encoding 'pause' 2024-10-30 18:41:16 -04:00
MacDue
4c851d204d Kernel: Try to reset the PS2 mouse multiple times before giving up
When using spice with `virt-viewer` the mouse rarely works on the first
initialization attempt. Simply retrying a few times makes it succeed
most of the time (although it can still fail, it's pretty rare now).
2024-10-26 14:01:14 -04:00
Jack Winch
88b569ba66 E1000NetworkAdapter: Fix incorrect cast of RX buffer descriptor pointer
Fix incorrect casts of (e1000_rx_desc*) to (e1000_tx_desc*) in functions
related to frame receive path.

Previous code appears to work because only fields common to both the TX
and RX descriptor types are used in the affected code and happen to be
at the same offset inside the packed structs.
2024-10-16 16:02:19 -04:00
logkos
3a610931f5 Kernel/Syscalls: Require inet promise for AF_INET6 domain 2024-10-05 12:52:10 -04:00
Liav A.
3edc6ae0d6 Kernel/Devices: Improve construction paths semantically
Do this by:
- Removing more instances of `LockRefPtr` and `NonnullLockRefPtr`.
- Using better names of construction methods (i.e. `create` instead of
  `try_create`).
- Only returning `NonnullRefPtr` on the `Device::try_create_device`
  method.
- Removing a version of the `Device::try_create_device` method that
  called `DeviceType::try_create(forward<Args>(args)...)`, which was
  only used in a construction point in a VirtIO driver which now doesn't
  need this anymore.
2024-10-05 12:26:48 +02:00
Liav A.
96e1391c23 Kernel/Devices: Remove the DeviceManagement singleton
This change has many improvements:
- We don't use `LockRefPtr` to hold instances of many base devices as
  with the DeviceManagement class. Instead, we have a saner pattern of
  holding them in a `NonnullRefPtr<T> const`, in a small-text footprint
  class definition in the `Device.cpp` file.
- The awkwardness of using `::the()` each time we need to get references
  to mostly-static objects (like the Event queue) in runtime is now gone
  in the migration to using the `Device` class.
- Acquiring a device feel more obvious because we use now the Device
  class for this method. The method name is improved as well.
2024-10-05 12:26:48 +02:00
sdomi
a781106a89 Kernel/Net: Introduce proper pointers for payload calls
Unifying with other structures, this introduces m_payload for all
relevant structures, except the TCP header (which has a different
concept of payload than the rest).

This allows us to return a pointer directly instead of doing pointer
arithmetic to point to the end of the structure.
2024-10-04 12:04:17 +02:00
sdomi
a706e81d41 Kernel/Net: Remove useless checks from handle_arp
According to ARP.h, address lengths default to size of their
underlying types (IPv4Address and MACAddress respectively). We never
modify those values, and in reality, ARP never carries anything else.
Hence, those checks resolved to comparing sizeof to itself, which
probably gets optimized out of the compiler anyways.

This change removes the checks that will never fail, plus changes the
function definition to pass adapter directly, matching other handlers.
2024-10-04 12:04:17 +02:00
sdomi
35c74bafc0 Net/Kernel: Add basic ICMPv6 support
This commit adds the minimum amount of code to make Serenity reply to
ICMPv6 ping packets. This includes basic Network Discovery Protocol
support, as well as a basic ICMPv6 Echo Request/Response handler.

This change also introduces a new debug flag, ICMPV6_DEBUG.

Co-Authored-By: kleines Filmröllchen <filmroellchen@serenityos.org>
2024-10-04 12:04:17 +02:00
sdomi
709ee9144c Kernel/Net: Add support functions for filling out IPv6 packets
This change also migrates the existing fill_in_ipv4_header from C-style
casts to proper C++ casts.
2024-10-04 12:04:17 +02:00
kleines Filmröllchen
11d46a4a00 Kernel/Net: Start work on IPv6
This commit introduces the first bit of IPv6 support into
SerenityOS. An IPv6 packet header structure allows NetworkTask to
recognize and log correctly shaped IPv6 packets, but nothing is done
with those yet. A new logging flag, IPV6_DEBUG, allows debugging of
IPv6 internals.

Co-Authored-By: sdomi <ja@sdomi.pl>
2024-10-04 12:04:17 +02:00
sdomi
93951597a5 Kernel/Net: Directly pass adapter to protocol handler calls
Up until now, protocol handlers for IPv4 and ARP had to rediscover the
adapter based on trying to match the address to all interfaces. This
approach is relatively slow, introduces more code duplication, and
doesn't work with multiple IPs per interface (as is the case with
IPv6).

This change introduces directly passing the adapter to all handlers
that need it, cutting out the retrieval process. Furthermore, we
discard the packet much faster if the IP doesn't match.
2024-10-04 12:04:17 +02:00