Embedded System Programming Introduction to Device Drivers.

Slides:



Advertisements
Similar presentations
DEVICE DRIVER VINOD KAMATH CS691X PROJECT WORK. Introduction How to write/install device drivers Systems, Kernel Programming Character, Block and Network.
Advertisements

Linux device-driver issues
Lecture 101 Lecture 10: Kernel Modules and Device Drivers ECE 412: Microcomputer Laboratory.
Device Drivers. Linux Device Drivers Linux supports three types of hardware device: character, block and network –character devices: R/W without buffering.
Lecture for Lab 3, Exp1 of EE505 (Developing Device Driver) T.A. Chulmin Kim CoreLab. Mar, 11, 2011 [XenSchedulerPaper_Hotcloud-commits] r21 - /
Computer System Laboratory
The UNIX File System Harry Chen Department of CSEE University of MD Baltimore County.
Devices and Drivers (Chapter 7) Khattab Alhabashi UNIX System Administration.
Linux can be generally divided into four major components: 1. KERNEL – OS, ultimate boss The kernel is the core program that runs programs and manages.
EEE 435 Principles of Operating Systems Operating System Concepts (Modern Operating Systems 1.5)
52 Advanced Operating Systems Writing Device Drivers.
Common System Components
Kernel module programming and debugging Advanced Operating Systems.
Introduction Operating Systems’ Concepts and Structure Lecture 1 ~ Spring, 2008 ~ Spring, 2008TUCN. Operating Systems. Lecture 1.
Word Processing, Web Browsing, File Access, etc. Windows Operating System (Kernel) Window (GUI) Platform Dependent Code Virtual Memory “Swap” Block Data.
LECTURE 14 Operating Systems and Utility Programs
Systems Software Operating Systems.
I/O Tanenbaum, ch. 5 p. 329 – 427 Silberschatz, ch. 13 p
An Introduction to Device Drivers Sarah Diesburg COP 5641 / CIS 4930.
1 Input/Output. 2 Principles of I/O Hardware Some typical device, network, and data base rates.
Operating Systems Operating System
Chapter 4 Operating Systems and File Management. 4 Chapter 4: Operating Systems and File Management 2 Chapter Contents  Section A: Operating System Basics.
Linux Installation and Administration – Lesson 5 Tutor: George Papamarkos Topic: Devices in Linux.
Device and Filesystem Management CSCI N321 – System and Network Administration Copyright © 2000, 2012 by Scott Orr and the Trustees of Indiana University.
Embedded Linux Systems Presented By: Kitrek Riese.
CS 1308 Computer Literacy and the Internet. Introduction  Von Neumann computer  “Naked machine”  Hardware without any helpful user-oriented features.
DOS  In the 1980s or early 1990s, the operating system that shipped with most PCs was a version of the Disk Operating System (DOS) created by Microsoft:
Drivers and The Kernel Chapter 12 Presentation by: Kathleen Pensy.
NETW 3005 I/O Systems. Reading For this lecture, you should have read Chapter 13 (Sections 1-4, 7). NETW3005 (Operating Systems) Lecture 10 - I/O Systems2.
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.
Eng.Abed Al Ghani H. Abu Jabal Introduction to computers.
1 What is a Kernel The kernel of any operating system is the core of all the system’s software. The only thing more fundamental than the kernel is the.
Device and Filesystem Management CSCI N321 – System and Network Administration Copyright © 2000, 2010 by Scott Orr and the Trustees of Indiana University.
Linux Kernel Management. Module 9 – Kernel Administration ♦ Overview The innermost layer of Linux operating system is the kernel, which is a thin layer.
An Introduction to Device Drivers Ted Baker  Andy Wang COP 5641 / CIS 4930.
Interfacing Device Drivers with the Kernel
CIS250 OPERATING SYSTEMS Chapter One Introduction.
CSC414 “Introduction to UNIX/ Linux” Lecture 2. Schedule 1. Introduction to Unix/ Linux 2. Kernel Structure and Device Drivers. 3. System and Storage.
Lab 12 Department of Computer Science and Information Engineering National Taiwan University Lab12 – Driver 2014/12/16 1 /21.
Linux Kernel Programming (LKP). LKP New sub-course New sub-course We will learn together We will learn together Evaluation of this part of course will.
Device Driver Concepts Digital UNIX Internals II Device Driver Concepts Chapter 13.
ICOM Noack Linux I/O structure Device special files Device switch tables and fops How the kernel finds a device Parts of a device driver or module.
Silberschatz, Galvin and Gagne ©2011 Operating System Concepts Essentials – 8 th Edition Chapter 2: The Linux System Part 5.
Kernel Modules – Introduction CSC/ECE 573, Sections 001 Fall, 2012.
Implementation Method Linux-USB Gadget Framework –The Linux-USB Gadget Framework makes it easy for peripherals and other devices embedding GNU/Linux system.
1 Setup and Compile Linux Kernel Speaker: Yi-Ji Jheng Date:
Chapter 4: server services. The Complete Guide to Linux System Administration2 Objectives Configure network interfaces using command- line and graphical.
1 Chapter 2: Operating-System Structures Services Interface provided to users & programmers –System calls (programmer access) –User level access to system.
Chapter 2 Operating System Overview Dave Bremer Otago Polytechnic, N.Z. ©2008, Prentice Hall Operating Systems: Internals and Design Principles, 6/E William.
Introduction to Operating Systems Concepts
Computer System Structures
Input/Output (I/O) Important OS function – control I/O
Chapter 13: I/O Systems Modified by Dr. Neerja Mhaskar for CS 3SH3.
Linux Kernel Module Programming
Chapter 12: File System Implementation
Linux Operating System Architecture
KERNEL ARCHITECTURE.
Introduction to the Kernel and Device Drivers
An Introduction to Device Drivers
I/O Systems I/O Hardware Application I/O Interface
Operating Systems Chapter 5: Input/Output Management
Operating System Concepts
Lab 4 Kernel Module Operating System Lab.
Department of School of Computing and Engineering
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
Computer System Laboratory
A very basic introduction
Module 12: I/O Systems I/O hardwared Application I/O Interface
Presentation transcript:

Embedded System Programming Introduction to Device Drivers

What are device drivers? Software interfaces to hardware resources in the kernel –Mirrors variety of hardware resources –Can change constantly –Will require reconfiguration –Different interfaces into the same devices –Require kernel resident programs –Uses module interface

Split level kernel User programs and applications Application level Kernel level Kernel parts features software hardware Hardware level Process mgment Memory mgment File systems Device Control Networking Achture code Memory Mang. Fs types Block Dvc Character Devices Networks If drivers Multi-tasking V Memory Files & Dirs TTYS & devs Connectivity CPURAM Disks & CDs Console S Ports Network Interfaces

Types of device driver There are some general types or characteristics of device drivers –Character devices Serial data stream –Block devices Accessed via blocked data stream –Network interfaces Although serial, has no mapping into file system

Recognising device drivers Apart from network devices most drivers appear like file in the Unix system ls –l /dev –crw-r--r-- 1 root root 10, 134 Jun apm_bios –brw-rw root floppy 2, 0 May fd0 Device type Major number Minor number File Name

Character Device Drivers Data is a serial stream No random access Even a block devices can be a character one! –Printers

Block Devices Data is read in blocks Block size depends upon the device Random access is supported Files systems can only be mounted block devices Block devices can have character interfaces –fsck works on character “raw” interface to file system

Network Interfaces Network interfaces act in some ways like a serial character orientated device, however they don’t exist in the file system For example eth0 is queried through the ifconfig command Weirdly, network devices can support block features for example network mounted file systems

Character & Block Device number assignment Character devices –1 Memory –4 Terminal –6 Parallel interfaces –7 Vitual consoles –9 SCSI tapes –10 Bus mice –12 QIC02 Tape –13 PC speaker driver Block devices –1 RAM disk –2 Floppy disk –3 IDE disk –8 SCSI disk –11 SCSI CD-ROM –13XT 8-bit hard disk

Loadable modules Historically there has been a split between monolithic kernels –All code is contained in the kernel, fixed at build or boot time This means that kernel can be fast and efficient And Micro kernels –Small lightweight kernel that load features in at run time, when required The kernel is smaller, easier to port, the feaure list of more flexible Linux loadable modules gives a compromise position –Mainly monolithic kernel but can load modules in when needed –The use of modules for devices is clearly important

Kernel Modules The provision of kernel modules allows code to be introduced into a running kernel. This requires the kernel to be built with this capability, it also requires the commands –Insmod and rmmod (plus lsmod, depmod and modprobe) Modules can be loaded on demand automatically.

Module programming The 2.6 kernel has changed the way module programming is handled. –We will look at this later on – for the moment we will deal with 2.4 Modules under 2.4 are just ordinary unlinked object files (cc –o) –Although they must link with the kernel and can bring it down, so they are rather special.

Module programs Requires header files –These will include others Needs an init_module and cleanup_module function The return value is important –Only return 0. Use of printk

Using macros Use of init & exit macros Use of __init and __initdata

Features of kernel programming Don’t use libraries – only kernel code –Printk not printf Set use of headers –/usr/include/asm & /usr/include/linux Beware of namespace pollution –Code shares names with the kernel –Use static