5. inputoutput

27
05/17/22 445_21 1 Input / Output

Upload: maadurim

Post on 04-Jun-2017

222 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: 5. InputOutput

05/03/23 445_21 1

Input / Output

Page 2: 5. InputOutput

05/03/23 445_21 2

Program-Controlled I/O

Keyboard Buffer Register

DATAIN Status Flag

SIN

Display Buffer Register

DATAOUT Status Flag

SOUT

Page 3: 5. InputOutput

05/03/23 445_21 3

Program-Controlled I/O

Bus

Processor

Keyboard

DATAIN

SIN

Display

DATAOUT

SOUT

Page 4: 5. InputOutput

05/03/23 445_21 4

Memory-Mapped I/O

Memory addresses used to refer to peripheral device buffer registers DATAIN DATAOUT

Device status registers INSTATUS

SIN OUTSTATUS

SOUT

Page 5: 5. InputOutput

05/03/23 445_21 5

Program-Controlled I/O

Move #LOC,R0READ TestBit #3,INSTATUS Branch=0 READ MoveByte DATAIN,(R0)ECHO TestBit #3,OUTSTATUS Branch=0 ECHO MoveByte (R0),DATAOUT Compare #CR,(R0)+ Branch≠0 READ

Page 6: 5. InputOutput

05/03/23 445_21 6

I/O Interface (Input)

Address LinesData LinesControl Lines

Bus

AddressDecoder

ControlCircuits

Data & StatusRegisters I/O Interface

Input Device

Page 7: 5. InputOutput

05/03/23 445_21 7

I/O Interface

STATUS DIRQ KIRQ SOUT SIN

CONTROL

DATAOUT

DATAIN

DEN KEN

Page 8: 5. InputOutput

05/03/23 445_21 8

Interrupts

Interrupt-request line Interrupt-request signal Interrupt-acknowledge signal

Interrupt-service routine Similar to subroutine May have no relationship to program being executed at

time of interrupt Program info must be saved Interrupt latency

Page 9: 5. InputOutput

05/03/23 445_21 9

Handling Interrupts

Many situations where the processor should ignore interrupt requests Interrupt-disable Interrupt-enable

Typical scenario Device raises interrupt request Processor interrupts program being executed Processor disables interrupts and acknowledges interrupt Interrupt-service routine executed Interrupts enabled and program execution resumed

Page 10: 5. InputOutput

05/03/23 445_21 10

Handling Multiple Devices

How can the processor recognize the device requesting an interrupt?

How can the processor obtain the starting address of the appropriate interrupt-service routine?

Should a device be allowed to interrupt the processor while another interrupt is being serviced?

How should two or more simultaneous interrupt requests be handled?

Page 11: 5. InputOutput

05/03/23 445_21 11

Handling Multiple Devices

Polling Interrupt-service routine checks IRQ bits

DIRQ, KIRQ Appropriate subroutine called to provide requested service

Vectored Interrupts Device requesting interrupt may identify itself directly to

the processor Special code over bus Code represents part of address for interrupt-service

routine Interrupt vector

Page 12: 5. InputOutput

05/03/23 445_21 12

Interrupt Priority

Multi-level priority organization During execution of interrupt-service routine

Disable interrupts from devices at the same level priority or lower

Continue to accept interrupt requests from higher priority devices

Privileged instructions executed in supervisor mode Controlling device requests

Interrupt-enable KEN, DEN

Page 13: 5. InputOutput

05/03/23 445_21 13

Interrupt Priority Schemes

Proc

esso

r

Device 1 Device 2 Device p

Priority arbitrationcircuit

...INTA1

INTR1 INTRp

INTApINTA2

INTR2Pr

oces

sor

Device 1 Device 2 Device p...INTA

INTR

Page 14: 5. InputOutput

05/03/23 445_21 14

Interrupt Priority Groups

Proc

esso

r

Device Device

Priority arbitrationcircuit

INTA1

INTR1

INTRp

INTAp

.

.

.

Device Device...

Page 15: 5. InputOutput

05/03/23 445_21 15

Exceptions

Any event that causes an interrupt Recovery from errors

Illegal instructions Divide by zero

Debugging Trace mode Breakpoints

Page 16: 5. InputOutput

05/03/23 445_21 16

Operating Systems

Coordinate all activities within a computer Make extensive use of interrupts

Perform (coordinate) I/O Communicate with user programs Control execution of user programs

Assign priorities Switch between programs (multi-tasking) Implement security and protection

Page 17: 5. InputOutput

05/03/23 445_21 17

68000 Interrupt Structure

8 interrupt priority levels 7 highest (non-maskable interrupt)

Priority groups (similar to Fig 4.8b) Interrupt saves PC and PS to processor stack 256 interrupt vectors

32-bit address of interrupt-service routine

T S X N Z V CPS

Trace

Supervisor

InterruptPriority

ConditionCodes

15 13 10 8 4 3 2 1 0

Page 18: 5. InputOutput

05/03/23 445_21 18

Direct Memory Access (DMA)

Polling or interrupt driven I/O incurs considerable overhead Multiple program instructions Saving program state Incrementing memory addresses Keeping track of word count

DMA Transfer large blocks of data directly between an

external device and memory Without continuous intervention by the processor

Page 19: 5. InputOutput

05/03/23 445_21 19

DMA Controller

Part of the I/O device interface DMA Channels

Performs functions that would normally be carried out by the processor Provides memory address Bus signals that control transfer Keeps track of number of transfers

Under control of the processor

Page 20: 5. InputOutput

05/03/23 445_21 20

DMA Transfer

Processor sends Starting address Number of words in block Direction of transfer

DMA controller Performs requested operation Interrupts processor when done

Page 21: 5. InputOutput

05/03/23 445_21 21

Example System

Processor MainMemory

Disk/DMAController

DMAController Printer Keyboard

Disk Disk NetworkInterface

System Bus

Page 22: 5. InputOutput

05/03/23 445_21 22

Access Priority

DMA devices given higher priority than processor DMA controller “steals” cycles from processor

Top priority given to high-speed peripherals Disk Network interface Graphics display

DMA controller can be given exclusive access to transfer block of data without interruption Block (burst) mode

Page 23: 5. InputOutput

05/03/23 445_21 23

Data Buffers

Most DMA controllers incorporate data storage buffers

Network interface example DMA controller reads block of data from main memory

Burst mode Stored in data buffer Data transmitted from buffer over the network

Network speed

Page 24: 5. InputOutput

05/03/23 445_21 24

Bus Arbitration

Resolves conflicts when multiple controllers try to use the bus at the same time

Bus Master Device that currently has use of the bus

Centralized arbitration Single entity controls bus access

Distributed arbitration All devices participate in selection of next bus master

Page 25: 5. InputOutput

05/03/23 445_21 25

Centralized Arbitration

Daisy Chain Bus-Request (BR) Bus-Grant (BGi) Bus-Busy (BBSY)

Processor

DMAController

1

DMAController

2BG1 BG2

BR

BBSY

Page 26: 5. InputOutput

05/03/23 445_21 26

Centralized Arbitration

Page 27: 5. InputOutput

05/03/23 445_21 27

Questions?