+ All Categories
Home > Documents > IOCTL and Device

IOCTL and Device

Date post: 03-Apr-2018
Category:
Upload: mitul-modi
View: 223 times
Download: 0 times
Share this document with a friend

of 18

Transcript
  • 7/29/2019 IOCTL and Device

    1/18

    IOCTL and Device drivers:

    Character Devices And Block Devices

    By: Bharat Parmar

    Roll No: 195M.E I (MSA)

  • 7/29/2019 IOCTL and Device

    2/18

    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 isgenerally called an I/O bus.

    The 80 x 86 microprocessors use 16 of their address pinsto 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 bymeans of a hierarchy of hardware components..

  • 7/29/2019 IOCTL and Device

    3/18

    IOCTL Functions

    IOCTL functions are used to control I/Odevices.

    IOCTL do not mean Transfer Of Data.

    Data transfer can take place through DOS or

    BIOS or Drivers.

  • 7/29/2019 IOCTL and Device

    4/18

    Types of Devices

    Devices are classified in Two Types

    Character Devices: Process single Bit at atime.

    Examples are.. Keyboard, Mouse, Printer.

    Block Devices :Process block of Datasimultaneously

    Examples.. Disk Drive, CDROM.

  • 7/29/2019 IOCTL and Device

    5/18

    Split view

  • 7/29/2019 IOCTL and Device

    6/18

    Character Devices

    They are controlled in either Binary or ASCIImode by IOCTL functions.

    They are named using DOS conventions.

    They are opened with file open function3DH.

  • 7/29/2019 IOCTL and Device

    7/18

    IOCTL character device names

    Name Device

    AUX The COM1 Device in most systems

    CLOCK$ The real time system clockCOM1 Serial communications port number 1COM2 Serial communications port number 2COM3 Serial communications port number 3COM4 Serial communications port number 4

    CON Console, the keyboard for Input and the videodisplay for output

    EMMXXXX0 The expanded memory manager EMM386.EXELPT1 Parallel Port Number 1LPT2 Parallel Port Number 2

    LPT3 Parallel Port Number 3LPT4 Parallel Port Number 4NUL A Nonexistent DevicePRN LPT1 in Most systemsXMSXXXX0 The Extended Memory Manager HIMEM.SYS

  • 7/29/2019 IOCTL and Device

    8/18

  • 7/29/2019 IOCTL and Device

    9/18

    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.

  • 7/29/2019 IOCTL and Device

    10/18

    Device Driver

    Special programs installed by CONFIG.SYS tocontrol installable devices.

    Used for the newly added device

    It is a .COM file ( TINY model )

  • 7/29/2019 IOCTL and Device

    11/18

    DEVICE DRIVER

    Device Driver

    Header Strategy Procedure Interrupt procedure

  • 7/29/2019 IOCTL and Device

    12/18

    Interrupt procedure

    Strategy procedure

    Driver Name

    (8 bytes)

    Interrupt offset address

    Strategy offset address

    Attribute

    Driver linkage

    Construction of a device driver

    0012H

    000AH

    0008H

    0006H

    0004H

    Header

    0000H

  • 7/29/2019 IOCTL and Device

    13/18

    HEADER

    Contains pointers that allow it to chain toother drivers loaded in the system.

    First doubleword (-1) informs that this is lastdriver in chain.

    It is followed by attribute word, whichindicates type of header included for driverand type of device the driver installs.

  • 7/29/2019 IOCTL and Device

    14/18

    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

  • 7/29/2019 IOCTL and Device

    15/18

    Strategy Procedure

    It is called whenever device driver is loadedin to memory or whenever I/O requests areissued.

    Its main purpose is to save the Request

    header and its address.

    Return Status Word Communicatesinformation back to DOS from Device Driver.

    Device Driver Commands in Request Header By DOS

  • 7/29/2019 IOCTL and Device

    16/18

    Device Driver Commands in Request Header By DOS

    Command Purpose

    00H Initialize Driver 01H Media Check

    02H Build BPB (Block Device Parameter Block) 03H Control Read 04H Read 05H Non destructive Read 06H Input StatusInput Status 07H Input FlushInput Flush 08H WriteWrite 09H Write with verifyWrite with verify 0AH Output StatusOutput Status 0BH Output FlushOutput Flush 0CH Control writeControl write 0DH Open DeviceOpen Device 0EH Close DeviceClose Device

    0FH Removable MediaRemovable Media 10H Output until BusyOutput until Busy 13H Generic IOCTLGeneric IOCTL 17H Get logical DeviceGet logical Device 18H Set logical DeviceSet logical Device 19H IOCTL QueryIOCTL Query

  • 7/29/2019 IOCTL and Device

    17/18

    INTERRUPT PROCEDRE

    It uses request header to determine thefunction requested by DOS.

    It performs all functions for Device Driver

    Interrupt Procedure is different from

    Interrupt Handler.

  • 7/29/2019 IOCTL and Device

    18/18


Recommended