Operating Systems II Unit OS6: Device Management 6.2. Windows I/O - - PowerPoint PPT Presentation

operating systems ii unit os6 device management 6 2
SMART_READER_LITE
LIVE PREVIEW

Operating Systems II Unit OS6: Device Management 6.2. Windows I/O - - PowerPoint PPT Presentation

Operating Systems II Unit OS6: Device Management 6.2. Windows I/O System Components Prof. Dr. Andreas Polze, Andreas Grapentin, Bernhard Rabe Roadmap for Sec.on 6.2 6.2. The Windows I/O System Components


slide-1
SLIDE 1

Operating Systems II Unit OS6: Device Management 6.2. Windows I/O System Components

  • Prof. Dr. Andreas Polze,

Andreas Grapentin, Bernhard Rabe

slide-2
SLIDE 2

2 ¡

Roadmap ¡for ¡Sec.on ¡6.2 ¡

  • 6.2. ¡The ¡Windows ¡I/O ¡System ¡Components ¡

– I/O ¡System ¡Design ¡Goals ¡ – I/O ¡System ¡Components ¡ – Func.ons ¡of ¡the ¡I/O ¡Manager ¡ – Control ¡flow ¡for ¡an ¡I/O ¡opera.on ¡ – Plug ¡and ¡Play ¡(PnP) ¡and ¡Power ¡Manager ¡ – Driver ¡Verifier ¡ – Windows ¡Driver ¡Model ¡(WDM) ¡classifica.on ¡

slide-3
SLIDE 3

3 ¡

I/O ¡System ¡Design ¡Goals ¡

  • Fast ¡I/O ¡processing ¡on ¡single ¡/ ¡mul.processor ¡systems ¡
  • Protec.on ¡for ¡shareable ¡resources ¡

– Using ¡Windows ¡security ¡mechanisms ¡

  • Meet ¡requirements ¡dictated ¡by ¡different ¡subsystems ¡
  • Provide ¡common ¡services ¡for ¡device ¡drivers ¡

– Ease ¡device ¡driver ¡development ¡ – Allow ¡drivers ¡to ¡be ¡wriSen ¡in ¡high-­‑level ¡language ¡

  • Dynamic ¡addi.on/removal ¡of ¡device ¡drivers ¡
  • Support ¡mul.ple ¡file ¡systems ¡(FAT, ¡CDFS, ¡UDF, ¡NTFS) ¡
  • Provide ¡mapped ¡file ¡I/O ¡capabili.es ¡
  • Windows ¡Management ¡Instrumenta.on ¡support ¡and ¡diagnosability ¡

– Drivers ¡can ¡ ¡be ¡managed ¡through ¡WMI ¡applica.ons ¡and ¡scripts. ¡

slide-4
SLIDE 4

4 ¡

I/O ¡System ¡Components ¡

Applica'ons ¡ Windows ¡ Services ¡ WMI ¡Service ¡ User-­‑Mode ¡ PnP ¡Manager ¡ Setup ¡ Components ¡ Setup ¡ Components ¡ Setup ¡ Components ¡ WDM ¡WMI ¡ Rou'nes ¡ PnP ¡Manager ¡ Power ¡ Manager ¡ I/O ¡Manager ¡ Driver ¡1 ¡ Driver ¡2 ¡ HAL ¡ .inf ¡files ¡ .cat ¡files ¡ Registry ¡ User ¡ Mode ¡ Kernel ¡ Mode ¡ I/O ¡System ¡ Drivers ¡ … ¡

slide-5
SLIDE 5

5 ¡

I/O ¡System ¡Components ¡

  • The ¡I/O ¡manager ¡ ¡

– Connects ¡applica.ons ¡and ¡system ¡components ¡to ¡virtual, ¡logical, ¡and ¡physical ¡ devices ¡ – Windows ¡APIs: ¡ReadFile, ¡WriteFile, ¡CreateFile, ¡CloseFile, ¡DeviceIoControl ¡ – Defines ¡the ¡infrastructure ¡that ¡supports ¡device ¡drivers ¡

  • A ¡device ¡driver ¡typically ¡provides ¡an ¡I/O ¡interface ¡for ¡a ¡par.cular ¡type ¡of ¡

device ¡

– Device ¡drivers ¡receive ¡commands ¡routed ¡to ¡them ¡by ¡the ¡I/O ¡manager ¡that ¡are ¡ directed ¡at ¡devices ¡they ¡manage, ¡and ¡they ¡inform ¡the ¡I/O ¡manager ¡when ¡ those ¡commands ¡complete ¡ – Device ¡drivers ¡oZen ¡use ¡the ¡I/O ¡manager ¡to ¡forward ¡I/O ¡commands ¡to ¡other ¡ device ¡drivers ¡that ¡share ¡in ¡the ¡implementa.on ¡of ¡a ¡device's ¡interface ¡or ¡

  • control. ¡

– Several ¡types: ¡

  • “ordinary”, ¡ ¡
  • file ¡system, ¡network, ¡ ¡
  • bus ¡drivers, ¡etc. ¡
slide-6
SLIDE 6

6 ¡

I/O ¡Manager ¡

  • Framework ¡for ¡delivery ¡of ¡I/O ¡request ¡packets ¡(IRPs) ¡
  • IRPs ¡control ¡processing ¡of ¡all ¡I/O ¡opera.ons ¡

(excep.on: ¡fast ¡I/O ¡does ¡not ¡use ¡IRPs) ¡

  • I/O ¡manager: ¡

– creates ¡an ¡IRP ¡for ¡each ¡I/O ¡opera.on; ¡ – passes ¡IRP ¡to ¡correct ¡drivers; ¡ – deletes ¡IRP ¡when ¡I/O ¡opera.on ¡is ¡complete ¡

  • Driver: ¡

– Receives ¡IRP ¡ – Performs ¡opera.ons ¡specified ¡by ¡IRP ¡ – Passes ¡IRP ¡back ¡to ¡I/O ¡manager ¡or ¡to ¡another ¡driver ¡(via ¡I/O ¡manager) ¡for ¡ further ¡processing ¡

slide-7
SLIDE 7

7 ¡

I/O ¡Manager ¡(contd.) ¡

  • Supplies ¡common ¡code ¡for ¡different ¡drivers: ¡

– Drivers ¡become ¡simpler, ¡more ¡compact ¡

  • I/O ¡manager: ¡

– Allows ¡driver ¡to ¡call ¡other ¡drivers ¡ – Manages ¡buffers ¡for ¡I/O ¡requests ¡ – Provides ¡.me-­‑out ¡support ¡for ¡drivers ¡ – Records ¡which ¡installable ¡file ¡systems ¡are ¡loaded ¡ – Provides ¡flexible ¡I/O ¡services ¡to ¡environment ¡subsystems ¡ (Windows/POSIX ¡asynchronous ¡I/O) ¡

  • Layered ¡processing ¡of ¡I/O ¡requests ¡possible: ¡

– Drivers ¡can ¡call ¡each ¡other ¡(via ¡I/O ¡manager) ¡

slide-8
SLIDE 8

8 ¡

I/O ¡Func.ons ¡

  • Advanced ¡features ¡beyond ¡open, ¡close, ¡read, ¡write: ¡
  • Asynchronous ¡I/O: ¡

– May ¡improve ¡throughput/performance: ¡ con.nue ¡program ¡execu.on ¡while ¡I/O ¡is ¡in ¡progress ¡ – Must ¡specify ¡FILE_FLAG_OVERLAPPED ¡on ¡ ¡CreateFile() ¡ – Programmer ¡is ¡responsible ¡for ¡synchroniza.on ¡of ¡I/O ¡requests ¡

  • Internally, ¡all ¡I/O ¡is ¡performed ¡asynchronously ¡

– I/O ¡ ¡system ¡returns ¡to ¡caller ¡only ¡if ¡file ¡was ¡opened ¡for ¡asynch. ¡I/O ¡ ¡ – For ¡synchronous ¡I/O, ¡wait ¡is ¡done ¡in ¡kernel ¡mode ¡depending ¡on ¡

  • verlapped ¡flag ¡in ¡file ¡object ¡
  • Status ¡of ¡pending ¡I/O ¡can ¡be ¡tested: ¡

– via ¡Windows-­‑API ¡func.on: ¡HasOverlappedIoCompleted() ¡ – when ¡using ¡I/O ¡comple.on ¡ports: ¡GetQueuedComple6onStatus() ¡

slide-9
SLIDE 9

9 ¡

Control ¡flow ¡for ¡an ¡I/O ¡opera.on ¡

Call ¡Nt ¡ReadFile() ¡ Dismiss ¡interrupt ¡ Call ¡Invoke ¡driver() ¡ Wait ¡or ¡return ¡ ¡ to ¡caller ¡ Ini.ate ¡I/O ¡opera.on ¡ Return ¡to ¡caller ¡ Call ¡ReadFile() ¡ Call ¡NtReadFile() ¡ Return ¡to ¡caller ¡ Int ¡2E ¡ Return ¡to ¡caller ¡ User ¡mode ¡ Kernel ¡mode ¡ Applica.on ¡ KERNEL32.DLL ¡ NTDLL.DLL ¡ NTOSKRNL.EXE ¡ NTOSKRNL.EXE ¡ DRIVER.SYS ¡ ReadFile ¡ NtReadFile ¡ KiSystemService ¡ NtReadFile ¡ Whether ¡to ¡wait ¡depends ¡

  • n ¡overlapped ¡flag ¡
slide-10
SLIDE 10

10 ¡

Advanced ¡I/O ¡Func.ons ¡

  • Fast ¡I/O ¡

– Bypass ¡genera.on ¡of ¡IRPs ¡ – Go ¡directly ¡to ¡file ¡system ¡driver ¡or ¡cache ¡manager ¡to ¡complete ¡I/O ¡

  • Mapped ¡File ¡I/O ¡and ¡File ¡Caching ¡

– Available ¡through ¡Windows-­‑API ¡CreateFileMapping() ¡/ ¡ MapViewOfFile() ¡ – Used ¡by ¡OS ¡for ¡file ¡caching ¡and ¡image ¡ac.va.on ¡ – Used ¡by ¡file ¡systems ¡via ¡cache ¡manager ¡to ¡improve ¡performance ¡

  • ScaQer/Gather ¡I/O ¡

– Windows-­‑API ¡func.ons ¡ReadFileScaSer()/WriteFileScaSer() ¡ – Read/write ¡mul.ple ¡buffers ¡with ¡a ¡single ¡system ¡call ¡ – File ¡must ¡be ¡opened ¡for ¡non-­‑cached, ¡asynchronous ¡I/O; ¡ buffers ¡must ¡be ¡page-­‑aligned ¡ ¡

slide-11
SLIDE 11

11 ¡

HAL ¡

  • The ¡hardware ¡abstrac.on ¡layer ¡(HAL) ¡insulates ¡drivers ¡from ¡

the ¡specifics ¡of ¡the ¡processor ¡and ¡interrupt ¡controller ¡by ¡ providing ¡APIs ¡that ¡hide ¡differences ¡between ¡plaoorms ¡ – in ¡essence, ¡the ¡HAL ¡is ¡the ¡bus ¡driver ¡for ¡all ¡the ¡devices ¡on ¡ the ¡computer's ¡motherboard ¡that ¡aren't ¡controlled ¡by ¡

  • ther ¡drivers ¡

– By ¡programming ¡to ¡the ¡HAL ¡drivers ¡are ¡source-­‑level ¡ compa.ble ¡across ¡CPU ¡architectures ¡ ¡

slide-12
SLIDE 12

12 ¡

PnP ¡and ¡Power ¡

  • The ¡PnP ¡manager ¡

– Handles ¡driver ¡loading ¡and ¡star.ng ¡ ¡ – Performs ¡resource ¡arbitra.on ¡ – It ¡relies ¡on ¡the ¡I/O ¡Manager ¡to ¡load ¡drivers ¡and ¡send ¡them ¡ PnP-­‑related ¡commands ¡

  • The ¡power ¡manager ¡controls ¡the ¡power ¡state ¡of ¡the ¡system ¡

– It ¡relies ¡on ¡the ¡I/O ¡Manager ¡to ¡ask ¡drivers ¡if ¡they ¡can ¡ change ¡power ¡state ¡and ¡to ¡inform ¡them ¡when ¡they ¡should ¡

slide-13
SLIDE 13

13 ¡

The ¡Driver ¡Verifier ¡

  • Driver ¡Verifier ¡is ¡a ¡tool ¡introduced ¡in ¡Windows ¡2000 ¡that ¡

helps ¡developers ¡test ¡their ¡drivers ¡and ¡systems ¡administrators ¡ iden.fy ¡faulty ¡drivers ¡

– Must ¡be ¡run ¡from ¡\windows\system32\verifier.exe (no shortcut) ¡

This ¡is ¡the ¡ Windows ¡ ¡ 2000 ¡GUI ¡ to ¡driver ¡ verifier ¡

slide-14
SLIDE 14

14 ¡

Verifica.on ¡Op.ons ¡

  • Special ¡Pool ¡

– The ¡memory ¡returned ¡for ¡driver ¡memory ¡ ¡ alloca.ons ¡is ¡bounded ¡with ¡invalid ¡regions ¡ ¡to ¡catch ¡buffer ¡overrun ¡and ¡underrun ¡ – To ¡be ¡described ¡in ¡Crash ¡Analysis ¡sec.on ¡

  • Force ¡IRQL ¡checking ¡

– Detects ¡drivers ¡that ¡access ¡paged ¡memory ¡ ¡ when ¡the ¡system ¡is ¡in ¡a ¡state ¡that ¡can’t ¡ ¡ tolerate ¡page ¡faults ¡

  • Low ¡Resource ¡Simula.on ¡

– Randomly ¡fails ¡driver ¡memory ¡alloca.ons ¡

  • Pool ¡Tracking ¡

– Associates ¡memory ¡with ¡the ¡driver ¡that ¡allocated ¡it ¡to ¡help ¡iden.fy ¡leaks ¡

  • I/O ¡verifica.on ¡

– Ensures ¡that ¡I/O ¡commands ¡are ¡properly ¡formaSed ¡and ¡handled ¡

slide-15
SLIDE 15

15 ¡

Driver ¡Verifier ¡– ¡XP/Server ¡2003 ¡ Enhancements ¡

  • Simpler ¡wizard-­‑style ¡UI ¡

– Default ¡is ¡verify ¡unsigned ¡drivers ¡

  • Four ¡new ¡verifica.on ¡op.ons ¡in ¡XP: ¡

– DMA ¡verifica.on ¡– ¡detects ¡improper ¡use ¡of ¡ DMA ¡buffers, ¡adapters, ¡and ¡map ¡registers ¡ – Deadlock ¡detec.on ¡– ¡detects ¡lock ¡hierarchy ¡ viola.ons ¡with ¡spinlocks, ¡mutexes, ¡fast ¡ mutexes ¡ – SCSI ¡verifica.on ¡-­‑ ¡monitors ¡the ¡interac.on ¡ between ¡a ¡SCSI ¡miniport ¡driver ¡and ¡the ¡port ¡ driver ¡ – Enhanced ¡I/O ¡Verifica.on ¡tests ¡drivers' ¡ support ¡for ¡power ¡management, ¡WMI, ¡and ¡ filters ¡ ¡

  • One ¡new ¡on ¡in ¡Server ¡2003: ¡

– Disk ¡integrity ¡checking ¡-­‑ ¡monitors ¡a ¡hard ¡disk ¡ and ¡detects ¡whether ¡the ¡disk ¡is ¡preserving ¡its ¡ data ¡correctly ¡ ¡

(this ¡is ¡the ¡Windows ¡ ¡ XP/2003 ¡GUI) ¡

slide-16
SLIDE 16

16 ¡

Kernel-­‑Mode ¡Drivers ¡

  • KMDF: ¡Kernel-­‑mode ¡Driver ¡Framework ¡
  • Windows ¡kernel-­‑mode ¡drivers ¡ ¡ ¡

– PnP ¡Drivers: ¡Integrate ¡with ¡the ¡power ¡manager ¡and ¡PnP ¡manager ¡

  • Mass ¡storage ¡devices ¡
  • Input ¡devices ¡

– Non ¡PnP ¡Drivers: ¡Don’t ¡have ¡to ¡integrate ¡with ¡the ¡PnP ¡manager ¡

  • Protocol ¡stacks ¡
  • Network ¡adapters ¡
  • Virtual ¡devices ¡(Filemon, ¡Regmon) ¡
  • File ¡system ¡drivers ¡accept ¡I/O ¡requests ¡to ¡files ¡and ¡sa.sfy ¡the ¡requests ¡by ¡

issuing ¡their ¡own, ¡more ¡explicit ¡requests ¡to ¡mass ¡storage ¡or ¡network ¡ device ¡drivers ¡

– Interact ¡closely ¡with ¡MM ¡and ¡Cache ¡Manager ¡

slide-17
SLIDE 17

17 ¡

User-­‑Mode ¡Drivers ¡

  • UMDF: ¡User-­‑mode ¡driver ¡Framework ¡
  • Virtual ¡device ¡drivers ¡(VDDs) ¡are ¡used ¡to ¡emulate ¡16-­‑bit ¡MS-­‑DOS ¡

applica.ons. ¡ ¡

– User-­‑mode ¡can't ¡access ¡hardware ¡directly ¡and ¡thus ¡must ¡go ¡through ¡a ¡real ¡ kernel-­‑mode ¡device ¡driver. ¡ ¡ – They ¡trap ¡what ¡an ¡MS-­‑DOS ¡applica.on ¡thinks ¡are ¡references ¡to ¡I/O ¡ports ¡and ¡ translates ¡them ¡into ¡na.ve ¡Windows ¡I/O ¡func.ons ¡

  • Windows ¡subsystem ¡printer ¡drivers ¡translate ¡device-­‑independent ¡graphics ¡

requests ¡to ¡printer-­‑specific ¡commands. ¡ ¡

– Commands ¡are ¡forwarded ¡to ¡a ¡kernel-­‑mode ¡port ¡driver ¡such ¡as ¡the ¡parallel ¡ port ¡driver ¡(Parport.sys) ¡or ¡the ¡universal ¡serial ¡bus ¡(USB) ¡printer ¡port ¡driver ¡ (Usbprint.sys) ¡

slide-18
SLIDE 18

18 ¡

WDM ¡Driver ¡Classifica.on ¡

  • Windows ¡Driver ¡Model ¡

– Unified ¡architecture ¡for ¡drivers ¡ – Originally ¡intended ¡to ¡be ¡Win9x/NT ¡cross ¡plaoorm ¡ – Most ¡PnP ¡Drivers ¡are ¡WDM ¡drivers ¡

  • There ¡are ¡three ¡types ¡of ¡WDM ¡drivers: ¡ ¡

– Bus ¡drivers ¡manage ¡a ¡logical ¡or ¡physical ¡bus ¡e.g. ¡PCMCIA, ¡PCI, ¡… ¡ – Func6on ¡drivers ¡manage ¡a ¡par.cular ¡type ¡of ¡device. ¡Bus ¡drivers ¡present ¡ devices ¡to ¡func.on ¡drivers ¡via ¡the ¡PnP ¡manager. ¡ ¡ – Filter ¡drivers ¡logically ¡layer ¡above ¡or ¡below ¡func.on ¡drivers, ¡augmen.ng ¡or ¡ changing ¡the ¡behavior ¡of ¡a ¡device ¡or ¡another ¡driver. ¡ ¡

slide-19
SLIDE 19

19 ¡

WDM ¡Driver ¡Classifica.on ¡

  • In ¡WDM, ¡no ¡one ¡driver ¡is ¡responsible ¡for ¡controlling ¡all ¡aspects ¡of ¡a ¡

par.cular ¡device. ¡ ¡

Bus ¡Driver ¡ Bus ¡Filter ¡ Func'on ¡Driver ¡ Func'on ¡Lower ¡Filter ¡ Func'on ¡Upper ¡Filter ¡

slide-20
SLIDE 20

20 ¡

Class/Port/Miniport ¡Driver ¡Classifica.on ¡

  • Hardware ¡support ¡might ¡be ¡split ¡between ¡different ¡modules ¡that ¡implement ¡

support ¡for ¡different ¡levels ¡of ¡abstrac.on ¡

– MicrosoZ ¡typically ¡provides ¡the ¡drivers ¡for ¡the ¡higher ¡levels ¡of ¡abstrac.on ¡ – Hardware ¡vendors ¡provide ¡the ¡lowest ¡level, ¡which ¡understands ¡a ¡par.cular ¡device ¡

  • The ¡conven.onal ¡division ¡is ¡three ¡levels: ¡

– Class ¡drivers ¡implement ¡the ¡I/O ¡processing ¡for ¡a ¡par.cular ¡class ¡of ¡devices, ¡such ¡as ¡disk, ¡ tape, ¡or ¡CD-­‑ROM. ¡ ¡ – Port ¡drivers ¡implement ¡the ¡processing ¡of ¡an ¡I/O ¡request ¡specific ¡to ¡a ¡type ¡of ¡I/O ¡port, ¡ such ¡as ¡SCSI, ¡and ¡are ¡also ¡implemented ¡as ¡kernel-­‑mode ¡libraries ¡of ¡func.ons ¡rather ¡than ¡ actual ¡device ¡drivers. ¡ ¡ – Miniport ¡drivers ¡map ¡a ¡generic ¡I/O ¡request ¡to ¡a ¡type ¡of ¡port ¡into ¡an ¡adapter ¡type, ¡such ¡ as ¡a ¡specific ¡SCSI ¡adapter. ¡Miniport ¡drivers ¡are ¡actual ¡device ¡drivers ¡that ¡import ¡the ¡ func.ons ¡supplied ¡by ¡a ¡port ¡driver. ¡

slide-21
SLIDE 21

21 ¡

Class/Port/Miniport ¡Driver ¡Classifica.on ¡

Miniport ¡Driver ¡ Port ¡Driver ¡ Class ¡Driver ¡

slide-22
SLIDE 22

22 ¡

Layered ¡Driver ¡Structure ¡

Rela.onships ¡among ¡ various ¡types ¡of ¡kernel-­‑ mode ¡device ¡drivers ¡

Windows ¡I/O ¡system ¡interface ¡ FAT ¡file ¡ system ¡ NTFS ¡ CD-­‑ROM ¡ file ¡system ¡ CD-­‑ROM ¡ class ¡driver ¡ Tape ¡class ¡ ¡driver ¡ FTDisk ¡ driver ¡ (striping, ¡ mirroring) ¡ Disk ¡class ¡ ¡driver ¡ port ¡ driver ¡ Miniport ¡ drivers ¡ Miniport ¡ drivers ¡

slide-23
SLIDE 23

23 ¡

Dynamically ¡Layering ¡a ¡File ¡System ¡Driver ¡and ¡a ¡ Disk ¡Driver ¡

Environment ¡ ¡ subsystem ¡

  • r ¡DLL ¡

User ¡mode ¡ Kernel ¡mode ¡ NtWriteFile(file_handle, ¡char_buffer) ¡ System ¡services ¡

I/O ¡ manager ¡

Write ¡data ¡at ¡specified ¡ byte ¡offset ¡within ¡a ¡file ¡ File ¡system ¡ driver ¡ Translate ¡file-­‑rela.ve ¡byte ¡offset ¡ into ¡disk-­‑rela.ve ¡byte ¡offset, ¡and ¡ ¡ call ¡next ¡driver ¡(via ¡I/O ¡manager) ¡ File ¡system ¡ driver ¡ Disk ¡driver ¡ Call ¡driver ¡to ¡write ¡data ¡at ¡ ¡ disk-­‑rela.ve ¡byte ¡offset ¡ Translate ¡disk-­‑rela.ve ¡byte ¡offset ¡into ¡ physical ¡loca.on, ¡and ¡transfer ¡data ¡ Call ¡next ¡driver ¡ to ¡write ¡data ¡to ¡ ¡ Disk ¡3 ¡at ¡disk-­‑ ¡ rela.ve ¡byte ¡offset ¡ Mul.-­‑ ¡ volume ¡ disk ¡ ¡driver ¡

Adding ¡a ¡ layered ¡driver ¡

Disk ¡2 ¡ Disk ¡3 ¡ Disk ¡1 ¡

slide-24
SLIDE 24

24 ¡

Internal ¡Structure ¡of ¡a ¡Driver ¡

  • I/O ¡manager ¡executes ¡ini.aliza.on ¡rou.ne ¡when ¡loading ¡a ¡driver ¡
  • PnP ¡manager ¡calls ¡add-­‑device ¡rou.ne ¡on ¡device ¡detec.on ¡
  • Dispatch ¡rou.nes: ¡open(), ¡close(), ¡read(), ¡write() ¡
  • Start ¡I/O ¡rou.ne ¡ini.ates ¡transfer ¡from/to ¡a ¡device ¡
  • ISR ¡runs ¡in ¡response ¡to ¡interrupt; ¡schedules ¡DPC ¡
  • DPC ¡rou.ne ¡performs ¡actual ¡work ¡of ¡handling ¡interrupt; ¡

starts ¡next ¡queued ¡I/O ¡opera.on ¡on ¡device ¡

Start ¡I/O ¡rou.ne ¡ Interrupt ¡service ¡ rou.ne ¡(ISR) ¡ Dispatch ¡rou.nes ¡ Ini.aliza.on ¡ rou.ne ¡ DPC ¡rou.ne ¡ Driver ¡ Dispatch ¡rou.nes ¡ Dispatch ¡rou.nes ¡ Add-­‑device ¡rou.ne ¡

slide-25
SLIDE 25

25 ¡

Other ¡components ¡of ¡device ¡drivers ¡

  • Comple'on ¡rou'nes ¡

– A ¡layered ¡driver ¡may ¡have ¡comple.on ¡rou.nes ¡that ¡will ¡no.fy ¡it ¡when ¡a ¡lower-­‑level ¡ driver ¡finishes ¡processing ¡an ¡IRP ¡ (I/O ¡Request ¡Packet) ¡

  • Cancel ¡I/O ¡rou'ne ¡
  • Unload ¡rou'ne ¡

– Releases ¡system ¡resources ¡

  • System ¡shutdown ¡no'fica'on ¡rou'ne ¡
  • Error-­‑logging ¡rou'nes ¡

– No.fy ¡I/O ¡manager ¡to ¡write ¡record ¡to ¡error ¡log ¡file ¡(e.g., ¡bad ¡disk ¡block) ¡

  • Windows ¡Driver ¡Model ¡(WDM) ¡ ¡

– Plug ¡& ¡Play ¡support ¡ ¡ – Source ¡compa.ble ¡between ¡Win98/ME ¡ ¡

slide-26
SLIDE 26

26 ¡

Further ¡Reading ¡

¡ ¡

  • Mark ¡E. ¡Russinovich ¡and ¡David ¡A. ¡Solomon, ¡ ¡

MicrosoZ ¡Windows ¡Internals, ¡4th ¡Edi.on, ¡MicrosoZ ¡Press, ¡

  • 2004. ¡
  • Chapter ¡9 ¡-­‑ ¡I/O ¡System ¡

– I/O ¡System ¡Components ¡(from ¡pp. ¡537) ¡ – Typical ¡I/O ¡Processing ¡(from ¡pp. ¡540) ¡ – Types ¡of ¡Device ¡Drivers ¡(from ¡pp. ¡541) ¡ – Driver ¡Objects ¡and ¡Device ¡Objects ¡(from ¡pp. ¡550) ¡ ¡

slide-27
SLIDE 27

27 ¡

Source ¡Code ¡References ¡

  • Windows ¡Research ¡Kernel ¡sources ¡

– \base\ntos\io ¡– ¡I/O ¡Manager ¡ – \base\ntos\inc\io.h ¡– ¡addi.onal ¡structure ¡ defini.ons ¡ – \base\ntos\verifer ¡– ¡Driver ¡Verifier ¡