Presentation is loading. Please wait.

Presentation is loading. Please wait.

Device Driver Concepts Digital UNIX Internals II Device Driver Concepts Chapter 13.

Similar presentations


Presentation on theme: "Device Driver Concepts Digital UNIX Internals II Device Driver Concepts Chapter 13."— Presentation transcript:

1 Device Driver Concepts Digital UNIX Internals II Device Driver Concepts Chapter 13

2 Device Driver Concepts Digital UNIX Internals II Topics Driver Interfaces Interrupt Handling and Drivers Classes of Drivers Accessing Hardware

3 Device Driver Concepts Digital UNIX Internals II Hardware Isolation Device Controller Bus Driver Kernel User Program Utility

4 Device Driver Concepts Digital UNIX Internals II Defined System Interfaces (1) System CallFunction 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 Device Driver Concepts Digital UNIX Internals II Kernel Interface Illustrated (open()) 1. open() DEVICE DRIVERS USER/APPLICATION 2. open() KERNEL System Call Layer return status 3. init tables 4. prepare device

6 Device Driver Concepts Digital UNIX Internals II 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 Device Driver Concepts Digital UNIX Internals II Interrupt Handling Illustrated DEVICE DRIVER USER/APPLICATION KERNEL 8. return status &data 9. return status & data 1. read() 2. read() 4. wait for data 3. prepare device if necessary some time passes 5. hardware interrupt 6. Kernel calls registered interrupt handler 7. place data in known location, set flag for driver, return Process unblocked return data clear flag

8 Device Driver Concepts Digital UNIX Internals II 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 Device Driver Concepts Digital UNIX Internals II 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 Device Driver Concepts Digital UNIX Internals II Classes of Device Drivers Character device drivers Block device drivers Network device drivers Pseudodevice drivers

11 Device Driver Concepts Digital UNIX Internals II 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 Device Driver Concepts Digital UNIX Internals II 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 Device Driver Concepts Digital UNIX Internals II 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 Device Driver Concepts Digital UNIX Internals II 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 Device Driver Concepts Digital UNIX Internals II 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 Device Driver Concepts Digital UNIX Internals II 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.


Download ppt "Device Driver Concepts Digital UNIX Internals II Device Driver Concepts Chapter 13."

Similar presentations


Ads by Google