Percival Hsu
Percival Hsu

Reputation: 11

How to get hardware info having no OS available

Like using CPUID instruction and you will get the info of the current cpu, how to get other hardware info when having no Os available. A similar question is how exactly do our Os know the hardware info.

Upvotes: 1

Views: 145

Answers (1)

Brendan
Brendan

Reputation: 37222

For larger systems (e.g. 80x86 PCs) the firmware gives you ACPI tables that describe some things (CPUs, interrupt controllers, PCI hosts, HPET/timers, ...). Then you enumerate PCI buses to find PCI devices. Most PCI devices are controllers of some sort with more stuff attached (e.g. USB controller with stuff plugged in USB ports, video controller with monitor/s plugged into DVI ports, SATA controller with none or more disk drives attached, ...); and have their own detection mechanism/s for whatever is plugged into them.

The general goal is to build a "device tree", working from top (motherboard) down to the end-points, where starting a device driver for one thing (e.g. USB controller) may cause that device driver to find attached devices (and add those attached devices to your tree).

For smaller systems (e.g. embedded systems) half of this is missing and you may have to resort to information compiled directly into the boot loader or some kind of config script (e.g. "flattened device tree" used by boot loaders like U-Boot).

In any case; "how" depends on what the hardware is.

Upvotes: 2

Related Questions