EECS 373 Design of Microprocessor-Based Systems Prabal Dutta

Slides:



Advertisements
Similar presentations
Computer Architecture
Advertisements

CSCI 4717/5717 Computer Architecture
1 EECS 373 Design of Microprocessor-Based Systems Prabal Dutta University of Michigan Lecture 6: AHB-Lite, Interrupts (1) September 18, 2014 Slides developed.
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.
A look at interrupts What are interrupts and why are they needed in an embedded system? Equally as important – how are these ideas handled on the Blackfin.
Architectural Support for Operating Systems. Announcements Most office hours are finalized Assignments up every Wednesday, due next week CS 415 section.
OS Spring’03 Introduction Operating Systems Spring 2003.
1 EECS 373 Design of Microprocessor-Based Systems Prabal Dutta University of Michigan Lecture 7: Exceptions and Interrupts September 27, 2011.
Computer System Structures memory memory controller disk controller disk controller printer controller printer controller tape-drive controller tape-drive.
1 EECS 373 Design of Microprocessor-Based Systems Prabal Dutta University of Michigan Lecture 7: Interrupts (2) January 29, 2015 Some slides prepared by.
1 EECS 373 Design of Microprocessor-Based Systems Prabal Dutta University of Michigan Lecture 7: Interrupts (2) September 23, 2014 Some slides prepared.
1 EECS 373 Design of Microprocessor-Based Systems Prabal Dutta University of Michigan Lecture 4: Memory-Mapped I/O, Bus Architectures January 20, 2015.
The 8051 Microcontroller and Embedded Systems
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.
Chapter 10 The Stack Stack: An Abstract Data Type An important abstraction that you will encounter in many applications. We will describe two uses:
CHAPTER 3 TOP LEVEL VIEW OF COMPUTER FUNCTION AND INTERCONNECTION
Khaled A. Al-Utaibi  Interrupt-Driven I/O  Hardware Interrupts  Responding to Hardware Interrupts  INTR and NMI  Computing the.
1 EECS 373 Design of Microprocessor-Based Systems Mark Brehob University of Michigan Lecture 7: Finish interrupts, group talks, start on serial buses Feb.
Interrupts Stopping program flow to execute a special piece of code that handles an event Definition and classification PowerPC interrupt structure Precise.
1 CS/COE0447 Computer Organization & Assembly Language Chapter 5 part 4 Exceptions.
1 EECS 373 Design of Microprocessor-Based Systems Mark Brehob University of Michigan Lecture 6: Interrupts Sept. 19 th 2013 Slides developed in part by.
1 EECS 373 Design of Microprocessor-Based Systems Mark Brehob University of Michigan Lecture 6: Interrupts January 30 th Slides developed in part by Prof.
13-Nov-15 (1) CSC Computer Organization Lecture 7: Input/Output Organization.
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.
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.
CE Operating Systems Lecture 2 Low level hardware support for operating systems.
EECS 373 Design of Microprocessor-Based Systems Mark Brehob
Embedded Systems Design 1 Lecture Set 8 MCS-51 Interrupts.
EECS 373 Design of Microprocessor-Based Systems Mark Brehob University of Michigan Lecture 6 & 7: Interrupts (please bring slides again on Thursday) January.
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.
© Janice Regan, CMPT 300, May CMPT 300 Introduction to Operating Systems Operating Systems Overview: Using Hardware.
Introduction to Exceptions 1 Introduction to Exceptions ARM Advanced RISC Machines.
Networked Embedded Systems Pengyu Zhang EE107 Spring 2016 Lecture 8 Serial Buses.
1 EECS 373 Design of Microprocessor-Based Systems Prabal Dutta University of Michigan Interrupts, Exceptions, Traps, Faults & ARM’s Nested Vectored Interrupt.
Interrupt 마이크로 프로세서 (Micro Processor) 2015년 2학기 충북대학교 전자공학과 박 찬식
A walk through interrupts on the PPC 823
Architectures of Digital Information Systems Part 1: Interrupts and DMA dr.ir. A.C. Verschueren Eindhoven University of Technology Section of Digital.
Interrupts and exceptions
8085 Interrupts LAKSHMI.B.E..
Operating Systems CMPSC 473
Exceptional Control Flow
68HC11 Interrupts & Resets.
Microprocessor Systems Design I
Slides developed in part by Mark Brehob & Prabal Dutta
Timer and Interrupts.
Anton Burtsev February, 2017
Computer Architecture
Interrupts In 8085 and 8086.
EECS 373 Design of Microprocessor-Based Systems Prabal Dutta
Chapter 8 Input/Output I/O basics Keyboard input Monitor output
Chapter 10 The Stack.
* * * * * * * 8051 Interrupts Programming.
EECS 373 Design of Microprocessor-Based Systems Mark Brehob
Interrupts Interrupt is a process where an external device can get the attention of the microprocessor. The process starts from the I/O device The process.
EECS 373 Design of Microprocessor-Based Systems Mark Brehob
BIC 10503: COMPUTER ARCHITECTURE
Interrupts.
CSE 451: Operating Systems Autumn 2003 Lecture 2 Architectural Support for Operating Systems Hank Levy 596 Allen Center 1.
CSE 451: Operating Systems Autumn 2001 Lecture 2 Architectural Support for Operating Systems Brian Bershad 310 Sieg Hall 1.
Interrupt handling Explain how interrupts are used to obtain processor time and how processing of interrupted jobs may later be resumed, (typical.
CSE 451: Operating Systems Winter 2003 Lecture 2 Architectural Support for Operating Systems Hank Levy 412 Sieg Hall 1.
COMP3221: Microprocessors and Embedded Systems
Chapter 13: I/O Systems.
Chapter 13: I/O Systems “The two main jobs of a computer are I/O and [CPU] processing. In many cases, the main job is I/O, and the [CPU] processing is.
Presentation transcript:

EECS 373 Design of Microprocessor-Based Systems Prabal Dutta University of Michigan Lecture 6: Interrupts January 27, 2015 Slides developed in part by Mark Brehob

Additional GSI/IA office hours (OH) Announcements Additional GSI/IA office hours (OH) Pat Pannuto 10-11am MW in EECS Learning Center (Glass rooms between BBB and Dow)

Interrupts, traps, exceptions, and faults Assembly Machine Code Central Processing Unit EECS 370 Software Hardware ISA SVC# fault ldr (read) str (write) INT# System Buses interrupts AHB/APB Interrupts GPIO/INT Timers USART DAC/ADC Internal & External Memory Internal External Input I2C SPI ADC DAC EMC Output Compare Capture UART Interrupt

Informs a program of some external events Breaks execution flow Interrupts Merriam-Webster: “to break the uniformity or continuity of” Informs a program of some external events Breaks execution flow Key questions: Where do interrupts come from? How do we save state for later continuation? How can we ignore interrupts? How can we prioritize interrupts? How can we share interrupts?

Interrupts Interrupt (a.k.a. exception or trap): An event that causes the CPU to stop executing current program Begin executing a special piece of code Called an interrupt handler or interrupt service routine (ISR) Typically, the ISR does some work Then resumes the interrupted program Interrupts are really glorified procedure calls, except that they: can occur between any two instructions are “transparent” to the running program (usually) are not explicitly requested by the program (typically) call a procedure at an address determined by the type of interrupt, not the program

Two basic types of interrupts (1/2) Those caused by an instruction Examples: TLB miss Illegal/unimplemented instruction div by 0 SVC (supervisor call, e.g.: SVC #3) Names: Trap, exception

Two basic types of interrupts (2/2) Those caused by the external world External device Reset button Timer expires Power failure System error Names: interrupt, external interrupt

Why are interrupts useful? Example: I/O Data Transfer Two key questions to determine how data is transferred to/from a non-trivial I/O device: How does the CPU know when data is available? Polling Interrupts How is data transferred into and out of the device? Programmed I/O Direct Memory Access (DMA)

Something tells the processor core there is an interrupt How it works Something tells the processor core there is an interrupt Core transfers control to code that needs to be executed Said code “returns” to old program Much harder then it looks. Why?

Devil is in the details How do you figure out where to branch to? How to you ensure that you can get back to where you started? Don’t we have a pipeline? What about partially executed instructions? What if we get an interrupt while we are processing our interrupt? What if we are in a “critical section?”

Where If you know what caused the interrupt then you want to jump to the code that handles that interrupt. If you number the possible interrupt cases, and an interrupt comes in, you can just branch to a location, using that number as an offset (this is a branch table) If you don’t have the number, you need to poll all possible sources of the interrupt to see who caused it. Then you branch to the right code

Get back to where you once belonged Need to store the return address somewhere. Stack might be a scary place. That would involve a load/store and might cause an interrupt (page fault)! So a dedicated register seems like a good choice But that might cause problems later… What happens if another interrupt happens?

Modern architectures A modern processor has many (often 50+) instructions in-flight at once. What do we do with them? Drain the pipeline? What if one of them causes an exception? Punt all that work Slows us down What if the instruction that caused the exception was executed before some other instruction? What if that other instruction caused an interrupt?

If we get one interrupt while handling another what to do? Nested interrupts If we get one interrupt while handling another what to do? Just handle it But what about that dedicated register? What if I’m doing something that can’t be stopped? Ignore it But what if it is important? Prioritize Take those interrupts you care about. Ignore the rest Still have dedicated register problems.

We probably need to ignore some interrupts but take others. Critical section We probably need to ignore some interrupts but take others. Probably should be sure our code can’t cause an exception. Use same prioritization as before. What about instructions that shouldn’t be interrupted? Disable interrupts while processing an interrupt?

Over 100 interrupt sources Our processor Over 100 interrupt sources Power on reset, bus errors, I/O pins changing state, data in on a serial bus etc. Need a great deal of control Ability to enable and disable interrupt sources Ability to control where to branch to for each interrupt Ability to set interrupt priorities Who wins in case of a tie Can interrupt A interrupt the ISR for interrupt B? If so, A can “preempt” B. All that control will involve memory mapped I/O. And given the number of interrupts that’s going to be a pain

SmartFusion interrupt sources

And the interrupt vectors (in startup_a2fxxxm3 And the interrupt vectors (in startup_a2fxxxm3.s found in CMSIS, startup_gcc) g_pfnVectors: .word _estack .word Reset_Handler .word NMI_Handler .word HardFault_Handler .word MemManage_Handler .word BusFault_Handler .word UsageFault_Handler .word 0 .word SVC_Handler .word DebugMon_Handler .word PendSV_Handler .word SysTick_Handler .word WdogWakeup_IRQHandler .word BrownOut_1_5V_IRQHandler .word BrownOut_3_3V_IRQHandler .............. (they continue)

How to change where to go on an interrupt How to change where to go on an interrupt? Answer: edit the interrupt vector table [IVT]

Enabling and disabling interrupt sources

Interrupt types Two main types Level-triggered Edge-triggered

Level-triggered interrupts Signaled by asserting a line low or high Interrupting device drives line low or high and holds it there until it is serviced Device deasserts when directed to or after serviced Can share the line among multiple devices (w/ OD+PU) Active devices assert the line Inactive devices let the line float Easy to share line w/o losing interrupts But servicing increases CPU load  example And requires CPU to keep cycling through to check Different ISR costs suggests careful ordering of ISR checks Can’t detect a new interrupt when one is already asserted PCI originally mandated level-triggered due to this

Edge-triggered interrupts Signaled by a level *transition* (e.g. rising/falling edge) Interrupting device drive a pulse (train) onto INT line What if the pulse is too short? Need a pulse extender! Sharing *is* possible...under some circumstances INT line has a pull up and all devices are OC/OD. Devices *pulse* lines Could we miss an interrupt? Maybe...if close in time What happens if interrupts merge? Need one more ISR pass Must check trailing edge of interrupt Easy to detect "new interrupts” Benefits: more immune to unserviceable interrupts Pitfalls: spurious edges, missed edges Source of "lockups" in early computers PCI originally mandated level-triggered due to this

Pending interrupts The normal case. Once Interrupt request is seen, processor puts it in “pending” state even if hardware drops the request. IPS is cleared by the hardware once we jump to the ISR. This figure and those following are from The Definitive Guide to the ARM Cortex-M3, Section 7.4

In this case, the processor never took the interrupt because we cleared the IPS by hand (via a memory-mapped I/O register)

Answer

Interrupt pulses before entering ISR

Answer