Sie sind auf Seite 1von 26

REAL TIME OPERATING SYSTEMS

Lesson-6:
Device Management Functions

2008 Chapter-8 L6: "Embedded Systems - Architecture, Programming 1


and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
1. Device manager functions

2008 Chapter-8 L6: "Embedded Systems - Architecture, Programming 2


and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
Device 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

2008 Chapter-8 L6: "Embedded Systems - Architecture, Programming 3


and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
Device manager
 Software that manages the device drivers of
each device
 Provides and executes the modules for
managing the devices and their drivers
ISRs.
 Effectively operates and adopts appropriate
strategy for obtaining optimal performance
for the devices.
 Coordinates between application-process,
driver and device-controller.
2008 Chapter-8 L6: "Embedded Systems - Architecture, Programming 4
and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
Device manager
 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.

2008 Chapter-8 L6: "Embedded Systems - Architecture, Programming 5


and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
Device manager
 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.]

2008 Chapter-8 L6: "Embedded Systems - Architecture, Programming 6


and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
Device manager

 Manages the physical as well as virtual


devices like the pipes and sockets through a
common strategy.

2008 Chapter-8 L6: "Embedded Systems - Architecture, Programming 7


and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
Device management has three standard
approaches
 Three types of device drivers:
 (i) Programmed I/Os by polling from each
device its the service need from each
device.
 Interrupt(s) from the device drivers device-
ISR and
 (iii) Device uses DMA operation used by
the devices to access the memory.
 Most common is the use of device driver
ISRs
2008 Chapter-8 L6: "Embedded Systems - Architecture, Programming 8
and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
Device Manager Functions

 Device Detection and Addition


 Device Deletion
 Device Allocation and
 Registration
 Detaching and Deregistration

2008 Chapter-8 L6: "Embedded Systems - Architecture, Programming 9


and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
Device 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

2008 Chapter-8 L6: "Embedded Systems - Architecture, Programming 10


and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
Device Manager Functions

 Device drivers updating and upload of new


device-functions
 Backup and restoration

2008 Chapter-8 L6: "Embedded Systems - Architecture, Programming 11


and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
Device Types

 char devices and


 block devices

2008 Chapter-8 L6: "Embedded Systems - Architecture, Programming 12


and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
2. Set of Command Functions for the
Device Management

2008 Chapter-8 L6: "Embedded Systems - Architecture, Programming 13


and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
Commands for Device

 create
 open
 write
 read
 ioctl
 close and
 delete
2008 Chapter-8 L6: "Embedded Systems - Architecture, Programming 14
and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
ioctl Command for Device

 (i) Accessing specific partition information


 (ii) Defining commands and control
functions of device registers
 (iii) IO channel control

2008 Chapter-8 L6: "Embedded Systems - Architecture, Programming 15


and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
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 defined
function are at the third argument

2008 Chapter-8 L6: "Embedded Systems - Architecture, Programming 16


and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
Example

 Status = ioctl (fd, FIOBAUDRATE, 19200)


is an instruction in RTOS VxWorks.
 fd is 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 operation
at 19200-baud rate.

2008 Chapter-8 L6: "Embedded Systems - Architecture, Programming 17


and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
3. Device Driver ISR functions

2008 Chapter-8 L6: "Embedded Systems - Architecture, Programming 18


and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
ISR 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
2008 Chapter-8 L6: "Embedded Systems - Architecture, Programming 19
and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
4. Unix OS functions

2008 Chapter-8 L6: "Embedded Systems - Architecture, Programming 20


and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
UNIX 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, read and write functions.

2008 Chapter-8 L6: "Embedded Systems - Architecture, Programming 21


and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
APIs and kernel interfaces in BSD (Berkley
sockets for devices)
 open,

 close,

 read

 write

2008 Chapter-8 L6: "Embedded Systems - Architecture, Programming 22


and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
in--kernel commands
in
 (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 block read or
write or character read or write

2008 Chapter-8 L6: "Embedded Systems - Architecture, Programming 23


and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
Summary

2008 Chapter-8 L6: "Embedded Systems - Architecture, Programming 24


and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
We learnt
• Device Manager initializes, controls, and
drives the physical devices and virtual
devices of the system.
• Main classes of devices are char devices
and block devices.
• Device driver functions may be similar to
file functions, open, read, lseek, write and
close

2008 Chapter-8 L6: "Embedded Systems - Architecture, Programming 25


and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
End of Lesson 6 of Chapter 8

2008 Chapter-8 L6: "Embedded Systems - Architecture, Programming 26


and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.

Das könnte Ihnen auch gefallen