I/O devices and interfaces
BUS
정의
shared communication channel
bottleneck이 될 수 있다 by physical factors (선의 길이, 연결의 수 등)
Bus Types
Processor - Memory buses
short & high speed
I/O buses
longer, multiple connections
Bus Signals and Synchronization
- Data lines : address와 data 운반
- Cahce miss 났을 때
- Control lines : metadata
- Synchronous : bus clock 사용
- Asynchronous : handshaking
Example
AMBA Bus Architecture

x86 PC IO System

- DDR2 : Memory
- Serial ATA : Disk
- LPC, USB : keyboard / mouse (long dist)
- PCIe : for High performance (short dist)
I/O addressing
I/O Management
- multiple program이 I/O resource 공유 -> scheduling 필요!
- I/O가 asynchronous interrupt 발생 -> interrupt처럼
- small interrupt handling routines
- I/O direct로 handle해야함
I/O Commands
Registers
S/W와 H/W의 interface 역할
위치 : Memory
Access:
RISC (MIPS / ARM): SW interrupt -> mode switch -> lw / sw
CISC (x86) : assembly로 access

- Command registers : 각 비트가 특정 명령 나타냄
- Status registers : 각 비트가 특정 상태 나타냄
- Data registers : data 내용..?

Interrupt vs Polling
Polling
주기적으로 I/O status register 확인
특징
- small / low performance real-time 시스템에 적합
- cycle이 wasted되는 단점
Interrupts
암것도 안하다가 interrupt 받으면 handler 구동
특징
- exception처럼 동작
- priority에 따라 동작
Interrupt handling in ARM
Modes
- Undefined
- IRQ
- FIQ
- Abort
- SVC
Mechanism
- CSPR(Current Processor Status Register)이 해당 mode에 맞는 SPSR(Saved Program Status Register)에 저장된다.
(context switch overhead 최소화 하기 위해 tmp에 저장해두는 느낌)
- 현재 PC를 해당 mode에 맞는 LR(Link Register)에 저장
- CSPR의 mode bit을 수정하고, 해당 mode에 진입한다
- exception handler의 address를 PC로 가져와서 vector table통해 jump
<vector table>

Interrupt Type
SWI (Internal interrupt)
Software interrupt (not by I/O devices)
IRQ (External interrupt)
used for general purposed interrupts
FIQ (External interrupt)
fast response를 위한 interrupt (e.g. DMA)
External interrupt 발생시 일어나는 일
- interrupt register가 할당됨
- interrupt register들이 IRQ, FIQ signal을 생성하기 위해 hirearchically하게 만들어짐.
- IRQ,FIQ 신호가 들어오면, CPU는 다른 Interrupt 차단
IRQ / FIQ 모드로 CPU 전환
vector table로 jump
- top half에 중요한거 처리, bottom half에 덜 중요한거 처리하고 원복
Direct Memory Access

Youtube Streaming하는데, CPU가 관여하고 있으면 다른 작업을 못함
-> DMA 필요
Serial Protocols
Single Data Wire로 주고받음
Firewire
USB
Parallel protocols
multiple bit을 parallel하게
PCI bus
ARM bus
Chip to Chip Communication
UART(Serial communications)

- stands for Universal Asynchronous Receiver Transmitter
- Two wire communicaiton
SPI (Serial-Peripheral Interface)

- MOSI : Master-Out-Slave-In
- MISO : Master-In-Slave-Out
- SCK : Serial Clock
- CE /CS : Chip Enable or Chip Select (for one to many communication)


특징
High Data rates
Micro controller, Sensor에서 사용
I2C
Example
