Presentation is loading. Please wait.

Presentation is loading. Please wait.

Outline  Examine some of the H/W supplied with a typical PC and consider the software required to control it.  Introduce Commkit, a software tool that.

Similar presentations


Presentation on theme: "Outline  Examine some of the H/W supplied with a typical PC and consider the software required to control it.  Introduce Commkit, a software tool that."— Presentation transcript:

1 Outline  Examine some of the H/W supplied with a typical PC and consider the software required to control it.  Introduce Commkit, a software tool that supports the development of practical data communication software  An example of an application that uses some of the PC’s hardware and Commkit.

2 The 8086 Family and its Hardware  The 8086 is the generic name given to a family of microprocessors developed by Intel 8086 : 80186 : 80286 : segmented memory management, multitasking 80386 : memory management, 32-bit arithmetic 80486 : built-in floating-point hardware Pentium : pipelining

3 8086 Devices  Standard PC configuration generally allows only eight device (clock, keyboard, screen, hard disk, floppy disk, printer, and two serial comm. interfaces).  AT configurations allow a total of 15 devices.  Devices are not accessed directly; instead, processor accesses a device through one or more ports.  All devices are assigned one or more unique port numbers.

4 Ports  Ports can be accessed through software using two “low-level” instructions. - in : allows a port to be read - out : allows a port to be written.  The “high-level” Turbo C counter parts of these instructions are unsigned char inportb (int portid) void outportb (int portid, unsigned char value) void outport (int portid, int value)  Key board buffer (port 0x60) : read  Clock command register (port 0x43) : write  Keyboard status register (port 0x61) : read, write

5 Keyboard  Though 8086 processor uses ASCII character code, PC keyboard does not generate ASCII characters.  Each character on the keyboard is associated with a one-byte scan code.  IBM has defined a scan code for each key. e.g. ESC : scan code 0x01 DEL : scan code 0x53  Scan code must be translated into the character code required by the application. Scan code Scan Code ASC11 0x01. 0x53.. ESC. DEL ASC11APP equivalent Keyboard

6  The processor is signaled twice whenever a key is touched : once when the key is pressed (generating the make scan code), and once when the key is released (generating the break scan code). Make Break  The keyboard can generate 127 different scan codes (1-127)  Scan code 0x00 is reserved to allow the keyboard to expand to more than 127 characters. 1 0 1 0 0 1 1 bit 8 7 6 5 4 3 2 1 0 0x53 1 0 1 0 0 1 11 0xD3 DEL

7  The keyboard software obtains the scan code by reading port 0x60.  It must then signal the keyboard that the character has been read. 1. Read port 0x61 to obtain the keyboard status. 2. Write port 0x61 with the keyboard status OR’ed with 0x80. 3. Write port 0x61 with the original keyboard status.

8  If multiple keys are pressed, the keyboard software must maintain state information about these keys, since the scan codes are supplied to the processor one at a time.  The keyboard software should be able to “remember” whether the CTRL, ALT mode, Left Shift, Right Shift keys have been pressed.  The state of any of these keys can be maintained as a Boolean condition.  Whenever one of these keys is pressed (make), the state becomes TRUE, and when the key is released (break), the state becomes FALSE.  Two mapping tables are required, one for unshifted character and the other for shifted characters.

9 Clock  The clock (or the 8253 timer chip) is used to supply the PC with a regular, periodic clock pulse that can be used to control various actions.  The independent timing channels in 8253 Channel Function 0 System timing and counting 1 Memory Refresh (via DMA controller) 2 PC speaker (for sound effects)  Channel 0 can be used by programs.  Channel 1 must not be changed.

10  Internally, the 8253 has a 1.19318MHz clock.  Most applications do not require this accuracy of timing.  Each channel is associated with a programmable 16-bit counter that can be decremented by the timer chip on each clock pulse.  When the counter reaches 0, the application can be informed.  For example, initialize the counter to 1193, resulting in the counter reaching 0 after approx. one millisecond.

11  The 8253 clock is associated with four ports:  Port 0x40, 0x41, 0x42 are clock counter registers and are used to supply the initial clock values to channels 0, 1 and 2, respectively.  Port 0x43 (the clock command register) allows the programmer to specify how a clock is to be used as well as how it is to be initialized.  0x40 0x41 0x42 clock counter registerclock latch

12 Accessing Devices  Accessing a device before it is ready can result in the duplication of information (e.g. read) or the loss of information (e.g. consecutive write).  To avoid the above problem, most devices are able to signal their status to the processor.  The status of the device can be obtained either by the processor polling the device or by having the device interrupt the processor.

13 Device Polling  The state of a device can be obtained by reading one or more ports associated with the device.  Software for device polling is typically written as a loop for ( ; ; ) { if (device 1_ready ( ) ) service_device_1 ( ); if (device 2_ready ( ) ) service_device_2 ( ); }  Two drawbacks 1. Processor performs no useful function other than polling. 2. If a device generates data faster than it takes the processor to execute the polling loop, data can be lost.

14 Interrupts  Interrupt is a mechanism to signal the processor when a device needs to be serviced or has information to supply to the processor.  When a device interrupts the processor: 1. The task currently being run is suspended while the processor handles the interrupt. 2. An interrupt handler (or interrupt service routine) is activated. 3. The suspended task is resumed once the interrupt handler is finished.

15  Each device is associated with a unique interrupt number.  This number is used as an index into the list of interrupt vectors stored in segment 0. Interrupt Number Interrupt Device Vector location 0x08 0x20---0x23 Clock 0x09 0x24—0x27 Keyboard 0x0A 0x28—0x2B From slave 8259 0x0B 0x2C—0x2F Serial Port 0x0C 0x30—0x33 Serial Port 0x0D 0x34—0x37 Hard disk 0x0E 0x38—0x38 Floppy disk 0x0F 0x3C---0x3F Printer

16  Only a single interrupt line connects the processor to the outside world.  Intel 8259 Interrupt Controller has been designed to share the single interrupt line between eight devices.  A device first signals the 8259, which then interrupts the 8086 processor.  The processor determines which device is interrupting by obtaining the device’s number from the 8259.  The device number is used to access the list of interrupt vectors that indicates which interrupt handler should be activated. Device 0 Device 1 Device 7...... 8259 Master 8086 Processor 8259 (Slave)

17  Programmer can select the devices that are to interrupt the 8086 processor by writing a 1-byte interrupt mask to the 8259. Clock Keyboard Slave 8259 Serial port Hard disk Floppy disk Printer

18  8259 Interrupt mask is accessed through port 0x21, the interrupt mask register. # define INT_MASK 0x21 # define CLKENA 0xFE # define KEYENA 0xFD # define PRTENA 0x7F outportb (INT_MASK, CLKENA & KEYENA & PRATNA) 0 1 1 1 1 1 0 0

19  If several devices interrupt simultaneously, the 8259 signals the processor with the highest-priority interrupt. All other devices with lower-priority interrupts are kept waiting.  Once the interrupt has been serviced, the 8259 must be informed so that any pending (or subsequent) interrupts can be signaled.  This is done by writing EOI (End of Interrupt 0x20) to the 8259 operation command word register (port number 0x20).


Download ppt "Outline  Examine some of the H/W supplied with a typical PC and consider the software required to control it.  Introduce Commkit, a software tool that."

Similar presentations


Ads by Google