CS452 - Real-Time Programming - Spring 2009
Lecture 13 - Interrupts
Practical Detail
Interrupts
General
Interrupt input (hardware) asserted
First instruction of interrupt handler put into pipeline
- Change processor mode to int
- Put next instruction address of interrupted task into lr_irq
- Put CPSR of interrupted task into spsr_irq
- New CPSR has interrupts disabled, mode changed
- Set pc to 0x18
Similar procedure for fast interrupt
- Extra duplicated registers: r8-r14
- Mode is fiq
- pc is set to 0x1c
- FIQ has higher priority
Many sources for interrupts
- How do you find out which one has been asserted?
- How do turn off the interrupt?
- at the CPU
- in the interrupt controller
- in the device
And in what order?
ARM Specific
Two controllers, nested
- VICINTSOURCE[0-31] to primary
- VICINTSOURCE[32-63] to secondary
- You care about
- VICINTSOURCE4: timer counter 1
- VICINTSOURCE5: timer counter 2
- VICINTSOURCE[23,24]: UART1 [receive, transmit]
- VICINTSOURCE[25,26]: UART2 [receive, transmit]
- VICINTSOURCE36: watchdog timer
- VICINTSOURCE51: timer counter 3
- VICINTSOURCE52: UART1 general
- VICINTSOURCE54: UART2 general
Registers at
- primary: 0x800b0000
- secondary: 0x800c0000
47 registers per controller
- 11: chip control
- 16: vector addresses
- 16: vector control
- 4: chip id
Priority
- FIQ-configured interrupts (not vectored)
- IRQ-configured vecored interrupts
- IRQ-configured non-vectored interrupts
Low-level primitive
This is what everything depends on
int AwaitEvent( int EventType );
What does it do?
- Blocks on an interrupt of the type specified
- When the interrupt occurs, may return one word of volatile data
Implementation notes
- Event may already have occurred
- AwaitEvent( ) can service the device.
- Then it must return the volatile data
- Need to think of priorities when you partition the work
- Kernel has interrupts turned off
- Therefore need
IdleTask( ). Why?
How is it used?
Example: Clock Server
Provides a sleep prinitive
int Delay( int interval )
- block and return later
- Send to a server which
- maintains an ordered list of sleepers
- receives clock ticks
- on each tick checks the list and replies to each sleeper who is
ready to wake up
- Server must receive clock ticks
What does the kernel do?
Software
- gets volatile data from device
- turns off source of interrupt
- device
- interrupt controller
- finds task waiting on the interrupt
- makes it ready
later
- enables interrupts in CPU
Return to: