Professional Documents
Culture Documents
Processor
Memory
Bus
I/O device 1
I/O de vice n
2 cara pengalamatan: Memory mapped I/O: Alamat I/O menempati sebagian dari alamat memory, pada Motorola. I/O mapped I/O atau Seperated I/O: Alamat memory dan I/O terpisah; dibedakan dgn IN dan READ , OUT dan WRITE, digunakan pada Intel.
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 display.
Teknik tranfer melalui I/O I/O terprogram(programmed I/O): I/O terjadi dibawah kontrol langsung prosesor melalui program. Prosesor menunggu sampai operasi selesai. Interrupt driven: program mengeluarkan perintah I/O, kemudian melanjutkan untuk mengeksekusi yg lain,kalau I/O siap akan menginterusi.Prosesor bertanggung jawab, tapi tidak terikat terus. DMA: Direct Memory Access, I/O dan memory saling bertukar data tanpa melibatkan prosesor.
i i +1
Figure 4.6.An equivalent circuit for an open-drain bus used to implement a common interrupt-request line.
Figure 4.7. Implementation of interrupt priority using individual interrupt-request and acknowledge lines.
I NTR1
Processor
INTA1 INTR p
Dev ice
Dev ice
Dev ice
Dev ice
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.
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 }
15 T
13 S
10
4 X
3 N
2 Z
1 V
0 C
Condition Codes
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.
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.
Disk
Disk
BG1
BG2
penghubung antara perangkat I/O dgn bus komputer. Satu sisi memiliki jalur data ,alamat dan kontrol; sisi lain memiliki jalur data dan kontrol untuk mentransfer data ke perangkat I/O (port) Port paralel: mentransfer data dalam bentuk sejumlah bit 8 atau 16 secara simultan. Port serial: mengirim dan menerima data satu bit tiap satu waktu.
Data Address R/W Master -ready Sla ve-ready Input interface DATAIN SIN Valid Data
Processor
DATAOUT Processor CPU R/W Masteready Slave-ready Output interface Idle SOUT Valid Printer
Standar bus yang banyak digunakan. Bus Peripheral Component Interconnect (PCI).
Dikembangkan sebagai low cost, processor dependent,mengikuti perkembangan bandwidth bus untuk disk high speed, perangkat grafik, video dan sistem multiprosesor. high speed,untuk menghubungkan perangkat tambahan didalam atau diluar komputer seperti disk dan video display. serial ke peralatan seperti keyboard,kontrol game sampai internet.; kecepatan operasi: low speed(1.5Mbit/det), fullspeed(12Mbit/det), high speed (480Mbit/det)
Processor
Main memory
Additional memory
USB controller
V ideo
Disk controller CD-R OM controller CDR OM
Disk 1
Disk 2
K eyboard
Game
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
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