Table of Content

Weight: 2

Description: Candidates should be able to determine and configure fundamental system hardware.

Key Knowledge Areas:

  • Enable and disable integrated peripherals
  • Configure systems with or without external peripherals such as keyboards
  • Differentiate between the various types of mass storage devices
  • Know the differences between coldplug and hotplug devices
  • Determine hardware resources for devices
  • Tools and utilities to list various hardware information (e.g. lsusb, lspci, etc.)
  • Tools and utilities to manipulate USB devices
  • Conceptual understanding of sysfs, udev, dbus

The following is a partial list of the used files, terms and utilities:

/sys/
/proc/
/dev/
modprobe
lsmod
lspci
lsusb

firmware

random access memory (RAM) typically volatile, meaning that if the power goes away so does the memory’s contents. The big advantage with RAM is that the access time for read and write is far faster than any EPROM or EEPROM.

electronically erasable programmable read-only memory (EEPROM) non-volatile

interrupts, I/O addresses, DMA addresses, the real-time clock, and Advanced Technology Attachment (ATA) hard disk interfaces

type of firmware:
Basic Input/Output System (BIOS)
Extensible Firmware Interface (EFI) or the Unifi ed EFI (UEFI) EFI 2.x

role of firmware:
When you turn on a computer, the firmware performs a power-on self-test (POST), initializes hardware to a known operational state, loads the boot loader from the boot device (typically the first hard disk), and passes control to the boot loader, which in turn loads the OS.

IRQs

An interrupt request (IRQ), or interrupt, is a signal sent to the CPU instructing it to suspend its current activity and to handle some external event such as keyboard input.

X86 IRQs 0-15
0 system timer
1 keyboard
3 COM2 RS-232
4 COM1 RS-232
5 sound card or LPT2
8 real-time clock
14 1st ATA /dev/hda /dev/hdb treat ATA as SCSI so could be /dev/sdx
15 2nd ATA /dev/hdc /dev/hdd

x86-64 more than 16 IRQs

The /proc/interrupts file lists IRQs that are in use by Linux, but Linux doesn’t begin using an IRQ until the relevant driver is loaded.

I/O address/port

I/O addresses (also referred to as I/O ports) are unique locations in memory that are reserved for communications between the CPU and specific physical hardware devices.

If two devices use the same IO ports, then it is unlikely that they will work together. One of them needs to be reconfigured – either by changing jumper settings, plug and play settings, or reconfiguring internal peripherals.

DMA

Direct memory addressing (DMA) is an alternative method of communication to I/O ports Rather than have the CPU mediate the transfer of data between a device and memory, DMA
permits the device to transfer data directly, without the CPU’s attention. The result can be lower CPU requirements for I/O activity, which can improve overall system performance.

coldplug/hotplug

Coldplug devices are designed to be physically connected and disconnected only when the computer is turned off.

coldplug dev – internal components
CPU, memory, PCI cards, and hard disks, RS-232

hotplug dev
Hot-plug SATA
external devices, such as Ethernet, USB, and IEEE-1394 devices

Sysfs

The sysfs virtual filesystem, mounted at /sys, exports information about devices so that user-space utilities can access the information.

A user space program is one that runs as an ordinary program, whether it runs as an ordinary user or as root. This contrasts with kernel space code, which runs as part of the kernel.

hald, d-bus, udev

hald Hardware Abstraction Layer (HAL) Daemon is a user-space program that runs at all times (that is, as a daemon) that provides other user-space programs with information about available hardware.

D-Bus The Desktop Bus (D-Bus) provides a further abstraction of hardware information access. new USB device

udev a virtual filesystem, mounted at /dev, which creates dynamic device files as drivers are loaded and unloaded. You can configure udev through files in /etc/udev, but the standard configuration is usually sufficient for common hardware.

pci

setpci
lspci

lspci -t # pci bus tree
lspci -mm # human readable format

lspci -mm |grep -i eth
02:01.0 "Ethernet controller" "Intel Corporation" "82545EM Gigabit Ethernet Controller (Copper)" -r01 "VMware" "PRO/1000 MT Single Port Adapter"

lspci -s 02:01.0 -v
02:01.0 Ethernet controller: Intel Corporation 82545EM Gigabit Ethernet Controller (Copper) (rev 01)
Subsystem: VMware PRO/1000 MT Single Port Adapter
Physical Slot: 33
Flags: bus master, 66MHz, medium devsel, latency 0, IRQ 19
Memory at fd5c0000 (64-bit, non-prefetchable) [size=128K]
Memory at fdff0000 (64-bit, non-prefetchable) [size=64K]
I/O ports at 2000 [size=64]
[virtual] Expansion ROM at fd500000 [disabled] [size=64K]
Capabilities:
Kernel driver in use: e1000

lcpci -k # kernel driver
lcpci -D # domain number

kernel module

module config
/etc/modprobe.d

lsmod |grep str

modinfo

insmod modulefine

modprobe module # will check dependency
modprobe -n|--dry-run|--show module # check config without real insert
modprobe -r module # remove module
modprobe -l v* # list all module starting with v
modporbe -f module # force load module
modprobe -D|--show-depends module # check depends

rmmod module
rmmod -f module # force remove module even in use
rmmod -w module # wait until module unused

usb

lsusb

cannot find /proc/bus/usb on ubuntu
The folder /proc/bus/usb is part of usbfs. Because of conflicts with udev, newer Ubuntu kernels come with usbfs disabled.

root@dclab-u1504s:/proc/bus/pci/00# ll /sys/kernel/debug/usb/devices
-r--r--r-- 1 root root 0 Oct 30 22:49 /sys/kernel/debug/usb/devices

lsusb
lsusb -s 002:003

lsusb

Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 004: ID 0e0f:0008 VMware, Inc.
Bus 002 Device 003: ID 0e0f:0002 VMware, Inc. Virtual USB Hub
Bus 002 Device 002: ID 0e0f:0003 VMware, Inc. Virtual Mouse
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

lsusb -s 001:001 -v
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Couldn't open device, some information will be missing
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 2.00
bDeviceClass 9 Hub
bDeviceSubClass 0 Unused
bDeviceProtocol 0 Full speed (or root) hub
bMaxPacketSize0 64
idVendor 0x1d6b Linux Foundation
idProduct 0x0002 2.0 root hub

HD

BIOS - CHS
cylinder/head/sector

disk expressed in cylinder, track/head per cylinder, sector per track/head

plain CHS 504MB
patched CHS 8GB

EFI - LBA
logical block addressing, a single unique number assigned to each sector on disk, dis's firmware is smart engough to read from correct head and cylinder when giving this sector number.

quiz

1. You have a system with an ISA bus and an internal modem requiring IRQ 5. The BIOS
assigns IRQ5 to the onboard parallel port. What problem will result (if any). How do you
make the modem and parallel port work simultaneously?
2. What is the significance of hard disk cylinder 1024 to the BIOS?
3. When is it better to use LBA mode?
4. What are the error handling settings supported by some BIOSes
5. Which “files” in /proc show the Linux view of the BIOS?
6. Which commands list PCI and ISA peripherals?
7. Why is dmesg significant for diagnosing BIOS problems?

Answers to quiz questions

1. You can either disable the parallel port in the “integrated peripherals” section, or you can change its settings so that it does not use IRQ 5. You also need to reserve IRQ 5 for the ISA bus.
2. BIOS max cylinder 1024 and totally up to 8.4GB
3. Always
4. Halt on keyboard, etc.
5. pci, dma, interrupts
6. lspci and lspnp (for newer kernels)
7. dmesg shows kernel messages, and the kernel talks to the BIOS as it boots up.

Quiz questions2

1. What is the purpose of an interrupt?
2. What is the purpose of an I/O address?
3. What is the purpose of a DMA channel?
4. What happens when there is a resource conflict between two devices?
5. Under what circumstances can two devices share the same IRQ value?

Answers to quiz questions2

1. An interrupt indicates that a peripheral requires CPU attention – i.e. reading or writing data.
2. An IO address is used on a bus to identify a particular peripheral or a component of a
peripheral.
3. A DMA channel is used for coordinating data transfers between peripherals and memory. This frees the CPU for more productive work.
4. Either one or both of the devices does not work. It is possible that one of the devices may function unreliably.
5. On a bus which uses level triggered interrupts it is possible to share interrupt values. On the ISA bus and the EISA bus interrupt sharing is not possible. On the PCI bus, interrupt sharing is the norm.