IO SPARC - PowerPoint PPT Presentation

1 / 11
About This Presentation
Title:

IO SPARC

Description:

CPU can do something else when the I/O controller and devices are busy ... on the processor state to allow the interrupted program to be resumed later ... – PowerPoint PPT presentation

Number of Views:19
Avg rating:3.0/5.0
Slides: 12
Provided by: mah138
Category:
Tags: sparc | resumed

less

Transcript and Presenter's Notes

Title: IO SPARC


1
I/O SPARC
2
  • A SPARC program in user mode communicates with
    I/O devices through OS
  • To do I/O a program makes a system call

3
System Components
CPU
bus
Controller Registers - data register - status
register - command register
Memory I/O buffer
Controller Data Status command
Controller Data Status command
  • Access to Controller Registers
  • memory-mapped
  • Isolated I/O

Device
Device
4
Interrupt-driven I/O
  • CPU can do something else when the I/O controller
    and devices are busy
  • Controller sends an external interrupt to signal
    that the device is ready
  • Currently executing program stops
  • processor enters the OS
  • Start executing an interrupt service routine
    (ISR)
  • Software routine
  • The instructions in ISR are fetched, decoded, and
    executed

5
Interrupts
  • External Interrupt
  • Controller sends an external interrupt to signal
    that the device is ready
  • Internal Interrupt
  • Divide by zero, unaligned memory access

6
Trap
  • To protect OS, calls to OS must be made by a
    special instruction that causes an interrupt
  • Trap (ta, te, )in SPARC
  • an interrupt must save a return address and
    information on the processor state to allow the
    interrupted program to be resumed later
  • save the program counter (PC)
  • save the processor state register (PSR)

7
(No Transcript)
8
  • trap sequence
  • 1. ET bit in PSR cleared so that further traps
    are disabled
  • 2. S bit saved into PS bit and S bit set gt
    places processor in supervisor mode
  • 3. CWP incremented to give trap handler new set
    of local registers (you can only use the eight
    local registers since the out registers are not
    guaranteed to be mapped to physical registers w/o
    window overflow processing also the in registers
    and global registers might be in use by
    interrupted process)
  • 4. pc, and npc are saved into l1 and l2
  • 5. trap type field placed into TBR and pc TBR,
    npc TBR4

9
(No Transcript)
10
(No Transcript)
11
Trap Example
  • Opening and printing a file
  • define(READ, 3)
  • define(OPEN, 5)
  • ...
  • set filename,o0
  • clr o1
  • clr o2
  • mov OPEN,g1
  • ta 0 ! fd
    open( char filename, o_flag, mode )
  • mov o0,fd_r
  • cmp fd_r,-1 ! if -1
    returned then file was not opened ...
  • mov fd_r,o0
  • set buf,o1
  • mov 1,o2
  • mov READ,g1
  • ta 0 !
    n_read read( fd, buf, 1 )
  • cmp o0,0 ! if 0
    returned then there are no characters
  • be done ! left in
    the file gt EOF
Write a Comment
User Comments (0)
About PowerShow.com