How Linux Handles Hardware
Learn the function of the /proc/pci, /proc/dma, /proc/interrupts, and /proc/ioports files
For everything to work correctly, the devices must be allocating computer resources.
These resources can be inbound and outbound ports, interrupt requests (IRQ), and direct memory access (DMA). Let’s look at these concepts.
Input/Output Ports
Inbound and outbound ports are memory addresses reserved on the microprocessor for devices to input and output information.
These memory addresses are used to exchange data between the processor and the devices in a simplified manner.
Devices may use more than one input/output port or address range. For example, a standard sound card uses ports 0x220, 0x330, and 0x388.
Each device has a unique port address that cannot be shared between other devices.
The I/O addresses in use in system can be viewed with the command:
# cat /proc/ioports
0000-001f: dma1
0020-003f: pic1
0040-005f: timer
0060-006f: keyboard
0070-007f: rtc
(…)
Requisition of Interruption (IRQ)
IRQs are calls that devices can make to require special attention from the processor.
Most computers offer just 16 hardware interrupts for the most diverse devices.
It may not seem like much for modern configurations with the most different devices. Fortunately, IRQs can be shared.
System interrupts can be viewed in the Kernel with the command:
# cat /proc/interrupts CPU0 0
: 604694 XT-PIC timer
1:35746 XT-PIC keyboard
2:0 XT-PIC cascade
3:13546 XT-PIC orinoco_cs
11: ; 15 XT-PIC ALi Audio Accelerator
14:38759 XT-PIC ide0
Direct Access to Memory (DMA)
DMA is used to allow the transfer of data between devices and memory without the intervention of the processor.
This access is through channels. Most computers have two DMA controllers. The first controls channels 0, 1, 2, 3 and the second channels 4, 5, 6, 7, totaling 8 channels.
The DMA channels in use in system can be viewed with the command:
# cat /proc/dma 4: cascade
It is important that you know that these resources are limited and need to be managed so that conflicts between devices are avoided.
Some devices, such as serial and parallel ports, already use the features in the following pattern:
TABLE - Linux device reference
Device Name on Linux | Device Name in Windows | I/O port | DMA | IRQ |
TTys0 | WITH 1 | 0x3F8 | - | 4 |
TTys1 | WITH 2 | 0x2F8 | - | 3 |
TTys2 | WITH 3 | 0x3E8 | - | 4 |
TTys3 | WITH 4 | 0x2E8 | - | 3 |
lp0 | LPT1 | 0x378 | - | 7 |
LP1 | LPT1 | 0x278 | - | 5 |
/dev/hda1 | C: | 0x1F0 | - | 14 |
/dev/fd0 | TO: | 0x3F0 | 2 | 6 |
Hotplug x Coldplug
There are devices that can be connected or removed with the computer turned on and fully functioning, which are categorized as hotplug.
For these, the Kernel will be able to recognize your presence or absence and load the drivers, scripts and programs necessary for its correct functioning.
This category includes: keyboard, mouse, webcam, external USB hard drive, USB external CD-Rom, printers, speakers, microphones, monitors, cell phones, pendrives, etc.
On the other hand, devices that must be connected and removed with the computer turned off are called coldplug.
Any attempt to change its state may cause the equipment to crash or even burn. They are: CPU, RAM memory, internal hard drives, internal cards (sound, video, etc.).
Storage Devices
Linux supports several types of mass data storage. These devices can be categorized as optical, magnetic, or in memory.
Optical discs are CD-ROMs (700Mb), DVDs (4.7-8.5Gb) and Blu-Rays (25-50Gb). They’re not as fast as hard drives, But they have great durability if packaged in appropriate places and not allow you to record the data several times.
Magnetic disks have a large data storage capacity, which can reach 8 Terabytes.
Some models are hybrid, since they have magnetic disks and large flash memories to store the most read data or even the operating system. They are sensitive to bumps and falls.
Still in the category of magnetic devices, we have magnetic tapes, which are widely used for data backup. They allow you to record data sequentially at low cost.
Its use is decreasing due to the low price of disks, cloud computing, and other more advanced backup strategies.
The “disks” in memory are actually banks of flash memory called Solid State Drive (SSD) - solid state drive - encapsulated in a box the size of an HD and have no moving parts such as optical and magnetic disks. Their access time to data is incredibly fast compared to magnetic and optical discs. They are resistant to falls and bumps, consume less energy, and other benefits.
However, the storage capacity does not exceed 1 Terabyte, and its cost is high compared to magnetic disks. They are widely used in Ultrabooks and high-performance servers.
PCI devices
During the system load process, the Kernel detects the PCI devices connected to the micro. The list of expansion cards found can be read through the special file /proc/pci.
# cat /proc/pci
PCI devices found:
Bus 0, device 0, function 0:
Host bridge: PCI device 10b 9:1644 (Acer Laboratories Inc. [Ali]) (rev 1).
Prefetchable 32-bit memory at 0xf0000000 [0xf3ffffff].
Bus 0, device 1, function 0:
PCI bridge: Acer Laboratories Inc. [ALi] M5247 (rev 0).
Master Capable. No bursts. Min. Gnt=8.
Bus 0, device 2, function 0:
USB controller: Acer Laboratories Inc. [ALi] M5237 USB (rev 3).
IRQ 11.
Do you want to learn more about special Linux files in /proc? Discover our LPIC-1 course
Learn much more about Linux in our online course. You can enroll here with a free 7-day trial. If you already have an account, you can log in here.