Exceptions and Interrupts 2

Slides:



Advertisements
Similar presentations
Chapter 3 Basic Input/Output
Advertisements

More on Processes Chapter 3. Process image _the physical representation of a process in the OS _an address space consisting of code, data and stack segments.
Interrupts Chapter 8 – pp Chapter 10 – pp Appendix A – pp 537 &
9/20/6Lecture 3 - Instruction Set - Al1 Exception Handling (2)
1/1/ / faculty of Electrical Engineering eindhoven university of technology Architectures of Digital Information Systems Part 1: Interrupts and DMA dr.ir.
9/20/6Lecture 3 - Instruction Set - Al1 The Hardware Interface.
1/1/ / faculty of Electrical Engineering eindhoven university of technology Introduction Part 3: Input/output and co-processors dr.ir. A.C. Verschueren.
68HC11 Polling and Interrupts
ECE 372 – Microcontroller Design Parallel IO Ports - Interrupts
Architecture of the 680XX Outline Goal Reading 680XX Family
Interrupts What is an interrupt? What does an interrupt do to the “flow of control” Interrupts used to overlap computation & I/O – Examples would be console.
COMP3221: Microprocessors and Embedded Systems Lecture 15: Interrupts I Lecturer: Hui Wu Session 1, 2005.
Architectural Support for OS March 29, 2000 Instructor: Gary Kimura Slides courtesy of Hank Levy.
Exception Processing ECE511: Digital System & Microprocessor.
7/23 Coldfire Exceptions and Interrupts Computer Science & Engineering Department Arizona State University Tempe, AZ Dr. Yann-Hang Lee
OS Spring’03 Introduction Operating Systems Spring 2003.
Computer System Organization S H Srinivasan
Midterm Tuesday October 23 Covers Chapters 3 through 6 - Buses, Clocks, Timing, Edge Triggering, Level Triggering - Cache Memory Systems - Internal Memory.
Computer System Structures memory memory controller disk controller disk controller printer controller printer controller tape-drive controller tape-drive.
1 Interrupts INPUT/OUTPUT ORGANIZATION: Interrupts CS 147 JOKO SUTOMO.
680XX Hardware Interface Outline Goal Reading
INPUT/OUTPUT ORGANIZATION INTERRUPTS CS147 Summer 2001 Professor: Sin-Min Lee Presented by: Jing Chen.
Midterm Wednesday 11/19 Overview: 25% First Midterm material - Number/character representation and conversion, number arithmetic - DeMorgan’s Law, Combinational.
COMPUTER SYSTEMS An Integrated Approach to Architecture and Operating Systems Chapter 4 Processor Implementation ©Copyright 2008 Umakishore Ramachandran.
What are Exception and Interrupts? MIPS terminology Exception: any unexpected change in the internal control flow – Invoking an operating system service.
Interrupts. 2 Definition: An electrical signal sent to the CPU (at any time) to alert it to the occurrence of some event that needs its attention Purpose:
Exception and Interrupt Handling
Introduction to Embedded Systems
COMP201 Computer Systems Exceptions and Interrupts.
Interrupts. What Are Interrupts? Interrupts alter a program’s flow of control  Behavior is similar to a procedure call »Some significant differences.
MICROPROCESSOR INPUT/OUTPUT
Three fundamental concepts in computer security: Reference Monitors: An access control concept that refers to an abstract machine that mediates all accesses.
1 CSE Department MAITSandeep Tayal Computer-System Structures Computer System Operation I/O Structure Storage Structure Storage Hierarchy Hardware Protection.
2: Computer-System Structures
Khaled A. Al-Utaibi  Interrupt-Driven I/O  Hardware Interrupts  Responding to Hardware Interrupts  INTR and NMI  Computing the.
Interrupts and reset operations. Overview  Introduction to interrupts – What are they – How are they used  68HC11 interrupt mechanisms – Types of interrupts.
13-Nov-15 (1) CSC Computer Organization Lecture 7: Input/Output Organization.
CSNB374: Microprocessor Systems Chapter 5: Procedures and Interrupts.
Interrupt driven I/O. MIPS RISC Exception Mechanism The processor operates in The processor operates in user mode user mode kernel mode kernel mode Access.
1 Interrupts, Resets Today: First Hour: Interrupts –Section 5.2 of Huang’s Textbook –In-class Activity #1 Second Hour: More Interrupts Section 5.2 of Huang’s.
AT91 Interrupt Handling. 2 Stops the execution of main software Redirects the program flow, based on an event, to execute a different software subroutine.
CE Operating Systems Lecture 2 Low level hardware support for operating systems.
Operating Systems 1 K. Salah Module 1.2: Fundamental Concepts Interrupts System Calls.
1 CS.217 Operating System By Ajarn..Sutapart Sappajak,METC,MSIT Chapter 2 Computer-System Structures Slide 1 Chapter 2 Computer-System Structures.
CE Operating Systems Lecture 2 Low level hardware support for operating systems.
Interrupt driven I/O Computer Organization and Assembly Language: Module 12.
بسم الله الرحمن الرحيم MEMORY AND I/O.
9/20/6Lecture 3 - Instruction Set - Al1 Exception Handling.
Interrupts and Exception Handling. Execution We are quite aware of the Fetch, Execute process of the control unit of the CPU –Fetch and instruction as.
Introduction to Exceptions 1 Introduction to Exceptions ARM Advanced RISC Machines.
Embedded Real-Time Systems Processing interrupts Lecturer Department University.
Architectures of Digital Information Systems Part 1: Interrupts and DMA dr.ir. A.C. Verschueren Eindhoven University of Technology Section of Digital.
An Interrupt is either a Hardware generated CALL (externally derived from a hardware signal) OR A Software-generated CALL (internally derived from.
Interrupts and exceptions
MICROPROCESSOR BASED SYSTEM DESIGN
68HC11 Interrupts & Resets.
Microprocessor Systems Design I
Timer and Interrupts.
Interrupts In 8085 and 8086.
Module 2: Computer-System Structures
COMPUTER PERIPHERALS AND INTERFACES
Architectural Support for OS
Module 2: Computer-System Structures
Interrupt handling Explain how interrupts are used to obtain processor time and how processing of interrupted jobs may later be resumed, (typical.
Basic Instruction Cycle
Lecture 3 - Instruction Set - Al
Architectural Support for OS
Module 2: Computer-System Structures
COMP3221: Microprocessors and Embedded Systems
Module 2: Computer-System Structures
Presentation transcript:

Exceptions and Interrupts 2 Outline Exception Vectors and Vector Table Exception Processing Exception Priority Hardware Exceptions Software Exceptions Real-Time Processing Goal Understand exception vectors Understand exception processing Understand details of major exceptions Reading Microprocessor Systems Design, Clements, Ch. 6

Exception Vectors and Vector Table 32-bit absolute address of exception-handling routine Exception vector table vectors stored in table of 256 longwords starting at $000000 in 68000 Each vector has vector number unique identifier, 0-255 some are unassigned and reserved vectors 64-255 are user interrupt vectors for vectored interrupts user programs vector into peripheral and handler address into table no vector 1 since vector 0 (reset) needs two longwords 4*vector number = location in table privilege violation is vector 8, stored at location $020

Exception Vector Table (cont.) Reset exception vector (vector 0) triggered by RESET* input signal $000000 is initial supervisor SP value $000004 is initial PC value - the real exception vector on reset SSP and then PC are loaded loading SSP means exceptions can be handled Vector address space type reset values are in supervisor program space (SP) function code 110 is output on pins FC2-FC0 all other vectors in supervisor data space (SD) code 101 on pins FC2-FC0 allows identification of reset processing

Table Implementation 1KB ROM at $000000 Vector base register (VBR) do not need to provide user interrupt vectors 64-255 if no vectored interrupts but should reserve memory space set all unused vectors to spurious interrupt handler (vector 24) vectors can point to handler in RAM or ROM Vector base register (VBR) in 68010-68040 base address of exception vector table VBR is initially $000000 have initial table in ROM at $000000 reset vector, etc. can have another table in RAM elsewhere can have table per process

Exception Processing Phase 1 Phase 2 set S-bit - enter supervisor mode clear T-bit - prevent tracing OS, stop infinite loop of traces if reset exception, set interrupt mask to priority 7 (111) i.e. disable all but unmaskable interrupts if interrupt, set interrupt mask to current exception priority i.e. only respond to higher priority interrupts Phase 2 determine exception vector number internal computation for all but interrupts interrupts get vector on D(7:0) of data bus during interrupt acknowledge cycle (FC2-FC0 = 111) sometimes vector is internally generated 4*vector_number + VBR = vector address

Exception Processing (cont.) Phase 3 CPU context is saved on SSP as exception stack frame all details CPU needs to return to normal processing nothing saved on reset exception information saved depends on type of exception two types for 68000-68010 six different types for 68020-68040 all save PC and SR Phase 4 load PC with handler address from exception table entry Completion of processing handler executes RTE except reset - nothing to return to

Exception Priority Can get exception during exception must prioritize processing Priority groups for 68020-68040 5 groups reset is highest interrupt, trace, coprocessor cleanup are lowest handle most abnormal thing first Priority groups for 68000-68010 3 groups reset, bus error, address error - highest trace, interrupt, illegal instruction, privilege TRAP, CHK, divide by zero - lowest

Reset Exception Reset Reset Logic occurs on power up or total system failure RESET* asserted RESET* and HALT* on 68000 for 10 clock cycles during operation for 100ms after Vdd is stable on power-up for 68000 for 520 clock cycles on power-up for 68020 programmer must set up VBR, MMU, cache, USP then can switch to user mode Reset Logic 555 timer for long power-up pulse button for manual reset will be pressed >> 10 clock cycles

Bus Error Exception Bus error Examples Rerun cycle system fails to complete a bus cycle hardware detects, asserts BERR* pin Examples illegal memory address - no memory at address, write to ROM faulty memory access - error detecting memory had error no VPA* asserted - during synchronous bus access memory privilege violation - e.g. due to page fault Rerun cycle when BERR* and HALT* asserted together usually allow one retry Bus error handling - usually page faults 68010 and later can continue instruction with RTE address error - cannot RTE, would just cause another bus error use stack frame info to emulate bus cycle, avoid original error

Interrupt Exception Interrupt hardware Interrupts are edge sensitive 8 to 3 line priority encoder - generate 3-bit priority level tie off input 0 7 active-low interrupt request lines 1 for each interrupt priority level resistor pullups, open collector pulldowns on peripherals can wire-OR several peripherals to each priority level example - peripherals 2 and 3 are both level 2 peripheral pulls down on line when it wants an interrupt Interrupts are edge sensitive IPL2-IPL0 must change to notice interrupt if level 7 is already being processed, will not notice another one until serviced peripheral releases IRQ7* and new device pulls it down

Vectored Interrupt Interrupt acknowledge A modified read cycle after accepting interrupt, processor runs IACK bus cycle A modified read cycle put out 111 on FC2-FC0 put out interrupt level accepted on A(3:1) address lines decode into IACK1* to IACK7* lines to peripherals device puts interrupt vector number on D(7:0) and asserts DTACK* puts $0F if uninitialized causes unitialized interrupt vector exception CPU uses vector number to access exception vector table normally vector numbers 64-255 - user-defined vectors

Autovectored Interrupt Older peripherals cannot supply interrupt vector 8-bit peripherals Assert VPA* to indicate autovectored interrupt instead of DTACK* in vectored interrupt use AVEC* pin on 68020 and later Autovectors vector determined by interrupt priority level vector numbers 25-31 correspond to interrupt levels 1-7 Multiple requests at same priority handler does not know who requested interrupt must poll each device (test interrupt bit in status register) Hardware add gate to generate VPA* for autovectored devices

Manual Interrupts System hangs, want to avoid using reset button Connect debounced switch to IRQ7* line pull down on IRQ7* when switch pushed use autovectored interrupt, since switch cannot supply vector vector 31 routine handles interrupt example - go to monitor or debugger use IACK7* to remove IRQ7* request

Breakpoints ILLEGAL instruction special illegal instruction opcode $4AFC generates illegal instruction exception BKPT illegal instructions (68010 and later) BKPT #<data> for data = 0 to 7 corresponds to opcodes $4848 to $484F take illegal instruction exception execute special breakpoint bus cycle before exception call dummy read cycle with FC2-FC1 = 111, A(31:5,1:0) low A(4:2) have breakpoint number on 68020 and later use to trigger logic analyzer external hardware can supply replacement instruction executed instead of illegal instruction exception

Trace Exceptions Trace exception after each instruction if T-bit set T-bit only set in supervisor mode make TRAP call to set it ORI.W #$8000,(SP) Set T-bit of SR on stack RTE Return to user mode User must supply trace handler arguments what to trace e.g. dump registers on condition print variable when modified 68020 and later has two trace bits regular trace mode trace only on program flow change BRA, JMP, TRAP, RTS, etc. instructions whenever SR is modified

Emulator Mode Exceptions Line A exception opcodes $AXXX call vector 10 exception handler XXX are user-definable bits can encode new instructions, handler implements them LEA 2(SP),A0 A0 points to address of instruction following exception MOVEA.L (A0),A0 Read address MOVE.W -2(A0),D0 Read instruction $AXXX then execute based on XXX Use to implement new instructions an extension facility Line F exception opcodes $FXXX call vector 11 exception handler use to implement coprocessor instructions can use when coprocessor is missing

TRAP Exceptions TRAP #<data> TRAPV - trap on overflow <data> = 0 to 15 cause exception numbers 32 to 47 TRAPV - trap on overflow causes vector 7, special form of TRAP Means for user programs to call operating system put system-specific code in trap handler Can pass arguments in registers or on stack e.g. string to put out on serial line Get results back in registers or stack e.g. string read from terminal

Real-Time Processing Device interrupts Timed interrupts Scheduler with specific handlers or through general handler can treat devices like other tasks to run Timed interrupts signal to switch between tasks - the time slice generate with timer peripheral at regular intervals Scheduler get interrupt, determine task to be executed devices needing service can be considered task to run Interprocess communication e.g. shared memory locations