计算机系 信息处理实验室 lecture 12 i/o system xlanchen@05/13/2005

42
计计计计•计计计计计计计 Lecture 12 I/O System xlanchen@05/13/2005

Upload: denis-boone

Post on 24-Dec-2015

313 views

Category:

Documents


5 download

TRANSCRIPT

Page 1: 计算机系 信息处理实验室 Lecture 12 I/O System xlanchen@05/13/2005

计算机系•信息处理实验室

Lecture 12 I/O System

xlanchen@05/13/2005

Page 2: 计算机系 信息处理实验室 Lecture 12 I/O System xlanchen@05/13/2005

xlanchen@05/13/2005 Understanding the Inside of Windows 2000 2计算机系

信息处理实验室

Contents

I/O System Components

I/O Data Structures

Driver Loading, Initialization, and Installation

I/O Processing

Page 3: 计算机系 信息处理实验室 Lecture 12 I/O System xlanchen@05/13/2005

xlanchen@05/13/2005 Understanding the Inside of Windows 2000 3计算机系

信息处理实验室

I/O System Components

I/O manager

Page 4: 计算机系 信息处理实验室 Lecture 12 I/O System xlanchen@05/13/2005

xlanchen@05/13/2005 Understanding the Inside of Windows 2000 4计算机系

信息处理实验室

The flow of a typical I/O request

Page 5: 计算机系 信息处理实验室 Lecture 12 I/O System xlanchen@05/13/2005

xlanchen@05/13/2005 Understanding the Inside of Windows 2000 5计算机系

信息处理实验室

I/O Manager

The I/O manager defines the orderly framework, or model, within which I/O requests are delivered to device drivers.

Packet driven

I/O request packet (IRP)

Flexible I/O services

Page 6: 计算机系 信息处理实验室 Lecture 12 I/O System xlanchen@05/13/2005

xlanchen@05/13/2005 Understanding the Inside of Windows 2000 6计算机系

信息处理实验室

Device Drivers

Types

File system drivers

Windows 2000 drivers

Legacy drivers

display drivers

WDM drivers

Bus drivers

Function drivers

Filter drivers

Page 7: 计算机系 信息处理实验室 Lecture 12 I/O System xlanchen@05/13/2005

xlanchen@05/13/2005 Understanding the Inside of Windows 2000 7计算机系

信息处理实验室

user-mode drivers Virtual device drivers (VDDs) Win32 subsystem printer drivers

Driver componentsClass driversPort drivers Miniport drivers

Page 8: 计算机系 信息处理实验室 Lecture 12 I/O System xlanchen@05/13/2005

xlanchen@05/13/2005 Understanding the Inside of Windows 2000 8计算机系

信息处理实验室

Layering of a FSD and a disk driver

Page 9: 计算机系 信息处理实验室 Lecture 12 I/O System xlanchen@05/13/2005

xlanchen@05/13/2005 Understanding the Inside of Windows 2000 9计算机系

信息处理实验室

Adding a layered driver

Page 10: 计算机系 信息处理实验室 Lecture 12 I/O System xlanchen@05/13/2005

xlanchen@05/13/2005 Understanding the Inside of Windows 2000 10计算机系

信息处理实验室

Structure of a Drive

The I/O system drives the execution of device drivers

Primary device driver routines

Page 11: 计算机系 信息处理实验室 Lecture 12 I/O System xlanchen@05/13/2005

xlanchen@05/13/2005 Understanding the Inside of Windows 2000 11计算机系

信息处理实验室

Plug and Play (PnP) Manager

Page 12: 计算机系 信息处理实验室 Lecture 12 I/O System xlanchen@05/13/2005

xlanchen@05/13/2005 Understanding the Inside of Windows 2000 12计算机系

信息处理实验室

Power Manager

Requirement

hardware must comply with ACPI specification

The six system power states

See table 9-2

Page 13: 计算机系 信息处理实验室 Lecture 12 I/O System xlanchen@05/13/2005

xlanchen@05/13/2005 Understanding the Inside of Windows 2000 13计算机系

信息处理实验室

System power-state transitions

Sleeping

waking

Page 14: 计算机系 信息处理实验室 Lecture 12 I/O System xlanchen@05/13/2005

xlanchen@05/13/2005 Understanding the Inside of Windows 2000 14计算机系

信息处理实验室

I/O Data Structures

File Objects Driver Objects and Device Objects I/O Request Packets I/O Completion Ports

Page 15: 计算机系 信息处理实验室 Lecture 12 I/O System xlanchen@05/13/2005

xlanchen@05/13/2005 Understanding the Inside of Windows 2000 15计算机系

信息处理实验室

File Objects

File Object Attributes

Filename

Current byte offset

Share modes

Open mode flags

Pointer to device object

Pointer to the volume parameter block (VPB)

Pointer to section object pointers

Pointer to private cache map

Page 16: 计算机系 信息处理实验室 Lecture 12 I/O System xlanchen@05/13/2005

xlanchen@05/13/2005 Understanding the Inside of Windows 2000 16计算机系

信息处理实验室

Opening a file object

Page 17: 计算机系 信息处理实验室 Lecture 12 I/O System xlanchen@05/13/2005

xlanchen@05/13/2005 Understanding the Inside of Windows 2000 17计算机系

信息处理实验室

Driver Objects and Device Objects

A driver object represents an individual driver in the system.

A device object represents a physical or logical device on the system and describes its characteristics

Page 18: 计算机系 信息处理实验室 Lecture 12 I/O System xlanchen@05/13/2005

xlanchen@05/13/2005 Understanding the Inside of Windows 2000 18计算机系

信息处理实验室

The driver object

Page 19: 计算机系 信息处理实验室 Lecture 12 I/O System xlanchen@05/13/2005

xlanchen@05/13/2005 Understanding the Inside of Windows 2000 19计算机系

信息处理实验室

I/O Request Packets

IRP is where the I/O system stores information it needs to process an I/O request.

Page 20: 计算机系 信息处理实验室 Lecture 12 I/O System xlanchen@05/13/2005

xlanchen@05/13/2005 Understanding the Inside of Windows 2000 20计算机系

信息处理实验室

Data structures involved in a single-layered driver I/O request

Page 21: 计算机系 信息处理实验室 Lecture 12 I/O System xlanchen@05/13/2005

xlanchen@05/13/2005 Understanding the Inside of Windows 2000 21计算机系

信息处理实验室

IRP Stack Locations

IRP

a fixed header

one or more stack locations

IRP Buffer Management

Buffered I/O

Direct I/O

Neither I/O

Page 22: 计算机系 信息处理实验室 Lecture 12 I/O System xlanchen@05/13/2005

xlanchen@05/13/2005 Understanding the Inside of Windows 2000 22计算机系

信息处理实验室

I/O Completion Ports

The IoCompletion ObjectApplications use the IoCompletion executive object, which is exported to Win32 as a completion port, as the focal point for the completion of I/O associated with multiple file handles.

Page 23: 计算机系 信息处理实验室 Lecture 12 I/O System xlanchen@05/13/2005

xlanchen@05/13/2005 Understanding the Inside of Windows 2000 23计算机系

信息处理实验室

I/O completion port operation

Page 24: 计算机系 信息处理实验室 Lecture 12 I/O System xlanchen@05/13/2005

xlanchen@05/13/2005 Understanding the Inside of Windows 2000 24计算机系

信息处理实验室

Driver Loading, Initialization, and Installation

Explicit loading

Enumeration-based loading

Page 25: 计算机系 信息处理实验室 Lecture 12 I/O System xlanchen@05/13/2005

xlanchen@05/13/2005 Understanding the Inside of Windows 2000 25计算机系

信息处理实验室

The Start Value

boot-start (0)

system-start (1)

auto-start (2)

demand-start (3)

Page 26: 计算机系 信息处理实验室 Lecture 12 I/O System xlanchen@05/13/2005

xlanchen@05/13/2005 Understanding the Inside of Windows 2000 26计算机系

信息处理实验室

Device Enumeration

PnP manager

primary bus driver

device tree

Page 27: 计算机系 信息处理实验室 Lecture 12 I/O System xlanchen@05/13/2005

xlanchen@05/13/2005 Understanding the Inside of Windows 2000 27计算机系

信息处理实验室

Example device tree

Page 28: 计算机系 信息处理实验室 Lecture 12 I/O System xlanchen@05/13/2005

xlanchen@05/13/2005 Understanding the Inside of Windows 2000 28计算机系

信息处理实验室

Devnodes

Page 29: 计算机系 信息处理实验室 Lecture 12 I/O System xlanchen@05/13/2005

xlanchen@05/13/2005 Understanding the Inside of Windows 2000 29计算机系

信息处理实验室

Driver Installation

Page 30: 计算机系 信息处理实验室 Lecture 12 I/O System xlanchen@05/13/2005

xlanchen@05/13/2005 Understanding the Inside of Windows 2000 30计算机系

信息处理实验室

I/O Processing

Types of I/OSynchronous I/O and Asynchronous I/O

Fast I/OMapped File I/O and File CachingScatter/Gather I/O

Page 31: 计算机系 信息处理实验室 Lecture 12 I/O System xlanchen@05/13/2005

xlanchen@05/13/2005 Understanding the Inside of Windows 2000 31计算机系

信息处理实验室

Control flow for an I/O operation

Page 32: 计算机系 信息处理实验室 Lecture 12 I/O System xlanchen@05/13/2005

xlanchen@05/13/2005 Understanding the Inside of Windows 2000 32计算机系

信息处理实验室

I/O Request to a Single-Layered Driver

Page 33: 计算机系 信息处理实验室 Lecture 12 I/O System xlanchen@05/13/2005

xlanchen@05/13/2005 Understanding the Inside of Windows 2000 33计算机系

信息处理实验室

Servicing an Interrupt

Phrase 1

Page 34: 计算机系 信息处理实验室 Lecture 12 I/O System xlanchen@05/13/2005

xlanchen@05/13/2005 Understanding the Inside of Windows 2000 34计算机系

信息处理实验室

Phrase 2

Page 35: 计算机系 信息处理实验室 Lecture 12 I/O System xlanchen@05/13/2005

xlanchen@05/13/2005 Understanding the Inside of Windows 2000 35计算机系

信息处理实验室

Completing an I/O Request

Phrase 1

Page 36: 计算机系 信息处理实验室 Lecture 12 I/O System xlanchen@05/13/2005

xlanchen@05/13/2005 Understanding the Inside of Windows 2000 36计算机系

信息处理实验室

Phrase 2

Page 37: 计算机系 信息处理实验室 Lecture 12 I/O System xlanchen@05/13/2005

xlanchen@05/13/2005 Understanding the Inside of Windows 2000 37计算机系

信息处理实验室

I/O Requests to Layered Drivers

Page 38: 计算机系 信息处理实验室 Lecture 12 I/O System xlanchen@05/13/2005

xlanchen@05/13/2005 Understanding the Inside of Windows 2000 38计算机系

信息处理实验室

Completing a layered I/O request

Page 39: 计算机系 信息处理实验室 Lecture 12 I/O System xlanchen@05/13/2005

xlanchen@05/13/2005 Understanding the Inside of Windows 2000 39计算机系

信息处理实验室

Queuing associated IRPs

Page 40: 计算机系 信息处理实验室 Lecture 12 I/O System xlanchen@05/13/2005

xlanchen@05/13/2005 Understanding the Inside of Windows 2000 40计算机系

信息处理实验室

Completing associated IRPs

Page 41: 计算机系 信息处理实验室 Lecture 12 I/O System xlanchen@05/13/2005

xlanchen@05/13/2005 Understanding the Inside of Windows 2000 41计算机系

信息处理实验室

I/O Completion Port Operation

Page 42: 计算机系 信息处理实验室 Lecture 12 I/O System xlanchen@05/13/2005

xlanchen@05/13/2005 Understanding the Inside of Windows 2000 42计算机系

信息处理实验室

Synchronization