Hardware management

This document describes how the kernel interacts with hardware.

Hardware detection

Devices are detected during the boot process and then periodically after startup. This allows to hotplug some additional components afterwards.

As all components do not use the same connection protocols, the detection process depends on the connection:

  • PCI-Express components are detected through their Configuration Space
  • IDE/SATA components are detected through the IDE/SATA controller
  • USB components are enumerated through the USB protocol stack

Some components may not be detected through these though, such as some legacy ISA devices, which will be detected through a set of methods like ACPI enumeration or simply checking UART serial ports.

Connection-specific device descriptor

All hardware components (devices) expose a normalized identifier whose format depends on the connection type (PCI-Express, SATA, ...). This identifier is called the connection-specific device descriptor (CSDD).

Its size can vary up to 256 bytes.

Connection interface identifier

The connection interface identifier (CII) is a 4-byte number describing what a component is connected to:

  • Connection type (1 byte):
    • 0x01: PCI-Express
    • 0x02: IDE
    • 0x03: SATA
    • 0x04: M.2
    • 0x05: USB
    • 0x06: RGB
  • Bus number (1 byte)
  • Port number (2 bytes)

For instance, the seventh USB port on the second bus will have the 0x05010006 CII.

Session device identifier

The kernel generates for each device a session device identifier (SDI), which is a random 4-byte number specific to the current session, allowing to plug up to 4 billion devices in a single session.

Raw device descriptor

The raw device descriptor (RDD) is a data structure (up to 264 bytes) made of the followings:

  • SDI (4 bytes)
  • CII (4 bytes)
  • CSDD (up to 256 bytes)

This descriptor is then used by the sys::hw service to expose the device to the rest of the operating system.

Drivers

Drivers and software <-> hardware devices communications are handled by the sys::hw system service.

You can find more about how drivers work in this section.