Devices and Drivers (Chapter 7) Khattab Alhabashi UNIX System Administration.

Slides:



Advertisements
Similar presentations
Chapter 12: File System Implementation
Advertisements

Device Drivers. Linux Device Drivers Linux supports three types of hardware device: character, block and network –character devices: R/W without buffering.
Drivers and the kernel1-1 Drivers and the kernel UNIX system has three layers: m The hardware m The operating system kernel m The user-level programs Kernel.
Operating System Structures
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.
Operating-System Structures
Allocation Methods - Contiguous
Essential System Administration 3rd Edition Chapter 2 The Unix Way(Cont.) University Of Palestine.
04/14/2008CSCI 315 Operating Systems Design1 I/O Systems Notice: The slides for this lecture have been largely based on those accompanying the textbook.
11/13/01CS-550 Presentation - Overview of Microsoft disk operating system. 1 An Overview of Microsoft Disk Operating System.
File management in UNIX and windows 2000
1 Web Server Administration Chapter 3 Installing the Server.
1 Device Management The von Neumann Architecture System Architecture Device Management Polling Interrupts DMA operating systems.
Common System Components
Operating Systems File systems
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Chapter 2: Operating-System Structures Modified from the text book.
Cambodia-India Entrepreneurship Development Centre - : :.... :-:-
Installing software on personal computer
I/O Tanenbaum, ch. 5 p. 329 – 427 Silberschatz, ch. 13 p
An Introduction to Device Drivers Sarah Diesburg COP 5641 / CIS 4930.
Chapter 10 File System Interface
Linux Installation and Administration – Lesson 5 Tutor: George Papamarkos Topic: Devices in Linux.
DOS Understanding what you can do. Operating System Traits An OS only works with one type of processor –X86 processors for us; Motorola for Mac –Must.
Lesson 7-Creating and Changing Directories. Overview Using directories to create order. Managing files in directories. Using pathnames to manage files.
Chapter Four UNIX File Processing. 2 Lesson A Extracting Information from Files.
Drivers and The Kernel Chapter 12 Presentation by: Kathleen Pensy.
Segmentation & O/S Input/Output Chapter 4 & 5 Tuesday, April 3, 2007.
COMP 3438 – Part I - Lecture 4 Introduction to Device Drivers Dr. Zili Shao Department of Computing The Hong Kong Polytechnic Univ.
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.
Chapter 2: Operating-System Structures. 2.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th Edition, Jan 14, 2005 Operating System.
File System Interface. File Concept Access Methods Directory Structure File-System Mounting File Sharing (skip)‏ File Protection.
Operating Systems COMP 4850/CISG 5550 File Systems Files Dr. James Money.
CE Operating Systems Lecture 3 Overview of OS functions and structure.
UNIX Files File organization and a few primitives.
Manage Directories and Files in Linux. 2 Objectives Understand the Filesystem Hierarchy Standard (FHS) Identify File Types in the Linux System Change.
Processes Introduction to Operating Systems: Module 3.
Distributed System Concepts and Architectures Services
An Introduction to Device Drivers Ted Baker  Andy Wang COP 5641 / CIS 4930.
Lecture 18 Windows – NT File System (NTFS)
CSC414 “Introduction to UNIX/ Linux” Lecture 2. Schedule 1. Introduction to Unix/ Linux 2. Kernel Structure and Device Drivers. 3. System and Storage.
Chapter 8: Installing Linux The Complete Guide To Linux System Administration.
Lecture 19 Linux/Unix – File System
Device Driver Concepts Digital UNIX Internals II Device Driver Concepts Chapter 13.
Lecture 02 File and File system. Topics Describe the layout of a Linux file system Display and set paths Describe the most important files, including.
2.1 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition System Programs (p73) System programs provide a convenient environment.
Silberschatz, Galvin and Gagne ©2011 Operating System Concepts Essentials – 8 th Edition Chapter 2: The Linux System Part 2.
DEVICE DRIVERS Presented by: Group 7. What are Device Drivers? Device driver or hardware driver is a program that manages the system’s interaction with.
CEG 2400 FALL 2012 Linux/UNIX Network Operating Systems.
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.
A+ Guide to Managing and Maintaining Your PC, 7e Chapter 2 Introducing Operating Systems.
Linux Filesystem Administration
Introduction to Operating Systems Concepts
OPERATING SYSTEM CONCEPTS AND PRACTISE
Chapter 11: File System Implementation
Linux Kernel Module Programming
Chapter 12: File System Implementation
Chapter 6 File Systems CSNB113 SYSTEM ADMINISTRATION
Module 4 Remote Login.
Drivers and the kernel UNIX system has three layers: Kernel
Introduction to the Kernel and Device Drivers
Chapter 2: Operating-System Structures
An Introduction to Device Drivers
Chapter 2: The Linux System Part 2
Chapter 2: System Structures
CS703 - Advanced Operating Systems
Chapter Four UNIX File Processing.
Drivers and the Kernel Chapter 12.
Outline Chapter 2 (cont) OS Design OS structure
Chapter 13: I/O Systems.
Presentation transcript:

Devices and Drivers (Chapter 7) Khattab Alhabashi UNIX System Administration

Introduction n Definition: A device driver is a program that manages the system’s interaction with a particular piece of hardware. n The driver translates between the hardware commands understood by the device and the stylized programming interface used by the kernel. n The existence of the driver layer helps to keep UNIX reasonably device- independent. n Device drivers are part of the kernel; they are not user processes. However, a driver can be accessed both from within the kernel and from user space. n User-level access to devices is provided through special device file that live in the /dev directory.

Introduction Contd. n Most devices in the system will fall into three categories: 1) SCSI: 1) SCSI: –Devices that attach to a SCSI bus are easy to configure. –Most systems have one driver that allows direct access to the SCSI bus, plus additional drivers for special types of devices such as disks and tapes. 2) Vendor: –Most devices you can buy from your hardware vendor will already be supported by the operating system. –Unless you have explicitly removed drivers, the kernel will usually recognize a new device as soon as you install it. –The appropriate device files in /dev will already have been created for you, or the OS will create them on the fly.

Introduction Contd. 3) Third-party: –When you purchase a piece of hardware from a third party (someone other than your hardware vendor), it will usually come with an installation script that installs the device, configures the kernel if necessary, and makes devices entries. –On systems with loadable drivers, kernel configuration may not be necessary.

Device Numbers and Jump Tables n Device files are mapped to devices via their “major and minor device numbers”, values that are stored in the file’s inode structure. n The major device number identifies the driver that the file is associated with. n The minor device number identifies which particular device of a given type is to be addressed. It is often called the unit number or “instance” of the device. n There are two types of device files: –Block device files: it is read or written a block (a group of bytes, usually multiple of 512) at a time. –Character device files: it can be read or written one byte at a time.

Device Numbers and Jump Tables Contd. n Some devices support access via both block and character device files. n Each driver has routines for performing some or all of the following functions: probe attach open close read reset stop probe attach open close read reset stop select strategy dump psize write timeout select strategy dump psize write timeout process a transmit interrupt process a receive interrupt ioctl (input / output control) n Inside the kernel, the addresses of these functions for each driver are stored in a structure called a jump table.

Device Numbers and Jump Tables Contd. n There are actually two tables: - One for character device and - One for block devices. n The jump tables are indexed by major device numbers. n When a program performs an operation on a device file, the kernel automatically catches the reference, looks up the appropriate function name in the jump table, and transfers control to it. n To perform an unusual operation that doesn’t have a direct analog in filesystem model (for example, ejecting floppy disk), the ioctl system call is used to pass a message directly from user space into the driver.

Device Numbers and Jump Tables Contd. n Three examples were discussed in this chapter about adding device drivers: - Adding a BSD Device Driver: Adding a completely new device driver to BSD machine involves adding it to a couple of configuration files and editing the kernel source code to include references to the driver’s routine. - Adding an HP-UX Device Driver: On HP-UX systems, the jump tables are constructed from specifications in a text file called master. - Adding an IRIX Device Driver: IRIX uses a directory of files (/var/sysgen/master.d) to perform the same function as the single master file in HP-UX.

Device Numbers and Jump Tables Contd. n There are some common steps in all three examples that have to be done after adding and modifying the files specified for each example: - Building a new kernel. - Copying the old kernel aside and installing the new kernel. - Rebooting and testing the new kernel. - Creating device files and test the device itself.

Device Files n By convention, device files are kept in the /dev directory. n ATT systems handle device files quite nicely by using separate subdirectory of /dev for each type of device: disk, tape, terminal, etc. n Device files are created with the mknod command, which has the syntax: mknod filename type major minor where where - filename is the device file to be created. - type is c for a character device or b for a block device. - major and minor are the major and minor device numbers.

Device Files Contd. n A shell script called MAKEDEV is sometimes provided (in /dev) to automatically supply default values to mknod. n You need to scan through the script to find the arguments needed for your device. For example, to make PTY entries on a SunOS system, you would use the following command: # cd /dev #./MAKEDEV pty

Naming Conventions For Devices n Devices that have both block and character identities usually - preface the character device name with the letter r for “row” (e.g., /dev/sd0 and /dev/rsd0), or - place it in a subdirectory with a name that starts with r (e.g., /dev/dsk/dks0d3s0 vs. /dev/rdsk/dks0d3s0). n Serial devices are usually named tty followed by a sequence of letters that identify the interface the port is attached to (See chapter 8 for more information about serial ports). about serial ports).

Naming Conventions For Devices Contd. n BSD disk names often begin with a two-letter abbreviation for either the drive of the controller, followed by the drive number and partition name. - Example: sd0a is the block device representing the partition of the first disk drive on a SCSI controller; rsd0a is the corresponding character device. n The names of tapes and devices often include not only a reference to the drive itself, but also an indication of whether the device rewinds after each tape operation and the density at which it reads and writes.

Loadable Kernel Modules n Loadable modules allow device drivers to be linked into and removed from the kernel while it is running. - This makes the installation of drivers much easier, since the kernel binary does not have to be changed. - It also allows the kernel to be smaller, because drivers are not loaded unless they are needed. n Loadable modules are implemented by providing one or more documents “hooks” into the kernel where additional device drivers can grab on. n A user-level command communicates with the kernel and tells it to load new modules into memory and to make entries for them in the system’s jump tables.

Loadable kernel Modules Contd. n Although loadable drivers are convenient, they are not entirely safe. n Any time you load or unload a module, you risk causing a kernel panic. n Like other aspects of device and driver management, the implementation of loadable modules is operating system dependent. n There are four of the example systems that support loadable modules: - Solaris: In Solaris, virtually everything is a loadable module. The modinfo command lists the currently-loaded modules. You can add a driver with the add_drv command.

Loadable Kernel Modules Contd. - HP-UX: Generic HP-UX does not support loadable modules, but there is an option that allows the loading of STREAMS modules. - IRIX: IRIX 5.2 supports loadable modules; earlier versions did not. Modules are manipulated with the ml command. ml with the list option catalogs the modules that the kernel is currently aware of. - SunOS: SunOS versions and later contain support for loadable modules. Currently-loaded modules can be listed with modstat.

END OF CHAPTER END OF CHAPTERQUESTIONS???