Driver

Device Controller

  • A device controller is in charge of the devices. 
  • It maintains 
    • some local buffer
    • and a set of special purpose registers
  • It is responsible for moving the data between the peripheral devices that it is controls and its local buffer storage.

Device Driver

  • The operating system has a device driver for each device controller
  • This device driver understands the device controller and presents a uniform interface to the device to the rest of the operating system

Interrupt Driver IO

  • Procedure
    • The device driver loads the appropriate registers within the device controller.
    • The device controller, in turn, examines the contents of these registers to determine what action to take.
    • The controller starts the transfer of the data from the device to its local buffer.
    • Once the transfer of data is complete, the device controller informs the device driver via an interrupt that it has finished its operation.
    • The device driver then returns control to the operating system, possibly returning the data or a pointer to the data if the operation was a read.
  • Drawback
    • High overhead when used for bulk data movement such as disk I/O.
    • To solve this problem, directed memory access (DMA) is used.

Directed Memory Access (DMA)

  • After setting up buffer, pointers and counters for the I/O device, the device controller transfers an entire block of data directly to or from its own buffer storage to the memory, with no intervention by the CPU.

Interrupt

Introduction


The occurrence of an event is usually signaled by an interrupt from either the hardware or the software.

  • Hardware
    • Hardware may trigger an interrupt at any time by sending signal to the CPU, usually by way of the system bus.
  • Software (called Trap)
    • Software may trigger an interrupt by executing a special operation called a system call.
    • The Trap could be, e.g., division by zero, or invalid memory access

Return Address

  • Before the interrupt
    • Before enter the interrupt, the return address will be stored on the system stack.
  • After the interrupt
    • After the interrupt is serviced, the saved return address is loaded into the program counter, and the interrupted computation resumes s through the interrupt had not occurred.

Bootstrap

Bootstrap

When a computer start running, i.e., when it is powered up or rebooted. it needs to have an initial program to run.

This initial program, or bootstrap program, tends to be simple. Typically, it is stored in read-only memory (ROM) or eletrically erasable programmable read-only memory (EEPROM), known by the general term firmware, within the computer hardware.