阅读:2045回复:1
关于device_object里的device_extension的问题
DDK文档里的描述为:
PVOID DeviceExtension Points to the device extension. The structure and contents of the device extension are driver-defined. The size is driver-determined, specified in the driver's call to IoCreateDevice. Most driver routines that process IRPs are given a pointer to the device object so the device extension is usually every driver's primary global storage area and frequently a driver's only global storage area for objects, resources, and any state the driver maintains about the I/O requests it handles. 也就是驱动开发者可以根据所开发的设备具体定义相关的device extension成员 请问自定义的这些成员如何初始化? 比如有一个pci9054的驱动里device extension的定义为: typedef struct _DEVICE_EXTENSION { PDEVICE_OBJECT pDeviceObject; // device object this extension belongs to PDEVICE_OBJECT pLowerDeviceObject; // next lower driver in same stack PDEVICE_OBJECT pPhysicalDeviceObject; // the PDO IO_REMOVE_LOCK RemoveLock; // removal control locking structure UNICODE_STRING InterfaceName; // interface name DEVICE_POWER_STATE DevicePower; // current device power state SYSTEM_POWER_STATE SystemPower; // current system power state PULONG IdleCount; // address of idle counter from idle detection registration DEVICE_CAPABILITIES DeviceCaps; // copy of most recent device capabilities LONG Handles; // # open handles // Interrupt handling variables ULONG InterruptSource; PKINTERRUPT pInterruptObject; // address of interrupt object LIST_ENTRY InterruptEventList; KSPIN_LOCK InterruptEventListLock; PUCHAR PortBase; // I/O port base address ULONG PortCount; // TODO add additional per-device declarations BOOLEAN bMappedPort; // true if we mapped port addr in StartDevice BOOLEAN bBusy; // true if device busy with a request BOOLEAN bStalledForPower; // power management has stalled IRP queue //ʼþ¶ÔÏóÖ¸Õë PKEVENT pWaitEvent; BOOLEAN bSetWaitEvent; PKEVENT pWaitEvent2; BOOLEAN bSetWaitEvent2; //PCI9054ÄÚ²¿¼Ä´æÆ÷Ó³ÉäµÄÄÚ´æ×ÊÔ´ ULONG *LocalRegisterMemBase; PHYSICAL_ADDRESS LocalRegisterPhysicalMemBase; ULONG LocalRegisterMemCount; //×Ô¶¨ÒåÄÚ´æ×ÊÔ´ ULONG *PdcMemBase0; PHYSICAL_ADDRESS PdcPhysicalMemBase0; ULONG PdcMemCount0; KSPIN_LOCK HardwareAccessLock; signed long UsageCount; //The pending I/O Count BOOLEAN bStopping; // KEVENT StoppingEvent; // Set when all pending I/O complete BOOLEAN GotResource; // NTSTATUS TransmitIrpStatus; //Power Defines DEVICE_POWER_STATE PowerState; //DMA // DMA access information DMA_CHANNEL_INFO DmaInfo[NUMBER_OF_DMA_CHANNELS]; KSPIN_LOCK DmaChannelLock; // Doorbell storage ULONG IntraDoorbellValue; } DEVICE_EXTENSION, *PDEVICE_EXTENSION; 可是这些元素都是在哪初始化的?在驱动程序里的addevice或iocreatedevice等例程里没有看到初始化操作啊 可是后面有一些例程直接用到device extension里的值! 比如那个ULONG *LocalRegisterMemBase; 应该是定义为PCI BAR0里的值的,可是木有定义啊,直接使用有木有 难道是系统自动赋值的吗?可是是自己定义的device extension啊 求解答!!! |
|
沙发#
发布于:2012-07-31 21:07
done
|
|