I/O Interface and Interrupt Systems

Slides:



Advertisements
Similar presentations
IO - 1Embedded Systems Lab./Honam University CPUs zInput and output. zSupervisor mode, exceptions, traps. zCo-processors.
Advertisements

Chapter 3 Basic Input/Output
Accessing I/O Devices Processor Memory BUS I/O Device 1 I/O Device 2.
INPUT-OUTPUT ORGANIZATION
Computer Organization and Architecture
Mehmet Can Vuran, Instructor University of Nebraska-Lincoln Acknowledgement: Overheads adapted from those provided by the authors of the textbook.
1 中斷 Interrupt. 2 謂何需要 Interrupt I/O  Busy/wait I/O is very inefficient. CPU can ’ t do other work while testing device. Hard to do simultaneous I/O.
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.
Computer System Organization S H Srinivasan
© 2008 Wayne Wolf Overheads for Computers as Components 2nd ed. CPUs Input and output. Supervisor mode, exceptions, traps. Co-processors. 1.
Chapter 13: I/O Systems I/O Hardware Application I/O Interface
INPUT-OUTPUT ORGANIZATION
Exception and Interrupt Handling
Interrupts. What Are Interrupts? Interrupts alter a program’s flow of control  Behavior is similar to a procedure call »Some significant differences.
CPUs Input and output. Supervisor mode, exceptions, traps. Co-processors.
MICROPROCESSOR INPUT/OUTPUT
© 2000 Morgan Kaufman Overheads for Computers as Components CPUs zInput and output mechanisms zInterrupts zMemory management unit (MMU) zCache mechanism.
Computer Architecture Lecture10: Input/output devices Piotr Bilski.
Accessing I/O Devices Processor Memory BUS I/O Device 1 I/O Device 2.
© 2000 Morgan Kaufman Overheads for Computers as Components CPUs zInput and output. zSupervisor mode, exceptions, traps. zCo-processors.
AT91 Interrupt Handling. 2 Stops the execution of main software Redirects the program flow, based on an event, to execute a different software subroutine.
© 2000 Morgan Kaufman Overheads for Computers as Components CPUs zInput and output. zSupervisor mode, exceptions, traps. zCo-processors.
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.
Lab 2 Microprocessor MPC430F2274 MSP-430 Architecture.
Introduction to Exceptions 1 Introduction to Exceptions ARM Advanced RISC Machines.
Computer System Structures Interrupts
Unit Microprocessor.
Lecture 2 Interrupts.
Architectures of Digital Information Systems Part 1: Interrupts and DMA dr.ir. A.C. Verschueren Eindhoven University of Technology Section of Digital.
COURSE OUTCOMES OF Microprocessor and programming
Interrupts and exceptions
Microprocessor Systems Design I
Mon. Oct 2 Announcements Quiz Postponed to Wednesday – still only on 2.a + 2.b Video lecture for 2.a posted Lab 6 experiment extension You must come to.
Timer and Interrupts.
Anton Burtsev February, 2017
Computer Architecture
Interrupts In 8085 and 8086.
1 Input-Output Organization Computer Organization Computer Architectures Lab Peripheral Devices Input-Output Interface Asynchronous Data Transfer Modes.
Chapter 3 Top Level View of Computer Function and Interconnection
Computer Organization and Design
CSCI 315 Operating Systems Design
Interrupt Driven I/O References Text: Tanenbaum ch.1.4.3, ch Receiver Interrupt Program Example:
Input/Output Organization
8255.
Computer System Overview
Parallel communication interface 8255
I/O Systems I/O Hardware Application I/O Interface
Overheads for Computers as Components 2nd ed.
Direct Memory Access Disk and Network transfers: awkward timing:
X1 & X2 These are also called Crystal Input Pins.
8259 Programmable Interrupt Controller
COMPUTER PERIPHERALS AND INTERFACES
Interrupts.
Md. Mojahidul Islam Lecturer Dept. of Computer Science & Engineering
Md. Mojahidul Islam Lecturer Dept. of Computer Science & Engineering
CSE 451: Operating Systems Autumn 2003 Lecture 2 Architectural Support for Operating Systems Hank Levy 596 Allen Center 1.
CNET 315 Microprocessor & Assembly Language
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.
Computer System Overview
CSE 451: Operating Systems Winter 2003 Lecture 2 Architectural Support for Operating Systems Hank Levy 412 Sieg Hall 1.
Architectural Support for OS
Chapter 11 Processor Structure and function
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:

I/O Interface and Interrupt Systems CPRE 488X Fall 2005

Overheads for Computers as Components I/O devices Usually includes some non-digital component: User I/O network, sensor, actuator, … Typical digital interface to CPU: status reg CPU mechanism data reg © 2000 Morgan Kaufman Overheads for Computers as Components

Overheads for Computers as Components Application: 8251 UART Universal asynchronous receiver transmitter (UART) : provides serial communication. 8251 functions are integrated into standard PC interface chip. Allows many communication parameters to be programmed. © 2000 Morgan Kaufman Overheads for Computers as Components

Overheads for Computers as Components Serial communication Characters are transmitted separately: no char bit 0 bit 1 bit n-1 ... start stop time © 2000 Morgan Kaufman Overheads for Computers as Components

Serial communication parameters Baud (bit) rate. Number of bits per character. Parity/no parity. Even/odd parity. Length of stop bit (1, 1.5, 2 bits). © 2000 Morgan Kaufman Overheads for Computers as Components

Overheads for Computers as Components 8251 CPU interface 8251 status (8 bit) CPU xmit/ rcv data (8 bit) serial port © 2000 Morgan Kaufman Overheads for Computers as Components

Overheads for Computers as Components Programming I/O Two types of instructions can support I/O: special-purpose I/O instructions; memory-mapped load/store instructions. Intel x86 provides in, out instructions. Most other CPUs use memory-mapped I/O. I/O instructions do not preclude memory-mapped I/O. © 2000 Morgan Kaufman Overheads for Computers as Components

PowerPC memory-mapped I/O Define location for device: DEV1 EQU 0x40001000 Read/write code: lis r3, DEV1@h ; load half address lbz r4, DEV1@l(r3); read value li r5, 8; set up value to write stb r5,DEV1@(r3) ; write value to device © 2000 Morgan Kaufman Overheads for Computers as Components

Overheads for Computers as Components Peek and poke Traditional HLL interfaces: int peek(char *location) { return *location; } void poke(char *location, char newval) { (*location) = newval; } © 2000 Morgan Kaufman Overheads for Computers as Components

Overheads for Computers as Components Busy/wait output Simplest way to program device. Use instructions to test when device is ready. current_char = mystring; while (*current_char != ‘\0’) { poke(OUT_CHAR,*current_char); while (peek(OUT_STATUS) != 0); current_char++; } © 2000 Morgan Kaufman Overheads for Computers as Components

Simultaneous busy/wait input and output while (TRUE) { /* read */ while (peek(IN_STATUS) == 0); achar = (char)peek(IN_DATA); /* write */ poke(OUT_DATA,achar); poke(OUT_STATUS,1); while (peek(OUT_STATUS) != 0); } © 2000 Morgan Kaufman Overheads for Computers as Components

Overheads for Computers as Components Interrupt I/O Busy/wait is very inefficient. CPU can’t do other work while testing device. Hard to do simultaneous I/O. Interrupts allow a device to change the flow of control in the CPU. Causes subroutine call to handle device. © 2000 Morgan Kaufman Overheads for Computers as Components

Overheads for Computers as Components Interrupt interface intr request status reg CPU intr ack mechanism IR PC data/address data reg © 2000 Morgan Kaufman Overheads for Computers as Components

Overheads for Computers as Components Interrupt behavior Interrupt forces next instruction to be a subroutine call to a predetermined location. Interrupt handler: the code that processes the interrupt event The handler borrows the processor from foreground program Return address are saved to resume executing foreground program. Any register, if to be changed, are saved and restored Interrupt handler uses its own stack frame © 2000 Morgan Kaufman Overheads for Computers as Components

Interrupt physical interface CPU and device are connected by CPU bus. CPU and device handshake: device asserts interrupt request; CPU asserts interrupt acknowledge when it can handle the interrupt. © 2000 Morgan Kaufman Overheads for Computers as Components

Example: character I/O handlers void input_handler() { achar = peek(IN_DATA); gotchar = TRUE; poke(IN_STATUS,0); } void output_handler() { © 2000 Morgan Kaufman Overheads for Computers as Components

Example: interrupt-driven main program while (TRUE) { if (gotchar) { poke(OUT_DATA,achar); poke(OUT_STATUS,1); gotchar = FALSE; } © 2000 Morgan Kaufman Overheads for Computers as Components

Example: interrupt I/O with buffers Queue for characters: head tail a head tail © 2000 Morgan Kaufman Overheads for Computers as Components

Buffer-based input handler void input_handler() { char achar; if (full_buffer()) error = 1; else { achar = peek(IN_DATA); add_char(achar); } poke(IN_STATUS,0); if (nchars == 1) { poke(OUT_DATA,remove_char(); poke(OUT_STATUS,1); } } © 2000 Morgan Kaufman Overheads for Computers as Components

Overheads for Computers as Components I/O sequence diagram :foreground :input :output :queue empty a empty b bc c © 2000 Morgan Kaufman Overheads for Computers as Components

Debugging interrupt code What if you forget to change registers? Foreground program can exhibit mysterious bugs. Bugs will be hard to repeat---depend on interrupt timing. © 2000 Morgan Kaufman Overheads for Computers as Components

Priorities and vectors Two mechanisms allow us to make interrupts more specific: Priorities determine what interrupt gets CPU first. Vectors determine what code is called for each type of interrupt. Mechanisms are orthogonal: most CPUs provide both. © 2000 Morgan Kaufman Overheads for Computers as Components

Prioritized interrupts device 1 device 2 device n interrupt acknowledge L1 L2 .. Ln CPU © 2000 Morgan Kaufman Overheads for Computers as Components

Interrupt prioritization Masking: interrupt with priority lower than current priority is not recognized until pending interrupt is complete. Non-maskable interrupt (NMI): highest-priority, never masked. Often used for power-down. © 2000 Morgan Kaufman Overheads for Computers as Components

Example: Prioritized I/O :interrupts :foreground :A :B :C B C A A,B © 2000 Morgan Kaufman Overheads for Computers as Components

Overheads for Computers as Components Example: Nested I/O :interrupts :foreground :A :B :C C B A © 2000 Morgan Kaufman Overheads for Computers as Components

Overheads for Computers as Components Interrupt vectors Allow different devices to be handled by different code. Interrupt vector table: Interrupt vector table head handler 0 handler 1 handler 2 handler 3 © 2000 Morgan Kaufman Overheads for Computers as Components

Interrupt vector acquisition :CPU :device receive request receive ack receive vector © 2000 Morgan Kaufman Overheads for Computers as Components

Generic interrupt mechanism continue execution intr? Assume priority selection is handled before this point. N Y intr priority > current priority? N ignore Y ack Y bus error Y N timeout? vector? Y call table[vector] © 2000 Morgan Kaufman Overheads for Computers as Components

Overheads for Computers as Components Interrupt sequence CPU acknowledges request. Device sends vector. CPU calls handler. Software processes request. Handler and CPU restore state to foreground program. © 2000 Morgan Kaufman Overheads for Computers as Components

Sources of interrupt overhead Handler execution time. Interrupt mechanism overhead. Register save/restore. Pipeline-related penalties. Cache-related penalties. © 2000 Morgan Kaufman Overheads for Computers as Components

MPC555 interrupt structure Interrupts are vectored and prioritized. Eight internal interrupt levels, eight external interrupt requests (IRQ) Internal interrupt levels are programmable Vector address is fixed at 0x40000000 or 0xFFF00000 © 2000 Morgan Kaufman Overheads for Computers as Components

Overheads for Computers as Components ARM interrupts ARM7 supports two types of interrupts: Fast interrupt requests (FIQs). Interrupt requests (IRQs). Interrupt table starts at location 0. © 2000 Morgan Kaufman Overheads for Computers as Components

Overheads for Computers as Components ARM interrupt latency Worst-case latency to respond to interrupt is 27 cycles: Two cycles to synchronize external request. Up to 20 cycles to complete current instruction. Three cycles for data abort. Two cycles to enter interrupt handling state. © 2000 Morgan Kaufman Overheads for Computers as Components

Overheads for Computers as Components Supervisor mode May want to provide protective barriers between programs. Avoid memory corruption. Need supervisor mode to manage the various programs. SHARC does not have a supervisor mode. © 2000 Morgan Kaufman Overheads for Computers as Components

Overheads for Computers as Components ARM supervisor mode Use SWI instruction to enter supervisor mode, similar to subroutine: SWI CODE_1 Sets PC to 0x08. Argument to SWI is passed to supervisor mode code. Saves CPSR in SPSR. © 2000 Morgan Kaufman Overheads for Computers as Components

Overheads for Computers as Components Exception Exception: internally detected error. Exceptions are synchronous with instructions but unpredictable. Build exception mechanism on top of interrupt mechanism. Exceptions are usually prioritized and vectorized. © 2000 Morgan Kaufman Overheads for Computers as Components

Overheads for Computers as Components Trap Trap (software interrupt): an exception generated by an instruction. Call supervisor mode. ARM uses SWI instruction for traps. SHARC offers three levels of software interrupts. Called by setting bits in IRPTL register. © 2000 Morgan Kaufman Overheads for Computers as Components

Overheads for Computers as Components Co-processor Co-processor: added function unit that is called by instruction. Floating-point units are often structured as co-processors. MPC555: Time-processing unit (TPU) can be seen as a simple co-processor ARM allows up to 16 designer-selected co-processors. Floating-point co-processor uses units 1 and 2. © 2000 Morgan Kaufman Overheads for Computers as Components