IBM CMX58886CX Intel 8259 Programmable Interrupt Controller, PCI Interrupts, Sample Code

Page 85

Intel 8259 Programmable Interrupt Controller

The chip responsible for handling interrupt requests in the PC is the Intel 8259 Programmable Interrupt Controller. To use interrupts, you need to know how to read and set the Intel 8259’s interrupt mask register (IMR) and how to send the end-of-interrupt (EOI) command to the Intel 8259.

Each bit in the IMR contains the mask status of an IRQ line; bit 0 is for IRQ0, bit 1 is for IRQ1, and so on. If a bit is set (1), then the corresponding IRQ is masked and will not generate an interrupt. If a bit is clear (0), then the corresponding IRQ is unmasked and can generate interrupts. The IMR is programmed through port 21h.

Note When in APIC mode, the PIC is programmed differently, and IRQ routing behaves differently. For more information, refer to the APIC datasheets and specifications provided by Intel.

PCI Interrupts

PCI devices can share interrupts. The BIOS or operating system may assign multiple PCI devices to the same IRQ line. Any interrupt service routine (ISR) written for PCI devices must be able to handle shared interrupts. Refer to Interrupt-Driven PC System Design (ISBN: 0-929392-50-7) for more information on PCI interrupts.

Writing an Interrupt Service Routine (ISR)

The first step in adding interrupts to your software is to write the ISR. This is the routine that will automatically be executed each time an interrupt request occurs on the specified IRQ. An ISR is different than standard routines that you write. First, on entrance, the processor registers should be pushed onto the stack BEFORE you do anything else. Second, just before exiting your ISR, you must clear the interrupt status flag and write an end-of-interrupt command to the Intel 8259 controller. Finally, when exiting the ISR, in addition to popping all the registers you pushed on entrance, you must use the IRET instruction and not a plain RET. The IRET automatically pops the flags, CS, and IP that were pushed when the interrupt was called.

Most C compilers allow you to identify a procedure (function) as an interrupt type and will automatically add these instructions to your ISR, with one important exception: most compilers do not automatically add the end-of-interrupt command to the procedure; you must do this yourself. Other than this and the few exceptions discussed below, you can write your ISR just like any other routine. It can call other functions and procedures in your program and it can access global data. If you are writing your first ISR, RTD recommends focusing on the basics, such as incrementing a global variable.

Most operating systems have restrictions on what instructions can be called in your ISR. Consult your OS documentation for details on writing your ISR.

Note A complete explanation of interrupt programming is beyond the scope of this manual. For more information on interrupts, refer to the Appendix.

Sample Code

RTD’s drivers provide examples of ISR’s and interrupt handling. Refer to them as working examples. These drivers were shipped with your cpuModule, but they they can also be downloaded from RTD’s website (www.rtd.com)..

BDM-610000050 Rev A

Chapter 4: Using the cpuModule 77

Image 85
Contents BDM-610000050 Revision a CMX58886CX cpuModulesRevision Date Reason for Change 06/30/06 Initial release Revision HistoryCMX58886CX cpuModules Iv CMX58886CX cpuModule Table of Contents Audio CN11 MultiPort CN6Memory Map Address Map BDM-610000050 Rev a Vii Application Notes System RecoveryChapter CMX58886CX cpuModule top view CMX58886CX cpuModulesThermal Monitor and Thermal Throttling Error-Correction CodesADIO with Wake-on-aDIO Ordering Information Cable Kits and AccessoriesCMX58886CX Model Options CMX58886CX cpuModule Model OptionsBoard Features VGA, SVGA, XGA, SXGA, Uxga Bios CMX58886CX cpuModule Simplified Block Diagram Block DiagramPhysical Characteristics SpecificationsPower Consumption Operating ConditionsElectrical Characteristics Electrical CharacteristicsSymbol Parameter Test Condition Min Max Ioc12 CMX58886CX cpuModule Contact Information 14 CMX58886CX cpuModule Getting Started CMX58886CX Connector Locations Connector LocationsCMX58886CX Basic Connectors Connecting a Keyboard Connecting the Utility CableConnecting to the PC/104-PlusPCI Bus PCI Bus Expansion Card Power Slot Selection SwitchesPCI Bus Signaling Levels Booting the CMX58886CX cpuModule for the First Time Connecting the cpuModule 22 CMX58886CX cpuModule Fan Power +5 Pin Auxiliary Power Connector CN31 Auxiliary Power CN3Pin Signal Function Reserved Power Supply Protection+3.3 +12 Utility Port Connector CN5 Utility Port Connector CN5Pin Signal Function In/Out SpeakerSoft Power Button System ResetKeyboard MouseBattery Svga Video Connector CN18 Svga Video Connector CN18Resolution Colors Refresh Rates Svga Video ResolutionsFlat Panel Video Connector CN19 Lvds Flat Panel Video Connector CN19Manufacturer Model Number Resolution Color Depth Tested Lvds PanelsEide Connector CN101 Eide Connector CN10Pin Signal ATA/IDE Disk Chip Socket U161 ATA/IDE Disk Chip Socket U16Serial Port Settings RS-232 Serial Port DefaultSerial Port in RS-232 Mode Serial Port 1 CN7 and Serial Port 2 CN8RS-422 or RS-485 Serial Port Half-Duplex RS-485 ModeFull-Duplex Connections PortPin Signal Function In/Out DB-9 Serial Port in RS-422/485 ModeMultiPort CN6 MultiPort Configured as an Advanced Digital I/O aDIO PortMultiPort aDIO Pinout CN6 Pin FunctionMultiPort Connector CN6 as a Parallel Port MultiPort Configured as a Parallel PortCN6 Pin Signal Function In/Out DB-25 MultiPort Connector Floppy Pinout CN61 MultiPort Configured as a Floppy Drive ControllerCN6 Pin Function DB-25 Floppy Drive Pin USB Connector CN17 USB 2.0 Connector CN17Ethernet Connector CN20 Ethernet 10/100Base-T and -TX Connector CN20RJ-45 Pin Pin DIL Pin Signal Function In/Out Pin DIL Pin Signal Function In/Out Audio Connector CN11Audio CN11 PC/104-PlusPCI Bus CN16 PC/104-PlusBus Signal Assignments1Pin Address and Data PC/104-PlusPCI Bus SignalsPower Supplies and VIO Bridge Link CN4 Bridge Link CN4Optional RTC Battery Input CN13 External Power Management CN12Fan Power, +5 V CN14 Fan Power, Switched CN15 Fan Power, Switched CN15Using the cpuModule Configuring the RTD Enhanced AMI Bios RTD Enhanced AMI BiosEntering the Bios Setup Setup KeysPower On Self Test Post Codes Main Menu Setup FieldsMain Menu Setup Fields Field Active Keys SelectionsBooting to Boot Block Flash with Fail Safe Boot ROM First Megabyte Memory Map Memory MapAddress hex Description O Addresses Reserved for the CMX58886CX cpuModule Address MapAddress Range hex Bytes Device Hardware Interrupts Interrupt Normal Use TimerHardware Interrupts Used on the CMX58886CX cpuModule Digital I/O Register Set MultiPort Advanced Digital I/O Ports aDIOPort 0 Data I/O Address 450h Port 1 Data I/O Address 451hDIO-Control I/O Address 453h-Write Access DIO-Control I/O Address 453h-Read AccessMulti-Function at Address 452h1 Interrupts =Interrupt is enabledWake Control I/O Address 451h =Interrupt triggers a Wake EventWake-on-aDIO WakeEnable Int Mask FunctionInterrupt and Wake Event Generation MultiPort Floppy Drive MultiPort Parallel Port ControlAC’97 Audio Ethernet 10/100Base-T and -TXCable Modes IDE Controller ConfigurationCable Detection Configuring the ATA/IDE Disk Chip Socket Legacy Mode and Native Mode IDEReal Time Clock Registers Real Time Clock ControlRegisters Number Function Wake Control I/O Address 455h Watchdog Timer ControlFurther Temperature Reduction Fan ModeThermal Management Advanced Power Management APM Power ManagementAdvanced Configuration and Power Interface Acpi Power Button ModesATX Power Supply Signals AT vs. ATX Power SuppliesReducing Power Consumption LED Colors Multi-Color LEDMulti-Color LED I/O Address 456h Manual LED Colors70 CMX58886CX cpuModule Reset Status I/O Address 457h Read Access Reset Status RegisterReset Status I/O Address 457h Write Access Address Reset Description Reset Status Description and PrioritesUser Eeprom Bit Signal Function Read / WriteUser Eeprom I/O Address 456h Eeprom Register DescriptionFeatures and Settings That Can Affect Boot Time Loading Default Bios Settings System RecoveryBooting to the Fail Safe Boot ROM Fsbr Basic Interrupt Information for Programmers What happens when an interrupt occurs?How long does it take to respond to an interrupt? Interrupt Request LinesIntel 8259 Programmable Interrupt Controller Writing an Interrupt Service Routine ISRPCI Interrupts Sample Code78 CMX58886CX cpuModule Appendix a Hardware Reference Jumper Settings and Locations Pins 1-2 +5 Pins 2-3 +3.3 Jumper Pins Function DefaultPins 1-2 +3.3 Pins 2-3 +5 Pins 1-2 +12 Pins 2-3 +5CMX58886CX Solder Blobs Solder Positions Function Default BlobPositions 1-2 +5 Positions 2-3 +3.3 Onboard PCI Devices Onboard PCI DevicesDevice ID Vendor ID Description CMX58886CX Physical Dimensions ±0.005 inches Physical DimensionsAppendix B Troubleshooting Troubleshooting Common Problems and SolutionsProblem Cause Solution Troubleshooting cont’d Troubleshooting a PC/104-PlusSystemHow to Obtain Technical Support Appendix C Idan Dimensions and Pinout IDAN-CMX58886CX Connectors Idan Dimensions and ConnectorsKeyboard 6-Pin mini-DIN Connector female PS/2 Mouse 6-Pin mini-DIN Connector femaleIdan Pin # Signal Function External I/O ConnectionsCOM1/COM2 RS-422/485 9-Pin D Connector male COM1/COM2 RS-232 9-Pin D Connector maleIdan Pin # Signal Function Mode Idan Pin # ADIO Port Parallel Port Floppy Port CPU Pin # MultiPort 25-Pin D Connector femaleIdan Pin # Signal Name CPU Pin # Panel 25-Pin mini D Connector femaleIdan Pin # Signal Function CPU Pin # Svga 15-Pin High Density D Connector femaleEthernet 9-Pin D Connector female USB 9-Pin D Connector maleIdan Pin # 10Base-T Signal CPU Pin # Idan Pin # Signal CPU Pin # Audio 9-Pin D Connector female98 CMX58886CX cpuModule Application Notes PC/104 and PC/104-PlusSpecificationsDrivers and Example Programs Interrupt Programming100 CMX58886CX cpuModule Appendix E Limited Warranty 102 CMX58886CX cpuModule