DOC PREVIEW
UB CSE 321 - Device Drivers

This preview shows page 1-2-19-20 out of 20 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 20 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 20 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 20 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 20 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 20 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Device DriversIntroductionWhy Device Driver?File abstraCtion/dev partial listingDevice SPACEExamples from XINULets Analyze the XINU UART DriverUART Driver in EXINUSlide 10Device drivers (contd.)Device driver (contd.)Device Driver PhilosophyGeneral Purpose OS vs. Embedded SystemDevice Driver development stepsExample: A serial device driverShift OperatorsLogic OperatorsRelevance of shift and logic operatorsSummaryB. Ramamurthy01/14/191Copyright 2009 B. RamamurthyA device driver is computer program that allows a system to interface with hardware devices.Example driver: printer driver, bluetooth driverExample devices: your IPRE robot, USB stickIt is a translator between the operating system and applications the use the devices and the devices.A typical operating system has many device drivers built into it.A device driver converts general IO instructions into device specific operations.Device drivers operate in a privileged mode requires careful design01/14/192Copyright 2009 B. RamamurthyA typical computing system (lap top, computer, cell phone, PDA, Point of sale system) deals with a variety of devices.Making a hardware device work as expected is a cumbersome task.Instead adding this code every application, operating system provides a single point interface for all devices by hosting the device drivers.Adding it under the operating systems provides the protection and security needed for the device drivers from malicious use.The device drivers are essentially shared dynamically linked libraries.01/14/193Copyright 2009 B. RamamurthyWhat do you with a device? {read, write}, {read only}, {write only}Lets look at some examples: USB device, CD-ROM, LED Display, What do you do with a file? open, close, read, write, ..File is an excellent abstraction for devices. 01/14/194Copyright 2009 B. Ramamurthytotal 380lrwxrwxrwx 1 root 30 Mar 7 2004 allkmem -> ../devices/pseudo/mm@0:allkmemlrwxrwxrwx 1 root 27 Aug 15 2001 arp -> ../devices/pseudo/arp@0:arplrwxrwxrwx 1 root 7 Aug 15 2001 audio -> sound/0lrwxrwxrwx 1 root 10 Aug 15 2001 audioctl -> sound/0ctllrwxrwxrwx 1 root 11 Oct 4 03:06 bd.off -> /dev/term/bdrwxr-xr-x 2 root 512 Aug 17 2001 cfglrwxrwxrwx 1 root 31 Aug 15 2001 conslog -> ../devices/pseudo/log@0:consloglrwxrwxrwx 1 root 30 Aug 15 2001 console -> ../devices/pseudo/cn@0:consoledrwxr-xr-x 2 root 512 Aug 15 2001 cuadrwxr-xr-x 2 root 2048 Aug 31 2002 dsklrwxrwxrwx 1 root 29 Aug 15 2001 dump -> ../devices/pseudo/dump@0:dumplrwxrwxrwx 1 root 50 Aug 15 2001 ecpp0 -> ../devices/pci@1f,4000/ebus@1/ecpp@14,3043bc:ecpp0lrwxrwxrwx 1 root 8 Aug 15 2001 fb0 -> fbs/ffb0drwxr-xr-x 2 root 512 Aug 15 2001 fbsdr-xr-xr-x 2 root 528 Nov 9 11:51 fdlrwxrwxrwx 1 root 30 Apr 7 2002 fssnapctl -> ../devices/pseudo/01/14/19Copyright 2009 B. Ramamurthy5Typically there are multiple devices of the same type. All the devices controlled by the same device driver is given the same “major number”A “minor number” distinguishes among the devices of the same type.Example: printers have a major number since purpose is same, minor# is denote a specific printer01/14/19Copyright 2009 B. Ramamurthy6Take a look at files in the include directory:device.htty.huart.hAlso in the system directory devtable.c, initialize.cBottom line is this, for a device xyz:1. Include a file in include directory: xyz.h-- define the operations/functions for the device2. Add a directory xyz -- implement all functions each in its own file3. Add an entry in the devtable.c for the device (note that this has the “minor” device number along with other things)01/14/19Copyright 2009 B. Ramamurthy7Starting point: uart.h in include directoryuart directory functionssystem directory devtable.c, initialize.cUsage of the devices is through device table:Ex: pdev = &devtab[i]; (pdevinit)(pdev);01/14/19Copyright 2009 B. Ramamurthy81. General device driver related files: device.h, devtable.c2. Uart files: uart.h defining the physical features of the uart3. All the files in the uart directory that implement the operations related to the uart. uartControl.c uartInit.c uartIntr.c uartPutChar.c uartWrite.c uartGetChar.c uartRead.c9On board devices are called internal peripherals and one outside are called external peripheralsUART Chip (internal)TTY (external)UART transceiverRS232D-9 connector  laptop serial socket WRT54GL board and modifications10Embedded processor interacts with a peripheral device through a set of control and status registers.Registers are part of the peripheral device.Registers within a serial controller are different from those in a timer.These devices are located in the memory space of the processor or I/O space of the processor-- two types: memory-mapped or I/O mapped respectively.11The keyword volatile should be used when declaring pointers to device drivers.Bit patterns for testing, setting, clearing, toggling, shifting bits, bitmasks, and bitfields.Struct overlays:In embedded systems featuring memory mapped IO devices, it is common to overlay a C struct on to each peripheral’s control and status registers.This will provide the offsets for the various registers from the base address of the device.1. 12Hide the hardware completely: hardware abstractionIf the device generates any interrupts include interrupt controllers.Device driver presents a generic interface for applications at higher level to access the devices: device.hDevice drivers in embedded systems are different from general purpose operating systems: See diagram in slide #7 Applications in general purpose systems accesses OS (Operating Systems) which in turn accesses device drivers.Applications in embedded systems can directly access device drivers.1314ApplicationprocessOperating System: dev/xyzDevice driverPhysical DevicehardwareApplicationprocessDevice driverPhysical DevicehardwareDEVICE DRIVER DEVELOPMENT DEVICE DRIVER DEVELOPMENT STEPSSTEPS1. An interface to the control and status registers.2. Variables to track the current state of the physical and logical devices -- Major and minor device number, device


View Full Document

UB CSE 321 - Device Drivers

Documents in this Course
Anomaly1

Anomaly1

48 pages

ProcSept9

ProcSept9

17 pages

LecSept2

LecSept2

30 pages

CRCNov23

CRCNov23

14 pages

Load more
Download Device Drivers
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Device Drivers and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Device Drivers 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?