Brief Introduction to PCI – Part I
Posted in design, lowlevel, programming | by evilbitz |This article is written in simple language and is intended for the common knowledge of the average computer user that should know what is happening under the “hood”, yet most advanced users can find this information interesting and it might introduce some new topics for them.
Before we will delve into the interesting part, let’s move through some basics. PCI is an acronym which stands for Peripheral Component Interconnect. It is the medium by which the CPU is talking with the rest of the devices in the computer. In the computer Jargon, it is called a bus. It is a set of lines that connects all the devices to the CPU and RAM (Random Access Memory) all together. For example, a sound card may be connected into a PCI slot on the Mother Board. When the operating system boots, it probes for PCI devices and get’s a list of all the devices which are connected in the system.
Each device owns the bus for just a period of time. Since there are several devices on the bus, a mechanism that determines which device may use the bus is needed. Fundamentally, this is called bus arbitration.
A PCI device also may have a need to communicate with its driver, which is a piece of software that runs in the operating system’s context and operates the device. Since there are a lot of operating systems, that same device may have several different versions of drivers, one for each OS. To communicate with the driver, the device holds an IRQ Line (Interrupt Request) and uses it to signal the CPU that the driver should be called and handle the event.
In this request, which is called an Interrupt, the driver may need to read some data from the device (think about a network packet that arrives to the machine). To pass the data (I/O), a PCI device may have two options, to pass the data by some I/O ports or by sharing a pre-determined memory region. The IRQ line and the addresses of the shared memory region are called the device’s resources.
When an interrupt occurs, the CPU stops the execution of the current software that is running and passes control to the driver. This is called pre-emption. So, the driver handles this event, and a function that is called the ISR (Interrupt Service Routine) is being executed. It reads and writes some data from the device and processes it. When a user’s software will ask for this data, the driver will have it ready.
Ok… let’s get back to PCI itself. PCI is actually the successor of an older bus called ISA, which was slower, and the predecessor of PCI-e (PCI Express ), which is newer and extremely faster. But yet, most of the hardware is designed for PCI and it is still the most common bus in the PC market. Don’t be mislead, even those “On-Board” devices which are so common those days are connected through the PCI bus. PCI slots are used for expansion.
The PCI bus is composed of 32 lines of electricity, each represents a bit, which is the smallest representation of data. It might be 0 or 1. Together, those 32 bits are composing a number in the range of 0 to 4,294,967,296. The PCI bus is working on a clock speed of 33MHz. That means that each line (bit) may be sampled in less than 1/33 of a second.
In the next article, I’ll introduce some new terms like DMA and BIOS.
Thanks for reading!