week 10 linux device drivers Flashcards
to learn
what is a device driver
View from user space:
Have special file in /dev associated with it, together with five
systems calls:
open: make device available
read: read from device
write: write to device
ioctl: Perform operations on device (optional)
close: make device unavailable
what are the five systems calls in a device driver.
open
read
write
ioctl
close
what is the open system call
make device available
what is the read system call
read from device
what is the write system call
write to device
what is the ioctl system call
Perform operations on device (optional)
what is the close system call
makes device unavailable
for device drivers there is one optional system call, what is it?
ioctl -> Perform operations on device (optional)
how can you list the the available options of a file in linux on the kernel side
linux/fs.h lists all available operations on files
Each file may have functions associated with it which are called
when corresponding system calls are made
what does kernel also keep track of
Physical dependencies between devices ,Example:
devices connected to a USB-hub
Buses: Channels between processor and one or more devices.
Can be either physical (eg pci, usb), or logical
Classes: Sets of devices of the same type, eg keyboards, mice
what is physical dependencies between devices in a kernel
. Example:
devices connected to a USB-hub
what are buses in a kernel
Channels between processor and one or more devices.
what are classes in a kernel
Classes: Sets of devices of the same type, eg keyboards, mice
what are the the types of buses in a a kernel
Can be either physical (eg pci, usb), or logical
how to handle interrupts in a device driver
Normal cycle of interrupt handling for devices: Device sends interrupt
CPU selects appropriate interrupt handler
Interrupt handler processes interrupt
Two important tasks to be done:
Data to be transferred to/from device
Waking up processes which wait for data transfer to be finished Interrupt handler clears interrupt bit of device
Necessary for next interrupt to arrive
describe the 2 halves of interrupt processing:
Interrupt processing time must be as short as possible
Data transfer fast, rest of processing slow
⇒ Separate interrupt processing in two halves:
Top Half is called directly by interrupt handler
Only transfers data between device and appropriate kernel
buffer and schedules software interrupt to start Bottom half
Bottom half still runs in interrupt context and does the rest of
the processing (eg working through the protocol stack, and
waking up processes)
describe top half in interrupt processing
Top Half is called directly by interrupt handler
Only transfers data between device and appropriate kernel
buffer and schedules software interrupt to start Bottom half
describe bottom half in interrupt processing
Bottom half still runs in interrupt context and does the rest of
the processing (eg working through the protocol stack, and
waking up processes)