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

Slides:



Advertisements
Similar presentations
Chapter 13: I/O Systems I/O Hardware Application I/O Interface
Advertisements

Process Description and Control
Copyright © 2003 Pearson Education, Inc. Slide 1 Computer Systems Organization & Architecture Chapters 8-12 John D. Carpinelli.
1 Copyright © 2013 Elsevier Inc. All rights reserved. Chapter 4 Computing Platforms.
Processes and Operating Systems
Copyright © 2011, Elsevier Inc. All rights reserved. Chapter 6 Author: Julia Richards and R. Scott Hawley.
1 Copyright © 2013 Elsevier Inc. All rights reserved. Chapter 3 CPUs.
1 RA I Sub-Regional Training Seminar on CLIMAT&CLIMAT TEMP Reporting Casablanca, Morocco, 20 – 22 December 2005 Status of observing programmes in RA I.
Chapter 5 Input/Output 5.1 Principles of I/O hardware
1 Chapter 11 I/O Management and Disk Scheduling Patricia Roy Manatee Community College, Venice, FL ©2008, Prentice Hall Operating Systems: Internals and.
Homework Reading Machine Projects Labs
Figure 12–1 Basic computer block diagram.
Chapter 3 Basic Input/Output
Accessing I/O Devices Processor Memory BUS I/O Device 1 I/O Device 2.
I/O Peripherals, Buses and Data Storage Systems
PP Test Review Sections 6-1 to 6-6
EIS Bridge Tool and Staging Tables September 1, 2009 Instructor: Way Poteat Slide: 1.
Operating Systems Operating Systems - Winter 2010 Chapter 3 – Input/Output Vrije Universiteit Amsterdam.
1 RA III - Regional Training Seminar on CLIMAT&CLIMAT TEMP Reporting Buenos Aires, Argentina, 25 – 27 October 2006 Status of observing programmes in RA.
Basel-ICU-Journal Challenge18/20/ Basel-ICU-Journal Challenge8/20/2014.
1..
CONTROL VISION Set-up. Step 1 Step 2 Step 3 Step 5 Step 4.
INPUT-OUTPUT ORGANIZATION
PIN DIAGRAM OF 8085 ENGR M.ZAKIR SHAIKH Visiting Faculty,IBT LUMHS
Gursharan Singh Tatla PIN DIAGRAM OF 8086 Gursharan Singh Tatla Gursharan Singh Tatla
Essential Cell Biology
PSSA Preparation.
Energy Generation in Mitochondria and Chlorplasts
Chapter 3 โพรเซสเซอร์และการทำงาน The Processing Unit
ECE 353 Introduction to Microprocessor Systems
Lab III Real-Time Embedded Operating System for a SoC System.
1/1/ / faculty of Electrical Engineering eindhoven university of technology Architectures of Digital Information Systems Part 1: Interrupts and DMA dr.ir.
Interrupts Disclaimer: All diagrams and figures in this presentation are scanned from the book “Microprocessors and Programmed Logic” authored by Kenneth.
I/O Unit.
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.
ECE 372 – Microcontroller Design Parallel IO Ports - Interrupts
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.
CSS 372 Lecture 1 Course Overview: CSS 372 Web page Syllabus Lab Ettiquette Lab Report Format Review of CSS 371: Simple Computer Architecture Traps Interrupts.
Introduction An interrupt is an event which informs the CPU that its service (action) is needed. Sources of interrupts: internal fault (e.g.. divide by.
Midterm Tuesday October 23 Covers Chapters 3 through 6 - Buses, Clocks, Timing, Edge Triggering, Level Triggering - Cache Memory Systems - Internal Memory.
Introduction to Interrupts
© 2008 Wayne Wolf Overheads for Computers as Components 2nd ed. CPUs Input and output. Supervisor mode, exceptions, traps. Co-processors. 1.
GURSHARAN SINGH TATLA PIN DIAGRAM OF 8085 GURSHARAN SINGH TATLA
INPUT-OUTPUT ORGANIZATION
ECE 265 – LECTURE 12 The Hardware Interface 8/22/ ECE265.
Introduction to Embedded Systems
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.
CHAPTER 3 TOP LEVEL VIEW OF COMPUTER FUNCTION AND INTERCONNECTION
Accessing I/O Devices Processor Memory BUS I/O Device 1 I/O Device 2.
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.
© 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.
Interrupt driven I/O Computer Organization and Assembly Language: Module 12.
Lab 2 Microprocessor MPC430F2274 MSP-430 Architecture.
Introduction to Exceptions 1 Introduction to Exceptions ARM Advanced RISC Machines.
Lecture 2 Interrupts.
Microprocessor Systems Design I
Timer and Interrupts.
I/O Interface and Interrupt Systems
Overheads for Computers as Components 2nd ed.
X1 & X2 These are also called Crystal Input Pins.
COMP3221: Microprocessors and Embedded Systems
Presentation transcript:

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

IO - 2Embedded Systems Lab./Honam University I/O devices zUsually includes some non-digital component. zTypical digital interface to CPU: CPU status reg data reg mechanism

IO - 3Embedded Systems Lab./Honam University Motorola 16-bit Microcontroller MC68HC16Z1 – 16-bit CPU, SIM, GPT, QSM, ADC, RAM. Powerful, complex modules w register banks z Intermodule Bus z 24-bit address bus, 16-bit data bus; External Bus shared with peer processors z7 level Extl Interrupts z8 Analog Inputs, Event capture and assertion Timer Inputs/outputs, Synchronous and Asynchronous Serial Communication;

IO - 4Embedded Systems Lab./Honam University Application: 8251 UART zUniversal asynchronous receiver transmitter (UART) : provides serial communication. z8251 functions are integrated into standard PC interface chip. zAllows many communication parameters to be programmed.

IO - 5Embedded Systems Lab./Honam University Serial communication zCharacters are transmitted separately: time bit 0bit 1bit n-1 no char start stop...

IO - 6Embedded Systems Lab./Honam University Serial communication parameters zBaud (bit) rate. zNumber of bits per character. zParity/no parity. zEven/odd parity. zLength of stop bit (1, 1.5, 2 bits).

IO - 7Embedded Systems Lab./Honam University 8251 CPU interface CPU 8251 status (8 bit) data (8 bit) serial port xmit/ rcv

IO - 8Embedded Systems Lab./Honam University Programming I/O zTwo types of instructions can support I/O: yspecial-purpose I/O instructions; ymemory-mapped load/store instructions. Intel x86 provides in, out instructions. Most other CPUs use memory-mapped I/O. zI/O instructions do not preclude memory- mapped I/O.

IO - 9Embedded Systems Lab./Honam University ARM memory-mapped I/O zDefine location for device: DEV1 EQU 0x1000 zRead/write code: LDR r1,#DEV1 ; set up device adrs LDR r0,[r1] ; read DEV1 LDR r0,#8 ; set up value to write STR r0,[r1] ; write value to device WHY ACCESS THESE REGISTERS?

IO - 10Embedded Systems Lab./Honam University SHARC memory mapped I/O zDevice must be in external memory space (above 0x400000). zUse DM to control access: I0 = 0x400000; M0 = 0; R1 = DM(I0,M0);

IO - 11Embedded Systems Lab./Honam University Peek and poke zTraditional HLL interfaces: int peek(char *location) { return *location; } void poke(char *location, char newval) { (*location) = newval; }

IO - 12Embedded Systems Lab./Honam University Busy/wait output zSimplest way to program device. yUse 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++; } Pg Dev Addr, String

IO - 13Embedded Systems Lab./Honam University Simultaneous busy/wait input and output while (TRUE) { /* read */ while (peek(IN_STATUS) == 0); achar = (char)peek(IN_DATA); Poke (IN_STATUS,0); /* write */ poke(OUT_DATA,achar); poke(OUT_STATUS,1); while (peek(OUT_STATUS) != 0); }

IO - 14Embedded Systems Lab./Honam University Interrupt I/O zBusy/wait is very inefficient. CPU can t do other work while testing device. yHard to do simultaneous I/O. zInterrupts allow a device to change the flow of control in the CPU. yCauses subroutine call to handle device.

IO - 15Embedded Systems Lab./Honam University Interrupt interface CPU status reg data reg mechanism PC intr request intr ack data/address IR

IO - 16Embedded Systems Lab./Honam University Interrupt behavior zBased on subroutine call mechanism. zInterrupt forces next instruction to be a subroutine call to a predetermined location. yReturn address is saved to resume executing foreground program.

IO - 17Embedded Systems Lab./Honam University Interrupt physical interface zCPU and device are connected by CPU bus. zCPU and device handshake: ydevice asserts interrupt request; yCPU asserts interrupt acknowledge when it can handle the interrupt.

IO - 18Embedded Systems Lab./Honam University Example: character I/O handlers void input_handler() { achar = peek(IN_DATA); gotchar = TRUE; poke(IN_STATUS,0); } void output_handler() { } Global Parameters to communicate with foreground program

IO - 19Embedded Systems Lab./Honam University Example: interrupt-driven main program main() { while (TRUE) { if (gotchar) { poke(OUT_DATA,achar); poke(OUT_STATUS,1); gotchar = FALSE; } Foreground program: still no useful work

IO - 20Embedded Systems Lab./Honam University Example: interrupt I/O with buffers zQueue for characters: headtail headtail a Example 3-6, Pg 114. Foreground: useful work Last spot unused

IO - 21Embedded Systems Lab./Honam University 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); } } Only to start off character outputting

IO - 22Embedded Systems Lab./Honam University I/O sequence diagram :foreground:input:output:queue empty a b bc c

IO - 23Embedded Systems Lab./Honam University Debugging interrupt code zWhat if you forget to change registers? yForeground program can exhibit mysterious bugs. yBugs will be hard to repeat---depend on interrupt timing. z Book Example 3-7, Page 119: Interrupt Handler changes value of j in the foreground matrix program. HOW? Is it time sensitive? Can we overcome the problem?

IO - 24Embedded Systems Lab./Honam University Priorities and vectors zTwo mechanisms allow us to make interrupts more specific: yPriorities determine what interrupt gets CPU first. yVectors determine what code is called for each type of interrupt. zMechanisms are orthogonal: most CPUs provide both.

IO - 25Embedded Systems Lab./Honam University Prioritized interrupts CPU device 1device 2device n R0 R1.. Rn interrupt acknowledge IR0 IR1 IRn

IO - 26Embedded Systems Lab./Honam University Interrupt prioritization zMasking: interrupt with priority lower than current priority is not recognized until pending interrupt is complete. zNon-maskable interrupt (NMI): highest-priority, never masked. yOften used for power-down.

IO - 27Embedded Systems Lab./Honam University Example: Prioritized I/O :interrupts:foreground:A:A:B:B:C:C B A,B C A

IO - 28Embedded Systems Lab./Honam University Interrupt vectors zAllow different devices to be handled by different code. zInterrupt vector table: handler 0 handler 1 handler 2 handler 3 Interrupt vector table head

IO - 29Embedded Systems Lab./Honam University Interrupt vector acquisition :CPU:device receive request receive ack receive vector

IO - 30Embedded Systems Lab./Honam University Generic interrupt mechanism intr? N Y Assume priority selection is handled before this point. N ignore Y ack vector? Y Y N timeout? Y bus error call table[vector] intr priority > current priority? continue execution

IO - 31Embedded Systems Lab./Honam University Interrupt sequence zCPU acknowledges request. zDevice sends vector. zCPU calls handler. zSoftware processes request. zCPU restores state to foreground program.

IO - 32Embedded Systems Lab./Honam University Sources of interrupt overhead zHandler execution time. zInterrupt mechanism overhead. zRegister save/restore. zPipeline-related penalties. zCache-related penalties.

IO - 33Embedded Systems Lab./Honam University ARM interrupts zARM7 supports two types of interrupts: yFast interrupt requests (FIQs). yInterrupt requests (IRQs). zInterrupt table starts at location 0.

IO - 34Embedded Systems Lab./Honam University ARM interrupt procedure zCPU actions: ySave PC. Copy CPSR to SPSR. yForce bits in CPSR to record interrupt. yForce PC to vector. zHandler responsibilities: yRestore proper PC. yRestore CPSR from SPSR. yClear interrupt disable flags.

IO - 35Embedded Systems Lab./Honam University ARM interrupt latency zWorst-case latency to respond to interrupt is 27 cycles: yTwo cycles to synchronize external request. yUp to 20 cycles to complete current instruction. yThree cycles for data abort. yTwo cycles to enter interrupt handling state.

IO - 36Embedded Systems Lab./Honam University SHARC interrupt structure zInterrupts are vectored and prioritized. zPriorities are fixed: reset highest, user SW interrupt 3 lowest. zVectors are also fixed. Vector is offset in vector table. Table starts at 0x20000 in internal memory, 0x40000 in external memory.v

IO - 37Embedded Systems Lab./Honam University SHARC interrupt sequence Start: must be executing or IDLE/IDLE Output appropriate interrupt vector address. 2. Push PC value onto PC stack. 3. Set bit in interrupt latch register. 4. Set IMASKP to current nesting state.

IO - 38Embedded Systems Lab./Honam University SHARC interrupt return Initiated by RTI instruction. 1. Return to address at top of PC stack. 2. Pop PC stack. 3. Pop status stack if appropriate. 4. Clear bits in interrupt latch register and IMASKP.

IO - 39Embedded Systems Lab./Honam University SHARC interrupt performance Three stages of response: y1 cycle: synchronization and latching; y1 cycle: recognition; y2 cycles: brancing to vector. Total latency: 3 cycles. Multiprocessor vector interrupts have 6 cycle latency.

IO - 40Embedded Systems Lab./Honam University Supervisor mode zMay want to provide protective barriers between programs. yAvoid memory corruption. zNeed supervisor mode to manage the various programs. zSHARC does not have a supervisor mode.

IO - 41Embedded Systems Lab./Honam University ARM supervisor mode zUse SWI instruction to enter supervisor mode, similar to subroutine: SWI CODE_1 zSets PC to 0x08. zArgument to SWI is passed to supervisor mode code. zSaves CPSR in SPSR.

IO - 42Embedded Systems Lab./Honam University Exception zException: internally detected error. zExceptions are synchronous with instructions but unpredictable. zBuild exception mechanism on top of interrupt mechanism. zExceptions are usually prioritized and vectorized.

IO - 43Embedded Systems Lab./Honam University Trap zTrap (software interrupt): an exception generated by an instruction. yCall supervisor mode. zARM uses SWI instruction for traps. zSHARC offers three levels of software interrupts. yCalled by setting bits in IRPTL register.

IO - 44Embedded Systems Lab./Honam University Co-processor zCo-processor: added function unit that is called by instruction. yFloating-point units are often structured as co- processors. zARM allows up to 16 designer-selected co- processors. yFloating-point co-processor uses units 1 and 2.