Вы находитесь на странице: 1из 18

IOCTL and Device drivers:

Character Devices And Block Devices

By: Bharat Parmar Roll No: 195 M.E I (MSA)

80x86 I/0 Ports


Any I/O device is hosted by one, and only one bus. The bus type affects the internal design of the I/O device, as well as how the device has to be handled by the kernel The data path that connects a CPU to an I/O device is generally called an I/O bus. The 80 x 86 microprocessors use 16 of their address pins to address I/O devices and 8, 16, or 32 of their data pins to transfer data. The I/O bus, in turn, is connected to each I/O device by means of a hierarchy of hardware components..

IOCTL Functions IOCTL functions are used to control I/O devices. IOCTL do not mean Transfer Of Data. Data transfer can take place through DOS or BIOS or Drivers.

Types of Devices
Devices are classified in Two Types

Character Devices: Process single Bit at a time.


Examples are.. Keyboard, Mouse, Printer.

Block Devices :Process block of Data simultaneously


Examples.. Disk Drive, CDROM.

Split view

Character Devices They are controlled in either Binary or ASCII mode by IOCTL functions. They are named using DOS conventions. They are opened with file open function3DH.

IOCTL character device names

Name
AUX CLOCK$ COM1 COM2 COM3 COM4 CON EMMXXXX0 LPT1 LPT2 LPT3 LPT4 NUL PRN XMSXXXX0

Device
The COM1 Device in most systems The real time system clock Serial communications port number 1 Serial communications port number 2 Serial communications port number 3 Serial communications port number 4 Console, the keyboard for Input and the video display for output The expanded memory manager EMM386.EXE Parallel Port Number 1 Parallel Port Number 2 Parallel Port Number 3 Parallel Port Number 4 A Nonexistent Device LPT1 in Most systems The Extended Memory Manager HIMEM.SYS

Block Devices
Block Devices transfer information block at a time They are indicated using numbers.

BL--00HDefault Block Device 01HBlock Device A 02H Block Device B.

Device Driver
Special programs installed by CONFIG.SYS to control installable devices. Used for the newly added device It is a .COM file ( TINY model )

DEVICE DRIVER

Device Driver

Header

Strategy Procedure

Interrupt procedure

Construction of a device driver

Interrupt procedure

Strategy procedure

0012H

Driver Name (8 bytes)

000AH 0008H 0006H 0004H 0000H

Interrupt offset address

Strategy offset address

Header
Attribute Driver linkage

HEADER Contains pointers that allow it to chain to other drivers loaded in the system. First doubleword (-1) informs that this is last driver in chain. It is followed by attribute word, which indicates type of header included for driver and type of device the driver installs.

Device Driver Attribute Values


| F | E | D | C | B | A-7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| | | | | | | | | | | | `-- 1 = character device is stdin | | | | | | | | | | | | 1 = block dev supports generic IOCTL | | | | | | | | | | | `---1 = character device is stdout | | | | | | | | | | | 1 = block dev supports generic IOCTL | | | | | | | | | | `---- 1 = current NUL device | | | | | | | | | `----- 1 = current clock device | | | | | | | `-------- reserved by DOS | | | | | | `--------- 1 = supports Get/Set logical device | | | | | `----------- reserved (must be zero) | | | | `------------- 1 = supports removable media | | | `-------------- reserved (must be zero) | | `--------------- 1 = non-IBM format (block device) | | 1 = output until busy (char device) | `---------------- 1 = supports IOCTL strings `----------------- 1 = character device, 0 = block device

Strategy Procedure It is called whenever device driver is loaded in to memory or whenever I/O requests are issued.

Its main purpose is to save the Request header and its address. Return Status Word Communicates information back to DOS from Device Driver.

Device Driver Commands in Request Header By DOS Command 00H 01H 02H 03H 04H 05H 06H 07H 08H 09H 0AH 0BH 0CH 0DH 0EH 0FH 10H 13H 17H 18H 19H Purpose Initialize Driver Media Check Build BPB (Block Device Parameter Block) Control Read Read Non destructive Read Input StatusInput Status Input FlushInput Flush WriteWrite Write with verifyWrite with verify Output StatusOutput Status Output FlushOutput Flush Control writeControl write Open DeviceOpen Device Close DeviceClose Device Removable MediaRemovable Media Output until BusyOutput until Busy Generic IOCTLGeneric IOCTL Get logical DeviceGet logical Device Set logical DeviceSet logical Device IOCTL QueryIOCTL Query

INTERRUPT PROCEDRE It uses request header to determine the function requested by DOS. It performs all functions for Device Driver Interrupt Procedure is different from Interrupt Handler.

Вам также может понравиться