Linux Details: Device Drivers

Slides:



Advertisements
Similar presentations
Device Drivers. Linux Device Drivers Linux supports three types of hardware device: character, block and network –character devices: R/W without buffering.
Advertisements

I/O and Networking Fred Kuhns
I/O Hardware n Incredible variety of I/O devices n Common concepts: – Port – connection point to the computer – Bus (daisy chain or shared direct access)
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.
Chapter 13: I/O Systems I/O Hardware Application I/O Interface
I/O Systems CSCI 444/544 Operating Systems Fall 2008.
Chapter 13: I/O Systems I/O Hardware Application I/O Interface
I/O Tanenbaum, ch. 5 p. 329 – 427 Silberschatz, ch. 13 p
Basics of Operating Systems March 4, 2001 Adapted from Operating Systems Lecture Notes, Copyright 1997 Martin C. Rinard.
An Introduction to Device Drivers Sarah Diesburg COP 5641 / CIS 4930.
Operating Systems Who’s in charge in there?. Types of Software Application Software : Does things we want to do System Software : Does things we need.
UART and UART Driver B. Ramamurthy.
Cpr E 308 Input/Output Recall: OS must abstract out all the details of specific I/O devices Today –Block and Character Devices –Hardware Issues – Programmed.
ITEC 502 컴퓨터 시스템 및 실습 Chapter 8-1: I/O Management Mi-Jung Choi DPNM Lab. Dept. of CSE, POSTECH.
ITEC 502 컴퓨터 시스템 및 실습 Chapter 8-2: I/O Management (Review) Mi-Jung Choi DPNM Lab. Dept. of CSE, POSTECH.
I/O Systems I/O Hardware Application I/O Interface
1 Lecture 20: I/O n I/O hardware n I/O structure n communication with controllers n device interrupts n device drivers n streams.
Windows Operating System Internals - by David A. Solomon and Mark E. Russinovich with Andreas Polze Unit OS6: Device Management 6.1. Principles of I/O.
Kernel, processes and threads Windows and Linux. Windows Architecture Operating system design Modified microkernel Layered Components HAL Interacts with.
Chapter 13: I/O Systems. 13.2/34 Chapter 13: I/O Systems I/O Hardware Application I/O Interface Kernel I/O Subsystem Transforming I/O Requests to Hardware.
1 Threads, SMP, and Microkernels Chapter Multithreading Operating system supports multiple threads of execution within a single process MS-DOS.
An Introduction to Device Drivers Ted Baker  Andy Wang COP 5641 / CIS 4930.
12/8/20151 Operating Systems Design (CS 423) Elsa L Gunter 2112 SC, UIUC Based on slides by Roy Campbell, Sam King,
Chapter 13 – I/O Systems (Pgs ). Devices  Two conflicting properties A. Growing uniformity in interfaces (both h/w and s/w): e.g., USB, TWAIN.
Chapter 13: I/O Systems Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th Edition, Jan 2, 2005 I/O through system calls Protection.
Silberschatz, Galvin, and Gagne  Applied Operating System Concepts Module 12: I/O Systems I/O hardwared Application I/O Interface Kernel I/O.
1 Device Controller I/O units typically consist of A mechanical component: the device itself An electronic component: the device controller or adapter.
Major OS Components CS 416: Operating Systems Design, Spring 2001 Department of Computer Science Rutgers University
ECE 456 Computer Architecture Lecture #9 – Input/Output Instructor: Dr. Honggang Wang Fall 2013.
Interrupts and Interrupt Handling David Ferry, Chris Gill CSE 522S - Advanced Operating Systems Washington University in St. Louis St. Louis, MO
Processes David Ferry, Chris Gill CSE 522S - Advanced Operating Systems Washington University in St. Louis St. Louis, MO
Introduction to Operating Systems Concepts
Computer Organization and Design
Input/Output (I/O) Important OS function – control I/O
Chapter 13: I/O Systems.
Module 12: I/O Systems I/O hardware Application I/O Interface
Chapter 13: I/O Systems Modified by Dr. Neerja Mhaskar for CS 3SH3.
Final Review David Ferry, Chris Gill
Linux Kernel Module Programming
Processes David Ferry, Chris Gill
CS703 - Advanced Operating Systems
Introduction to the Kernel and Device Drivers
Interrupts and Interrupt Handling
Computer Architecture
An Introduction to Device Drivers
CSCI 315 Operating Systems Design
CPSC 457 Operating Systems
I/O Systems I/O Hardware Application I/O Interface
Operating Systems Chapter 5: Input/Output Management
Operating System Concepts
13: I/O Systems I/O hardwared Application I/O Interface
CS703 - Advanced Operating Systems
Direct Memory Access Disk and Network transfers: awkward timing:
Chapter 5: I/O Systems.
Linux Details: Device Drivers
System Calls David Ferry CSCI 3500 – Operating Systems
Top Half / Bottom Half Processing
Chapter 2: Operating-System Structures
Chapter 2: The Linux System Part 5
LINUX System : Lecture 7 Lecture notes acknowledgement : The design of UNIX Operating System.
Chapter 13: I/O Systems I/O Hardware Application I/O Interface
Linux Block I/O Layer Chris Gill, Brian Kocoloski
Chapter 13: I/O Systems I/O Hardware Application I/O Interface
Chapter 2: Operating-System Structures
Interrupts and Interrupt Handling
Processes David Ferry, Chris Gill, Brian Kocoloski
Page Cache and Page Writeback
Shared Memory David Ferry, Chris Gill
Module 12: I/O Systems I/O hardwared Application I/O Interface
Presentation transcript:

Linux Details: Device Drivers David Ferry, Chris Gill CSE 522S - Advanced Operating Systems Washington University in St. Louis St. Louis, MO 63130

Goal of a Device Driver Hide details of how a device works behind a standard interface User Code User Space Standard Interface Black Box Device Driver Kernel Space Device Hardware CSE 522S – Advanced Operating Systems

Goal of a Device Driver Hide details of how a device works behind a standard interface Be modular and flexible User Code User Code Standard Interface Standard Interface Black Box Device Driver Modified Driver Device Device (version 2) CSE 522S – Advanced Operating Systems

Driver Design Philosophy Support mechanism, not policy Mechanism: technical capabilities Policy: how those capabilities are used Example – sockets: Sockets abstract many types of connections Synchronous or asynchronous access FTP or UDP Variety of protocols By being flexible, sockets place little constraint on how they are used. Expect hardware devices to be used in many contexts! CSE 522S – Advanced Operating Systems

Traditional Driver Types Character Devices Reads and writes a stream of characters May only implement read, write, open, close Console drivers, keyboard, etc. Block Devices Reads and writes whole blocks of bytes E.g. a hard drive only reads and writes 4K bytes at a time Hard drives, CD-ROM drives, floppy drives Network Devices Provides network interfaces (like eth0 or loopback) Packet based read & write CSE 522S – Advanced Operating Systems

CSE 522S – Advanced Operating Systems Driver Interface A driver typically communicates through (how else?) a special file. struct file – kernel representation of an open file struct file_operations – list of function pointers to be called when file is accessed via file system calls (i.e. read, write, flush, etc.), used in file CSE 522S – Advanced Operating Systems

Accessing Hardware Devices Control over peripheral devices is done by writing and the device’s registers How do we read and write those? I/O Ports – R/W special processor instructions I/O Memory – R/W special memory addresses Memory mapping is preferred (and faster)! Maps large regions (e.g. video frame buffer) Some architectures don’t support I/O Ports CSE 522S – Advanced Operating Systems

Memory Mapped I/O Functions #include <linux/ioport.h> request_mem_region() – allocates a memory region suitable for I/O memory map ioremap() – maps peripheral physical I/O space into kernel memory space ioread32(), iowrite32(), io_memcpy() – family of functions for reading and writing memory mapped I/O CSE 522S – Advanced Operating Systems

Devices and Interrupts Syscalls provide a synchronous interface to hardware devices Interrupts allow asynchronous operations Many devices are much slower than processor Processor 3) Interrupt notifies CPU that work is done 4) Deferred processing 1) Writes requested block to device 2) Seeks and writes block into I/O mapped memory Hard-drive CSE 522S – Advanced Operating Systems

CSE 522S – Advanced Operating Systems More Details There are whole books about how to write good device drivers, plus lots of example code: Linux Device Drivers, 3rd ed. by Corbet, Rubini, and Kroah-Hartmann Available online (free) under creative commons license CSE 522S – Advanced Operating Systems