820 likes | 916 Views
Ch. 9 I/O System. 발표자 : 서우석 발표일 : 2006 년 11 월 6 일. 목차. I/O System Components Device Drivers I/O Processing The Plug and Play (PnP) Manager The Power Manager Conclusion. 목차. I/O System Components Device Drivers I/O Processing The Plug and Play (PnP) Manager The Power Manager
E N D
Ch. 9 I/O System 발표자: 서우석 발표일: 2006년 11월 6일
목차 • I/O System Components • Device Drivers • I/O Processing • The Plug and Play (PnP) Manager • The Power Manager • Conclusion
목차 • I/O System Components • Device Drivers • I/O Processing • The Plug and Play (PnP) Manager • The Power Manager • Conclusion
Design Goal • Provide an abstraction of devices to apps. • Features • High performance asynchronous packet-based I/O • Services support High-Level language and different machine architecture • Layering and extensibility • Dynamic loading and unloading of device drivers • Support for Plug and Play • Support for power management • Support for multiple installable file systems • Windows Management Instrumentation
I/O Manager • The Core of the I/O System • I/O System is packet driven • Presented by an I/O Request Packet (IRP) • Create Passing (Forwarding ) Disposing • Supply common code • Individual drivers become simpler and more compact. • Other features • Manages buffers for I/O requests • Provides timeout support • Records installable file systems • Common routines • Asynchronous I/O
Typical I/O Processing • Abstracts all I/O requests as operations on a virtual file, even if it is not a file. • virtual files refers to any source or destination for I/O • open, close, read, write functions
목차 • I/O System Components • Device Drivers • I/O Processing • The Plug and Play (PnP) Manager • The Power Manager • Conclusion
Types of Device Drivers • user-mode drivers • Virtual device drivers to emulate 16-bit MS-DOS app • Printer drivers • kernel-mode drivers • File system drivers • Plug and Play drivers • Non–Plug and Play drivers • ex) network API and protocol drivers
WDM Drivers • support for Windows power management, Plug and Play, and WMI • Types of WDM drivers • Bus drivers manage a logical or physical bus • ex) PCMCIA, PCI, USB, IEEE 1394, and ISA • detecting and informing the PnP manager of devices attached to the bus • Function drivers with the most knowledge about the operation of the device • Filter drivers logically layer above or below function drivers, augmenting or changing the behavior of a device or another driver • ex) keyboard capture driver
Layered Drivers • Class drivers • implement the I/O processing for a particular class of devices, such as disk, tape, or CD-ROM • where the hardware interfaces have been standardized and so one driver can serve devices from a wide variety of manufacturers • Port drivers • implement the processing of an I/O request specific to a type of I/O port, such as SCSI • implemented as kernel-mode libraries of functions • Miniport drivers • map a generic I/O request to a type of port into an adapter type, such as a specific SCSI adapter
Key driver-function routines initiate a data transfer to or from a device. This routine is defined only in drivers that rely on the I/O manager to queue its incoming I/O requests the main functions that a device driver provides When a device interrupts, the kernel's interrupt dispatcher transfers control to this routine. Only drivers for interrupt- driven devices have ISRs; a file system driver, for example, doesn't have one. The PnP manager sends a driver notification via this routine. driver typically allocates a device object DPC routine executes at a lower IRQL (DPC/dispatch level) than that of the ISR fills in system data structures to register the rest of the driver's routines with the I/O manager and performs any global driver initialization that's necessary
Other routines • One or more I/O completion routines • notify it when a lower-level driver finishes processing an IRP • A cancel I/O routine • I/O operation can be canceled • An unload routine • I/O manager can remove drivers from memory • A system shutdown notification routine • allows driver cleanup on system shutdown • Error-logging routines • When unexpected errors occur (for example, when a disk block goes bad), a driver's error-logging routines note the occurrence and notify the I/O manager
Driver Objects and Device Objects • driver object • represents an individual driver in the system • The I/O manager obtains the address of each of the driver's dispatch routines (entry points) from the driver object • device object • represents a physical or logical device on the system and describes its characteristics • Create driver object calls the driver's initialization routine create device objects to represent devices (Most PnP drivers create devices with add-device routines, optionally assign the device a name (\Device)) unload
Location of Device object • Symbolic link • make it possible for applications to open the device object • in the \Global?? directory • Non–Plug and Play and file system drivers typically create a symbolic link with a well-known name • ex) \Device\Hardware2 • IoRegisterDeviceInterface • determines the symbolic link that is associated with a device instance • SetupDiEnumDeviceInterfaces • enumerate the interfaces present for a particular GUID and to obtain the names of the symbolic links • SetupDiGetDeviceInterfaceDetail • obtain additional information about the device
Opening Devices • File objects • the kernel-mode constructs for handles to files or devices • system resources that two or more user-mode processes can share • have names • protected by object-based security • support synchronization
File Object Attributes • FILE_OBJECT in Ntddk.h
EXPERIMENT: Viewing Windows Device Name to Windows Device Name Mappings
목차 • I/O System Components • Device Drivers • I/O Processing • The Plug and Play (PnP) Manager • The Power Manager • Conclusion
Fast I/O • bypass generating an IRP and instead go directly to the file system driver or cache manager to complete an I/O request. • A driver registers its fast I/O entry points by entering them in a structure pointed to by the PFAST_IO_DISPATCH pointer in its driver object
EXPERIMENT: Looking at a Driver's Registered Fast I/O Routines
Mapped File I/O and File Caching • the ability to view a file residing on disk as part of a process's virtual memory • CreateFileMapping and Map- ViewOfFile functions • File systems use the cache manager to map file data in virtual memory to provide better response time for I/O- bound programs
Data structures involved in a single-layered driver I/O request
Synchronization • The execution of a driver can be preempted by higher-priority threads and time-slice (or quantum) expiration or can be interrupted by interrupts • On multiprocessor systems, Windows can run driver code simultaneously on more than one processor • KeAcquireInterruptSpinLock
Driver Verifier • looking for a number of illegal operations—including calling kernel-memory pool functions at invalid IRQL, double-freeing memory, and requesting a zero-sized memory allocation