Drivers Flashcards
What do device drivers do?
Exchange high-level messages with userspace.
Communication with hardware via low-level instructions
What high-level messages fo drivers exchange with userspace?
Specific system calls.
IO Control mechanisms
File and memory mapped regions
What do drivers communicate with HW?
HW devices send messages via HW interrupts
What are the elements of a modern device drive?
Userspace should not talk to hardware directly. Device drivers are parts of the kernel which do this, proving an interface for userspace processes to access HW functionality.
Why would you move drivers to userspace?
Driver crash will not crash the system (Microkernel approach)
However there is a trade-off between protection and performance.
How are devices controlled?
By changing the values of their registers, called I/O registers.
What is memory-mapped I/O and how does it work?
Map registers into memory address region, controllers listen for specific addresses on address bus. Controlling devices amounts to writing to memory.
What is port-mapped I/O and how does it work?
Seperate instructions for writing to I/O registers, using port number and value as parameters.
What are the UNIX device types?
- Character devices
- Block devices
- Network devices
What are the elements of a character device? (UNIX)
Direct, unbuffered access
Used for real-time devices: Sound, graphics, printing
What are the elements of a block device? (UNIX)
Buffered access (read/write blocks of arbitrary size) Used for storage
What are the elements of a network device? (UNIX)
Packet-based, use specific system calls
Built on top of socket abstraction
How does UNIX treat devices?
Same as files. Communication with the driver is by reading/writing to the files in /dev
Init and exit can be used to load/unload modules.
How can you create a device file? (UNIX)
Manually (mknod) or automatically.
name follows convention:
Disk drive: hdX, sdX, fdX
Terminals: ttyX
ports: parport, lp, ttyS
major number identifies drive, minor number identifies particular device of this type.
How can actions that are driver specific be executed?
ioctl syscall, userspace programs must understand some HW detail.