阅读:1466回复:9
startdevice中的关于资源分配???
以下摘自ddk:
CM_RESOURCE_LIST typedef struct _CM_RESOURCE_LIST { ULONG Count; //The number of elements contained in the List array. // For WDM drivers, this value is always 1. :P CM_FULL_RESOURCE_DESCRIPTOR List[1]; } CM_RESOURCE_LIST, *PCM_RESOURCE_LIST; typedef struct _CM_FULL_RESOURCE_DESCRIPTOR { INTERFACE_TYPE InterfaceType; ULONG BusNumber; CM_PARTIAL_RESOURCE_LIST PartialResourceList; } CM_FULL_RESOURCE_DESCRIPTOR, *PCM_FULL_RESOURCE_DESCRIPTOR; typedef struct _CM_RESOURCE_LIST { ULONG Count; CM_FULL_RESOURCE_DESCRIPTOR List[1]; //The number of elements contained in the List array. //For WDM drivers, this value is always 1. :P } CM_RESOURCE_LIST, *PCM_RESOURCE_LIST; 一段程序: devExt =(P_DEVICE_EXT)DeviceObject ->DeviceExtension; curstack= IoGetCurrentIrpStackLocation(Irp);//returns a pointer to the caller\'s stack location in the given IRP. resources=curstack->Parameters.StartDevice.AllocatedResourcesTranslated; 这么说来:resource中只有一个CM_FULL_RESOURCE_DESCRIPTOR ,那不是只有一个资源吗???? [编辑 - 3/8/03 by Xman] |
|
|
沙发#
发布于:2003-03-08 16:55
好好看书呀
|
|
板凳#
发布于:2003-03-08 19:08
你就指点一二吧!我看了书也没找到!
|
|
|
地板#
发布于:2003-03-08 21:45
兄弟,你查找一下CM_FULL_RESOURCE_DESCRIPTOR 的定义吧,他好像是有多个描述子结构的,我既不太清楚了,手边也没有书,好像是一本 NT驱动编程的书上有讲解的
|
|
地下室#
发布于:2003-03-08 22:12
这是个结构。 InterfaceType和BusNumber在WDM不用了。 typedef struct _CM_PARTIAL_RESOURCE_LIST { USHORT Version; USHORT Revision; ULONG Count; CM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptors[1]; } CM_PARTIAL_RESOURCE_LIST, *PCM_PARTIAL_RESOURCE_LIST; 这个PartialDescriptors就有资源了呀。 |
|
5楼#
发布于:2003-03-08 23:36
我知道阿!
问题是 CM_PARTIAL_RESOURCE_LIST 也只有一个PartialDescriptors! 而PartialDescriptors的定义是一个联合!!!! typedef struct _CM_PARTIAL_RESOURCE_DESCRIPTOR { UCHAR Type; UCHAR ShareDisposition; USHORT Flags; union { struct { PHYSICAL_ADDRESS Start; ULONG Length; } Generic; struct { PHYSICAL_ADDRESS Start; ULONG Length; } Port; struct { ULONG Level; ULONG Vector; ULONG Affinity; } Interrupt; struct { PHYSICAL_ADDRESS Start; ULONG Length; } Memory; struct { ULONG Channel; ULONG Port; ULONG Reserved1; } Dma; struct { ULONG Data[3]; } DevicePrivate; struct { ULONG Start; ULONG Length; ULONG Reserved; } BusNumber; struct { ULONG DataSize; ULONG Reserved1; ULONG Reserved2; } DeviceSpecificData; } u; } CM_PARTIAL_RESOURCE_DESCRIPTOR, *PCM_PARTIAL_RESOURCE_DESCRIPTOR; |
|
|
6楼#
发布于:2003-03-09 01:53
[url] http://www.driverdevelop.com/forum/viewthread.php?tid=32892#pid234885[/url]
|
|
7楼#
发布于:2003-03-10 08:59
我的代码和那个差不多,我主要是想搞清楚为什么ddk上说:
typedef struct _CM_PARTIAL_RESOURCE_LIST { USHORT Version; USHORT Revision; ULONG Count; CM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptors[1]; } CM_PARTIAL_RESOURCE_LIST, *PCM_PARTIAL_RESOURCE_LIST; Count The number of elements contained in the PartialDescriptors array. For WDM drivers, this value is always 1. . :P |
|
|
8楼#
发布于:2003-03-10 12:11
这是一个LIST结构,或叫链结构。看来C++没学好。
|
|
9楼#
发布于:2003-03-10 13:50
多谢各位帮助!
|
|
|