阅读:3191回复:3
关于PCI寄存器读写问题 PCI_COMMON_CONFIG。
在NT下,可以直接用HalGetBusData, HalGetBusDataByOffset, HalSetBusData, HalSetBusDataByOffset访问PCI寄存器,但是Win2k以后他把这些Routine放到PCI相关的driver里面了,所以要自己写代码来发IRP_MN_READ_CONFIG 或者IRP_MN_WRITE_CONFIG的IRP。
我看到微软的网站有这么个Function来替代 NTSTATUS ReadWriteConfigSpace( IN PDEVICE_OBJECT DeviceObject, IN ULONG ReadOrWrite, // 0 for read 1 for write IN PVOID Buffer, IN ULONG Offset, IN ULONG Length ) { KEVENT event; NTSTATUS status; PIRP irp; IO_STATUS_BLOCK ioStatusBlock; PIO_STACK_LOCATION irpStack; PDEVICE_OBJECT targetObject; PAGED_CODE(); KeInitializeEvent( &event, NotificationEvent, FALSE ); targetObject = IoGetAttachedDeviceReference( DeviceObject ); irp = IoBuildSynchronousFsdRequest( IRP_MJ_PNP, targetObject, NULL, 0, NULL, &event, &ioStatusBlock ); if (irp == NULL) status = STATUS_INSUFFICIENT_RESOURCES; goto End; } irpStack = IoGetNextIrpStackLocation( irp ); if (ReadOrWrite == 0) irpStack->MinorFunction = IRP_MN_READ_CONFIG; }else irpStack->MinorFunction = IRP_MN_WRITE_CONFIG; } irpStack->Parameters.ReadWriteConfig.WhichSpace = PCI_WHICHSPACE_CONFIG; irpStack->Parameters.ReadWriteConfig.Buffer = Buffer; irpStack->Parameters.ReadWriteConfig.Offset = Offset; irpStack->Parameters.ReadWriteConfig.Length = Length; // // Initialize the status to error in case the bus driver does not // set it correctly. // irp->IoStatus.Status = STATUS_NOT_SUPPORTED ; status = IoCallDriver( targetObject, irp ); if (status == STATUS_PENDING) KeWaitForSingleObject( &event, Executive, KernelMode, FALSE, NULL ); status = ioStatusBlock.Status; } End: // // Done with reference // ObDereferenceObject( targetObject ); return status; } 但是它里面的Buffer指的是什么?是指PCI_COMMON_CONFIG吗? 但是PCI_COMMON_CONFIG这个结构没有SlotNumber和BusNumber成员。 怎样来填充这个Buffer? 那位高人知道?请指点。谢谢 各位中秋节快乐。 |
|
|
沙发#
发布于:2004-09-28 17:47
用户被禁言,该主题自动屏蔽! |
|
板凳#
发布于:2004-11-13 22:59
可以自己写个小的汇编程序读配置信息!!
|
|
|
地板#
发布于:2004-11-16 13:33
谢谢各位,我自己搞定了。
|
|
|