Lecture 4_5 - IR- Shlomo
Lecture 4_5 - IR- Shlomo
381-1-0103
1
Lecture 5 – Interrupts
Shlomo Greenberg
no
Interrupt Sequence
13
CPU
Internal (Pre-defined)
30
Interrupts
Pre-defined interrupts reserved by the manufacturer
E.g. (In Intel):
INT0 – division by 0
INT1 – Single Step TF
INT2 – Non-maskable interrupt
INT3 – Breakpoint trap
INT4 – Overflow trap
INT5 .. INT31 – Reserved by Intel
OS-s such as Linux are free to use the remaining
available interrupt ID numbers for their own
purposes (e.g., for service-requests from external
devices, or for other purposes such as system-calls)
31 Interrupt Priority
Interrupt Priority
32
The most common method. Less lines than the previous scheme
The interrupt request line INTR_B is common to all devices.
However, the interrupt acknowledge line (INTA) is connected in a
daisy chain fashion. When one or more devices issue an interrupt
request, the INTR_B line is activated. The CPU responds, after
some delay, by setting the INTA line to 1. The signal is received by
device 1. Device 1 passes the signal on to the next device only if it
does not require any service. If device 1 has a pending request for
an interrupt, it blocks the acknowledgement signal INTA and
proceeds to put its interrupt vector (IRQ#) on the data lines.
The device that is electrically closest to the CPU is having the
highest priority
Arrangement of Priority
35
groups
Combination of the previous 2 schemes
Additional Flexibility
Complex control circuity in the device
(CPU) interface
Selective Interrupt Masking
36
INTA:
Mask points
255
APIC (LAPIC, IO-APIC)
Advanced PIC (APIC) is used in SMP
systems
Used in all modern systems
Interrupts “routed” to CPU over system
bus
IPI: inter-processor interrupt
Local APIC (LAPIC) versus “frontend”
IO-APIC
Devices connect to front-end IO-APIC
IO-APIC communicates (over bus) with
Local APIC
Interrupt Routing
Allows broadcast or selective routing
of interrupts
Ability to distribute interrupt
handling load
Routes to lowest priority process
priority
Multiple Logical Processors
Multi-CORE CPU
CPU CPU
0 1 I/O
APIC
LOCAL LOCAL
APIC APIC
(The legacy PICs are masked when the APICs are enabled)
Assigning IRQs to Devices
IRQ assignment is hardware-dependent
Sometimes it’s hardwired, sometimes it’s set
physically, sometimes it’s programmable
Some IRQs are fixed by the architecture
IRQ0: Interval timer
IRQ2: Cascade pin for 8259A
Note: especially useful for dynamically-loaded
drivers, such as for USB or PCMCIA devices
Two devices that aren’t used at the same time
can share an IRQ, even if the hardware
doesn’t support simultaneous sharing
Interrupt Masking
Two different types: global and per-IRQ
Global — delays all interrupts
Selective — individual IRQs can be masked
selectively
Selective masking is usually what’s
needed — interference most common
from two interrupts of the same type
Interrupt Priority
48
Fixed/Rotating priority
Fixed: INT0 is highest priority, INTn is lowest priority.
Only an interrupt with a higher priority than the
one that is currently being served can interrupt.
Dependent on masking
Rotating: FIFO, first coming priority is served first,
last coming priority is served last
SW interrupt has always lower priority than HW
interrupt, because SW interrupt is part of the
program and interrupt will be called only when
reaching that point in the program.
SW interrupt is just like any other program
command
49
Intel 8259A Interrupt
Controller
8259A Programmable
50
Interrupt Controller (PIC)
The 8259A is a programmable interrupt controller designed to
work with Intel microprocessor 8080 A, 8085, 8086, 8088. The
8259 A interrupt controller can:
Handle eight interrupt inputs. This is equivalent to providing eight
interrupt pins on the processor in place of one INTR/INTA pin.
Vector an interrupt request anywhere in the memory map.
However, all the eight interrupt are spaced at the interval of either
four or eight location. This eliminates the major drawback, 8085
interrupt, in which all interrupts are vectored to memory location
on page 00H.
Resolve eight levels of interrupt priorities in a variety of modes.
Mask each interrupt request individually.
Read the status of pending interrupts, in service interrupts, and
masked interrupts.
Be set up to accept either the level triggered or edge triggered
interrupt request.
Mine 8259 as can be cascade in a master slave configuration to
handle 64 interrupt inputs.
8259A pin diagram
51
INTA
8259A INTR
CPU
8259A PIC
PIC (master)
(slave)
Programming is via
I/O-ports 0x20-0x21
Programming is via
I/O-ports 0xA0-0xA1
Three internal registers
input-signals
8259A
output-signal
IRR
IMR
input-signal
ISR
Interrupt controller
Extension to 64 interrupts
using cascade architecture
58
– Cont.
Slave is responsible for TYPE
INTA is connected to all cascaded devices (slaves)
Master knows which interrupt was delivered to
CPU
CAS bus: from master to all slaves
If an interrupt controller is connected as slave, it
has to pass TYPE to master
else the master has to pass the TYPE
Only the device which its number is coded using
CAS bus will assert TYPE on the data bus
Each controller has a control register which stores
whether the controller is master or slave
8259A - Operation
59
“Real”
Interrupt in
priority 7
Dummy Interrupt – Cont.
75