Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Learning Outcomes
Pada akhir pertemuan ini, diharapkan mahasiswa akan mampu :
Mahasiswa dapat membandingkan beberapa metode pengaksesan peralatan I/O dalam sistem komputer ( C4 ) ( No TIK : 7 )
Chapter 4.
Input/Output Organization: I
Processor
Memory
Bus
I/O device 1
I/O de vice n
Address decoder
Control circuits
ST ATUS
SIN
CONTR OL 7 6 5 4
DEN 3
KEN 2 1 0
WAITK
WAITD
Move TestBit Branc h=0 Move TestBit Branch=0 Move Move Compare Branc 0 h Move Call
#LINE,R0 #0,ST TUS A WAITK DA TAIN,R1 #1,ST TUS A WAITD R1,DATA OUT R1,(R0)+ #$0D,R1 WAITK #$0A,DA TA OUT PROCESS
Initialize memory pointer. Test SIN. Wait for character to be entered. Read character. Test SOUT. Wait for displa to becomeready y . Send characterto display . Store characterand adv ance pointer. Chec if Carriage Return. k If not, get anothercharacter. Otherwise, send Line Feed. Call a subroutineto process the input line.
Figure 4.4 A program that reads one line from the keyboard stores it in memory buffer, and echoes it back to the disp
i i +1
Figure 4.6.An equivalent circuit for an open-drain bus used to implement a common interrupt-request line.
Processor
Figure 4.7. Implementation of interrupt priority using individual interrupt-request and acknowledge lines.
Figure 4.7. Implementation of interrupt priority using individual interrupt-request and acknowledge lines.
10
Processor
I NT R
INTA
Dev ice 1
Dev ice 2
Dev icen
I NT R 1
Processor
INTA1 INTR p
Dev ice
Dev ice
Dev ice
Dev ice
11
Main Program
Initialize buffer pointer. Clear end-of-line indicator. Enable keyboard interrupts. Set in terrupt-enable in the PS. bit
In terrupt-serviceroutine MoveMultiple R0-R1, (SP) Move PNTR,R0 MoveByte DATAIN,R1 MoveByte R1,(R0)+ Move R0,PNTR CompareByte #$0D,R1 Branc 0 h RTRN Move #1,EOL BitClear #2,CONTR OL MoveMultiple (SP)+,R0-R1 Return-from-in terrupt Sa e registersR0 and R1 on stac v k. Load addresspointer. Get input characterand store it in memory . Updatepointer. Chec if CarriageReturn. k Indicate end of line. Disable keyb oard interrupts. Restoreregisters R0 and R1.
RTRN
Figure 4.9. Using interrupts to read a line of characters from a keyboard via the registers in Figure 4.3.
12
OSINIT
Set in terrupt v ectors: Time-slice clo c k SCHEDULER Soft w are in terrupt OSSER VICES Keyb oard in terrupts IOData . . . Examine stac k to determine requested op eration. Call appropriate routine. Sa v e program state. Select a runnable pro cess. Restore sa v ed con text of new pro cess. Push new v alues for PS and PC on stac k. Return from in terrupt.
(a) OS initialization, services, and scheduler
IOINIT
Set pro cess status to Blo c ked. Initialize memory buffer address p oin ter and coun ter. Call device driv er to initialize device and enable in terrupts in the device in terface. Return from subroutine. Poll devices to determine source of in terrupt. Call appropriate driv er. If END = 1, then set pro cess status to Runnable. Return from in terrupt.
(b) I/O routines
IOD A T A
KBDINIT KBDD A T A
Enable in terrupts. Return from subroutine. Chec k device status. If ready , then transfer c haracter. If c haracter = CR, then { set END else set END = 0. Return from subroutine.
(c) Keyboard driver
= 1; Disable
in terrupts }
13
7 I
6 F
4 M4
3 M3
2 M2
1 M1
0 M0
14
Fi gure 4.12. Accessi bl e regi sters i n di fferent m odes of the ARM processor.
15
Main
program
Clear EOL flag. Load address of Register D A T AIN. register. Get contents of CONTROL Set bit KEN in register CONTR OL to enable k eyb oard in terrupts. Enable IR Q in terrupts in pro cessor and switc h to user mo de.
irq }
Sa v e R0, R1, and R14 irq on the stack. Load address of register D A T AIN. Get input character. Load pointer v alue. Store character and increment pointer. Up date p oin ter v alue in the memory . Chec k if Carriage Return. If not, restore registers and return. Otherwise get CONTROL register. Clear bit KEN to disable k eyb oard in terrupts. Set EOL flag. Restore registers and return.
Figure 4.13. An ARM interrupt-service routine to read an input line from a keyboard based on Figure 4.9.
16
15 T
13 S
10
4 X
3 N
2 Z
1 V
0 C
Condition Codes
17
Main program MOVE.L CLR ORI.B MOVE . . . READ MOVEM.L MOVEA.L MOVE.B MOVE.B MOVE.L CMPI.B BNE MOVE ANDI.B MOVEM.L RTE #LINE,PNTR EOL #4,CONTR OL #$100,SR Initialize buffer pointer. Clear end-of-line indicator. Set bit KEN. Setprocessorpriority to 1.
In terrupt-serviceroutine A0/D0, (A7) PNTR,A0 DATAIN,D0 D0,(A0)+ A0,PNTR #$0D,D0 RTRN #1,EOL #$FB,CONTR OL (A7)+,A0/D0 Save registers D0 on stac A0, k. Load addresspointer. Get input character. Store it in memory buffer. Updatepointer. Chec if CarriageReturn. k Indicateend of line. Clear bit KEN. Restore registersD0, A0.
RTRN
Figure 4.15. A 68000 interrupt-service routine to read an input line from a keyboard based on Figure 4.9.
18
19
Main program MOV MOV OR STI . . . READ PUSH PUSH MOV MOV MOV INC CMP JNE MOV X OR MOV POP POP IRET EOL,0 BL,4 CONTROL,BL
Set KEN to enable keyb oard in terrupts. Set in terruptflag in processor register.
In terrupt-serviceroutine EAX EBX EAX,PNTR BL,DATAIN [EAX],BL DWORDPTR[EAX] BL,0DH RTRN BL,4 CONTROL,BL EOL,1 EBX EAX Sa e registerEAX on stac v k. Sa e registerEBX on stac v k. Load addresspointer. Get input character. Storecharacter. Incremen PNTR. t Chec if characteris CR. k
RTRN
Clear bit KEN. Set EOL flag. Restore register EBX. Restore register EAX.
Figure 4.17. An interrupt-servicing routine to read one line from a keyboard using interrupts on IA-32 processors.
20
30
IRQ IE
Done R/ W
Starting address
Word count
21
Disk
Disk
22
BG1
BG2
23
Time BR
BG1
BG2
Processor
DMA controller 2
Processor
Figure 4.21. Sequence of signals during transfer of b us mastership for the deices in Figure 4.20. v
Figure 4.21. Sequence of signals during transfer of bus mastership for the devices in Figure 4.20.
24
O.C.
25
26
Learning Outcomes
Pada akhir pertemuan ini, diharapkan mahasiswa akan mampu :
Membandingkan beberapa metode pengaksesan peralatan I/O dalam sistem komputer ( C4 ) ( No TIK : 7 )
27
Chapter 4.
Input/Output Organization: II
28
Data
t0
t1 Bus cy cle
t2
29
Figure 4.24. A detailed timing diagram for the input transfer of Figure 4.23.
30
31
Data
t0
t1
t2 Bus cy cle
t3
t4
t5
32
t0
t1
t2 Bus cy cle
t3
t4
t5
33
Data Address R/W Master -ready Sla ve-ready Input interface DATAIN SIN Valid Data
Processor
34
D0
Q0
D0
Valid
Readdata
35
36
DATAOUT Processor CPU R/W Masteready Slave-ready Output interface Idle SOUT Valid Printer
37
38
D7 D1 D0
Bus D A T AIN
P A7
P A0 SIN Input status CA PB7 D A TA OUT PB0 SOUT Handshak e control CB1 CB2
Sla v eReady
D ATAOUT
My -address RS2 RS1 RS0 R/ W Ready Accept INTR Status and control C1 C2
Re gister select
40
D A T A OUT D7 D7 Q7 Printer data D0 D0 SOUT Read status Load data D1 D0 Q1 Q0 Handshak e control Idle V alid
R/ W Sla v eready A31 Address decoder A1 A0 Clock My-address Respond Go=1 My-address T iming Logic Go
Idle
Figure 4.35. A parallel point interface for the bus of Figure 4.25, with a state-diagram for the timing logic.
41
Time 1 2 3
Clock
Address
R/W
Data
Go
Slave-ready
Figure 4.36. Timing for the output interf in Figure 4.35. ace
42
RS1 RS0 R/W Ready Accept Status and control Recei ing clock v Transmission clock Chip and register select Output shif t re gister Serial output
I NTR
43
Processor
Main memory
Additional memory
USB controller
V ideo
Disk controller CD-R OM controller CDR OM
Disk 1
Disk 2
K eyboard
Game
44
Disk
Printer
Ethernet interface
45
46
47
Targets e xamine ID DB 2
DB 5
DB 6
BSY
SEL
Free
Arbitration
Selection
Figure 4.42. Arbitration and selection on the SCSI bus. Device 6 wins arbitration and selects device2.
48
Hub
Hub
Hub
I/O de vice
I/O de vice
I/O de vice
I/O de vice
I/O de vice
I/O de vice
49
Host computer Root Hub HS Hub A HS F/LS HS F/LS De vice C De vice D - High speed - Full/Lo w speed HS Hub B
50
PID
PID
PID
PID
PID
PID
PID
PID
Bits
8 PID
7 ADDR
(b) Token packet, IN or OUT
4 ENDP
5 CRC16
Bits
8 PID
0 to 8192 D A TA
(c) Data packet
16 CRC16
51
ACK
52
Bits
8 PID
11 Frame number
(a) SOF Packet
5 CRC5
1-ms frame S T3 D T7 D S T3 D
53
BG1
BG2
BGn
BR1
BR2
BRn
54
Table 4.1. Interrupt vector addresses for ARM processor Address Exception (hex) 0 Reset Mode entered
Sup ervisor
4
8 C 10 14 18 1C
Undefinedinstruction
Software interrupt Ab ort during prefetc h Abort during data Reserv ed IRQ FIQ
Undefined
Sup ervisor Abort Abort IRQ FIQ
55
Exception
Saved address* Desired return address PC+4 PC+4 PC+4 PC+8 PC+4 PC+4 PC PC
Return instruction
IRQ
FIQ
PC+4
PC+4
PC
PC
SUBS PC,R14irq,#4
SUBS PC,R14fiq,#4
* PC is the addressof the instruction that causedthe exception. For IR Q and FIQ, it is the addressof the first instruction not executedb ecauseof the interrupt.
56
Name
CLK FRAME# AD C/BE#
Function
A 33-MHz or 66-MHz clock. Sen by the initiator to indicate the duration of a t transaction. 32 address/data lines, which may be optionally increasedto 64. 4 command/b yte-enablelines (8 for a 64-bit bus).
IDSEL#
57
Table 4.4 The SCSI bus signals. Category Data Name DB(0) DB(7) DB(P) BSY SEL C/D MSG Handshak e REQ A CK Direction transfer Other of I/O A TN RST F unction Data lines: Carry one b yte of information during the information transfer phase and iden tify device during arbitration, selection and reselection phases P arit y bit for the data bus Busy: Asserted when the bus is not free Selection: Asserted during selection and reselection Con trol/Data: Asserted during transfer of con trol information (command, status or message) Message: indicates that the information being transferred is a message Request: Asserted b y a target to request a data transfer cycle Ac kno wledge: Asserted b y the initiator when it has completed a data transfer op eration Input/Output: Asserted to indicate an input op eration (relativ e to the initiator) A tten tion: Asserted b y an initiator when it wishes to send a message to a target Reset: Causes all device con trols to disconnect from the bus and assume their start-up state
to
Phase
Information t yp e
58