1 COMP541 Interrupts, DMA, Serial I/O Montek Singh April 18, 2012.

Slides:



Advertisements
Similar presentations
CPU Structure and Function
Advertisements

I/O Organization popo.
Dr. Rabie A. Ramadan Al-Azhar University Lecture 3
Chapter 10 Input/Output Organization. Connections between a CPU and an I/O device Types of bus (Figure 10.1) –Address bus –Data bus –Control bus.
Interrupts Chapter 8 – pp Chapter 10 – pp Appendix A – pp 537 &
1/1/ / faculty of Electrical Engineering eindhoven university of technology Architectures of Digital Information Systems Part 1: Interrupts and DMA dr.ir.
Processor System Architecture
1 COMP541 Wrap Up Montek Singh Nov 24, Conclusion of this course  What did we learn this semester? Combinational logic Combinational logic Sequential.
1/1/ / faculty of Electrical Engineering eindhoven university of technology Introduction Part 3: Input/output and co-processors dr.ir. A.C. Verschueren.
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.
6-1 I/O Methods I/O – Transfer of data between memory of the system and the I/O device Most devices operate asynchronously from the CPU Most methods involve.
Chapter 7 Interupts DMA Channels Context Switching.
Pipeline Exceptions & ControlCSCE430/830 Pipeline: Exceptions & Control CSCE430/830 Computer Architecture Lecturer: Prof. Hong Jiang Courtesy of Yifeng.
University College Cork IRELAND Hardware Concepts An understanding of computer hardware is a vital prerequisite for the study of operating systems.
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.
Hardware Support for Operating Systems Sunny Gleason Vivek Uppal COM S 414
TECH CH03 System Buses Computer Components Computer Function
Computer System Structures memory memory controller disk controller disk controller printer controller printer controller tape-drive controller tape-drive.
1 COMP541 Interrupts, DMA, Serial I/O Montek Singh April 24, 2007.
1 COMP541 Interrupts, DMA, Serial I/O Montek Singh Nov 19, 2014.
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.
I/O Tanenbaum, ch. 5 p. 329 – 427 Silberschatz, ch. 13 p
What are Exception and Interrupts? MIPS terminology Exception: any unexpected change in the internal control flow – Invoking an operating system service.
CS-334: Computer Architecture
COMP201 Computer Systems Exceptions and Interrupts.
3/11/2002CSE Input/Output Input/Output Control Datapath Memory Processor Input Output Memory Input Output Network Control Datapath Processor.
Interrupts. What Are Interrupts? Interrupts alter a program’s flow of control  Behavior is similar to a procedure call »Some significant differences.
CPU BASICS, THE BUS, CLOCKS, I/O SUBSYSTEM Philip Chan.
MICROPROCESSOR INPUT/OUTPUT
Interrupts and DMA CSCI The Role of the Operating System in Performing I/O Two main jobs of a computer are: –Processing –Performing I/O manage and.
Contact Information Office: 225 Neville Hall Office Hours: Monday and Wednesday 12:00-1:00 and by appointment.
CHAPTER 3 TOP LEVEL VIEW OF COMPUTER FUNCTION AND INTERCONNECTION
I/O Example: Disk Drives To access data: — seek: position head over the proper track (8 to 20 ms. avg.) — rotational latency: wait for desired sector (.5.
Top Level View of Computer Function and Interconnection.
DMA Versus Polling or Interrupt Driven I/O
I/O management is a major component of operating system design and operation Important aspect of computer operation I/O devices vary greatly Various methods.
EEE440 Computer Architecture
Fall EE 333 Lillevik 333f06-l21 University of Portland School of Engineering Computer Organization Lecture 21 Subroutines, stack Interrupts, service.
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 CSE451 Architectural Supports for Operating Systems Autumn 2002 Gary Kimura Lecture #2 October 2, 2002.
Operating Systems 1 K. Salah Module 1.2: Fundamental Concepts Interrupts System Calls.
Chapter 13 – I/O Systems (Pgs ). Devices  Two conflicting properties A. Growing uniformity in interfaces (both h/w and s/w): e.g., USB, TWAIN.
Dr Mohamed Menacer College of Computer Science and Engineering, Taibah University CE-321: Computer.
1 Lecture 1: Computer System Structures We go over the aspects of computer architecture relevant to OS design  overview  input and output (I/O) organization.
Interrupt driven I/O Computer Organization and Assembly Language: Module 12.
Copyright © 2007 by Curt Hill Interrupts How the system responds.
1 COMP541 Interrupts, DMA, Serial I/O Montek Singh April 13, 2010.
بسم الله الرحمن الرحيم MEMORY AND I/O.
Chapter 3 System Buses.  Hardwired systems are inflexible  General purpose hardware can do different tasks, given correct control signals  Instead.
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.
1 COMP541 Wrap Up Montek Singh Apr 24, Conclusion of this course  What did we learn this semester? Combinational logic Combinational logic Sequential.
Dr. Michael Nasief Lecture 2
Architectural Support for OS
Architectural Support for OS
Chapter 13: I/O Systems.
CMSC 611: Advanced Computer Architecture
Presentation transcript:

1 COMP541 Interrupts, DMA, Serial I/O Montek Singh April 18, 2012

2Interrupts  Two main kinds  Internal Error when executing an instruction Error when executing an instruction  Floating point exception  Virtual memory page fault  Trying to access protected memory  Invalid opcode! System call requested by software System call requested by software  To request OS services  External I/O I/O

3Internal  More complicated because two possible actions may abort instruction may abort instruction  access to protected memory not allowed or, OS corrects the situation and restarts instruction or, OS corrects the situation and restarts instruction  e.g., virtual memory page fault  Question: What happens for arithmetic overflow/divide-by-0? What happens for arithmetic overflow/divide-by-0?

4 When Interrupt Occurs  Interrupt enable register Sometimes levels of interrupts individually enabled/disabled Sometimes levels of interrupts individually enabled/disabled  PC is changed to new location One or more interrupt locations stored One or more interrupt locations stored  “vectored interrupts” Or a fixed location Or a fixed location  example: MIPS (e.g., 0xC )  Old PC saved to register or stack Many machines have stack pointer Many machines have stack pointer

5Registers  Sometimes registers saved by hardware Some machines have one or more sets of registers Some machines have one or more sets of registers  Often: software must save registers Push them onto stack Push them onto stack  Return from interrupt Some CPUs provide a special instruction to return from interrupt Some CPUs provide a special instruction to return from interrupt  “rfi” or “iret” Others use the standard procedure return instruction Others use the standard procedure return instruction  jr, ret, etc. Restore registers before returning Restore registers before returning

6 Cause of Interrupt  Need way to determine what caused interrupt Note it can be more than one thing Note it can be more than one thing  Vectored Interrupts Different types cause branches to different locations Different types cause branches to different locations Sometimes prioritized Sometimes prioritized  Register to store cause “Cause” register “Cause” register

7 Supervisory Mode  Modern computers have user mode and one or more “supervisory modes”  User mode restricted Can’t write to many system registers, such as interrupt enable Can’t write to many system registers, such as interrupt enable Can’t write to some parts of memory Can’t write to some parts of memory Usually I/O restricted Usually I/O restricted  Interrupts cause switch to supervisory mode In this mode, software has access to several privileged parts of the system In this mode, software has access to several privileged parts of the system  e.g.: kernel memory, IE register, etc. Question: Which interrupts? Question: Which interrupts?

Some Interrupt Hardware  An example implementation Interrupts ORed Interrupts ORed Response if IE and at end of instruction Response if IE and at end of instruction Ack interrupt Ack interrupt Vector address to PC Vector address to PC Save PC on stack Save PC on stack 8

9 Potential Microcode The following is a typical sequence of actions taken by the CPU upon triggering of an interrupt: SP  SP – 1 M[SP]  PC SP  SP – 1 M[SP]  PSR –PSR is processor status register EI  0 INTACK  1 PC  IVAD

10 Return Similar  Very similar to return from procedure  Some additional actions PSR holds IE bit PSR holds IE bit Restoring PSR turns interrupts on Restoring PSR turns interrupts on

Exception (from Patterson Hennessey, multicycle MIPS) 11 Just two causes PC – 4 stored Branch to fixed addr Undefined instruction and arithmetic overflow

12 Restarting Instruction?  Imagine the interrupt (exception) was a page fault Need to get the page, and then rerun the instruction Need to get the page, and then rerun the instruction  Keeping instructions simple/short helps out! Otherwise may need to save some intermediate state Otherwise may need to save some intermediate state  Imagine block-move instruction such as the Pentium MOVS –moves/copies an entire string (of variable length) in a single instruction!

Types of I/O Programmed I/O Direct Memory Access (DMA) 13

14 Direct Memory Access (DMA)  Programmed I/O is when CPU reads/writes every word Problem: overhead is high; nothing else getting done on CPU Problem: overhead is high; nothing else getting done on CPU Especially for mass-storage devices like disk Especially for mass-storage devices like disk  DMA: Let device controller read/write directly to memory CPU goes about its usual business of executing other instructions CPU goes about its usual business of executing other instructions  typically cannot access memory while DMA is going on! Challenges? Challenges?

15Protocol  DMA protocol DMA device takes over main bus DMA device takes over main bus Becomes bus master Becomes bus master Asserts addresses Asserts addresses Basically interfaces to memory or memory controller Basically interfaces to memory or memory controller

How?  DMA device requests bus (assert BR)  CPU grants request (assert BG)  CPU takes its signals to Hi-Z now DMA can use its signals to connect with memory now DMA can use its signals to connect with memory no conflict with CPU’s signals (they are floating) no conflict with CPU’s signals (they are floating) 16

Transfer Modes  Several types of transfer modes Continuous: DMA controller transfers all data (say a disk sector) at once Continuous: DMA controller transfers all data (say a disk sector) at once  As many memory cycles as data Burst: DMA controller cycle steals, takes a cycle at end of every CPU instruction Burst: DMA controller cycle steals, takes a cycle at end of every CPU instruction  Note: today’s processors are more sophisticated there is a memory controller (“Northbridge”) there is a memory controller (“Northbridge”) sits in-between CPU and memory sits in-between CPU and memory Why? Memories are more complex, caches, etc. Why? Memories are more complex, caches, etc. 17

18 End of DMA  Controller needs to inform CPU De-assert BR De-assert BR Then CPU lowers BG and proceeds Then CPU lowers BG and proceeds

19 DMA Controller  Needs typical I/O signals Interrupt request Interrupt request Status of device Status of device  Also needs controls for DMA transfer Memory address Memory address Word count Word count

20 Block Diagram

21 Typical Driver Interface  Software drivers Set the memory address Set the memory address Set word count Set word count Assert “GO” (usually bit in control word) Assert “GO” (usually bit in control word) DMA controller starts copying … DMA controller starts copying … … and requests interrupt when transfer complete … and requests interrupt when transfer complete

Trends in Communications  Older bus standards, such as ISA and PCI, were parallel (conventional “bus”)  Newer (PCI Express) use serial channels (lanes) So slots for slower devices can be x1 So slots for slower devices can be x1 Slots for devices such as GPUs can be x16 (max x32 in spec) Slots for devices such as GPUs can be x16 (max x32 in spec) lane PCI-E (below) 1 lane (right)

Disks  Change from ATA/IDE to SATA IDE had 16 data channels IDE had 16 data channels SATA has 2 twisted pair (xmit and recv) SATA has 2 twisted pair (xmit and recv) 23

24RS-232/UART  Called “Asynchronous” But both sides have precise clocks But both sides have precise clocks Agree on speed Agree on speed Receiver syncs during start bit Receiver syncs during start bit

25USB  One master The PC The PC  Idea was to have thin cables and plug and play  Specs include hardware and software We only cover hardware We only cover hardware

26 USB – Packet serial I/O  Four wires total  +5v and GND  Two signal wires Twisted pair Twisted pair Differential signaling Differential signaling Differential 1 is D+ > 2.8v and D- 2.8v and D- < 0.3v Differential 0 is opposite Differential 0 is opposite Also a single-ended zero when D+ & D- low (end of packet, reset, disconnect) Also a single-ended zero when D+ & D- low (end of packet, reset, disconnect)

27Speed  Three speeds High is 480 Mb/s High is 480 Mb/s Full is 12 Mb/s Full is 12 Mb/s Low is 1.5 Mb/s Low is 1.5 Mb/s New Super Speed, 5Gb/s!! New Super Speed, 5Gb/s!!  Pull-up indicates full/low  High speed starts as full, then handshakes and transitions  High and low speeds interpret zeros and ones inverted.

28Coding  NRZI Non-Return to Zero Inverted Non-Return to Zero Inverted Transition if sending 0, none if sending 1 Transition if sending 0, none if sending 1  Bit stuffing Since a string of 1s causes no transitions, synchronization may be lost Since a string of 1s causes no transitions, synchronization may be lost A zero is stuffed in after six consecutive ones A zero is stuffed in after six consecutive ones  Sync field Each packet starts with a sync Each packet starts with a sync 8 bits: bits:

29Packets  Won’t go into details

Summary  Many types of I/O memory-mapped is most common memory-mapped is most common  different devices given different address ranges many different device protocols many different device protocols  PS/2: keyboard, mice  RS-232: serial ports  USB: most common today  also Firewire, Thunderbolt, …  ethernet also monitors, displays also monitors, displays  we did VGA (other higher resolutions also possible)  DVI is most common today 30

Conclusion of this course  What did we learn this semester? Combinational logic Combinational logic Sequential logic, finite-state machines Sequential logic, finite-state machines Basic building blocks Basic building blocks  registers, counters  adders, subtractors, ALUs  memories, and memory-mapped I/O  datapaths Verilog Verilog  hierarchical design  display interfaces, input devices, debouncing CPUs CPUs  single-cycle, multicycle  pipelining, hazards, forwarding, stalling  Built an entire MIPS CPU! 31

Some Tips for your final project  Use MARS to assemble your program! use:.text 0x use:.text 0x  then simply copy all the machine code into your project  SLT if you want to implement SLT, talk to me! if you want to implement SLT, talk to me!  BEQ, BNE make sure “delayed branching” is off in MARS make sure “delayed branching” is off in MARS  J  JAL, JR not necessary, but could simplify your code not necessary, but could simplify your code  if you want to use procedure calls PC=PC+4 (not 8) because our MIPS is unpipelined, no delayed jumps PC=PC+4 (not 8) because our MIPS is unpipelined, no delayed jumps 32

Timeline  April 19 (Thu): Test #1 graded, ready for pickup Test #1 graded, ready for pickup  April 20 (Fri): First set of final project demos First set of final project demos HW #2 due HW #2 due Test #2 (take home) released Test #2 (take home) released  April 23 (Mon): Tentative grades for those already demo’ed Tentative grades for those already demo’ed Second set of final project demos Second set of final project demos Hw #2 due (last chance) Hw #2 due (last chance)  April 25 (Wed): Tentative grades for those already demo’ed Tentative grades for those already demo’ed Last chance to demo final project Last chance to demo final project 33