After some research I designed the following scheme to represent the devices in my kernel:
PS: I'm targeting an ARM SoC (Raspberry Pi), but I believe these ideas can be applied to PC.
The hardware enumeration will build a tree. In the root level we have the "System" node, which represents the computer. It children are buses (e.g. USB, I2C, SPI, etc.) and each bus have it attached devices (mostly peripherals). In my case, I have the 'virtual' SOC bus which contains devices implemented directly in the SOC and can't be enumerated (e.g. graphic display). Finally, we have 'virtual devices' which are devices built on top of other devices (e.g. filesystems, host bridges, etc). They could be used, for example, to mount a NFS filesystem (filesystem device attached to a network device).
Devices and buses are associated to a driver and contains a block of information (e.g. vendor, model, addresses, class, etc.).
Something to illustrate:
- SOC bus
- USB bus
- Host Bridge (e.g. USB hub)
- Host Bridge (e.g. another USB hub)
- Mass storage (e.g. USB stick, external HDD)
- WiFi dongle
- SPI bus
I admit that It's a not detailed description, but it gives a general view of the design.Question:
this seems a good way to represent a device hierarchy?