B. RAMAMURTHY 6/13/2013 1 Device Drivers. Introduction 6/13/2013 2  A device driver is computer program that allows a system to interface with hardware.

Slides:



Advertisements
Similar presentations
Operating System Structures
Advertisements

Microprocessors Typical microprocessor controlled devices: Camera, mobile phone, stereo, mp3 player, electronic toys… High-level microprocessor controlled.
Chapter 2 Operating System Overview Operating Systems: Internals and Design Principles, 6/E William Stallings.
Chapter 10 Input/Output Organization. Connections between a CPU and an I/O device Types of bus (Figure 10.1) –Address bus –Data bus –Control bus.
EEE226 MICROPROCESSORBY DR. ZAINI ABDUL HALIM School of Electrical & Electronic Engineering USM.
Lecture 12 Page 1 CS 111 Online Devices and Device Drivers CS 111 On-Line MS Program Operating Systems Peter Reiher.
Introduction to Operating Systems CS-2301 B-term Introduction to Operating Systems CS-2301, System Programming for Non-majors (Slides include materials.
04/16/2010CSCI 315 Operating Systems Design1 I/O Systems Notice: The slides for this lecture have been largely based on those accompanying an earlier edition.
Midterm Tuesday October 23 Covers Chapters 3 through 6 - Buses, Clocks, Timing, Edge Triggering, Level Triggering - Cache Memory Systems - Internal Memory.
Cs238 Lecture 3 Operating System Structures Dr. Alan R. Davis.
Railway Foundation Electronic, Electrical and Processor Engineering.
Mehmet Can Vuran, Instructor University of Nebraska-Lincoln Acknowledgement: Overheads adapted from those provided by the authors of the textbook.
Topic 1: Introduction to Computers and Programming
ASPPRATECH.
Operating Systems Concepts 1. A Computer Model An operating system has to deal with the fact that a computer is made up of a CPU, random access memory.
Microcontroller: Introduction
I/O Tanenbaum, ch. 5 p. 329 – 427 Silberschatz, ch. 13 p
COMPONENTS OF THE SYSTEM UNIT
Walkie-Talkie via Bluetooth By : Kopitman Reem Stolberg Dmitri Instructor: Chen Koren The final presentation.
Device Management. Serial Port Serial Device Serial Device Memory CPU Printer Terminal Modem Mouse etc.
Department of Electronic & Electrical Engineering Embedded system Aims: Introduction to: Hardware. Software Ideas for projects ? Robotics/Control/Sensors.
Chapter 3.1:Operating Systems Concepts 1. A Computer Model An operating system has to deal with the fact that a computer is made up of a CPU, random access.
Computer Organization
System Calls 1.
UART and UART Driver B. Ramamurthy.
1 Computer System Overview Chapter 1. 2 n An Operating System makes the computing power available to users by controlling the hardware n Let us review.
Segmentation & O/S Input/Output Chapter 4 & 5 Tuesday, April 3, 2007.
CSC 322 Operating Systems Concepts Lecture - 25: by Ahmed Mumtaz Mustehsan Special Thanks To: Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall,
CISC105 General Computer Science Class 1 – 6/5/2006.
Three fundamental concepts in computer security: Reference Monitors: An access control concept that refers to an abstract machine that mediates all accesses.
5/26/ Embedded XINU and WRT54GL. 5/26/ Topics Demo of number game and avionics FSM Logic and shift operators Optimizing operations (mul, div.
1 Nios II Processor Architecture and Programming CEG 4131 Computer Architecture III Miodrag Bolic.
Typical Microcontroller Purposes
Recall: Three I/O Methods Synchronous: Wait for I/O operation to complete. Asynchronous: Post I/O request and switch to other work. DMA (Direct Memory.
10/12/ Embedded XINU and WRT54GL. 10/12/ Topics Logic and shift operators Data-driven vs function-driven Embedded XINU and WRT54GL.
Operating Systems Lecture 7 OS Potpourri Adapted from Operating Systems Lecture Notes, Copyright 1997 Martin C. Rinard. Zhiqing Liu School of Software.
Hardware process When the computer is powered up, it begins to execute fetch-execute cycle for the program that is stored in memory at the boot strap entry.
I/O Computer Organization II 1 Interconnecting Components Need interconnections between – CPU, memory, I/O controllers Bus: shared communication channel.
Data Manipulation CSC 2001 TTU CSC 2001 TTU. Now what?  Program can be represented (and stored) like data. So, now what happens?  The program needs.
1 Threads, SMP, and Microkernels Chapter Multithreading Operating system supports multiple threads of execution within a single process MS-DOS.
Operating System Structure A key concept of operating systems is multiprogramming. –Goal of multiprogramming is to efficiently utilize all of the computing.
MICROPROCESSOR FUNCTION Technician Series Created Mar 2015 gmail.com.
Kaaba Technosolutions Pvt Ltd1 Objectives Learn that a computer requires both hardware and software to work Learn about the many different hardware components.
CSC414 “Introduction to UNIX/ Linux” Lecture 2. Schedule 1. Introduction to Unix/ Linux 2. Kernel Structure and Device Drivers. 3. System and Storage.
Computer Hardware – System Unit
1/8/ Embedded XINU and WRT54GL. 1/8/ Topics WRT54GL architecture and internals Embedded XINU Logic and shift operators.
Digital Computer Concept and Practice Copyright ©2012 by Jaejin Lee Control Unit.
Hardware process When the computer is powered up, it begins to execute fetch-execute cycle for the program that is stored in memory at the boot strap entry.
What is a Process ? A program in execution.
B. Ramamurthy 2/28/ Copyright 2009 B. Ramamurthy.
ECE 456 Computer Architecture Lecture #9 – Input/Output Instructor: Dr. Honggang Wang Fall 2013.
3/12/ Embedded XINU and WRT54GL. 3/12/ Topics Logic and shift operators Optimizing operations (mul, div VS shiftL, shiftR) WRT54GL architecture.
Digital Computer Concept and Practice Copyright ©2012 by Jaejin Lee Control Unit.
ARM Embedded Programming Lecture 4 Accessing Memory Mapped Registers.
SEPTEMBER 8, 2015 Computer Hardware 1-1. HARDWARE TERMS CPU — Central Processing Unit RAM — Random-Access Memory  “random-access” means the CPU can read.
MICROPROCESSOR INTEL 8086/8088 BY: SERA SYARMILA SAMEON.
1.3 Operating system services An operating system provide services to programs and to the users of the program. It provides an environment for the execution.
Introduction to Operating Systems Concepts
Computer System Structures
Introduction to Operating Systems
Computer Hardware – System Unit
Computer System Laboratory
Implementation of Embedded OS
UNIT – Microcontroller.
Operating System Structure
UART and UART Driver B. Ramamurthy.
CS703 - Advanced Operating Systems
Introduction to Operating Systems
UART and UART Driver B. Ramamurthy.
Embedded XINU and WRT54GL
Presentation transcript:

B. RAMAMURTHY 6/13/ Device Drivers

Introduction 6/13/  A device driver is computer program that allows a system to interface with hardware devices.  Example driver: printer driver, bluetooth driver  Example devices: your USB stick, sensors: accelerometer  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 design

Why Device Driver? 6/13/  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.

File abstraCtion 6/13/ 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.

/dev partial listing 6/13/  total 380  lrwxrwxrwx 1 root 30 Mar allkmem  allkmem  lrwxrwxrwx 1 root 27 Aug arp  lrwxrwxrwx 1 root 7 Aug audio -> sound/0  lrwxrwxrwx 1 root 10 Aug audioctl -> sound/0ctl  lrwxrwxrwx 1 root 11 Oct 4 03:06 bd.off -> /dev/term/b  drwxr-xr-x 2 root 512 Aug cfg  lrwxrwxrwx 1 root 31 Aug conslog  :conslog  lrwxrwxrwx 1 root 30 Aug console  console  drwxr-xr-x 2 root 512 Aug cua  drwxr-xr-x 2 root 2048 Aug dsk  lrwxrwxrwx 1 root 29 Aug dump  ump  lrwxrwxrwx 1 root 50 Aug ecpp0   lrwxrwxrwx 1 root 8 Aug fb0 -> fbs/ffb0  drwxr-xr-x 2 root 512 Aug fbs  dr-xr-xr-x 2 root 528 Nov 9 11:51 fd  lrwxrwxrwx 1 root 30 Apr fssnapctl ->../devices/pseudo/

Device SPACE 6/13/  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 printer

Examples from XINU 6/13/  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 device 2. Add a directory xyz -- implement all functions each in its own file 3. Add an entry in the devtable.c for the device (note that this has the “minor” device number along with other things)

Lets Analyze the XINU UART Driver 6/13/ 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);

UART Driver in EXINU 9 1. General device driver related files: device.h, devtable.c 2. Uart files: uart.h defining the physical features of the uart 3. 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.c 6/13/2013

Device Drivers 10 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 modifications 6/13/2013

Device drivers (contd.) 11 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. 6/13/2013

Device driver (contd.) 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. 6/13/2013

Device Driver Philosophy 13  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 #14  Applications in general purpose systems accesses OS (Operating Systems) which in turn accesses device drivers.  Applications in embedded systems can directly access device drivers. 6/13/2013

14 General Purpose OS vs. Embedded System Application process Operating System: dev/xyz Device driver Physical Device hardware Application process Device driver Physical Device hardware 6/13/2013

Device Driver development steps 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 name 3. A routine to initialize the hardware to known state 4. An API for users of the device driver -- Read, write, seek 5. Interrupts service routines 6/13/2013

Example: A serial device driver 16 Read the text for explanation and general example of a timer Now lets look at the UARTdriver of the embedded xinu and WRT54GL. Study the tty driver that is a logical device that is layered on top of the UART driver. Discuss how you would develop a device driver for a framebuffer.. This was a lab2 last year. 6/13/2013

Shift Operators 6/13/ << left shift >> right shift Usage: unsigned int x = 70707; //x = unsigned int y, z; y = x << 2; // y = z = x >> 2; //z =

Logic Operators 6/13/ Bitwise & (AND) Bitwise inclusive | (OR) Bitwise exclusive ^ (XOR) Bitwise negation ~ Usage: unsigned exp1 = 1; unsigned exp2 = 4; printf (“ %d\n”, exp1 | exp2); printf (“ %d\n”, exp1 & exp2); printf (“ %d\n”, exp1 ^ exp2); printf (“ %d\n”, ~exp1);

Relevance of shift and logic operators 6/13/  Bitwise operations are necessary for much low-level programming, such as writing to device drivers, low- level graphics, communications protocol packet assembly and decoding.  Device drivers use these operators to test the presence or absence of a bit in a serial port or a device input, for example. (checking for on or off)

Summary 20 We studied the design and development of device drivers. We analyzed the code for a sample UART driver. 6/13/2013