When you connect a new peripheral, you suddenly see how the operating system recognizes it and installs the drivers from an online repository or, if you can’t find them, ask us for some. But, have you ever wondered how your PC can identify the peripheral you have connected to it? In this tutorial we are going to explain how your PC does it to identify which peripheral it is through the USB ID and the PCI ID.
Nowadays the term plug and play we no longer see it repeated everywhere, the reason is very simple, all peripherals are plug and play but there was a time when the system had no way of knowing what type of peripheral it was. communicating and it was necessary to touch certain parameters manually.
This ended with the implementation of the first PCI port, nowadays evolved in the various generations of PCI Express, and the USB later, which in their standards make use of identification codes that identify each and every one of the peripherals that are in he
Identification on PCI and PCI Express peripherals: the PCI ID
Any device that is connected to a port of the PCI or PCI Express type is identified by a hexadecimal code divided into two parts:
- The first figures belong to the manufacturer, this identification is assigned in a perpetual way by the PCI-SIG, which is the consortium that develops the different standards of the PCI Express bus, as well as its different advances.
- The second part of the ID is assigned by the manufacturer.
Each of the two parts of the identification code is stored in the form of two 16-bit integers, which are stored in a specific register. This means that there may be up to 65,536 peripheral manufacturers of PCI devices and each of them can manufacture 65,536 devices that use this interface, let us tell you that not even the most veteran hardware manufacturers have managed to manufacture this amount of devices at all This weather.
Many manufacturers subdivide the product ID into several sub IDs, which can mark things like the generation of the hardware, its nature, the type of variant, and so on. So, unlike what happens with USB ID, each of the hardware manufacturers has greater freedom to assign IDs, but the trade-off is that it is more difficult to assign generic drivers to PCIe peripherals.
Identification on USB peripherals: the USB ID
The USB bus was designed so that the host system could identify the peripheral that is connected through the USB port, that is why, as with PCI devices, these also have an identification but work differently. But they work somewhat differently than PCI IDs.
First of all, there are a number of common identifications that serve to categorize the different types of devices that we can connect to a USB port, among them are:
- Human Interface Descriptor (HID): It is used by keyboards, mice and even tablets and game controllers such as joysticks and game pads. Many peripherals of this type do not have their own controllers and use the generic ones for this type of device.
- Mass Storage Descriptor (MSD): It is used for external storage such as hard drives, USB keys, etc.
There are different types of identifications by type of peripheral, these identifications are called classes, for example the Human Interface Descriptor is a type of class and then the sub-class for the type of hardware, for example a sub-class would be the keyboard. making it easy to load generic drivers for each type of hardware.
Apart from classes and sub-classes, other descriptors are also included, which are the following:
- Vendor ID (VID) : The identification code of the vendor of the USB peripheral, each manufacturer of USB devices, whatever their type, has a unique identification.
- Product ID (PID): The identification code of the device, this is given by the manufacturer of the same.
- Revision : In the event that there are several revisions of the same product, these may also have an identification.
The revision descriptor is used in very specific cases, especially when there has been a small improvement that requires the use of a new type of driver as long as the software can make use of it.
Finally, it must be clarified that the ID should not be confused with the drivers, both the USB ID and the PCI ID are used by the operating system to find the appropriate driver that will serve to communicate with that specific hardware, either between system files or from an online repository.