1 / 16

Device Driver Concepts

Device Driver Concepts. Chapter 13. Topics. Driver Interfaces Interrupt Handling and Drivers Classes of Drivers Accessing Hardware. Hardware Isolation. Utility. Device Controller Bus Driver Kernel User Program. Defined System Interfaces (1). System Call Function

ayla
Télécharger la présentation

Device Driver Concepts

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Device Driver Concepts Chapter 13

  2. Topics • Driver Interfaces • Interrupt Handling and Drivers • Classes of Drivers • Accessing Hardware

  3. Hardware Isolation Utility Device Controller Bus Driver Kernel User Program

  4. Defined System Interfaces (1) System Call Function mknod Creates a device special file ioctl Allows manipulation of underlying device parameters for the device special file open Makes a device available close Marks device no longer is use read Initiates data transfer from device to memory write Initiates data transfer from memory to device mmap For TURBOchannel

  5. 2. open() Kernel Interface Illustrated(open()) return status 1. open() USER/APPLICATION KERNEL System Call Layer return status DEVICE DRIVERS 3. init tables 4. prepare device

  6. Driver Models for Device Interfaces • polling • drive constantly checks on the devices it supports. • drawback: overhead of CPU cycles • interrupt handling • the supporting hardware has the capability of interrupting the CPU (with a hardware interrupt). • The CPU in turn invokes a procedure provided by the driver to handle the interrupt as quickly as possible so normal processing can continue.

  7. 1. read() 2. read() 4. wait for data 3. prepare device if necessary Interrupt Handling Illustrated USER/APPLICATION Process unblocked some time passes 9. return status & data 6. Kernel calls registered interrupt handler KERNEL 8. return status &data DEVICE DRIVER return data clear flag 7. place data in known location, set flag for driver, return 5. hardware interrupt

  8. Registering Interrupts • Interrupt handler must be registered with the kernel prior to enabling interrupts. • The kernel places this address in its System Control Block (SCB) indexed by the interrupt level • A subsequent hardware interrupt causes the PAL code to interrupt the CPU and call _XentInt() • This routine stores critical registers for the interrupted process, • and sets up a call stack for the interrupt routine which it then calls. • The interrupt routine must service the interrupt as fast as possible with no wait(s) on any resource.

  9. System Control Block • The system control block (SCB) • 8-KB, page aligned area in physical memory • specifies entry points for interrupt service routines. • the physical address of the start of the SCB is contained in the System Control Block Base (SCBB) register. • The SCB contains 512 entries, each of which is 16 bytes long. • The first 8 bytes specifies the virtual address of the service routine associated with the interrupt • The second 8 bytes is a parameter, an arbitrary quadword to be passed to the service routine.

  10. Classes of Device Drivers • Character device drivers • Block device drivers • Network device drivers • Pseudodevice drivers

  11. Block Devices • Provide structured access to the hardware. • Block devices are accessible directly through device special files. • Disks are the most common block I/O devices. • Support a file system and using file system sized buffers • A buffer is allocated when the first disk read is encountered. Use of buffer cache improves the disk I/O performance. • A block I/O device interface converts between the user's concept of a sequence of bytes on the disk to the restrictions imposed by the structure of the physical device.

  12. Character Devices • Can do transfers as small as one character • Can transfer much larger transfers as well • Can be very high speed (does not imply “slow”!) • And can transfer large buffers (not restricted to a single character!) • Example: serial port driver, raw devices

  13. Network Devices • May be character or block device • Often use the standard streams interface for interoperability with other vendors (see Appendix A) • Often uses direct memory access (DMA)

  14. Pseudo-devices • Require the low-memory access of the kernel, even though there is no hardware controller with which to interface. • Never has an ISR registered in the interrupt dispatching of the system. • Examples: pty pseudo terminals

  15. Direct Memory Access • Certain hardware is capable of writing to or reading from memory directly (highspeed vs. device registers) • This is not to be confused with buffer cache • DMA devices can be either block or character devices.

  16. Mapped Access I/O • Using mapped access I/O, the processor accesses a remote I/O interface register using a mapping of that remote address space into the processor's local I/O space. • I/O access is accomplished by reading and writing interface registers directly. Mapped access can be used by TURBOchannel based, low-end, low-cost models. • Mapped I/O solves granularity problems by doubly mapping I/O locations in both dense as well as sparse I/O spaces.

More Related