Chapter 3. Hardware & Architecture

David Horton

Table of Contents

1. A Brief Look At The Objectives
2. Ports, Interrupts and DMA
3. IDE Disks and LBA
4. SCSI Devices
5. USB Devices
6. Modems and Sound Cards
7. Practice Questions
8. Answers To Practice Questions
9. Additional Resources

1. A Brief Look At The Objectives

Successful completion of the Hardware & Architecture section of the LPI exam requires familiarity with Personal Computer (PC) expansion cards and peripherals and how those devices interact with the system BIOS and the Linux Kernel. This includes understanding the difference between Industry Standard Architecture (ISA) and Peripheral Component Interconnect PCI as well as what interrupts (IRQs), Input/Output (I/O) ports and Direct Memory Access (DMA) channels are used for. If you are the type of person whose PC spends as much time with the cover off as it does with the cover on you probably have a good head start on the preceding items. You will also need to know about Small Computer Systems Interface (SCSI) and Universal Serial Bus (USB) architectures, which are perhaps more difficult subjects. SCSI is more commonly used in high-end servers and may not be familiar to PC users. USB although more common in PC's is relatively new feature in the Linux kernel.

2. Ports, Interrupts and DMA

Expansion cards communicate with the PC using three basic methods, i/o ports, interrupts and DMA. The Linux kernel must keep track of these communication resources in order to properly interact with the expansion cards. The system administrator can see the kernel's view of i/o ports, interrupts and DMA channels by looking in the proc filesystem. There are three files in particular to note.

  • /proc/ioports

  • /proc/interrupts

  • /proc/dma

All of these files can be viewed using the cat command. For example, cat /proc/ioports will show the the i/o ports used by the system. Take a moment to become familiar with the contents of these files. See if you can identify the various devices in your PC. Below are some excepts from the three files from a typical PC:

bash$ head -5 /proc/ioports
0000-001f : dma1
0020-003f : pic1
0040-005f : timer
0060-006f : keyboard
0070-007f : rtc

bash$ head -5 /proc/interrupts
           CPU0
  0:     204783          XT-PIC  timer
  1:       2410          XT-PIC  keyboard
  2:          0          XT-PIC  cascade
  5:       4004          XT-PIC  aic7xxx

bash$ cat /proc/dma
 4: cascade

Most modern expansion cards have their resources assigned automatically using plug-and-play (PnP) technology and it is rare to find a card that requires manual configuration. The way resources are assigned to a card depends upon which bus technology it uses. All PCI cards are designed to be plug-and-play and are assigned resources by the PC's BIOS during boot-up. The results of the configuration can be viewed using the lspci command. Older ISA cards may need to have their resources assigned by the operating system rather than the BIOS. Linux systems use the isapnp command and the corresponding /etc/isapnp.conf file to set up ISA plug-and-play cards. The pnpdump command queries ISA plug-and-play cards to find their desired resource configuration and its output can be used to construct the /etc/pnp.conf file.

3. IDE Disks and LBA

Exploration of the /proc/ide directory reveals information about IDE devices present in the system. Of particular interest is the /proc/ide/hda directory since it contains information about the first, bootable IDE hard disk in the system. Two files in the /proc/ide/hda directory, capacity and geometry, are used to describe the size of the hard disk. The example below shows the contents of the files for an 80G hard disk.

bash# cat /proc/ide/hda/geometry
physical     38322/16/255
logical      9732/255/63

bash# cat /proc/ide/hda/capacity
156355584

The output of geometry shows the size in a cylinder/head/sector (CHS) format while capacity shows the size in logical block addressing (LBA) format. The older CHS format is limited to 1024 cylinders and can only describe disks up to 8G in size. Because of this limitation modern hard disks are almost always described using LBA. The Linux kernel uses LBA exclusively and provides the CHS parameters in geometry for informational purposes only. Because the operating system uses LBA it is important that the PC BIOS also be configured to use LBA.

4. SCSI Devices

In addition to IDE many high-performance systems use SCSI. Typical SCSI devices attached to a Linux system include hard drives, cd-roms and tape drives, but there can be others as well. All SCSI devices must be attached to a SCSI Host Adapter in order to interact with the system. The SCSI adapter is responsible for handling communication between the SCSI devices and the Linux kernel. Information about the host adapter and the devices attached to it will appear in the proc filesystem under the /proc/scsi directory. The following example shows a typical /proc/scsi directory.

bash# ls -F /proc/scsi
aic7xxx/  scsi

The directory aic7xxx contains information about the configuration of the host adapter (an Adaptec 2940 in this case.) There are many manufacturers of SCSI host adapters so the name and contents of the directory will vary depending on the partcular setup.

There is also a file named /proc/scsi/scsi that shows all SCSI devices as seen by the Linux kernel. An example is shown below.

bash# cat /proc/scsi/scsi
Attached devices:
Host: scsi0 Channel: 00 Id: 00 Lun: 00
  Vendor: IBM      Model: DNES-309170W     Rev: SA30
  Type:   Direct-Access                    ANSI SCSI revision: 03
Host: scsi0 Channel: 00 Id: 04 Lun: 00
  Vendor: PHILIPS  Model: CDD2600          Rev: 1.07
  Type:   CD-ROM                           ANSI SCSI revision: 02
Host: scsi0 Channel: 00 Id: 05 Lun: 00
  Vendor: IOMEGA   Model: ZIP 100          Rev: E.03
  Type:   Direct-Access                    ANSI SCSI revision: 02
Host: scsi0 Channel: 00 Id: 06 Lun: 00
  Vendor: HP       Model: HP35480A         Rev: 1009
  Type:   Sequential-Access                ANSI SCSI revision: 02

Take a moment to look at the information contained in the file. Notice how each device on the SCSI bus has its own unique SCSI ID number. Hard disks are generally given lower SCSI ID's than CD-ROM's and tape drives and ID 0 is reserved for the bootable hard disk.

When accessing SCSI devices in Linux it is done using nodes in the /dev directory just like any other piece of hardware. Refering to the example above the IBM hard disk would be accessed as /dev/sda while the Iomega Zip disk is /dev/sdb. The Philips CD-ROM is /dev/sr0 and the HP tape drive is /dev/st0.

5. USB Devices

Support for USB first appeared in Linux kernel version 2.2 and became much more robust in kernel version 2.4. USB is very similar to SCSI in many respects. The system has a USB host controller which functions much like a SCSI host adapter and USB storage devices appear as SCSI disks in the /dev directory.

In order for USB devices to be recognized there must be USB support in the kernel either compiled in or loaded as a module. In the case of a modular kernel the files required for basic USB support are as follows.

  • usbcore

  • usb-uhci or usb-ohci depending on the motherboard manufacturer.

The kernel will also need to have modules loaded for the particular USB device being used. For example acm for USB modems and usb-storage for storage devices like USB hard drives and USB CD-ROMs.

Many times it is also necessary to include hotplug support in the kernel because most USB devices are designed to be added and removed from the system without requiring a reboot. There is also a userspace program /sbin/hotplug that helps the kernel deal with dynamically adding and removing USB devices. /sbin/hotplug does this by looking for a shell script (also called an agent) in the /etc/hotplug directory with the same name as the USB device being added or removed. The agent is responsible for handling the particulars of adding and removing the device.

6. Modems and Sound Cards

Modems and sound cards are given special attention on the LPI exam since they can be slightly more complicated than other types of hardware.

Modems have extra requirements to work properly with Linux and these are listed below.

  • The modem must have the serial port set to the correct speed with setserial.

  • If the modem is a winmodem, the device must be supported.

In addition to setting up modem hardware the LPI exam also covers setting up a Point-to-Point Protocol (PPP) connection to an Internet provider. DSL and Cable modem users may want to refresh their memories by skimming the pppd and chat man pages or the PPP-HOWTO.

Sound cards are typically difficult to configure because they use many different resources (i/o ports, interrupts & DMA channels) making it more likely that some sort of resource conflict will occur.

7. Practice Questions

You can gauge your familiarity with the subject of Hardware & Architecture by answering the practice questions below.

  1. You are working with your hardware vendor's technical support people to troubleshoot a network card problem. The technical support representative wants to know which IRQ channel the card is using. Which file would tell you the IRQ channel for the card?

    1. /proc/interrupts

    2. /proc/ioports

    3. /proc/irqs

    4. /proc/sysconfig

  2. You are providing telephone support to a novice user at a remote location, because the dial-in modem is not working. When you ask the user to tell you what port the modem is connected to he says, "COM1." What is the Linux device that corresponds to COM1? (provide the full path)

  3. Management has finally approved the budget for you to buy your first high-capacity SCSI tape drive and SCSI host adapter. You install the host adapter in PCI slot 4 and set the tape drive's SCSI ID to 5. What Linux device would you use to access the new tape drive?

    1. /dev/st0

    2. /dev/st1

    3. /dev/st4

    4. /dev/st5

  4. In which file would you look to find the base address of your system's sound card?

    1. /proc/sysconfig

    2. /proc/ioports

    3. /proc/interrupts

    4. /proc/base

  5. What is the name of the file that contains information about direct memory access channels and the devices associated with them? (give the full path)

  6. You have just purchased a 56kbps external modem and attached it to the PC serial port labled COM2. Communication with the modem is not working and /proc/ioports shows no serial devices. What might be the cause?

    1. The serial port is disabled in the BIOS

    2. The modem is turned off

    3. COM2 is reserved for serial mice

    4. The setserial command was not run properly at start-up

  7. What BIOS feature can be turned on to enable the BIOS to access hard disks larger than 8 gigabytes?

    1. CHS

    2. LBA

    3. PIO

    4. DMA

  8. Which of the following utilities can be used to create the configuration file isapnp.conf?

    1. lspci

    2. isapnp

    3. lsmod

    4. pnpdump

  9. In which kernel version were USB devices were first supported?

  10. Which of the following kernel modules is required for USB? (choose 2)

    1. hotplug

    2. usbcore

    3. usb-uhci

    4. usbmgr

  11. You have just purchased a second-hand PCI modem from an online auction. The modem does not appear to be working, but the seller assures you that it worked fine in his Windows PC. What could be the problem?

  12. What is the name of the daemon that Linux systems use to establish a Point-to-Point connection? (specify the command name only with no options)

  13. Which program can be used in conjuction with Point-to-Point connections to execute modem connection scripts non-interactively.

    1. minicom

    2. chat

    3. pscript

    4. uucico

8. Answers To Practice Questions

  1. The correct answer is A, /proc/interrupts shows IRQ lines and the devices using them. Answer B is incorrect because /proc/ioports will give the base address for the NIC card, not the IRQ. Answers C and D both refer to nonexistent files.

  2. The correct answer is /dev/ttyS0. Remember that Linux numbers devices starting from zero.

  3. The correct answer is A, /dev/st0. Answer B is incorrect because /dev/st1 refers to the second SCSI tape drive and the question states that this is the first SCSI tape drive. Answers C and D are trying to trick you into thinking that the the device number is determined by the PCI slot number or the SCSI ID, but this is not the case.

  4. The correct answer is B, /proc/ioports. Answer C is incorrect because /proc/interrupts gives the IRQ channels used by the system. Answers A and D both refer to nonexistent files.

  5. The correct answer is /proc/dma.

  6. The correct answer is A, the modem is disabled in the BIOS. Answer B is incorrect because the modem is external and powering it off would not prevent the serial port device from appearing in /proc/ioports. Answer C is complete fiction as Linux does not reserve serial ports. Answer D is incorrect since setserial is used to set parameters such as handshaking and speed and not to enable or disable devices.

  7. The correct answer is B, LBA. LBA stands for Logical Block Addressing and allows the BIOS to to access larger disks than could be accessed with the older CHS, or Cylinder Head Sector addressing. Answer A is incorrect for reasons just described. Answer C and D are incorrect because PIO and Ultra DMA both describe methods of data transfer, not data addressing.

  8. Answer D is correct, pnpdump can be used to create the isapnp.conf file. Answer A, lspci gives information about devices on the PCI bus, not the ISA bus. The isapnp command cannot be used to generate its own configuration file so answer B is incorrect. Answer C, lsmod, is incorrect since this utility is used for listing kernel modules.

  9. The correct answer is kernel 2.2. USB was not supported in kernels prior to this.

  10. The correct answers are B and C. USB requires the modules usbcore and usb-uhci. Other motherboards might require usb-ohci in place of usb-uhci so do not be surprised if this is on the exam. Answers A and D are incorrect, because hotplug and usbmgr do not exist as modules. However, you will see /etc/hotplug and /etc/usbmgr directories which are used with USB.

  11. Most likely the modem is a winmodem that is not supported by Linux.

  12. The correct answer is pppd.

  13. The correct answer is B, chat is used to run non-interactive login scripts for ppp connections. Answer A is incorrect, minicom is an interactive program. Answer C is a ficticious program. Answer D is incorrect, uucico is used for uucp not ppp.

9. Additional Resources

Listed below are some documents that may be helpful when preparing for the Hardware & Architecture portion of the LPI 101 exam.

  • The Linux kernel documentation contains a useful file called devices.txt. This file contains information about virtually every device one could expect to find in the /dev directory. Kernel documentation is generally found in the /usr/src/linux/Documentation directory.

  • The Large-Disk-HOWTO does a good job of describing LBA, CHS and 1024 cylinder limitations.

  • The SCSI-2.4-HOWTO goes into great detail about the Linux SCSI implentation.

  • The Linux USB web site maintains an FAQ that covers using USB devices with Linux.

  • Modems and sound cards are covered in the older, but still relevant PPP-HOWTO and Sound-HOWTO.