1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 10:47:44 +00:00
serenity/Kernel/Devices
Liav A 446200d6f3 Kernel+Services: Enable barebones hot-plug handling capabilities
Userspace initially didn't have any sort of mechanism to handle
device hotplug (either removing or inserting a device).
This meant that after a short term of scanning all known devices, by
fetching device events (DeviceEvent packets) from /dev/devctl, we
basically never try to read it again after SystemServer initialization
code.

To accommodate hotplug needs, we change SystemServer by ensuring it will
generate a known set of device nodes at their location during the its
main initialization code. This includes devices like /dev/mem, /dev/zero
and /dev/full, etc.

The actual responsible userspace program to handle hotplug events is a
new userspace program called DeviceMapper, with following key points:
- Its current task is to to constantly read the /dev/devctl device node.
  Because we already created generic devices, we only handle devices
  that are dynamically-generated in nature, like storage devices, audio
  channels, etc.

- Since dynamically-generated device nodes could have an infinite minor
  numbers, but major numbers are decoded to a device type, we create an
  internal registry based on two structures - DeviceNodeFamily, and
  RegisteredDeviceNode. DeviceNodeFamily objects are attached in the
  main logic code, when handling a DeviceEvent device insertion packet.
  A DeviceNodeFamily object has an internal HashTable to hold objects of
  RegisteredDeviceNode class.

- Because some device nodes could still share the same major number (TTY
  and serial TTY devices), we have two modes of allocation - limited
  allocation (so a range is defined for a major number), or infinite
  range. Therefore, two (or more) separate DeviceNodeFamily objects can
  can exist albeit sharing the same major number, but they are required
  to allocate from a different minor numbers' range to ensure there are
  no collisions.

- As for KCOV, we handle this device differently. In case the user
  compiled the kernel with such support - this happens to be a singular
  device node that we usually don't need, so it's dynamically-generated
  too, and because it has only one instance, we don't register it in our
  internal registry to not make it complicated needlessly.

The Kernel code is modified to allow proper blocking in case of no
events in the DeviceControlDevice class, because otherwise we will need
to poll periodically the device to check if a new event is available,
which would waste CPU time for no good reason.
2023-09-07 11:50:50 -06:00
..
Audio Kernel: Decouple Intel HDA interrupt handling from controller 2023-07-04 16:24:04 +02:00
Generic Kernel+Services: Enable barebones hot-plug handling capabilities 2023-09-07 11:50:50 -06:00
GPU Everywhere: Remove needless trailing semi-colons after functions 2023-07-08 10:32:56 +01:00
HID Kernel: Change the code point of numpad keys to 0, when Num Lock is off 2023-08-20 12:21:57 -06:00
Storage NVMe: Add shadow doorbell support 2023-08-18 15:47:51 +02:00
AsyncDeviceRequest.cpp AK: Rename Time to Duration 2023-05-24 23:18:07 +02:00
AsyncDeviceRequest.h Kernel: Hold a weak reference to a Process object in AsyncDeviceRequest 2023-08-20 13:04:42 -06:00
BlockDevice.cpp Kernel/Devices: Abstract SysFS Device add/remove methods more properly 2022-07-19 11:02:37 +01:00
BlockDevice.h Kernel: Make self-contained locking smart pointers their own classes 2022-08-20 17:20:43 +02:00
CharacterDevice.cpp Kernel/Devices: Abstract SysFS Device add/remove methods more properly 2022-07-19 11:02:37 +01:00
CharacterDevice.h Kernel/Devices: Abstract SysFS Device add/remove methods more properly 2022-07-19 11:02:37 +01:00
Device.cpp Kernel: Get rid of *LockRefPtr in the SysFS filesystem code 2023-04-14 19:24:54 +02:00
Device.h Kernel: Move FileSystem/DeviceFileTypes.h => API/DeviceFileTypes.h 2023-09-07 11:50:50 -06:00
DeviceManagement.cpp Kernel+Services: Enable barebones hot-plug handling capabilities 2023-09-07 11:50:50 -06:00
DeviceManagement.h Kernel+Services: Enable barebones hot-plug handling capabilities 2023-09-07 11:50:50 -06:00
KCOVDevice.cpp Everywhere: Move global Kernel pattern code to Kernel/Library directory 2023-06-04 21:32:34 +02:00
KCOVDevice.h Kernel: Use non-locking {Nonnull,}RefPtr for OpenFileDescription 2023-03-07 00:30:12 +01:00
KCOVInstance.cpp Kernel: Propagate overflow errors from Memory::page_round_up 2021-12-28 23:08:50 +01:00
KCOVInstance.h Kernel+Userland: Unify declarations for KCOV in Kernel/API/kcov.h 2023-02-24 20:35:45 +01:00
PCISerialDevice.cpp Everywhere: Move global Kernel pattern code to Kernel/Library directory 2023-06-04 21:32:34 +02:00
PCISerialDevice.h Kernel: Add PCISerialDevice WCH CH351 IDs 2023-08-12 13:08:07 +02:00
SerialDevice.cpp Everywhere: Move global Kernel pattern code to Kernel/Library directory 2023-06-04 21:32:34 +02:00
SerialDevice.h Everywhere: Move global Kernel pattern code to Kernel/Library directory 2023-06-04 21:32:34 +02:00