summaryrefslogtreecommitdiff
path: root/Kernel/Devices
AgeCommit message (Collapse)Author
2021-08-08Everywhere: Replace AK::Singleton => SingletonAndreas Kling
2021-08-07Kernel: Move SpinLock.h into Locking/Jean-Baptiste Boric
2021-08-07Kernel: Move Mutex into Locking/Jean-Baptiste Boric
2021-08-06Kernel: Add convenience values to the Memory::Region::Access enumAndreas Kling
Instead of `Memory::Region::Access::Read | Memory::Region::AccessWrite` you can now say `Memory::Region::Access::ReadWrite`.
2021-08-06Kernel: Rename Process::space() => Process::address_space()Andreas Kling
We commonly talk about "a process's address space" so let's nudge the code towards matching how we talk about it. :^)
2021-08-06Kernel: Rename Range => VirtualRangeAndreas Kling
...and also RangeAllocator => VirtualRangeAllocator. This clarifies that the ranges we're dealing with are *virtual* memory ranges and not anything else.
2021-08-06Kernel: Move Kernel/Memory/ code into Kernel::Memory namespaceAndreas Kling
2021-08-06Kernel: Rename Kernel/VM/ to Kernel/Memory/Andreas Kling
This directory isn't just about virtual memory, it's about all kinds of memory management.
2021-08-06Kernel: Fix handful of remaining "return -EFOO" mistakesAndreas Kling
Now that all KResult and KResultOr are used consistently throughout the kernel, it's no longer necessary to return negative error codes. However, we were still doing that in some places, so let's fix all those (bugs) by removing the minuses. :^)
2021-08-06Kernel: Make AsyncDeviceRequest::name() return StringViewAndreas Kling
2021-08-03Kernel: Make NullDevice (/dev/null) seekableAndreas Kling
2021-07-26Kernel: Fix integer overflow in KCOV_SETBUFSIZE ioctlPatrick Meyer
2021-07-27Kernel: Make KCOVDevice::ioctl() return KResultAli Mohammad Pur
Recent ioctl() changes broke this, this commit fixes that and the build.
2021-07-27Kernel: Modify the IOCTL API to return KResultBrian Gianforcaro
The kernel has been gradually moving towards KResult from just bare int's, this change migrates the IOCTL paths.
2021-07-27Kernel: Utilize AK::Userspace<T> in the ioctl interfaceBrian Gianforcaro
It's easy to forget the responsibility of validating and safely copying kernel parameters in code that is far away from syscalls. ioctl's are one such example, and bugs there are just as dangerous as at the root syscall level. To avoid this case, utilize the AK::Userspace<T> template in the ioctl kernel interface so that implementors have no choice but to properly validate and copy ioctl pointer arguments.
2021-07-26Kernel: Add option to build with coverage instrumentation and KCOVPatrick Meyer
GCC and Clang allow us to inject a call to a function named __sanitizer_cov_trace_pc on every edge. This function has to be defined by us. By noting down the caller in that function we can trace the code we have encountered during execution. Such information is used by coverage guided fuzzers like AFL and LibFuzzer to determine if a new input resulted in a new code path. This makes fuzzing much more effective. Additionally this adds a basic KCOV implementation. KCOV is an API that allows user space to request the kernel to start collecting coverage information for a given user space thread. Furthermore KCOV then exposes the collected program counters to user space via a BlockDevice which can be mmaped from user space. This work is required to add effective support for fuzzing SerenityOS to the Syzkaller syscall fuzzer. :^) :^)
2021-07-22Kernel: Consolidate API for creating AnonymousVMObject with given pagesAndreas Kling
We don't need to have a dedicated API for creating a VMObject with a single page, the multi-page API option works in all cases. Also make the API take a Span<NonnullRefPtr<PhysicalPage>> instead of a NonnullRefPtrVector<PhysicalPage>.
2021-07-17Kernel: Rename Lock to MutexAndreas Kling
Let's be explicit about what kind of lock this is meant to be.
2021-07-15Kernel: Optionally dump scheduler state with stack tracesTom
This will dump stack traces of all threads when pressing Ctrl+Shift+Alt+F12
2021-07-11Kernel: Standardize the header include style to 'include <Kernel/...>'Brian Gianforcaro
This is the overwhelming standard in the project, but there were some cases in the kernel which were not following it, lets fix those cases!
2021-07-11Kernel: Remove unused header includes in Devices subtreeBrian Gianforcaro
2021-07-11Kernel: Rename various *VMObject::create*() => try_create()Andreas Kling
try_*() implies that it can fail (and they all return RefPtr with nullptr signalling failure.)
2021-07-11Kernel: Make various T::class_name() and similar return StringViewAndreas Kling
Instead of returning char const*, we can also give you a StringView.
2021-07-07Kernel+KeyboardSettings: Remove numlock syscall and implement ioctlEdwin Hoksberg
2021-07-07Kernel: Add keyboard ioctl to get num/caps lock stateEdwin Hoksberg
2021-07-05KeyboardSettings+Kernel: Setting to enable Num Lock on loginForLoveOfCats
2021-07-03Kernel: Clarify and make it easy to not use raw numbersLiav A
Let's put the PCI IDs as enums in the PCI namespace so they're free to pollute that namespace, but it's also more easier to use them.
2021-07-03Kernel: Fix miscellaneous warnings when building with ClangDaniel Bertalan
These small changes fix the remaining warnings that come up during kernel compilation with Clang. These specific fixes were for benign things: unused lambda captures and braces around scalar initializers.
2021-07-03Kernel: Add missing override specifiersDaniel Bertalan
The `#pragma GCC diagnostic` part is needed because the class has virtual methods with the same name but different arguments, and Clang tries to warn us that we are not actually overriding anything with these. Weirdly enough, GCC does not seem to care.
2021-07-02Kernel/USB: Move the USB components as a subfolder to the Bus directoryLiav A
2021-07-02Kernel/PCI: Move the PCI components as a subfolder to the Bus directoryLiav A
2021-06-30Kernel: Give Devices without a custody a less fake absoulte_pathAndrew Kaster
This hack allows self-test mode run-tests-and-shutdown.sh to give TestProcFs a stat(2)-able /proc/self/fd/0. For some reason, when stdin is a SerialDevice, /proc/self/fd/0 will be a symlink to the device as expected, but, calling realpath or stat on /proc/self/fd/0 will error out. realpath will give the string from Device::absolute_path() which would be something like "device:4,64 (SerialDevice)". When VFS is trying to resolve_path so that we can stat the file, it would bail out on this fake-y path. Change the fake path (that doesn't show up when you ls a device, nor when checking the devices tab in SystemMonitor) from the major/minor device number and class_name() to /dev/device_name(). There's probably a very hairy yak standing behind this issue that was only discovered due to the ProcFS rework.
2021-06-29Kernel: Remove some unnecessary JSON related includesAndreas Kling
2021-06-29Kernel: Introduce the new ProcFS designLiav A
The new ProcFS design consists of two main parts: 1. The representative ProcFS class, which is derived from the FS class. The ProcFS and its inodes are much more lean - merely 3 classes to represent the common type of inodes - regular files, symbolic links and directories. They're backed by a ProcFSExposedComponent object, which is responsible for the functional operation behind the scenes. 2. The backend of the ProcFS - the ProcFSComponentsRegistrar class and all derived classes from the ProcFSExposedComponent class. These together form the entire backend and handle all the functions you can expect from the ProcFS. The ProcFSExposedComponent derived classes split to 3 types in the manner of lifetime in the kernel: 1. Persistent objects - this category includes all basic objects, like the root folder, /proc/bus folder, main blob files in the root folders, etc. These objects are persistent and cannot die ever. 2. Semi-persistent objects - this category includes all PID folders, and subdirectories to the PID folders. It also includes exposed objects like the unveil JSON'ed blob. These object are persistent as long as the the responsible process they represent is still alive. 3. Dynamic objects - this category includes files in the subdirectories of a PID folder, like /proc/PID/fd/* or /proc/PID/stacks/*. Essentially, these objects are always created dynamically and when no longer in need after being used, they're deallocated. Nevertheless, the new allocated backend objects and inodes try to use the same InodeIndex if possible - this might change only when a thread dies and a new thread is born with a new thread stack, or when a file descriptor is closed and a new one within the same file descriptor number is opened. This is needed to actually be able to do something useful with these objects. The new design assures that many ProcFS instances can be used at once, with one backend for usage for all instances.
2021-06-29Kernel: Fix `adopt_ref_if_nonnull(new T).release_nonnull()` patternDaniel Bertalan
This does the exact thing as `adopt_ref`, which is a recent addition to AK. Note that pointers returned by a bare new (without `nothrow`) are guaranteed not to return null, so they can safely be converted into references.
2021-06-25Kernel: Pass TTY-switch keyboard combo to userspaceSahan Fernando
2021-06-24Everywhere: Use nothrow new with `adopt_{ref,own}_if_nonnull`Daniel Bertalan
This commit converts naked `new`s to `AK::try_make` and `AK::try_create` wherever possible. If the called constructor is private, this can not be done, so we instead now use the standard-defined and compiler-agnostic `new (nothrow)`.
2021-06-24Kernel: Move special sections into Sections.hHendiadyoin1
This also removes a lot of CPU.h includes infavor for Sections.h
2021-06-24Kernel: Pull apart CPU.hHendiadyoin1
This does not add any functional changes
2021-06-19Kernel: Don't use naked new statements in init processLiav A
Instead, try to create the device objects in separate static methods, and if we fail for some odd reason to allocate memory for such devices, just panic with that reason.
2021-06-18USB: Store device descriptor on enumerationJesse Buhagiar
We now store the device descriptor obtained from the device during enumeration in the device's object in memory instead of exposing all of the different members contained within it.
2021-06-18USB: Store devices in globally accessible arrayJesse Buhagiar
USB Devices are now stored so that they may be later retrieved and operated on (i.e, fetching their assigned device address via ProcFS)
2021-06-17Kernel: Add a VERIFY() to make sure our DMA address is validGunnar Beutner
This checks whether the address we're trying to use for DMA is low enough so as not to overflow the I/O register.
2021-06-17Kernel/Interrupts: Return boolean on whether we handled the interruptLiav A
If we are in a shared interrupt handler, the called handlers might indicate it was not their interrupt, so we should not increment the call counter of these handlers.
2021-06-17Kernel/Interrupts: Add sensible purposes to VirtIO and USB devicesLiav A
When we enumerate the interrupt handlers, it's a good idea to show a meaningful name to the user instead of "IRQ Handler".
2021-06-16Kernel: Remove various other uses of ssize_tGunnar Beutner
2021-06-12USB: Further Implement USB StructuresJesse Buhagiar
These are the actual structures that allow USB to work (i.e the ones actually defined in the specification). This should provide us enough of a baseline implementation that we can build on to support different types of USB device.
2021-06-09Kernel: Mark PCISerialDevice::detect() as UNMAP_AFTER_INITBrian Gianforcaro
2021-05-31Kernel: Fix crash when switching to console 5 & 6Sebastian Zaha
The changes in commit 20743e8 removed the s_max_virtual_consoles constant and hardcoded the number of consoles to 4. But in PS2KeyboardDevice the keyboard shortcuts for switching to consoles were hardcoded to 6. I reintroduced the constant and added it in both places.
2021-05-27Kernel: Let the user read/write more than one page from/to dev filesGunnar Beutner
Previously reads and writes to /dev/zero, /dev/full, /dev/null and /dev/random were limited to 4096 bytes. This removes that restriction so that users can enjoy more zero bytes in their buffers.