26
2008 Chapter-4 L13: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc. 1 DEVICE DRIVERS AND TERRUPTS SERVICE MECHANISM Lesson Lesson - - 14: Device types, Physical and Virtual 14: Device types, Physical and Virtual device functions device functions

device functions Lesson MECHANISM - Devi Ahilya · PDF file · 2008-06-16Like physical device, virtual device drivers ... Driver filename in Windows OS is used ... Linux Internals

Embed Size (px)

Citation preview

Page 1: device functions Lesson MECHANISM - Devi Ahilya · PDF file · 2008-06-16Like physical device, virtual device drivers ... Driver filename in Windows OS is used ... Linux Internals

2008 Chapter-4 L13: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc. 1

DEVICE DRIVERS AND TERRUPTS SERVICE MECHANISMLessonLesson--14: Device types, Physical and Virtual 14: Device types, Physical and Virtual device functionsdevice functions

Page 2: device functions Lesson MECHANISM - Devi Ahilya · PDF file · 2008-06-16Like physical device, virtual device drivers ... Driver filename in Windows OS is used ... Linux Internals

2008 Chapter-4 L13: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc. 2

� For each type of device, there is a set of the generic commands.

� For example, for char device one set of commands and for block device there can be another set.

Device TypesDevice Types

Page 3: device functions Lesson MECHANISM - Devi Ahilya · PDF file · 2008-06-16Like physical device, virtual device drivers ... Driver filename in Windows OS is used ... Linux Internals

2008 Chapter-4 L13: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc. 3

� Types of Physical and Virtual devices in a system may be as follows:

char, block, loop back device, file, pipe, socket, RAM disk, sound, video and media.

Device TypesDevice Types

Page 4: device functions Lesson MECHANISM - Devi Ahilya · PDF file · 2008-06-16Like physical device, virtual device drivers ... Driver filename in Windows OS is used ... Linux Internals

2008 Chapter-4 L13: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc. 4

Virtual device driver- Definition : A virtual-device driver is the

component of a device driver that communicates directly between an application and memory or a physical device.

- Virtual device driver controls the flow of data

- Allows more than one application to access the same memory or physical device without conflict.

Page 5: device functions Lesson MECHANISM - Devi Ahilya · PDF file · 2008-06-16Like physical device, virtual device drivers ... Driver filename in Windows OS is used ... Linux Internals

2008 Chapter-4 L13: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc. 5

� Char Device: For example, a device to which one character is sent at one time or is read from it at one time. For example, mouse, keyboard, keypad, timer .

Char DeviceChar Device

Page 6: device functions Lesson MECHANISM - Devi Ahilya · PDF file · 2008-06-16Like physical device, virtual device drivers ... Driver filename in Windows OS is used ... Linux Internals

2008 Chapter-4 L13: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc. 6

• Block Device: For example, a device to which one block of characters is sent at one time or is read from it at one time. For example, printer, disk.

Block DeviceBlock Device

Page 7: device functions Lesson MECHANISM - Devi Ahilya · PDF file · 2008-06-16Like physical device, virtual device drivers ... Driver filename in Windows OS is used ... Linux Internals

2008 Chapter-4 L13: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc. 7

� Block as well as Char device: For example, a device to which one block of characters or a single character is sent at one time or is read from it at one time. For, example, LCD display unit. A device can be configured as char or block as per the need by a generic command.

Block Device configuration as Char DeviceBlock Device configuration as Char Device

Page 8: device functions Lesson MECHANISM - Devi Ahilya · PDF file · 2008-06-16Like physical device, virtual device drivers ... Driver filename in Windows OS is used ... Linux Internals

2008 Chapter-4 L13: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc. 8

� Loop-back Device: A device to which one character or set of characters are sent, and those are echoed back to same.

Configuration as loopConfiguration as loop--back Deviceback Device

Page 9: device functions Lesson MECHANISM - Devi Ahilya · PDF file · 2008-06-16Like physical device, virtual device drivers ... Driver filename in Windows OS is used ... Linux Internals

2008 Chapter-4 L13: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc. 9

• Copy Device: A device using which a set of characters are sent, and those are returned to another device. For example, disk_copy device when characters are copied from one disk to another or a keyboard-cum-display device. Keyboard input is sent to a buffer and display unit uses that buffer for display.

Configuration as copy DeviceConfiguration as copy Device

Page 10: device functions Lesson MECHANISM - Devi Ahilya · PDF file · 2008-06-16Like physical device, virtual device drivers ... Driver filename in Windows OS is used ... Linux Internals

2008 Chapter-4 L13: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc. 10

Virtual DevicesVirtual Devices• Besides the physical devices of a system,

drivers are also used in a systems for virtual devices.

• Physical device drivers and virtual device drivers have analogies.

• Like physical device, virtual device drivers may also have functions for device connect or open, read, write and close.

Page 11: device functions Lesson MECHANISM - Devi Ahilya · PDF file · 2008-06-16Like physical device, virtual device drivers ... Driver filename in Windows OS is used ... Linux Internals

2008 Chapter-4 L13: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc. 11

� A memory block can have data buffers for input and output in analogy to buffers at an IO device and can be accessed from a char driver or block or pipe or socketdriver.

DriverDriver

Page 12: device functions Lesson MECHANISM - Devi Ahilya · PDF file · 2008-06-16Like physical device, virtual device drivers ... Driver filename in Windows OS is used ... Linux Internals

2008 Chapter-4 L13: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc. 12

• Pipe device: A device from to which the blocks of characters are send from one end and accessed from another ends in FIFO mode (first-in first-out) after a connect function is executed to connect two ends.

Virtual Device ExamplesVirtual Device Examples

Page 13: device functions Lesson MECHANISM - Devi Ahilya · PDF file · 2008-06-16Like physical device, virtual device drivers ... Driver filename in Windows OS is used ... Linux Internals

2008 Chapter-4 L13: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc. 13

� Socket device: A device from to which (a) the blocks of characters are send from one end with a set of the port (application) and sender addresses, (b) accessed from another end port (application) and receiver addresses, (c) access is in FIFO mode (first-in first-out) only after a connect function is executed to connect two sockets.

Virtual Device Examples ...Virtual Device Examples ...

Page 14: device functions Lesson MECHANISM - Devi Ahilya · PDF file · 2008-06-16Like physical device, virtual device drivers ... Driver filename in Windows OS is used ... Linux Internals

2008 Chapter-4 L13: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc. 14

� File device: A device from which the blocks of characters are accessed similar to a disk in a tree like format (folder, subfolder,...). For example, a named file at the memory stick.

Virtual Device Examples...Virtual Device Examples...

Page 15: device functions Lesson MECHANISM - Devi Ahilya · PDF file · 2008-06-16Like physical device, virtual device drivers ... Driver filename in Windows OS is used ... Linux Internals

2008 Chapter-4 L13: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc. 15

� RAM disk Device: A set of RAM memory blocks used like a disk, which is accessed by defining addresses of directory, subdirectory, second level subdirectory, folder and subfolder

Virtual Device ExamplesVirtual Device Examples

Page 16: device functions Lesson MECHANISM - Devi Ahilya · PDF file · 2008-06-16Like physical device, virtual device drivers ... Driver filename in Windows OS is used ... Linux Internals

2008 Chapter-4 L13: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc. 16

� Pipe needs one address at an end, � Socket one addresses and one port

number at an end, and � File and disk can have multiple

addresses. Reading and writing into a file is from or to current cursor address in the currently open folder.

Difference between various types of virtual Difference between various types of virtual devicesdevices

Page 17: device functions Lesson MECHANISM - Devi Ahilya · PDF file · 2008-06-16Like physical device, virtual device drivers ... Driver filename in Windows OS is used ... Linux Internals

2008 Chapter-4 L13: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc. 17

• Just as a file is sent read call, a device must be sent a driver command when its input buffer(s) is to be read.

• Just as a file is sent write call, a device needs to be sent a driver command when its output buffer is to be written.

Page 18: device functions Lesson MECHANISM - Devi Ahilya · PDF file · 2008-06-16Like physical device, virtual device drivers ... Driver filename in Windows OS is used ... Linux Internals

2008 Chapter-4 L13: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc. 18

Virtual device example for Remote Virtual device example for Remote System accessSystem access

� A virtual device example is a device description that is used to form a connection between a user and a physical system networked or connected to a remote system.

Page 19: device functions Lesson MECHANISM - Devi Ahilya · PDF file · 2008-06-16Like physical device, virtual device drivers ... Driver filename in Windows OS is used ... Linux Internals

2008 Chapter-4 L13: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc. 19

Virtual device driver File name (VxD)

- Driver filename in Windows OS is used where the V stands for virtual and D stands for device.The “d" can be replaced with other characters; for example, VdD means a display driver.

Page 20: device functions Lesson MECHANISM - Devi Ahilya · PDF file · 2008-06-16Like physical device, virtual device drivers ... Driver filename in Windows OS is used ... Linux Internals

2008 Chapter-4 L13: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc. 20

• Linux has internal functions called Internals. Internals exist for the device-drivers and network-management functions.

• Useful Linux drivers for the embedded system and gives the uses of each.

Linux Internals and Device Drivers and Linux Network Functions

Page 21: device functions Lesson MECHANISM - Devi Ahilya · PDF file · 2008-06-16Like physical device, virtual device drivers ... Driver filename in Windows OS is used ... Linux Internals

2008 Chapter-4 L13: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc. 21

• Char (For driving a character)• Block (For driving a block of char)• Input (For standard IO devices)• Media (For standard media device functions)• Video (For standard video device functions)• Sound (For standard auido device functions)

Linux drivers

Page 22: device functions Lesson MECHANISM - Devi Ahilya · PDF file · 2008-06-16Like physical device, virtual device drivers ... Driver filename in Windows OS is used ... Linux Internals

2008 Chapter-4 L13: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc. 22

The Linux internal functions exist foro Sockets, o Handling of Socket buffers, o firewalls, o network Protocols (for examples, NFS, IP, IPv6

and Ethernet) and o bridges.• They work separately as drivers and also form

a part of the network management function of the operating system.

Linux drivers in the net directory

Page 23: device functions Lesson MECHANISM - Devi Ahilya · PDF file · 2008-06-16Like physical device, virtual device drivers ... Driver filename in Windows OS is used ... Linux Internals

2008 Chapter-4 L13: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc. 23

SummarySummary

Page 24: device functions Lesson MECHANISM - Devi Ahilya · PDF file · 2008-06-16Like physical device, virtual device drivers ... Driver filename in Windows OS is used ... Linux Internals

2008 Chapter-4 L13: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc. 24

We learntWe learnt

• Physical and virtual devices• Drivers for virtual devices are also written

similar to the physical device drivers • Use the same generic commands. • Device Types : char, block, loop back, file

device, pipe, socket, RAM disk, sound, video and media.

• Device examples are char device, block device, loop back device, file device, pipe, socket and RAM disk

Page 25: device functions Lesson MECHANISM - Devi Ahilya · PDF file · 2008-06-16Like physical device, virtual device drivers ... Driver filename in Windows OS is used ... Linux Internals

2008 Chapter-4 L13: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc. 25

We learnt� Linux operating system has internals and a

large number of readily available device drivers for the most common physical and virtual devices and has the functions for the network sockets and protocols

Page 26: device functions Lesson MECHANISM - Devi Ahilya · PDF file · 2008-06-16Like physical device, virtual device drivers ... Driver filename in Windows OS is used ... Linux Internals

2008 Chapter-4 L13: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc. 26

End of Lesson 14 of Chapter 4End of Lesson 14 of Chapter 4