CET1172C Lecture #3 - I/O Addresses Lecture

Materials:
Working complete PC
Student bootable floppy diskette - "New Boot A Version 2"
Objectives:
Familiarity with hardware system resources,
Discuss how I/O addresses work,
List the industry standard I/O address assignments,
Be able to discern between 8-bit and 16-bit I/O addresses,
Be able to discern between command and status I/O addresses.
Competency:
The student will become familiar with I/O address system resources. The student will understand the fundamental functionality of this resource and be able to list all industry standard assignments. The student will be able to determine the I/O addresses being used by a device and be able to change these settings when possible in BIOS, DOS, and Windows.
Procedures
  1. The instructor will issue each student a complete system unit, monitor, keyboard, and mouse.

  2. Boot the PC into Windows 98 Normally. Open the Device Manager by right clicking on My Computer > Properties > Device Manager tab. Device Manager is the central location from which to troubleshoot the PCs hardware including installing or reinstalling device drivers, and investigating system resource conflicts. Just as was done in the IRQ's module, in order to view the PCs devices listed by system resource category rather than device type categories, first right click on the Computer Icon and then click properties. A new window appears that provides system resource usage lists.

  3. Click on the I/O Input/Output radio button and the list of devices using I/O addresses will appear. It happens that every single peripheral device that possesses data (input devices), transmits data (output devices) or stores data (storage devices) must have at least one I/O address through which that data can travel. Think of the I/O port like post office boxes. The postal workers in the back are in essence the microprocessor. When the processor has data for you it is placed into your P.O. Box. Eventually you will come around open your box and retrieve the data. If you have data for the microprocessor, you will drop it into the Outgoing Mail box in the lobby. Your personal box is an output I/O address, and the box in the lobby is an input I/O address. The analogy fails here in that each device must have its own specific input and output addresses for the processor to use, there is absolutely no sharing of I/O addresses except in the case of the keyboard and mouse. This is only done because they are so slow that they never actually use the ports simultaneously.

  4. Write down the eight bit I/O addresses. These must have a value smaller than a byte which written in hexadecimal is FFh. The eight bit in and out instructions for the processor to write to or read from these ports are very fast instructions compared to the 16 bit instructions. Write down the 16 bit I/O ports for the devices in the list at the back of this lab module.

  5. Close Device Manager and open Start > Run. In the run box type: MSINFO32 and hit [Enter]. This is an alternative method to executing a program when you know its name but you don’t want to fish around through Window’s endless menus looking for it. It functions very similarly to typing a command’s name and hitting [Enter] at the DOS prompt.

  6. The System Information Program opens. In the left window pane, click the [+] in front of Hardware. The Tree view expands to show its contents. Now click on I/O Ports. Compare the list in the right pane with the values you got from Device Manager. They should agree. If they ever differ, you should expect problems with the device(s) involved. Close MSINFO32.

  7. Under normal circumstances you should not be able to change an I/O address manually because this address functions like a single byte RAM memory cell located on the peripheral component itself. The address is "hardwired" to respond to a specific address location and cannot be changed. Some devices have many addresses in a block for example the floppy drives addresses range from 3F0h to 3F5h. In that case we refer to 3F0h as the base I/O address (or port, notice the two terms are interchangeable). However, many devices have several groups of these memory cells onboard and they allow you to choose which ones to use. This process is exactly what is meant by the term "configuring the device". Almost all devices have a factory preset default I/O address that they will try to use immediately. You should only change the I/O ports if they are flagged by windows as a problem. Most devices have such restrictions on their I/O address choices that this resource is almost never stepped on but when it is the devices will both assuredly fail.

  8. Use either Device Manager, or MSINFO32 to determine the base I/O address of the system speaker. Once you have the address close the program you used to find it and Start > Shutdown > Restart the computer.

  9. At the boot menu choose Command Prompt Only and at the DOS prompt:

    C:\>debug
    -o 61 3  <= (and that’s the letter "o" in front)
    
  10. The reason this must be done from a clean DOS boot is because Windows takes control of the speaker and most other devices and doesn’t appear to return control properly even when you exit Windows.

  11. By the way you should turn that speaker off now:

    C:\>debug
    -o 61 3
    -o 61 0
    
  12. Debug is a powerful tool that allows us among other things to send a specific byte of data to a specific I/O port. We can send a byte to any specific device on the PC including the serial communication ports, the printer port, the hard drive, or in this case the speaker controller circuit. The byte does not go directly to the speaker because it is a single fluctuation of voltage carrying data. The tone from the speaker is an example of an analog signal. It is a fluctuating voltage waveform which the speaker converts directly into sound. This fluctuating signal is being generated by one of the system timers. The speaker control circuit closes the switch for this signal to pass to the speaker when we send 00000011 to it. And it opens (disconnects) the switch when we send it 00000000. Similarly, all of the peripheral devices can be sent instructions to do something through their ports.

  13. Reboot the PC and enter the BIOS Setup program. Open the Integrated peripherals menu and write down the choices presented to you for the COM ports and the printer port. Make a note of the printer port’s current setting which should be 378h. Change it to 3BCh Save and Exit.

  14. Boot to Windows 98 Normally. Use Device Manager to inspect the I/O address of the printer port. Use MSINFO32 to inspect the address of the printer port.

  15. Start > Shutdown > Restart in MS-DOS mode. From the DOS prompt:

    C:\>msd
    
  16. The Microsoft Diagnostic utility will open and announce that it is examining the system:

      File  Utilities  Help

     


    Microsoft (R) Diagnostics
    Version 2.11
    Copyright (C) Microsoft Corporation, 1990-94
    All Rights Reserved

    The Microsoft Diagnostics are designed to assist
    Microsoft Product Support personel in obtaining
    detailed technical information about your computer.

    Thank you for using Microsoft Products.

    MSD is examining your system ...


     

    Once this examination is complete it offers a screen of buttons. Notice that each buttons label has a highlighted red letter. This is that choice’s "hot key" Check the printer port settings and the COM port settings using MSD.

  17. MSD is dangerous to use inside of Windows because Window’s drivers "capture" most of the system resources which MSD checks while examining the system. MSD is equipped with some POST codes and is able to send device resets and then check the device’s responses to these instructions in their input (to the CPU) I/O addresses. Sometimes when you are troubleshooting a resource conflict it is so bad that MSD locks up during the examination. To avoid this you can execute MSD like this:

    C:\>msd /i
    

    The /i apparently means "ignore" the initial examination. MSD can also be used to generate a text report file that contains all of the information that it will display in the various category screens when they are chosen. To create this report file in the root execute it like this:

    C:\>msd /P report.msd
    

    There will be a delay as MSD gathers the information and then writes it out to the file. MSD will generate error messages on screen if it cannot open a file such as SYSTEM.INI because it does not exist, this is not a problem as long as the fact that the file is missing is expected (i.e. a DOS only machine will not have a SYSTEM.INI file). Once complete open the file with EDIT.COM and take a look at what information goes into the report file.

  18. Reboot and enter BIOS Setup. Change the identity of the PCs serial ports, reverse them so that the port that was COM1 is now COM2 and vice versa. Do not confuse printer ports and COM ports with I/O ports. I/O ports should really be referred to as I/O addresses because that is how the processor handles them. Like special RAM memory locations. The COM port has two different meanings. It is the Male DB9 connector on the back of the PC. That is the physical COM port. And it is the controller chip which we will discuss in detail in that lab module. Once reversed, Save and Exit.

  19. Use MSD, then MSINFO32, then Device Manager to identify the I/O addresses of the COM ports. Shutdown properly and change the ports back in the BIOS Setup and reboot to Command Prompt Only.

  20. Run debug and we will use it to display the I/O addresses that BIOS has stored in the BIOS environmental variables area of RAM with this command:

    C:\>debug
    -d 0:400
    0000:0400 F8 03 F8 02 00 00 00 00-78 03 00 00 00 00 00 00 ........x.......
    0000:0410 ...
    
  21. This first line is of the most importance for now. This is a way from the command prompt to ascertain if the ports have been recognized by the BIOS, because BIOS uses this area of RAM to look up the base addresses of the COM ports and the printer ports. Because the Intel processors are little endians the high order byte of a word value is stored behind the low order byte (at the end of the number). So the first two bytes are a word stored at memory location 0000:0400 and represent what the I/O address of the physical Male DB9 connector labeled COM1. But we must reverse the bytes so F8 03 = 03F8 which is what we expect. The next two bytes represent the physical serial port 2 connector on the back of the PC. Reversing the bytes F8 02 = 02F8 again this is what we expect. The next two bytes represent COM3. 00 00 means unrecognized or not installed which is correct. The next two bytes represent COM4. Also not installed. The next two bytes which are located at memory address 0000:0408 hold the I/O address of the first parallel port on the back of the PC: 78 03 = 0378 which is what we expect. The next two words hold the I/O addresses of the next two parallel ports.

  22. There are three different behaviors of I/O addresses. Some are Read Only and function as conduits of information coming from the device into the processor. Some I/O addresses are Write Only and serve as the port through which the processor can transmit information out to the device and some I/O ports support both read and write operations.

  23. The speaker’s port has been used as a port that can be written to in order to send an instruction to the port that will activate the speaker. A program could then delay for a period of time then send the instruction to turn the speaker off effectively sounding a beep. Even the BIOS POST code includes instructions to do this if all devices passed the POST tests. The CMOS RAM itself actually resides within the Real Time Clock circuit. This is not necessarily a physical location but a wiring location like this:

       

    The I/O addresses 70h and 71h are addressable and therefore physically connected to the Address bus and Data bus of the PC and can be accessed by the processor. The CMOS RAM bank has a private address and data bus for reading and writing to and from the CMOS RAM locations that is attached only to the Real Time Clock circuitry which is essentially the same kind of digital clock/calendar chip that resides within the one on your night stand. This chip keeps the time and date even when the PC is off and unplugged by running off of the same CMOS battery that keeps the CMOS RAM from clearing.

  24. To read or write to a particular CMOS address, the address requested must be sent to port 70h. Then the value currently in that CMOS address can be read from port 71h. Writing to any CMOS port is potentially catastrophic since the values held at all of the addresses are added together and stored at certain addresses as well. This is the CMOS checksum. If one address is modified, then the checksum must be recalculated and stored there as well. If this is not done, the POST will check the checksum, see that it is wrong and clear all CMOS then load default values which can severely impair the functioning of the system if a certain device had to be manually configured. There is no backup for these values either.

  25. In debug, type in the following commands: o 70 6[enter] (Next line) i 71[enter]. That is, letter "oh", space, number 70, space, number 6, enter key, letter "i", space, number 71, enter key. This sends the number six to I/O port 70h which indicates to the RTC chip that the value in CMOS RAM address 06h is to be made available at port 71h. In the next command, you will read this value which is then displayed on screen and the dash prompt returns.

  26. So what day of the week is it? This is where the RTC circuitry stores the current day of the week starting with Sunday = 1.

  27. At times the BIOS Setup program on a PC might be password protected but the user does not know the password. Research online as many default BIOS passwords as you can find and record them in your technician’s notebook. Some day one of these might save you from having to perform the next operation on a customer’s PC.

  28. In the event that the BIOS is completely inaccessible due to an unknown password, but the system will still boot up, then run debug and enter the following instructions:

    C:\>debug
    -o 70 17
    -o 71 17
    

    Now reboot. Notice that changes to CMOS take place immediately and the old value is completely lost. That is why the CMOS RAM does not lie within the regular memory address space. It would be far too easy to corrupt, which can render a PC unbootable. Upon reboot the BIOS should complain about a checksum failure and want to reload defaults. Enter BIOS and load defaults, then autodetect the hard drives, set the boot sequence to A:, then C:, then CD-ROM, and disable virus warning. Save and Exit. Notice that this debug trick trashed all of the BIOS settings and if a particular device had been set to some obscure non-standard resource settings it may be impossible to get that device to function properly ever again since the old values were completely lost. This should only be done on systems where there is absolutely no other choice and the customer has been made aware of the potential for leaving the PC or some component in it unusable.

  29. List the following 8 bit I/O address devices:

    Device NameBase I/O Address
    PIC #1 
    PIC #2 
    DMA #1 
    DMA #2 
    Keyboard (Low address) 
    Keyboard (High address) 
    System Timer 
    Speaker 
    FPU 
    RTC 
  30. List the following 16-bit I/O address devices:

    Device NameBase I/O Address
    LPT1 
    LPT2 
    Primary ATA 
    Secondary ATA 
    Game Port 
    COM1 
    COM2 
    COM3 
    COM4 
    LPT1 (of 3) 
  31. List two Windows tools for viewing system resources:


  32. List the DOS program that will display system resources and the syntax to prevent it from examining the system as it opens:


  33. Write out the complete debug operation to "kill CMOS" and thereby deactivate a BIOS Setup password:



  34. What are the three types of I/O port?


  35. What type of an I/O port is 70h?


  36. What type of an I/O port is 71h?


  37. What type of an I/O port is 1F6h?


  38. What is the difference between ports 20h, 60h, and F0h versus ports 170h, 2F8h and 378h?


  39. Which devices are more likely to use the 8 bit I/O ports?


  40. Which devices are more likely to use the 16 bit I/O ports?


  41. Go online and research the standard CMOS RAM offsets and what piece of configuration data each one holds. Run debug on your PC and read and confirm as many values as you can. Record the values as well. Remember to READ not WRITE to the addresses!

Copyright©2000-2004 Brian Robinson ALL RIGHTS RESERVED