summaryrefslogtreecommitdiff
path: root/Kernel/Devices
AgeCommit message (Collapse)Author
2022-01-21Kernel: Stop using LibKeyboard's CharacterMap in HIDManagementIdan Horowitz
This was easily done, as the Kernel and Userland don't actually share any of the APIs exposed by it, so instead the Kernel APIs were moved to the Kernel, and the Userland APIs stayed in LibKeyboard. This has multiple advantages: * The non OOM-fallible String is not longer used for storing the character map name in the Kernel * The kernel no longer has to link to the userland LibKeyboard code * A lot of #ifdef KERNEL cruft can be removed from LibKeyboard
2022-01-20Kernel: Add horizontal mouse scroll supportDmitry Petrov
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.
2022-01-09Kernel: Page-align AC'97 audio buffer descriptor listJelle Raaijmakers
This was broken in commit 0a1b34c753 / PR #11687 since the buffer descriptor list size was not page-aligned, and the new `MM.allocate_dma_buffer_pages` expects a page-aligned size.
2022-01-09Kernel: Use DMA helper everywherePankaj Raghav
Port UCHI, AC97, SB16, BMIDEChannel and AHCIPort to use the helper to allocate DMA buffers.
2022-01-08Kernel: Avoid potential memory info leak when doing mmap on /dev/memLiav A
Although we can still consider this impossible to happen now, because the mmap syscall entry code verifies that specified offset must be page aligned, it's still a good practice to VERIFY we actually take a start address as page-aligned in case of doing mmap on /dev/mem. As for read(2) on /dev/mem, we don't map anything to userspace so it's safe to read from whatever offset userspace specified as long as it does not break the original rules of reading physical memory from /dev/mem.
2022-01-08Kernel: Implement read functionality for MemoryDeviceLiav A
So far we only had mmap(2) functionality on the /dev/mem device, but now we can also do read(2) on it. The test unit was updated to check we are doing it safely.
2022-01-08Kernel: Remove needless did_seek method override in MemoryDevice classLiav A
2022-01-08Kernel: Change method name to clarify physical memory mmap validationLiav A
2022-01-03Kernel: Allow backspace '\b' to be remappedCorey Williamson
Previously, one could put '\b' in a keymap, but in non-Terminal applications, it would just insert a literal '\b' character instead of behaving like backspace. This patch modifes `visible_code_point_to_key_code` to include backspace, as well as renaming it to `code_point_to_key_code` since '\b' is not a visible character. Additionally, `KeyboardDevice::key_state_changed` has been rearranged to apply the user's keymap before checking for things like caps lock.
2022-01-01Kernel/NVMe: Add initial NVMe driver supportPankaj Raghav
Add a basic NVMe driver support to serenity based on NVMe spec 1.4. The driver can support multiple NVMe drives (subsystems). But in a NVMe drive, the driver can support one controller with multiple namespaces. Each core will get a separate NVMe Queue. As the system lacks MSI support, PIN based interrupts are used for IO. Tested the NVMe support by replacing IDE driver with the NVMe driver :^)
2021-12-29Kernel: Rename File::{before_removing => will_be_destroyed}Idan Horowitz
This will allow File and it's descendants to use RefCounted instead of having a custom implementation of unref. (Since RefCounted calls will_be_destroyed automatically) This commit also removes an erroneous call to `before_removing` in AHCIPort, this is a duplicate call, as the only reference to the device is immediately dropped following the call, which in turns calls `before_removing` via File::unref.
2021-12-28Kernel: Propagate overflow errors from Memory::page_round_upGuilherme Goncalves
Fixes #11402.
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-28Kernel: Remove the KString::try_create(String::formatted(...)) patternDaniel Bertalan
We can now directly create formatted KStrings with KString::formatted. :^)
2021-12-23Kernel: Make major and minor numbers to be DistinctNumericsLiav A
This helps avoid confusion in general, and make constructors, methods and code patterns much more clean and understandable.
2021-12-16Kernel+LibC: Move errno definitions to Kernel/API/POSIXsin-ack
This fixes at least half of our LibC includes in the kernel. The source of truth for errno codes and their description strings now lives in Kernel/API/POSIX/errno.h as an enumeration, which LibC includes.
2021-12-14Kernel/SysFS: Prevent allocation for component name during constructionLiav A
Instead, allocate before constructing the object and pass NonnullOwnPtr of KString to the object if needed. Some classes can determine their names as they have a known attribute to look for or have a static name.
2021-12-11Kernel: Remove unused String.h includesHendiadyoin1
This makes searching for not yet OOM safe interfaces a bit easier.
2021-11-30Kernel: Handle string format errors in Device::pseudo_path(..) :^)Brian Gianforcaro
2021-11-30Kernel: Handle string format errors in KCOVInstance :^)Brian Gianforcaro
2021-11-28Kernel: Ignore AC97 non-completion interruptsJelle Raaijmakers
Fixes #11094
2021-11-28Kernel: Add AC97_DEBUG macroJelle Raaijmakers
2021-11-27Kernel/Audio: Implement 2 correctness fixes in AC97Liav A
The fixes are: 1. Don't copy PCI::DeviceIdentifier during construction. This is a heavy structure to copy so we definitely don't want to do that. Instead, use a const reference to it like what happens in other parts in the Kernel. 2. Declare the constructor as explicit to avoid construction errors.
2021-11-26Kernel: Implement variable rate audio support for AC97 devicesJelle Raaijmakers
Previously we `VERIFY()`ed that the device supports variable-rate audio (VRA). Now, we query the VRA bit and if VRA is not supported, we do not enable double-rate audio and disallow setting any sample rate except the fixed 48kHz rate as defined by the AC'97 specification. This should allow the driver to function on a wider array of hardware. Note that in the AC'97 specification, DRA without VRA is allowed when supported: this effectively doubles the sample rate to 96kHZ. For now, we ignore that possibility and let it default to 48kHZ.
2021-11-26Kernel: Ensure KeyEvent::key sent to Userspace respects keyboard layoutmacarc
Before, only KeyEvent::code_point took the user's keyboard layout into consideration, while KeyEvent::key was hardcoded QWERTY. This affected, among other things, Vim Emulation. Now, KeyEvent::key respects the user's keyboard layout, so will be the same as KeyEvent::code_point for visible (alphanumeric + symbol) keys. Co-Authored-By: Ben Wiederhake <BenWiederhake.GitHub@gmx.de>
2021-11-24Kernel: Allow higher audio sample rates than 65kHZ (`u16`)Jelle Raaijmakers
Executing `asctl set r 96000` no longer results in weird sample rates being set on the audio devices. SB16 checks for a sample rate between 1 and 44100 Hz, while AC97 implements double-rate support which allows sample rates between 8kHz and 96kHZ.
2021-11-23Kernel: Allow writes larger than `PAGE_SIZE` to AC97 deviceJelle Raaijmakers
Previously, `cat /dev/random > /dev/audio` would crash Serenity. Fix this by splitting up the written data into `PAGE_SIZE` chunks.
2021-11-23Kernel: Add generic channel support to AC97Jelle Raaijmakers
This factors out some hardcoded PCMOut registers into a new private class called AC97Channel, which wraps around a channel's registers and provides some shared functionality. No functional changes.
2021-11-23Kernel: Implement AC97 audio device driverJelle Raaijmakers
2021-11-23Kernel: Teach DeviceManagement to handle multiple audio devicesJelle Raaijmakers
2021-11-23Kernel: Move SB16 to Audio subdirectoryJelle Raaijmakers
2021-11-18Kernel: Use DistinctNumeric for filesystem ID'sAndreas Kling
This patch adds the FileSystemID type, which is a distinct u32. This prevents accidental conversion from arbitrary integers.
2021-11-12Kernel: Drain I8042 PS/2 keyboard output after enablingJelle Raaijmakers
As soon as we enable the first PS/2 port on the I8042 controller, the output buffer may become full. We need to drain it before attempting any new commands with the controller (such as enabling the second PS/2 port). Fixes #10872.
2021-11-10Kernel: Make Inode::traverse_as_directory() callback return ErrorOrAndreas Kling
This allows us to propagate errors from inside the callback with TRY().
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-11-04Kernel: Process available VMWare mouse events immediatelyJelle Raaijmakers
The Qemu I8042 controller does not send one IRQ per event, it sends over four since it will not stop trying to emulate the PS/2 mouse. If the VMWare backdoor is active, a fake I8042 mouse event will be sent that we can then use to check if there are VMWare mouse events present. However, we were only processing one mouse event at a time, even though multiple events could have been queued up. Luckily this does not often lead to issues, since after the first IRQ we would still get three additional interrupts that would then empty the queue. This change makes sure we always empty the event queue immediately, instead of waiting on the next interrupt to happen. Functionally this changes nothing - it could merely improve latency by not waiting for new interrupts to come in. Coincidently, this brings our implementation closer to how Linux deals with the VMMouse.
2021-11-04Kernel: Clean up VMWareMouseDevice and VMWareBackdoorJelle Raaijmakers
No functional changes.
2021-11-03Revert "Kernel: Prevent VMWareMouseDevice from handling invalid mouse packets"Andreas Kling
This reverts commit 4131b3585164761e3841bb1c9609b302658ee2c0. We're swallowing way too many mouse events from QEMU with this code enabled. Something is not right, so let's revert it for now.
2021-10-31Kernel: Clarify ambiguous {File,Description}::absolute_pathBen Wiederhake
Found due to smelly code in InodeFile::absolute_path. In particular, this replaces the following misleading methods: File::absolute_path This method *never* returns an actual path, and if called on an InodeFile (which is impossible), it would VERIFY_NOT_REACHED(). OpenFileDescription::try_serialize_absolute_path OpenFileDescription::absolute_path These methods do not guarantee to return an actual path (just like the other method), and just like Custody::absolute_path they do not guarantee accuracy. In particular, just renaming the method made a TOCTOU bug obvious. The new method signatures use KResultOr, just like try_serialize_absolute_path() already did.
2021-10-27Everywhere: Rename back-click to backward-clickFiliph Sandström
This matches the current forward-click terminology.
2021-10-24Kernel: Prevent VMWareMouseDevice from handling invalid mouse packetsJelle Raaijmakers
Bit 3 is set here: https://github.com/qemu/qemu/blob/c5b2f559814104f4145f8bc310f4d33c7ead8f49/hw/input/ps2.c#L736 Spurious mouse packets can be received without this bit set, for example when double-clicking and keeping the mouse button depressed instead of releasing it the second time (i.e. mousedown > mouseup > mousedown). We should not process such packets. This makes interaction with our buttons much smoother! Fixes #5881.
2021-10-24Kernel: Do not detect mouse or keyboard when handling IRQ for I8042Jelle Raaijmakers
Instead of detecting which flag was set in the status register, we can use the instrument type passed to us. This works because the mouse and keyboard use different IRQs.
2021-10-24Kernel: Enumify all magic constants for I8042 devicesJelle Raaijmakers
This makes the code much easier to read.
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 class_name() 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-09-29Kernel/PCI: Remove Address from enumeration callbackLiav A
If we need that address, we can always get it from the DeviceIdentifier.
2021-09-29Kernel: Rename two PCI componentsLiav A
Rename ID => HardwareID, and PhysicalID => DeviceIdentifier. This change merely does that to clarify what these objects really are.
2021-09-29Kernel/PCI: Cache more details about PCI devices when enumerating themLiav A
There's no good reason to fetch these values each time we need them.