ladybird/Kernel
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
..
API Kernel: Move FileSystem/DeviceFileTypes.h => API/DeviceFileTypes.h 2023-09-07 11:50:50 -06:00
Arch Kernel: Add riscv64 assembly startup code 2023-08-29 11:07:06 +02:00
Boot Kernel: Move all boot-related code to the new Boot subdirectory 2023-06-04 21:32:34 +02:00
Bus Kernel: Don't allocate memory for names of processes and threads 2023-08-09 21:06:54 -06:00
Devices Kernel+Services: Enable barebones hot-plug handling capabilities 2023-09-07 11:50:50 -06:00
FileSystem Kernel: Move FileSystem/DeviceFileTypes.h => API/DeviceFileTypes.h 2023-09-07 11:50:50 -06:00
Firmware/ACPI Kernel: Overhaul system shutdown procedure 2023-07-15 00:12:01 +02:00
Heap Everywhere: Remove needless trailing semi-colons after functions 2023-07-08 10:32:56 +01:00
Interrupts Everywhere: Remove needless trailing semi-colons after functions 2023-07-08 10:32:56 +01:00
Library AK+Kernel: Introduce StdLib function to copy FixedStringBuffer to user 2023-08-25 11:51:52 +02:00
Locking Kernel: Move all tasks-related code to the Tasks subdirectory 2023-06-04 21:32:34 +02:00
Memory Kernel: Don't allocate memory for names of processes and threads 2023-08-09 21:06:54 -06:00
Net Kernel: Implement Nagle’s Algorithm 2023-08-28 00:28:15 +02:00
Prekernel Everywhere: Resolve conflicts with LibC and libc++ 2023-06-27 12:40:38 +02:00
Security Everywhere: Remove needless trailing semi-colons after functions 2023-07-08 10:32:56 +01:00
Syscalls Kernel+Userland: Remove the {get,set}_thread_name syscalls 2023-08-25 11:51:52 +02:00
Tasks Kernel: Allow Ext2FS::flush_writes() to return ErrorOr<void> 2023-08-25 11:36:57 +01:00
Time Everywhere: Remove needless trailing semi-colons after functions 2023-07-08 10:32:56 +01:00
TTY Kernel: Move m_uid and m_gid from the Device class to SlavePTY 2023-08-31 11:59:18 +02:00
CMakeLists.txt Kernel: Add riscv64 assembly startup code 2023-08-29 11:07:06 +02:00
Debug.h.in Kernel: Put loopback adapter debug spam behind a flag 2023-06-18 08:50:33 +01:00
embedmap.sh Kernel: Make new kernel build process work on macOS 2021-07-15 11:04:30 +02:00
Forward.h Kernel+LibCore+LibC: Split the mount syscall into multiple syscalls 2023-07-02 01:04:51 +02:00
generate-version-file.sh Kernel: Bake version information into the Kernel 2022-10-14 13:45:33 +02:00
kprintf.cpp Kernel: Move all Graphics-related code into Devices/GPU directory 2023-06-06 00:40:32 +02:00
kstdio.h Kernel: Remove includes to LibC stdarg definitions 2023-03-01 19:36:53 -07:00
KSyms.cpp Kernel: Move all tasks-related code to the Tasks subdirectory 2023-06-04 21:32:34 +02:00
KSyms.h Kernel: Add ability to dump backtrace from provided frame pointer 2022-10-01 14:09:01 +02:00
mkmap.sh Kernel: Use the toolchain's nm in mkmap.sh 2021-12-30 18:10:51 +01:00
SanCov.cpp Kernel: Move all tasks-related code to the Tasks subdirectory 2023-06-04 21:32:34 +02:00
Sections.h Kernel: Move all boot-related code to the new Boot subdirectory 2023-06-04 21:32:34 +02:00
UnixTypes.h Kernel: Add support for SA_SIGINFO 2022-03-04 20:07:05 +01:00