Docsity

Hardware/Software Interfacing: I/O, Interrupts, DMA, and Device Drivers - Prof. G. Quan, Study notes of Computer Science

Partial preview of the text

Download Hardware/Software Interfacing: I/O, Interrupts, DMA, and Device Drivers - Prof. G. Quan and more Study notes Computer Science in PDF only on Docsity!

Hardware/software Interfacing

Interfacing^ Interfacing

z

Program I/O

z

Interrupt I/O

9 Direct Memory Access (DMA) z

Device driver

memory^ memory

- -

mapped I/Omapped I/O

z

Define location for device:

DEV1 EQU 0x1000; device I/O ports

z

Read/write code:

LDR

r1,#DEV

set up device adrs LDR r0,[r1]

read

DEV

LDR

r0,#

set up value to write STR r0,[r1]

write value to device

Peek and poke^ Peek and poke

z

Traditional interfaces:

int peek(char *location)

return *location;

void poke(char *location, char newval)

(*location)

newval;

Address Management^ Address Management

z

Embedded processor design requires you to manage thefollowing:

9 Address map for the peripherals 9 Location of the application code in the memory space — Block RAM — External memory z

Memory requirements for your programs are based onthe following:

9 The amount of memory required for storing the instructions 9 The amount of memory required for storing the data associated with the program

PowerPC Processor^ PowerPC Processor

z

Memory and peripherals

9 PPC405 uses 32-bit addresses z

Special addresses

9 Every PowerPC™ system should have the boot section starting at 0xFFFFFFFC z

Default linker options

9 Program space occupies a contiguous address space from 0xFFFF0000 to 0xFFFFFFFF 9 Stack size: 4 KB 9 Heap size: 4 KB 0xFFFF_FFFC0xFFFF_0000^ 0x0000_ Peripherals PLB/OPB Memory PLB/OPB Memory Reset Address

Exceptions vs. Interrupts^ Exceptions vs. Interrupts

z Exceptions are events detected by the processor that require actionby the system software 9 Unexpected error conditions (e.g., bus error) 9 Programmed to occur (e.g., timed interval) 9 Generated by external devices (e.g., keypad) z Interrupts are automatic control transfers as a result of an exception 9 Execution of the current program is suspended after the currentinstruction 9 Some context info is saved so execution can return to the currentprogram 9 Execution is transferred to the interrupt handler to service the interrupt 9 The interrupt handler must be registered 9 The interrupt must be enabled

Generic interrupt mechanism^ Generic interrupt mechanism

intr? N Y Assume priority selection is handled before thispoint. N ignore Y ack vector? Y Y N timeout? Y bus error call table[vector] intr priority > current priority?

continue execution

Priorities and vectors^ Priorities and vectors

z

Two mechanisms allow us to make interrupts morespecific:

9 Priorities determine what interrupt gets CPU first. 9 Vectors determine what code is called for each type of interrupt. z

Mechanisms are orthogonal: most CPUs provide both.

Interrupt prioritization^ Interrupt prioritization

z

Masking: interrupt with priority lower than current priorityis not recognized until pending interrupt is complete.

z

Non-maskable interrupt (NMI): highest-priority, nevermasked.

9 Often used for power-down.

Arbitration: Daisy^ Arbitration: Daisy

- -

chain arbitrationchain arbitration

z Peripherals connected to each other in daisy-chain manner 9 One peripheral connected to resource, all others connected“upstream” 9 Peripheral’s req flows “downstream” to resource, resource’s ack flows “upstream” to requesting peripheral 9 Closest peripheral has highest priority μP System bus Inta^ Int Peripheral Ack_in Ack_out Req_out Req_in Peripheral Ack_in Ack_out Req_out Req_in Daisy-chain aware peripherals 0

Arbitration: Daisy^ Arbitration: Daisy

- -

chain arbitrationchain arbitration

z

Pros/cons

9 Easy to add/remove peripheral - no system redesignneeded 9 Does not support dynamic priority 9 One broken peripheral can cause loss of access to otherperipherals

Sources of interrupt overhead^ Sources of interrupt overhead

z

Handler execution time.

z

Interrupt mechanism overhead.

z

Register save/restore.

z

Pipeline-related penalties.

z

Cache-related penalties.

Direct memory access (DMA)^ Direct memory access (DMA)

z DMA provides parallelism on bus by controlling transfers without CPU . 9 Microprocessor could handle this with ISR — Storing and restoring microprocessor state inefficient — Regular program must wait 9 DMA controller more efficient — Separate single-purpose processor — Microprocessor relinquishes control of system bus to DMA controller — Microprocessor can meanwhile execute its regular program

No inefficient storing and restoring state due to ISR call - Regular program need not wait unless it requires the system bus

CPU

memory

I/O

DMA