Commit graph

8497 commits

Author SHA1 Message Date
Sönke Holz 8878e0c815 Kernel/riscv64: Implement everything in PageDirectory.cpp
This code is heavily based on aarch64's PageDirectory.cpp.
2024-01-29 05:17:03 -07:00
Sönke Holz 0a4ef6f3b7 Kernel/riscv64: Stub out InterruptManagement::find_controllers
We don't support any IRQControllers for RISC-V (like the PLIC) yet,
so just do nothing here for now.
2024-01-23 13:13:18 -07:00
Sönke Holz cec20908a5 Kernel/riscv64: Add assembly trap handler
This trap handler can't handle traps from userspace yet.
2024-01-23 13:13:18 -07:00
Sönke Holz df21d435eb Kernel/riscv64: Add C++ trap handler
This is a basic trap handler which can handle interrupts and some
exceptions. Syscalls aren't handled yet.
2024-01-23 13:13:18 -07:00
Sönke Holz 0111fe0d24 Kernel/riscv64: Implement Processor::exit_trap
This function is copy-pasted from aarch64's Processor.cpp
2024-01-23 13:13:18 -07:00
Sönke Holz 0e6659d1eb Kernel/riscv64: Implement dump_registers() 2024-01-23 13:13:18 -07:00
Sönke Holz 9bbf513c27 Kernel/riscv64: Implement initialize_interrupts() 2024-01-23 13:13:18 -07:00
Sönke Holz 7b7578bc1b Kernel/riscv64: Add AK::Formatter for scause CSR 2024-01-23 13:13:18 -07:00
Sönke Holz 6d8378735b Kernel/riscv64: Add AK::Formatter for sstatus CSR 2024-01-23 13:13:18 -07:00
Sönke Holz d061da4cf5 Kernel/riscv64: Clean up Timer class
I just copy-pasted microseconds_since_boot and
set_interrupt_interval_usec from aarch64.
However, on RISC-V, they are not in microseconds.
The TimerRegisters struct is also unused.

current_time and set_compare can also be private and static.
2024-01-23 13:13:18 -07:00
Sönke Holz 8582f0720f Kernel/riscv64: Make RISC-V Timer inherit from GenericInterruptHandler
IRQHandler is not the correct class to inherit from, as the timer
is not connected to an IRQController.
Each hart has one of these Timers directly connected to it.
2024-01-23 13:13:18 -07:00
Sönke Holz 8c017c3078 Kernel/riscv64: Remove unnecessary InterruptController header
I originally added this header because I misunderstood how
IRQControllers are supposed to be used.
I thought that I would need a IRQController class for the hart-local
interrupt controller, but apparently, this class is supposed to be used
for non-local interrupt controllers like the IOAPIC or RISC-V PLIC.
x86 LAPICs don't use this class either.
2024-01-23 13:13:18 -07:00
Sönke Holz 0e6d87fe83 Kernel/riscv64: Don't disable stack protector and sanitizers
I am not sure why 096cecb95e disabled the stack protector and sanitizers
for all files, but this is not necessary.
Only the pre_init code needs to run without them, as that code runs
identity mapped.
2024-01-22 20:07:36 -07:00
Jelle Raaijmakers f5dec55fd6 Kernel: Correct mapping of PS/2 keyboard exclamation point
Pressing Shift+1 resulted in `Key_Escape` being sent as the event's key.
2024-01-14 15:06:37 -07:00
Jelle Raaijmakers 015622bc22 Kernel: Set correct KeyCode count
The underlying value of the `KeyCode::Key_*` enum values starts at 0,
so we should add 1 to `Key_Menu` to get the correct count.
2024-01-14 15:06:37 -07:00
Liav A a10e63f08e Kernel/FileSystem: Send proper filetypes when traversing RAM-backed FSes
SysFS, ProcFS and DevPtsFS were all sending filetype 0 when traversing
their directories, but it is actually very easy to send proper filetypes
in these filesystems.
This patch binds all RAM backed filesystems to use only one enum for
their internal filetype, to simplify the implementation and allow
sharing of code.
Please note that the Plan9FS case is currently not solved as I am not
familiar with this filesystem and its constructs.

The ProcFS mostly keeps track of the filetype, and a fix was needed for
the /proc root directory - all processes exhibit a directory inside it
which makes it very easy to hardcode the directory filetype for them.
There's also the `self` symlink inode which is now exposed as DT_LNK.

As for SysFS, we could leverage the fact everything inherits from the
SysFSComponent class, so we could have a virtual const method to return
the proper filetype.
Most of the files in SysFS are "regular" files though, so the base class
has a non-pure virtual method.

Lastly, the DevPtsFS simply hardcodes '.' and '..' as directory file
type, and everything else is hardcoded to send the character device file
type, as this filesystem is only exposing character pts device files.
2024-01-13 19:01:07 -07:00
Sönke Holz 959f2c0342 Kernel/riscv64: Implement debug_output and change cmdline to use it
Just implementing `debug_output` (and adding "serial_debug" to the
cmdline) makes the kernel print its first assertion failure!
2024-01-12 16:46:46 -07:00
Sönke Holz dfce2f6341 Kernel/riscv64: Explicitly discard temporary local symbols
This is for some reason needed for riscv64 clang, as otherwise the
kernel.map file would grow too big to fit in its section inside the
kernel image.
None of our other architectures have temporary locals in their
kernel.map.
2024-01-12 16:46:46 -07:00
Sönke Holz da33e2a564 Kernel/riscv64: Add MMU initialization code
We initialize the MMU by first setting up the page tables for the
kernel image and the initial kernel stack.
Then we jump to a identity mapped page which makes the newly created
kernel root page table active by setting `satp` and then jumps to
`init`.
2024-01-12 16:46:46 -07:00
Sönke Holz 27860cfaa2 Kernel/riscv64: Add a basic trap handler to pre_init
This trap handler uses the SBI to print an error message via a newly
introduced panic function, which is necessary as `pre_init` is running
identity mapped.
Also add a header file for `pre_init.cpp` as we wan't to use the panic
and `dbgln` function in the MMU init code as well.
2024-01-12 16:46:46 -07:00
Jared dd53f64d2f Kernel: Properly ack segment
Fixed a mistake where we did not acknowledge a segment in the FinWait2
state.
2024-01-12 16:29:08 -07:00
Sönke Holz e4244f7469 Kernel/riscv64: Implement support for "panic=shutdown" cmdline option 2024-01-12 16:25:46 -07:00
Sönke Holz 8547813b6d Kernel/riscv64: Implement arch_specific_{reboot,shutdown} using the SBI
We first try to use the newer "SRST" extension for rebooting and
shutting down and if that fails, we try to shutdown using the legacy
"System Shutdown" extension (which can't reboot, so we always shutdown).
The kernel will halt, if we return from here due to all attempts at
rebooting / shutting down failing.
2024-01-12 16:25:46 -07:00
Sönke Holz 21b2d1de65 Kernel/riscv64: Add AK::Formatter for SBI errors
This allows us to print errors returned to us via the SBI.
The error messages are taken from the SBI spec.
2024-01-12 16:25:46 -07:00
Sönke Holz 27087318bc Kernel/riscv64: Add support for SRST "System Reset" SBI extension
This extension will be used for rebooting and shutting down.
2024-01-12 16:25:46 -07:00
Sönke Holz cac7dc8d71 Kernel/riscv64: Add support for legacy "System Shutdown" SBI extension 2024-01-12 16:25:46 -07:00
Liav A 8a0a3638f0 Kernel/HID: Introduce the all-mice device
This device will be used by userspace to read mouse packets from all
mouse devices that are attached to the machine.

This change is a preparation before we can enable seamless hotplug
capabilities in WindowServer for mouse devices, without any major change
on the userspace side.
2024-01-12 16:08:08 -07:00
Liav A b634792022 Kernel: Enable i8042 first port translation by default
Without this, we have many issues with the keyboard, so enable this for
now until this is figured out.
2024-01-12 16:02:13 -07:00
Liav A 2a5f66e4d8 Kernel/HID: Fix PS2 keyboard scan code tables
We do this by implementing the following fixes:
- The Key_Plus is assigned to a proper map entry index now which is 0x4e
  both on the keypad and non-keypad keys.
- Shift+Q now prints out "Q" properly on scan code set 2.
- Key BackSlash (or Pipe on shift key being pressed down) is now working
  properly as well.
- Key_Pipe (which is "|" for en-US layout) is now working in scan code
  set 2.
- Numpad keys as well as the decimal separator key are working again.
2024-01-12 16:02:13 -07:00
Hendiadyoin1 23d6c88027 Kernel/MM: Don't allocate a temporary Vector when parsing the memory map
Instead we can achieve the same by just using an optional.
2024-01-12 15:59:47 -07:00
Hendiadyoin1 adac43ab1c Kernel: Use new PCI BAR API in IOWindow and correct IO bounds checks
The IO bounds checks were on 32 bit instead of the actual limit of
16 bit, which would have caused problems later down the line.
2024-01-12 15:59:47 -07:00
Hendiadyoin1 bd118f4eb0 Kernel: Use the new BAR address API for the NVMe stack
This includes changing the cached `m_bar` value to a `PhysicalAddress`
2024-01-12 15:59:47 -07:00
Hendiadyoin1 2dc20f9e39 Kernel: Use the new API to query and map BAR spaces in most places
This might be a bit overkill in some instances, but it's nice to be
consistent
2024-01-12 15:59:47 -07:00
Hendiadyoin1 c65455e122 Kernel: Expand BAR address mask up to 64 bit
Otherwise we would end up truncating the address when applying the mask

Co-Authored-By: Sönke Holz <sholz8530@gmail.com>
2024-01-12 15:59:47 -07:00
Hendiadyoin1 2f98c7d470 Kernel: Add convenience helpers for mapping PCI BAR spaces 2024-01-12 15:59:47 -07:00
Taj Morton 55cd89aea8 Kernel/FileSystem/FATFS: Use AssertSize to enforce FAT structure sizes 2024-01-12 15:54:46 -07:00
Taj Morton d6a519e9af Kernel/FileSystem/FATFS: Restrict reads to the size of the file
Resolves issue where empty portions of a sector (or empty sectors in
a cluster) would be included with the returned data in a read().
2024-01-12 15:54:46 -07:00
Taj Morton 2995ee5858 Kernel/FileSystem/FATFS: Support FAT12 file system clusters 2024-01-12 15:54:46 -07:00
Taj Morton 1f70a728f0 Kernel/FileSystem/FATFS: Support FAT16 file system clusters 2024-01-12 15:54:46 -07:00
Taj Morton 67f567348f Kernel/FileSystem/FATFS: Support for FAT12/16 DOS BIOS Parameter Blocks 2024-01-12 15:54:46 -07:00
hanaa12G 7abda6a36f Kernel: Add new sysconf option _SC_GETGR_R_SIZE_MAX 2024-01-06 04:59:50 -07:00
jared 3dfd8defa9 Kernel: Properly ack segments in the half-close state
We didn't proberly ack incoming packets while in the FinWait2. This fix
addresses that.
2024-01-06 03:13:01 -07:00
jared 7244369aff Kernel: Add unhandled cases for the FinWait2 state
According to RFC 9293 Section 3.6.1. Half-Closed Connections, we should
still accept incoming packets in the FinWait2 state. Additionally, we
didn't handle the FIN+ACK case. We should handle this the same we
handle the FIN flag. The ACK is only added to signify successful
reception of the last packet.
2024-01-06 03:13:01 -07:00
Idan Horowitz c5187c6bb3 Kernel: Replace incorrect RTL8168 multicast config registers address
The specification uses awkward numbering, marking the first byte as 7,
and the last one as 0, which caused me to misunderstand their ordering,
and use the last byte's address as the first one, and so on.
2024-01-05 10:52:43 -07:00
implicitfield 48e848a9fd Kernel/Ext2: Only handle extended attributes when they are supported 2024-01-05 04:00:11 +03:30
implicitfield 280d5feac9 Kernel/Ext2: Allow checking for the presence of extended attributes 2024-01-05 04:00:11 +03:30
Liav A 475ef6965a Kernel: Add boot parameter to determine i8042 first port translation
This can be used mainly for bare metal hardware, if the user experiences
problems with output from the PS2 keyboard.
2024-01-04 10:38:03 -07:00
Liav A c8f27d7cb8 Kernel+Userland: Implement support for PS2 scan code set 2
This scan code set is more advanced than the basic scan code set 1, and
is required to be supported for some bare metal hardware that might not
properly enable the PS2 first port translation in the i8042 controller.

LibWeb can now also generate bindings for keyboard events like the Pause
key, as well as other function keys (such as Right Alt, etc).

The logic for handling scan code sets is implemented by the PS2 keyboard
driver and is abstracted from the main HID KeyboardDevice code which
only handles "standard" KeyEvent(s).
2024-01-04 10:38:03 -07:00
Sönke Holz 6bc16ad62e Kernel/riscv64: Add RISC-V support to TimeManagement 2024-01-02 06:50:59 -07:00
Sönke Holz 9e4286d782 Kernel/riscv64: Stub out optional_current_time
This function is used in TimeManagement.cpp
2024-01-02 06:50:59 -07:00