Simple analysis of the disk drive

In atapi.sys in the DriverEntry calls ScsiPortInitialize. PCI there are eight pieces PCI bus. In the middle of each PCI Bus ScsiPortInitialize called once AtapiFindCompatiblePciController or AtapiFindIsaBusController, used to find the ATAPI Controller. If you find HBA, call ScsiPortCreatePortDevice scsi function to create objects.

The system calls are twice AtapiFindCompatiblePciController
were found Prime and Second Channel, correspond to the interrupt 14 and 15, respectively, then call AtapiFindDevices, will find each Channel IDE devices, respectively.

 

Which AtapiFindCompatiblePciController calls ScsiPortGetBusData to enumerate function of each pci. If it is found BaseClass == 1 and SubClass == 1, i.e. identified as IDE Controller.

image

(Abstract in pci2_2.pdf in Figure D-1: Programming Interface Byte Layout for IDE Controller Class Code)

 

If AtapiFindCompatiblePciController find IDE devices, call ScsiPortCreatePortDevice, to create a scsi device.

Because the chamber support scsi Command ATAPI devices, it is possible to transmit by sending ATAPI Command To this scsi scsi devices, and then interpreted.

ScsiPortCreatePortDevice will create an object with IoCreateDevice, then the connection is interrupted by IoConnectInterrupt Prime or Secondary Channel of the device with the object and set the interrupt callback function ScsiPortIsr.

ScsiPortIsr routine calls the DPC, the DPC routine will then apply SRB block, and the request is transmitted into the target SCSI device.

DriverEntry in disk.sys of calls ScsiClassInitialize, it will enumerate scsi device object created.
ScsiClassInitialize calls DiskClassFindDevices,
and DiskClassFindDevices will call ScsiClassGetCapabilities, ScsiClassGetInquiryData, ScsiClassFindUnclaimedDevices

then DiskClassCreateDeviceObject all Unclaimed equipment

 

In DiskClassCreateDeviceObject, first create a root directory of the hard disk object, that is \ Device \ Harddisk0.
Then immediately call ScsiClassClaimDevice
then ScsiClassCreateDeviceObject create partitions 0, \ Device \ Harddisk0 \ Partition0
then call ScsiClassReadDriveCapacity ask for the partition 0 device
then call IoReadPartitionTable, read the partition table information, he is calling xHalIoReadPartitionTable achieved

DiskClassCreateDeviceObject by reading \ Device \ Harddisk0 \ Partition0 read MBR information, analysis out of a total number of partitions.
Then in turn create a device object for each partition, for example, \ Device \ Harddisk0 \ Partition1


vfatfs.sys the DriverEntry calls IoRegisterFileSystem function.

Reproduced in: https: //www.cnblogs.com/fanzi2009/archive/2009/06/03/1495769.html

Guess you like

Origin blog.csdn.net/weixin_34129145/article/details/94192546