Наши партнеры








Книги по Linux (с отзывами читателей)

Библиотека сайта rus-linux.net

 Purchase  Copyright © 2002 Paul Sheer. Click here for copying permissions.  Home 

next up previous contents
Next: 4. Basic Commands Up: rute Previous: 2. Computing Sub-basics   Contents

Subsections

3. PC Hardware

This chapter explains a little about PC hardware. Readers who have built their own PC or who have configuring myriad devices on Windows can probably skip this section. It is added purely for completeness. This chapter actually comes under the subject of Microcomputer Organization, that is, how your machine is electronically structured.

3.1 Motherboard

Figure 3.1: Partially assembled motherboard
\begin{figure}\begin{center}
{\setlength{\epsfysize}{\motherboardh}\epsfbox{motherboard90.eps}}
\end{center}\end{figure}

Inside your machine you will find a single, large circuit board called the motherboard (see Figure 3.1). It is powered by a humming power supply and has connector leads to the keyboard and other peripheral devices. [Anything that is not the motherboard, not the power supply and not purely mechanical.]

The motherboard contains several large microchips and many small ones. The important ones are listed below.

RAM
Random Access Memory or just memory. The memory is a single linear sequence of bytes that are erased when there is no power. It contains sequences of simple coded instructions of one to several bytes in length. Examples are: add this number to that; move this number to this device; go to another part of RAM to get other instructions; copy this part of RAM to this other part. When your machine has ``64 megs'' (64 megabytes), it has 64 x 1024 x 1024 bytes of RAM. Locations within that space are called memory addresses, so that saying ``memory address 1000'' means the 1000th byte in memory.

ROM
A small part of RAM does not reset when the computer switches off. It is called ROM, Read Only Memory. It is factory fixed and usually never changes through the life of a PC, hence the name. It overlaps the area of RAM close to the end of the first megabyte of memory, so that area of RAM is not physically usable. ROM contains instructions to start up the PC and access certain peripherals.

CPU
Central Processing Unit. It is the thing that is called 80486, 80586, Pentium, or whatever. On startup, it jumps to memory address 1040475 (0xFE05B) and starts reading instructions. The first instructions it gets are actually to fetch more instructions from disk and give a Boot failure message to the screen if it finds nothing useful. The CPU requires a timer to drive it. The timer operates at a high speed of hundreds of millions of ticks per second (hertz). That's why the machine is named, for example, a ``400 MHz'' (400 megahertz) machine. The MHz of the machine is roughly proportional to the number of instructions it can process per second from RAM.

I/O ports
Stands for Input/Output ports. The ports are a block of RAM that sits in parallel to the normal RAM. There are 65,536 I/O ports, hence I/O is small compared to RAM. I/O ports are used to write to peripherals. When the CPU writes a byte to I/O port 632 (0x278), it is actually sending out a byte through your parallel port. Most I/O ports are not used. There is no specific I/O port chip, though.

There is more stuff on the motherboard:

ISA slots
ISA (eye-sah) is a shape of socket for plugging in peripheral devices like modem cards and sound cards. Each card expects to be talked to via an I/O port (or several consecutive I/O ports). What I/O port the card uses is sometimes configured by the manufacturer, and other times is selectable on the card through jumpers [Little pin bridges that you can pull off with your fingers.] or switches on the card. Other times still, it can be set by the CPU using a system called Plug and Pray [This means that you plug the device in, then beckon your favorite deity for spiritual assistance. Actually, some people complained that this might be taken seriously--no, it's a joke: the real term is Plug 'n Play]or PnP. A card also sometimes needs to signal the CPU to indicate that it is ready to send or receive more bytes through an I/O port. They do this through 1 of 16 connectors inside the ISA slot. These are called Interrupt Request lines or IRQ lines (or sometimes just Interrupts), so numbered 0 through 15. Like I/O ports, the IRQ your card uses is sometimes also jumper selectable, sometimes not. If you unplug an old ISA card, you can often see the actual copper thread that goes from the IRQ jumper to the edge connector. Finally, ISA cards can also access memory directly through one of eight Direct Memory Access Channels or DMA Channels, which are also possibly selectable by jumpers. Not all cards use DMA, however.

In summary, the peripheral and the CPU need to cooperate on three things: the I/O port, the IRQ, and the DMA. If any two cards clash by using either the same I/O port, IRQ number, or DMA channel then they won't work (at worst your machine will crash). [Come to a halt and stop responding.]

``8-bit'' ISA slots
Old motherboards have shorter ISA slots. You will notice yours is a double slot (called ``16-bit'' ISA) with a gap between them. The larger slot can still take an older 8-bit ISA card: like many modem cards.

PCI slots
PCI (pee-see-eye) slots are like ISA but are a new standard aimed at high-performance peripherals like networking cards and graphics cards. They also use an IRQ, I/O port and possibly a DMA channel. These, however, are automatically configured by the CPU as a part of the PCI standard, hence there will rarely be jumpers on the card.

AGP slots
AGP slots are even higher performance slots for Accelerated Graphics Processors, in other words, cards that do 3D graphics for games. They are also auto-configured.

Serial ports
A serial port connection may come straight from your motherboard to a socket on your case. There are usually two of these. They may drive an external modem and some kinds of mice and printers. Serial is a simple and cheap way to connect a machine where relatively slow (less that 10 kilobytes per second) data transfer speeds are needed. Serial ports have their own ``ISA card'' built into the motherboard which uses I/O port 0x3F8-0x3FF and IRQ 4 for the first serial port (also called COM1 under DOS/Windows) and I/O port 0x2F8-0x2FF and IRQ 3 for COM2. A discussion on serial port technology proceeds in Section 3.4 below.

Parallel port
Normally, only your printer would plug in here. Parallel ports are, however, extremely fast (being able to transfer 50 kilobytes per second), and hence many types of parallel port devices (like CD-ROM drives that plug into a parallel port) are available. Parallel port cables, however, can only be a few meters in length before you start getting transmission errors. The parallel port uses I/O port 0x378-0x37A and IRQ 7. If you have two parallel ports, then the second one uses I/O port 0x278-0x27A, but does not use an IRQ at all.

USB port
The Universal Serial Bus aims to allow any type of hardware to plug into one plug. The idea is that one day all serial and parallel ports will be scrapped in favor of a single USB socket from which all external peripherals will daisy chain. I will not go into USB here.

IDE ribbon
The IDE ribbon plugs into your hard disk drive or C: drive on Windows/DOS and also into your CD-ROM drive (sometimes called an IDE CD-ROM). The IDE cable actually attaches to its own PCI card internal to the motherboard. There are two IDE connectors that use I/O ports 0xF000-0xF007 and 0xF008-0xF00F, and IRQ 14 and 15, respectively. Most IDE CD-ROMs are also ATAPI CD-ROMs. ATAPI is a standard (similar to SCSI, below) that enables many other kinds of devices to plug into an IDE ribbon cable. You get special floppy drives, tape drives, and other devices that plug into the same ribbon. They will be all called ATAPI-(this or that).

SCSI ribbon
Another ribbon might be present, coming out of a card (called the SCSI host adaptor or SCSI card) or your motherboard. Home PCs will rarely have SCSI, such being expensive and used mostly for high-end servers. SCSI cables are more densely wired than are IDE cables. They also end in a disk drive, tape drive, CD-ROM, or some other device. SCSI cables are not allowed to just-be-plugged-in: they must be connected end on end with the last device connected in a special way called SCSI termination. There are, however, a few SCSI devices that are automatically terminated. More on this on page [*].

3.2 Master/Slave IDE

Two IDE hard drives can be connected to a single IDE ribbon. The ribbon alone has nothing to distinguish which connector is which, so the drive itself has jumper pins on it (see Figure 3.2) that can be set to one of several options. These are one of Master (MA), Slave (SL), Cable Select (CS), or Master-only/Single-Drive/and-like. The MA option means that your drive is the ``first'' drive of two on this IDE ribbon. The SL option means that your drive is the ``second'' drive of two on this IDE ribbon. The CS option means that your machine is to make its own decision (some boxes only work with this setting), and the Master-only option means that there is no second drive on this ribbon.

Figure 3.2: Connection end of a typical IDE drive
\begin{figure}\begin{center}
{\setlength{\epsfxsize}{\textwidth}\epsfbox{harddrive.eps}}\\
\end{center}\end{figure}

There might also be a second IDE ribbon, giving you a total of four possible drives. The first ribbon is known as IDE1 (labeled on your motherboard) or the primary ribbon, and the second is known as IDE2 or the secondary ribbon. Your four drives are then called primary master, primary slave, secondary master, and secondary slave. Their labeling under LINUX is discussed in Section 18.4.

3.3 CMOS

The ``CMOS'' [Stands for Complementary Metal Oxide Semiconductor, which has to do with the technology used to store setup information through power-downs.] is a small application built into ROM. It is also known as the ROM BIOS configuration. You can start it instead of your operating system (OS) by pressing F2 or Delete (or something else) just after you switch your machine on. There will usually be a message Press <key> to enter setup to explain this. Doing so will take you inside the CMOS program where you can change your machine's configuration. CMOS programs are different between motherboard manufacturers.

Inside the CMOS, you can enable or disable built-in devices (like your mouses and serial ports); set your machine's ``hardware clock'' (so that your machine has the correct time and date); and select the boot sequence (whether to load the operating system off the hard drive or CD-ROM--which you will need for installing LINUX from a bootable CD-ROM). Boot means to start up the computer. [The term comes from the lack of resources with which to begin: the operating system is on disk, but you might need the operating system to load from the disk--like trying to lift yourself up from your ``bootstraps.''] You can also configure your hard drive. You should always select Hardrive autodetection [Autodetection refers to a system that, though having incomplete information, configures itself. In this case the CMOS program probes the drive to determine its capacity. Very old CMOS programs required you to enter the drive's details manually.] whenever installing a new machine or adding/removing disks. Different CMOSs will have different procedures, so browse through all the menus to see what your CMOS can do.

The CMOS is important when it comes to configuring certain devices built into the motherboard. Modern CMOSs allow you to set the I/O ports and IRQ numbers that you would like particular devices to use. For instance, you can make your CMOS switch COM1 with COM2 or use a non-standard I/O port for your parallel port. When it comes to getting such devices to work under LINUX, you will often have to power down your machine to see what the CMOS has to say about that device. More on this in Chapter 42.

3.4 Serial Devices

Serial ports facilitate low speed communications over a short distance using simple 8 core (or less) cable. The standards are old and communication is not particularly fault tolerant. There are so many variations on serial communication that it has become somewhat of a black art to get serial devices to work properly. Here I give a short explanation of the protocols, electronics, and hardware. The Serial-HOWTO and Modem-HOWTO documents contain an exhaustive treatment (see Chapter 16).

Some devices that communicate using serial lines are:

  • Ordinary domestic dial-up modems.
  • Some permanent modem-like Internet connections.
  • Mice and other pointing devices.
  • Character text terminals.
  • Printers.
  • Cash registers.
  • Magnetic card readers.
  • Uninterruptible power supply (UPS) units.
  • Embedded microprocessor devices.

A device is connected to your computer by a cable with a 9-pin or 25-pin, male or female connector at each end. These are known as DB-9 (DB9) or DB-25 (DB25) connectors. Only eight of the pins are ever used, however. See Table 3.1.

\begin{table}[H]
\begin{center}
\caption{Pin assignments for DB-9 and DB-25 sock...
...space{1ex}5 & & 7 & & & Signal Ground & \\
\end{tabular}\end{center}\end{table}

The way serial devices communicate is very straightforward: A stream of bytes is sent between the computer and the peripheral by dividing each byte into eight bits. The voltage is toggled on a pin called the TD pin or transmit pin according to whether a bit is 1 or 0. A bit of 1 is indicated by a negative voltage (-15 to -5 volts) and a bit of 0 is indicated by a positive voltage (+5 to +15 volts). The RD pin or receive pin receives bytes in a similar way. The computer and the serial device need to agree on a data rate (also called the serial port speed) so that the toggling and reading of voltage levels is properly synchronized. The speed is usually quoted in bps (bits per second). Table 3.2 shows a list of possible serial port speeds.

\begin{table}[H]
\begin{center}
\caption{Serial port speeds in bps}\begin{tabula...
...000 & 1,500,000 & 4,000,000 \\
\cline{4-4}
\end{tabular}\end{center}\end{table}

A typical mouse communicates between 1,200 and 9,600 bps. Modems communicate at 19,200, 38,400, 57,600, or 115,200 bps. It is rare to find serial ports or peripherals that support the speeds not blocked in Table 3.2.

To further synchronize the peripheral with the computer, an additional start bit proceeds each byte and up to two stop bits follow each byte. There may also be a parity bit which tells whether there is an even or odd number of 1s in the byte (for error checking). In theory, there may be as many as 12 bits sent for each data byte. These additional bits are optional and device specific. Ordinary modems communicate with an 8N1 protocol--8 data bits, No parity bit, and 1 stop bit. A mouse communicates with 8 bits and no start, stop, or parity bits. Some devices only use 7 data bits and hence are limited to send only ASCII data (since ASCII characters range only up to 127).

Some types of devices use two more pins called the request to send (RTS) and clear to send (CTS) pins. Either the computer or the peripheral pull the respective pin to +12 volts to indicate that it is ready to receive data. A further two pins call the DTR (data terminal ready) pin and the DSR (data set ready) pin are sometimes used instead--these work the same way, but just use different pin numbers. In particular, domestic modems make full use of the RTS/CTS pins. This mechanism is called RTS/CTS flow control or hardware flow control. Some simpler devices make no use of flow control at all. Devices that do not use flow control will loose data which is sent without the receiver's readiness.

Some other devices also need to communicate whether they are ready to receive data, but do not have RTS/CTS pins (or DSR/DTR pins) available to them. These emit special control characters, sent amid the data stream, to indicate that flow should halt or restart. This is known as software flow control. Devices that optionally support either type of flow control should always be configured to use hardware flow control. In particular, a modem used with LINUX must have hardware flow control enabled.

Two other pins are the ring indicator (RI) pin and the carrier detect (CD) pin. These are only used by modems to indicate an incoming call and the detection of a peer modem, respectively.

The above pin assignments and protocol (including some hard-core electrical specifications which I have omitted) are known as RS-232. It is implemented using a standard chip called a 16550 UART (Universal Asynchronous Receiver-Transmitter) chip. RS-232 is easily effected by electrical noise, which limits the length and speed at which you can communicate: A half meter cable can carry 115,200 bps without errors, but a 15 meter cable is reliable at no more than 19,200 bps. Other protocols (like RS-423 or RS-422) can go much greater distances and there are converter appliances that give a more advantageous speed/distance tradeoff.

3.5 Modems

Telephone lines, having been designed to carry voice, have peculiar limitations when it comes to transmitting data. It turns out that the best way to send a binary digit over a telephone line is to beep it at the listener using two different pitches: a low pitch for 0 and a high pitch for 1. Figure 3.3 shows this operation schematically.

Figure 3.3: Communication between two remote computers by modem
\begin{figure}\begin{center}
{\setlength{\epsfxsize}{4in}\epsfbox{modem.eps}}\\
\end{center}\end{figure}

Converting voltages to pitches and back again is known as modulation-demodulation and is where the word modem comes from. The word baud means the number of possible pitch switches per second, which is sometimes used interchangeably with bps. There are many newer modulation techniques used to get the most out of a telephone line, so that 57,600 bps modems are now the standard (as of this writing). Modems also do other things to the data besides modulating it: They may pack the data to reduce redundancies (bit compression) and perform error detection and compensation (error correction). Such modem protocols are given names like V.90 (57,600 bps), V.34 (33,600 bps or 28,800 bps), V.42 (14,400 bps) or V.32 (14,400 bps and lower). When two modems connect, they need to negotiate a ``V'' protocol to use. This negotiation is based on their respective capabilities and the current line quality.

A modem can be in one of two states: command mode or connect mode. A modem is connected if it can hear a peer modem's carrier signal over a live telephone call (and is probably transmitting and receiving data in the way explained), otherwise it is in command mode. In command mode the modem does not modulate or transmit data but interprets special text sequences sent to it through the serial line. These text sequences begin with the letters AT and are called ATtention commands. AT commands are sent by your computer to configure your modem for the current telephone line conditions, intended function, and serial port capability--for example, there are commands to: enable automatic answering on ring; set the flow control method; dial a number; and hang up. The sequence of commands used to configure the modem is called the modem initialization string. How to manually issue these commands is discussed in Section 32.6.3, 34.3, and 41.1 and will become relevant when you want to dial your Internet service provider (ISP).

Because each modem brand supports a slightly different set of modem commands, it is worthwhile familiarizing yourself with your modem manual. Most modern modems now support the Hayes command set--a generic set of the most useful modem commands. However, Hayes has a way of enabling hardware flow control that many popular modems do not adhere to. Whenever in this book I give examples of modem initialization, I include a footnote referring to this section. It is usually sufficient to configure your modem to ``factory default settings'', but often a second command is required to enable hardware flow control. There are no initialization strings that work on all modems. The web sites http://www.spy.net/~dustin/modem/ and http://www.teleport.com/~curt/modems.html are useful resources for finding out modem specifications.


next up previous contents
Next: 4. Basic Commands Up: rute Previous: 2. Computing Sub-basics   Contents