summaryrefslogtreecommitdiff
path: root/Kernel/Devices
AgeCommit message (Collapse)Author
2022-07-10Kernel+SystemServer: Make KCOVDevice a character deviceLiav A
This device should not be a block device, as in Serenity, block devices represent an interface to either disk partitions or storage devices.
2022-06-23Kernel/Audio: Fix buffer size underflow for non-page-aligned sizeskleines Filmröllchen
When the size of the audio data was not a multiple of a page size, subtracting the page size from this unsigned variable would underflow it close to 2^32 and be clamped to the page size again. This would lead to writes into garbage addresses because of an incorrect write size, interestingly only causing the write() call to error out. Using saturating math neatly fixes this problem and allows buffer lengths that are not a multiple of a page size.
2022-06-17Kernel/SysFS: Migrate components code from SysFS.cpp to the SysFS folderLiav A
2022-06-17Kerenl/Firmware: Add map_ebda and map_bios methods in the original placeLiav A
In a previous commit I moved everything into the new subdirectories in FileSystem/SysFS directory without trying to actually make changes in the code itself too much. Now it's time to split the code to make it more readable and understandable, hence this change occurs now.
2022-06-17Kernel/SysFS: Stop cluttering the codebase with pieces of SysFS partsLiav A
Instead, start to put everything in one place to resemble the directory structure of the SysFS when actually using it.
2022-06-15Kernel: Don't VERIFY that the DMA channel is running on AC'97 interruptkleines Filmröllchen
Fixes #13771; as discussed it's not really a problem to receive an interrupt while the DMA channel is not running, but we do want to log it.
2022-05-06Kernel/HID: Take a spinlock when calling KeyboardClient::on_key_pressedLiav A
The KeyboardClient class member could be updated due to TTY switch, so we must ensure we always use a valid pointer.
2022-04-20Kernel: Allow WorkQueue items allocation failures propagationLiav A
In most cases it's safe to abort the requested operation and go forward, however, in some places it's not clear yet how to handle these failures, therefore, we use the MUST() wrapper to force a kernel panic for now.
2022-04-20Kernel: Move VMWareBackdoor to new directory in the Firmware directoryLiav A
2022-04-18Kernel: Enable PS2 keyboard scan code translation if not already enabledLiav A
On the QEMU microvm machine type, it became apparent that the BIOS was not setting the i8042 controller to function as expected. To ensure that the controller is always outputting correct scan codes, set it to scan code 2 and enable first port translation to ensure all scan codes are translated to scan code set 1. This is the expected behavior when using SeaBIOS, but on qboot (the BIOS for the QEMU microvm machine type), the firmware doesn't take care of this so we need to do this ourselves.
2022-04-01Everywhere: Run clang-formatIdan Horowitz
2022-04-01Kernel: Stop debug spam when using read on /dev/mem deviceLiav A
This is not really useful and quite annoying so let's disable it by default.
2022-04-01Kernel: Stop debug spam when using mmap on /dev/mem deviceLiav A
This is not really useful and quite annoying so let's disable it by default.
2022-04-01Kernel: Declare Device major and minor data member numbers as constLiav A
This is just another "safety guard" to ensure these numbers don't ever change after being set for a certain Device at construction time.
2022-03-28Kernel: Propagate HIDManagement initialisation error to initLorenz Steinert
Initialisation errors for HIDManagement are now returned to the init. In the init we assert by MUST if we get an error.
2022-03-28Kernel/Devices/HID: Propagate errors of HIDDevices properlyLorenz Steinert
Some error indication was done by returning bool. This was changed to propagate the error by ErrorOr from the underlying functions. The returntype of the underlying functions was also changed to propagate the error.
2022-03-27Kernel: Expose block size in AsyncBlockDeviceRequest structPankaj Raghav
Expose the block size variable via a member function in the AsyncBlockDeviceRequest so that the driver doesn't need to assume any value such as 512 bytes.
2022-03-22Kernel: Create SelfTTYDevice class to help replace /dev/tty symlinkLiav A
This will replace the /dev/tty symlink created by SystemServer, so instead of a symlink, a character device will be created. When doing read(2), write(2) and ioctl(2) on this device, it will "redirect" these operations to the attached TTY of the current process.
2022-03-19Kernel: Increase i8042 timeout when writing and reading from deviceLiav A
This proved to be crucial on my ICH7 test machine because it takes a bit more time to do IO on its i8042 controller.
2022-03-18Kernel: Default initialize AC97::m_codec_revisionBrian Gianforcaro
Found by PVS-Studio.
2022-03-17Kernel: Use default constructors/destructorsLenny Maiorani
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#cother-other-default-operation-rules "The compiler is more likely to get the default semantics right and you cannot implement these functions better than the compiler."
2022-03-14Kernel/PCI: Don't hold spinlocks when doing fast device enumerationLiav A
Instead, hold the lock while we copy the contents to a stack-based Vector then iterate on it without any locking. Because we rely on heap allocations, we need to propagate errors back in case of OOM condition, therefore, both PCI::enumerate API function and PCI::Access::add_host_controller_and_enumerate_attached_devices use now a ErrorOr<void> return value to propagate errors. OOM Error can only occur when enumerating the m_device_identifiers vector under a spinlock and trying to expand the temporary Vector which will be used locklessly to actually iterate over the PCI::DeviceIdentifiers objects.
2022-03-07Kernel: Wrap HIDManagement keymap data in SpinlockProtectedAndreas Kling
This serializes access to the current keymap data everywhere in the kernel, allowing to mark sys$setkeymap() as not needing the big lock.
2022-03-04Kernel: Report AC'97 vendor and device IDJelle Raaijmakers
2022-03-02Kernel/Audio: Don't try to enumerate PCI adapters if PCI is disabledLiav A
2022-02-27Kernel: Whitespace and `Error` cleanup in `AC97`Jelle Raaijmakers
No functional changes.
2022-02-27Kernel: Do not reset AC'97 PCM out on buffer completionJelle Raaijmakers
We now only reset the PCM out channel during initialization, and handle the case where the channel's current index has passed the last valid index properly. This fixes issues with stuttering audio between multiple subsequent `aplay` invocations, for example.
2022-02-27Kernel: Read and report AC'97 codec revisionJelle Raaijmakers
This might help with debugging on bare metal. Since the minimum version that can be specified is revision 2.1, and we do not use any feature from revision 2.2 or newer, this is merely future-proofing ourselves for new features yet to be built. Additionally, removing the `VERIFY()` ensures we will not crash on cards that only support earlier revisions.
2022-02-27Kernel: Make AC'97 initialization fallibleJelle Raaijmakers
Let's not crash in `AudioManagement` if we run into trouble.
2022-02-27Kernel: Add DeviceManagement::try_for_each() for fallible iterationIdan Horowitz
This API will allow users to short circuit iteration and properly propagate errors.
2022-02-26Kernel: Allow setting AC'97 sample rate during playbackJelle Raaijmakers
The Qemu AC'97 device stops its PCM channel's DMA engine when it is running and the sample rate is changed. We now make sure the DMA engine is restarted after changing the sample rate, allowing you to e.g. run `asctl set r 22050` during `aplay` playback.
2022-02-26Kernel: Clean up AC'97 driver code styleJelle Raaijmakers
* Remove braces from single-line conditionals * Use aggregate initialization style for member variables
2022-02-24Kernel/Audio: Remove the SB16 driverLiav A
This driver is not tested and probably not used on any modern hardware machine, because it is plugged into the ISA bus and not the PCI bus. Also, the run script doesn't utilize this device anymore, making it more hard to test this driver and to ensure it doesn't rot.
2022-02-20Kernel: Make i8042 existence check more robust against faulty hardwareLiav A
Some hardware controllers might reset when trying to do self-test, so keep the configuration byte to restore it later on. To ensure we are not missing the response from the i8042 controller, bump the attempts count to 20 times after initiating self-test check. Also, try to drain the i8042 controller output buffer as it might be a early good indication on whether i8042 is present or not. To ensure we drain all the output buffer, we attempt to read from the buffer 50 times and not 20 times.
2022-02-19Kernel: Increase i8042 IO attempt counts, againLinus Groh
This is very similar to the change that was done in 32053e8, except it turned out that the new limit of 50 iterations was not enough when testing on bare metal - most IO operations would succeed in the first or second iteration, but two of them took 140 and 150 iterations respectively. Increase the limit from 50 to 250 to account for this, and have some additional headroom.
2022-02-19Kernel: Only do i8042 existence check via probing as a fallbackLinus Groh
This caused an initialization failure of the i8042 when I tested on bare metal. We cannot entirely get rid of this method as QEMU for example doesn't indicate the existence of an i8042 via ACPI, but we can get away with only doing the manual probing if ACPI is disabled or we didn't get a 'yes' from it. Increasing the number of maximum loops did eventually lead to a successful return from the function, but would later fail the actual self test.
2022-02-16Kernel+LibELF+LibVT: Remove unused AK::String header includesIdan Horowitz
2022-02-14Kernel/Audio: Ignore buffers with more than 4096 bytes of data in SB16Liav A
The SB16 card driver doesn't swallow more than 4096 bytes of data at once, so instead of asserting just return ENOSPC for now. To test this, either play normal sound or just this (very!) loud noise: dd if=/dev/random of=/dev/audio/0 bs=4096
2022-02-14Kernel/Audio: Introduce a new design architecture for the subsystemLiav A
We have 3 new components: 1. The AudioManagement singleton. This class like in other subsystems, is responsible to find hardware audio controllers and keep a reference to them. 2. AudioController class - this class is the parent class for hardware controllers like the Sound Blaster 16 or Intel 82801AA (AC97). For now, this class has simple interface for getting and controlling sample rate of audio channels, as well a write interface for specific audio channel but not reading from it. One AudioController object might have multiple AudioChannel "child" objects to hold with reference counting. 3. AudioChannel class - this is based on the CharacterDevice class, and represents hardware PCM audio channel. It facilitates an ioctl interface which should be consistent across all supported hardware currently. It has a weak reference to a parent AudioController, and when trying to write to a channel, it redirects the data to the parent AudioController. Each audio channel device should be added into a new directory under the /dev filesystem called "audio".
2022-02-14Kernel: Evaluate block conditions only once on new mouse packetsIdan Horowitz
Since we're in an IRQ each of these evaluate_block_conditions() calls enqueues a new deferred call, so to save on some space in the deferred call queue let's just do it once.
2022-02-12Kernel: Increase attempts count when waiting before doing i8042 IOLiav A
Apparently on VirtualBox the keyboard device refused to complete the reset sequence. With longer delays and more attempts before giving up, it seems like the problem is gone.
2022-02-12Kernel: Increase delay and attempts count when checking i8042 existenceLiav A
2022-02-10Kernel: Convert i8042 code to use the ErrorOr pattern more broadlyLiav A
Not only does it makes the code more robust and correct as it allows error propagation, it allows us to enforce timeouts on waiting loops so we don't hang forever, by waiting for the i8042 controller to respond to us. Therefore, it makes the i8042 more resilient against faulty hardware and bad behaving chipsets out there.
2022-02-10Kernel: Check i8042 existence before trying to use itLiav A
If we don't do so, we just hang forever because we assume there's i8042 controller in the system, which is not a valid assumption for modern PC hardware.
2022-02-06AK: Move integral log2 and exp to IntegerMath.hHendiadyoin1
2022-02-03Kernel: Stop using the make<T> factory method in the KernelIdan Horowitz
As make<T> is infallible, it really should not be used anywhere in the Kernel. Instead replace with fallible `new (nothrow)` calls, that will eventually be error-propagated.
2022-02-03Kernel: Protect global device map with spinlock instead of mutxAndreas Kling
2022-01-30Kernel: Remove unnecessary includes from Thread.hAndreas Kling
...and deal with the fallout by adding missing includes everywhere.
2022-01-30Kernel: Support PS/2 right super keyJelle Raaijmakers
We currently support the left super key. This poses an issue on keyboards that only have a right super key, such as my Steelseries 6G. The implementation mirrors the left/right shift key logic and effectively considers the right super key identical to the left one.
2022-01-29Kernel: Add block_size_log helper to BlockDevicePankaj Raghav
It is useful to have the log2 value of the block size while calculating index for an IO.