How does the OS detect hardware?

Whether the OS receives this information from the BIOS or scans the buses on its own to determine what equipment is installed on the system. Looking around the Internet, different sources say different things. Some say that the BIOS detects the hardware and then stores it in the memory that the OS then reads, others say that the OS scans the buses (like pci) to find out about the hardware.

I would think that with modern operating systems, he would ignore the BIOS and do it himself.

Any help would be appreciated.

Thanks.

+4
source share
1 answer

In general, most modern operating systems (Windows and Linux) will rescan the detected equipment as part of the boot sequence. Trusting the BIOS to detect and configure everything correctly turned out to be unreliable.

In a typical x86 computer, there is a combination of methods used to discover connected equipment.

The PCI and PCI Express buses have a standard mechanism called Configuration Space , which you can scan to get a list of connected devices. This includes devices installed in the PCI / PCIe slot, as well as the controller in the chipset (Video Controller, SATA, etc.).

If an IDE or SATA controller is detected, the OS / BIOS should talk to the controller to get a list of mapped drives.

If a USB controller is detected, the OS / BIOS loads the USB protocol stack and then lists the attached hubs and devices.

For "obsolete" ISA devices, things are a little more complicated. Even if your motherboard does not have an ISA slot, you usually have several "ISA" devices in the system (serial ports, parallel ports, etc.). These devices usually do not have a truly standardized method for automatic detection. There are 2 options for detecting these devices:

  • Known probe addresses - Serial ports are usually 0x3F8, 0x2F8, 0x3E8, 0x2E8, so read from these addresses and see if there is anything like a serial UART port. This is far from ideal. You may have a serial port with a non-standard address that is not scanned. You may also have a device without a serial port at one of these addresses that responds poorly to sounding. Remember how Windows 95 and 98 were used to lock when hardware was detected during installation?

  • ISA Plug-n-Play - This standard was popular for a hot minute as ISA was gradually disabled in favor of PCI. You probably won't come across many devices that support this. I believe ISA PnP is disabled by default in Windows Vista and later, but I'm struggling to find the source for this now.

  • ACPI Enumeration - The OS can rely on the BIOS to describe these devices in ASL code. (See below.)

In addition, the system may have several non-PnP devices at half-fixed addresses, such as a TPM chip , HPET, or those β€œspecial” buttons on laptop keyboards. For these devices to be explained by the OS, the standard method is to use ACPI.

In the ACPI BIOS tables, a list of devices on the motherboard for the OS should be presented. These tables are written in a language called ASL (or AML for compiled form) . At boot time, the OS reads the ACPI tables and lists all the devices described. Please note that this requires the motherboard manufacturer to write their ASL code correctly. It is not always so.

And, of course, if all automatic detection methods fail, you may have to manually install the driver. You do this using the Add New Hardware Wizard in Windows. (The exact procedure depends on your version of Windows.)

+8
source

Source: https://habr.com/ru/post/1502648/


All Articles