8/9/2019 4 Device Management
1/26
2008 Chapter-8 L6: "Embedded Systems - Architecture, Programming
and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.1
REAL TIME OPERATING SYSTEMS
Lesson-6:Device Management Functions
8/9/2019 4 Device Management
2/26
2008 Chapter-8 L6: "Embedded Systems - Architecture, Programming
and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.2
1. Device manager functions1. Device manager functions
8/9/2019 4 Device Management
3/26
2008 Chapter-8 L6: "Embedded Systems - Architecture, Programming
and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.3
Device Driver ISRsDevice Driver ISRs
Number of device driver ISRs in a
system,
Each device or device function having s a
separate driver, which is as per its
hardware
8/9/2019 4 Device Management
4/26
2008 Chapter-8 L6: "Embedded Systems - Architecture, Programming
and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.4
Software that manages the device drivers ofeach device
Provides and executes the modules for
managing the devices and their driversISRs.
Effectively operates and adopts appropriatestrategy for obtaining optimal performancefor the devices.
Coordinates between application-process,driver and device-controller.
Device managerDevice manager
8/9/2019 4 Device Management
5/26
2008 Chapter-8 L6: "Embedded Systems - Architecture, Programming
and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.5
Process sends a request to the driver by an
interrupt; and the driver provides the actions
by executing an ISR.
Device manager polls the requests at the
devices and the actions occur as per their
priorities.
Manages IO Interrupts (requests) queues.
Device managerDevice manager
8/9/2019 4 Device Management
6/26
2008 Chapter-8 L6: "Embedded Systems - Architecture, Programming
and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.6
Creates an appropriate kernel interface and
API and that activates the control register
specific actions of the device. [Activates
device controller through the API and
kernel interface.]
Device managerDevice manager
8/9/2019 4 Device Management
7/26
2008 Chapter-8 L6: "Embedded Systems - Architecture, Programming
and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.7
Device managerDevice manager
Manages the physical as well as virtual
devices like the pipes and sockets through a
common strategy.
8/9/2019 4 Device Management
8/26
2008 Chapter-8 L6: "Embedded Systems - Architecture, Programming
and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
8
Device management has three standardDevice management has three standard
approachesapproaches
Three types of device drivers:
(i) Programmed I/Os by polling from eachdevice its the service need from each
device. Interrupt(s) from the device drivers device-
ISR and
(iii) Device uses DMA operation used bythe devices to access the memory.
Most common is the use of device driverISRs
8/9/2019 4 Device Management
9/26
2008 Chapter-8 L6: "Embedded Systems - Architecture, Programming
and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
9
Device Manager FunctionsDevice Manager Functions
Device Detection and Addition
Device Deletion
Device Allocation and
Registration
Detaching and Deregistration
8/9/2019 4 Device Management
10/26
2008 Chapter-8 L6: "Embedded Systems - Architecture, Programming
and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
10
Device Manager FunctionsDevice Manager Functions
Restricting Device to a specific process
Device Sharing
Device control
Device Access Management
Device Buffer Management
Device Queue, Circular-queue or blocks of
queues Management
8/9/2019 4 Device Management
11/26
2008 Chapter-8 L6: "Embedded Systems - Architecture, Programming
and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
11
Device Manager FunctionsDevice Manager Functions
Device drivers updating and upload of new
device-functions
Backup and restoration
8/9/2019 4 Device Management
12/26
2008 Chapter-8 L6: "Embedded Systems - Architecture, Programming
and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
12
Device TypesDevice Types
char devices and
block devices
8/9/2019 4 Device Management
13/26
2008 Chapter-8 L6: "Embedded Systems - Architecture, Programming
and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
13
2.2. Set of Command Functions for theSet of Command Functions for the
Device ManagementDevice Management
8/9/2019 4 Device Management
14/26
2008 Chapter-8 L6: "Embedded Systems - Architecture, Programming
and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
14
Commands for DeviceCommands for Device
create
open
write read
ioctl
close and
delete
8/9/2019 4 Device Management
15/26
2008 Chapter-8 L6: "Embedded Systems - Architecture, Programming
and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
15
ioctl Command for Deviceioctl Command for Device
(i) Accessing specific partition information
(ii) Defining commands and control
functions of device registers
(iii) IO channel control
8/9/2019 4 Device Management
16/26
2008 Chapter-8 L6: "Embedded Systems - Architecture, Programming
and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
16
Three arguments in ioctl ( )Three arguments in ioctl ( )
First Argument: Defines the chosen device and
its function by passing as argument the device
descriptor (a number), for example, fd or sfd
Example is fd = 1 for read, fd = 2 for write. Second Argument: Defines the control option or
uses option for the IO device, for example, baud
rate or other parameter optional function
Third Argument: Values needed by the definedfunction are at the third argument
8/9/2019 4 Device Management
17/26
2008 Chapter-8 L6: "Embedded Systems - Architecture, Programming
and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
17
ExampleExample
Status = ioctl (fd, FIOBAUDRATE, 19200)
is an instruction in RTOS VxWorks.
fdis the device descriptor (an integer
returned when the device is opened)
FIOBAUDRATE is the function that takes
value = 19200 from the argument.
This at configures the device for operationat 19200-baud rate.
8/9/2019 4 Device Management
18/26
2008 Chapter-8 L6: "Embedded Systems - Architecture, Programming
and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
18
3. Device Driver ISR functions3. Device Driver ISR functions
8/9/2019 4 Device Management
19/26
2008 Chapter-8 L6: "Embedded Systems - Architecture, Programming
and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
19
ISR functionsISR functions
intlock( ) to disable device-interrupts
systems,
intUnlock ( ) to enable device-interrupts,
intConnect( ) to connect a C function to an
interrupt vector
Interrupt vector address for a device ISR
points to its specified C function. intContext ( ) finds whether interrupt is
called when an ISR was in execution
8/9/2019 4 Device Management
20/26
2008 Chapter-8 L6: "Embedded Systems - Architecture, Programming
and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
20
4. Unix OS functions4. Unix OS functions
8/9/2019 4 Device Management
21/26
2008 Chapter-8 L6: "Embedded Systems - Architecture, Programming
and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
21
UNIX Device driver functionsUNIX Device driver functions
Facilitates that for devices and files have an
analogous implementation as far as
possible.
open ( ),
close ( ),
read( ),
write ( ) functions analogous to a file open,close, readand write functions.
8/9/2019 4 Device Management
22/26
2008 Chapter-8 L6: "Embedded Systems - Architecture, Programming
and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
22
APIs and kernel interfaces in BSD (BerkleyAPIs and kernel interfaces in BSD (Berkley
sockets for devices)sockets for devices) open,
close,
read
write
8/9/2019 4 Device Management
23/26
2008 Chapter-8 L6: "Embedded Systems - Architecture, Programming
and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
23
inin--kernel commandskernel commands
(i) select( ) to check whther read/write will
succeed and then select
(ii) ioctl ( )
(iii) stop ( ) to cancel the output activity
from the device.
(iv) strategy ( ) to permit a blockread or
write or character read or write
8/9/2019 4 Device Management
24/26
2008 Chapter-8 L6: "Embedded Systems - Architecture, Programming
and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
24
SummarySummary
8/9/2019 4 Device Management
25/26
2008 Chapter-8 L6: "Embedded Systems - Architecture, Programming
and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
25
We learntWe learnt
Device Manager initializes, controls, anddrives the physical devices and virtual
devices of the system.
Main classes of devices are char devicesand block devices.
Device driver functions may be similar to
file functions, open, read, lseek, write and
close
8/9/2019 4 Device Management
26/26
2008 Chapter-8 L6: "Embedded Systems - Architecture, Programming
and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
26
End of Lesson 6 of Chapter 8End of Lesson 6 of Chapter 8
Top Related