Unformatted text preview:

Exceptions, Interrupts, and the OSSlide 2Slide 3Slide 4Slide 5Slide 6Slide 7HC11 ExceptionsSlide 9Slide 10Slide 11LC-3 ExceptionsLC-3 Interrupt-Driven I/OLC-3 Interrupt-Driven I/OPriorityTesting for Interrupt SignalFull Implementation of LC-3 Memory-Mapped I/OSlide 18Processor StateWhere to Save Processor State?Operating SystemsSlide 22Slide 23Slide 24Slide 25Slide 26Slide 27Slide 28Slide 29Slide 30Slide 31Questions?Slide 331Exceptions, Interrupts, and Exceptions, Interrupts, and the OS the OS STOP!! Do this!!!STOP!! Do this!!!2Interrupts Interrupts •Have device tell OS/CPU it is readyHave device tell OS/CPU it is ready•Requires hardware to support.Requires hardware to support.•OS/CPU can then interrupt what it is OS/CPU can then interrupt what it is doing to:doing to:•Determine what device wants Determine what device wants serviceservice•Determine what service it wantsDetermine what service it wants•Perform or start the servicePerform or start the service•Go back to what OS/CPU was doingGo back to what OS/CPU was doing““External condition related to IO devices”External condition related to IO devices”3Interrupts Interrupts Examples of InterruptsExamples of Interrupts• Disk drive at sector/track position Disk drive at sector/track position (old days)(old days)• Mouse movedMouse moved• Keyboard key pressedKeyboard key pressed• Printer out of paperPrinter out of paper• Video card wants memory accessVideo card wants memory access• Modem sending or receivingModem sending or receiving• USB scanner has dataUSB scanner has data4Interrupts Interrupts Interrupt PropertiesInterrupt Properties•They arrive asynchronouslyThey arrive asynchronously•Can’t communicate with a running Can’t communicate with a running program (no args or return values)program (no args or return values)•They are associated with various They are associated with various prioritiespriorities•You want to handle them soon You want to handle them soon (interrupt latency)(interrupt latency)•(usually) want to resume program(usually) want to resume program5TrapTrap““Internal conditions related to instruction Internal conditions related to instruction stream”stream”Trap Examples:Trap Examples:• “ “TRAP” instructionTRAP” instruction• Illegal instructionIllegal instruction• Arithmetic overflowArithmetic overflow• Divide by zeroDivide by zero• “ “LD” from illegal/protected memory LD” from illegal/protected memory addressaddress6• They arrive synchronouslyThey arrive synchronously• Get trap in same place if you re-run programGet trap in same place if you re-run program• They are associated with various prioritiesThey are associated with various priorities• Must handle immediatelyMust handle immediately• Want to resume program Want to resume program (usually) (usually) Trap PropertiesTrap Properties7Exceptions Exceptions ““Mechanism used to handle both interruptsMechanism used to handle both interruptsand traps”and traps”•HW handles initial reactionHW handles initial reaction•Then invokes SW called an “Exception Then invokes SW called an “Exception Handler” to take care of the interrupt/trapHandler” to take care of the interrupt/trap8HC11 ExceptionsHC11 Exceptions•HC11 is real hardware and thus has HC11 is real hardware and thus has mechanisms to deal with both Traps and mechanisms to deal with both Traps and Interrupts.Interrupts.•We will deal with interrupts only.We will deal with interrupts only.•HC11 does things very similar to the LC-3.HC11 does things very similar to the LC-3.•Uses an “Interrupt Vector” table to find Uses an “Interrupt Vector” table to find address of interrupt and goes straight to address of interrupt and goes straight to specific specific Interrupt Service RoutineInterrupt Service Routine (ISR). (ISR).9HC11 Micro Kit Jump TableHC11 Micro Kit Jump Table //// 1 1unavailable to userunavailable to userSCISCIISR_JUMP2ISR_JUMP2EQUEQU0x7BC50x7BC5//SPI//SPIISR_JUMP3ISR_JUMP3EQUEQU0x7BC80x7BC8// Pulse Accumulator Input// Pulse Accumulator InputISR_JUMP4ISR_JUMP4EQUEQU0x7BCB0x7BCB// Pulse Accumulator Overflow// Pulse Accumulator Overflow//// 5 5unavailable to userunavailable to userTimer OverflowTimer Overflow//// 6 6unavailable to userunavailable to userOutput Compare 5Output Compare 5ISR_JUMP7ISR_JUMP7EQUEQU0x7BD40x7BD4// Output Compare 4// Output Compare 4ISR_JUMP8ISR_JUMP8EQUEQU0x7BD70x7BD7// Output Compare 3// Output Compare 3ISR_JUMP9ISR_JUMP9EQUEQU0x7BDA0x7BDA// Output Compare 2// Output Compare 2ISR_JUMP10ISR_JUMP10EQUEQU0x7BDE0x7BDE// Output Compare 1// Output Compare 1ISR_JUMP11ISR_JUMP11EQUEQU0x7BE30x7BE3// Input Capture 3// Input Capture 3ISR_JUMP12ISR_JUMP12EQUEQU0x7BE60x7BE6// Input Capture 2// Input Capture 2ISR_JUMP13ISR_JUMP13EQUEQU0x7BE90x7BE9// Input Capture 1// Input Capture 1//// 14 14unavailable to userunavailable to userReal Time InterruptReal Time InterruptISR_JUMP15ISR_JUMP15EQUEQU0x7BEC0x7BEC// IRQ – Button on Kit// IRQ – Button on Kit//// 16 16unavailable to userunavailable to userXIRQXIRQ//// 17 17unavailable to userunavailable to userSWISWI//// 18 18unavailable to userunavailable to userIllegal OpcodeIllegal OpcodeISR_JUMP19ISR_JUMP19EQUEQU0x7BF80x7BF8// Cop fail// Cop failISR_JUMP20ISR_JUMP20EQUEQU0x7BFB0x7BFB// Cop clock fail// Cop clock fail//// 21 21unavailable to userunavailable to userReset (found at 0x8040)Reset (found at 0x8040)See Motorola documentation for discussion of unavailable See Motorola documentation for discussion of unavailable vectorsvectors. . HC11 ExceptionsHC11 Exceptions10Configuring interrupts for the HC11 is pretty easy.Configuring interrupts for the HC11 is pretty easy.What you need to do is:What you need to do is:1) Make an ISR, it is just like a procedure but returns with RTI.1) Make an ISR, it is just like a procedure but returns with RTI.2) Put the address of the ISR into the Jump Table.2) Put the address of the ISR into the Jump Table.Example:Example:// initializes the ISR jump vectors to our interrupt service routines// initializes the ISR jump vectors to our interrupt service routines// jump vectors are defined in v2_18g3.asm// jump vectors are defined in v2_18g3.asmldx #BUTTON_isrldx #BUTTON_isrstx ISR_JUMP15stx ISR_JUMP15BUTTON_isr:BUTTON_isr:// Put your code in here. Do not do any I/O in an ISR// Put your code in here. Do not do any I/O in an ISR……// Use this to return from an interrupt//


View Full Document

UCSC CMPE 012 - Exceptions, Interrupts and the OS

Download Exceptions, Interrupts and the OS
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Exceptions, Interrupts and the OS and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Exceptions, Interrupts and the OS 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?