reactos操作系统实现(102)

前端之家收集整理的这篇文章主要介绍了reactos操作系统实现(102)前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

ATAPI驱动程序的源码在目录drivers/storage/ide/atapi里,其实ATAPI是一个IDE的小端口驱动程序,主要初始化不同总线上的ATAPI设备,其中最重要的就是从PCI总线里查找到IDE控制器。下面来分析这个驱动程序的入口函数

#001 ULONG

#002 NTAPI

#003 DriverEntry(

#004 IN PVOID DriverObject,

#005 IN PVOID Argument2

#006 )

#007

#008 /*++

#009

#010 Routine Description:

#011

#012 Installable driver initialization entry point for system.

#013

#014 Arguments:

#015

#016 Driver Object

#017

#018 Return Value:

#019

#020 Status from ScsiPortInitialize()

#021

#022 --*/

#023

#024 {

DriverObject是驱动程序对象。

Argument2是驱动程序在注册表里的路径。

#025 HW_INITIALIZATION_DATA hwInitializationData;

#026 ULONG adapterCount;

#027 ULONG i;

#028 ULONG statusToReturn,newStatus;

#029

#030 DebugPrint((1,"/n/nATAPI IDE MiniPort Driver/n"));

#031

设置返回状态码。

#032 statusToReturn = 0xffffffff;

#033

#034 //

#035 // Zero out structure.

#036 //

#037

清空硬件初始化数据结构。

#038 AtapiZeroMemory(((PUCHAR)&hwInitializationData),sizeof(HW_INITIALIZATION_DATA));

#039

#040 //

#041 // Set size of hwInitializationData.

#042 //

#043

设置结构的大小。

#044 hwInitializationData.HwInitializationDataSize =

#045 sizeof(HW_INITIALIZATION_DATA);

#046

#047 //

#048 // Set entry points.

#049 //

#050

设置实始化ATAPI调用函数

#051 hwInitializationData.HwInitialize = AtapiHwInitialize;

#052 hwInitializationData.HwResetBus = AtapiResetController;

#053 hwInitializationData.HwStartIo = AtapiStartIo;

#054 hwInitializationData.HwInterrupt = AtapiInterrupt;

#055

#056 //

#057 // Specify size of extensions.

#058 //

#059

设置扩展结构的大小。

#060 hwInitializationData.DeviceExtensionSize = sizeof(HW_DEVICE_EXTENSION);

#061 hwInitializationData.SpecificLuExtensionSize = sizeof(HW_LU_EXTENSION);

#062

#063 //

#064 // Indicate PIO device.

#065 //

#066

设置为PIO的操作方式。

#067 hwInitializationData.MapBuffers = TRUE;

#068

初始化原始模式的设备。一般有两个通道,每个通道有两个IDE控制器,一个主控制器,一个从控制器。

#069 //

#070 // Native Mode Devices

#071 //

#072 for (i=0; i <NUM_NATIVE_MODE_ADAPTERS; i++) {

#073 hwInitializationData.HwFindAdapter = AtapiFindNativeModeController;

#074 hwInitializationData.NumberOfAccessRanges = 4;

#075 hwInitializationData.AdapterInterfaceType = PCIBus;

#076

#077 hwInitializationData.VendorId = NativeModeAdapters[i].VendorId;

#078 hwInitializationData.VendorIdLength = (USHORT) NativeModeAdapters[i].VendorIdLength;

#079 hwInitializationData.DeviceId = NativeModeAdapters[i].DeviceId;

#080 hwInitializationData.DeviceIdLength = (USHORT) NativeModeAdapters[i].DeviceIdLength;

#081

调用函数ScsiPortInitialize来初始化SCSI端口对象。

#082 newStatus = ScsiPortInitialize(DriverObject,

#083 Argument2,

#084 &hwInitializationData,

#085 (PVOID) i);

#086 if (newStatus < statusToReturn)

#087 statusToReturn = newStatus;

#088 }

#089

#090 hwInitializationData.VendorId = 0;

#091 hwInitializationData.VendorIdLength = 0;

#092 hwInitializationData.DeviceId = 0;

#093 hwInitializationData.DeviceIdLength = 0;

#094

#095 //

#096 // The adapter count is used by the find adapter routine to track how

#097 // which adapter addresses have been tested.

#098 //

#099

查找ISA总线的设备。

#100 adapterCount = 0;

#101

#102 hwInitializationData.HwFindAdapter = AtapiFindPCIController;

#103 hwInitializationData.NumberOfAccessRanges = 4;

#104 hwInitializationData.AdapterInterfaceType = Isa;

#105

#106 newStatus = ScsiPortInitialize(DriverObject,

#107 Argument2,

#108 &hwInitializationData,

#109 &adapterCount);

#110 if (newStatus < statusToReturn)

#111 statusToReturn = newStatus;

#112

#113 //

#114 // Indicate 2 access ranges and reset FindAdapter.

#115 //

#116

#117 hwInitializationData.NumberOfAccessRanges = 2;

#118 hwInitializationData.HwFindAdapter = AtapiFindController;

#119

初始化ISA总线的设备。

#120 //

#121 // Indicate ISA bustype.

#122 //

#123

#124 hwInitializationData.AdapterInterfaceType = Isa;

#125

#126 //

#127 // Call initialization for ISA bustype.

#128 //

#129

#130 newStatus = ScsiPortInitialize(DriverObject,

#131 Argument2,

#132 &hwInitializationData,

#133 &adapterCount);

#134 if (newStatus < statusToReturn)

#135 statusToReturn = newStatus;

#136

#137 //

#138 // Set up for MCA

#139 //

#140

初始化MCA总线的设备。

#141 hwInitializationData.AdapterInterfaceType = MicroChannel;

#142 adapterCount = 0;

#143

#144 newStatus = ScsiPortInitialize(DriverObject,

#145 Argument2,

#146 &hwInitializationData,

#147 &adapterCount);

#148 if (newStatus < statusToReturn)

#149 statusToReturn = newStatus;

#150

#151 return statusToReturn;

#152

#153} // end DriverEntry()

原文链接:https://www.f2er.com/react/308425.html

猜你在找的React相关文章