windows wdf 驱动开发总结(5)--PCI 驱动

2024-01-13 02:08

本文主要是介绍windows wdf 驱动开发总结(5)--PCI 驱动,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

PCI驱动相关(CY7C09449)AMCC5933

    PCI总线标准是一种将系统外部设备连接起来的总线标准,它是PC中最重要的总线。其它总线ISA总线,USB总线都挂在PCI总线上。

2.1WDF_INTERRUPT_CONFIG_INIT

函数功能:initializes a WDF_INTERRUPT_CONFIG structure.

VOID
  
WDF_INTERRUPT_CONFIG_INIT(
    OUT PWDF_INTERRUPT_CONFIG Configuration,
    IN PFN_WDF_INTERRUPT_ISR  
EvtInterruptIsr,
    IN PFN_WDF_INTERRUPT_DPC  
EvtInterruptDpc
    );

参数:

Configuration

A pointer to a WDF_INTERRUPT_CONFIG structure.

EvtInterruptIsr

A pointer to the driver's EvtInterruptIsr callback function.

EvtInterruptDpc

A pointer to the driver's EvtInterruptDpc callback function, or NULL.

Comments

The WDF_INTERRUPT_CONFIG_INIT function zeros the specified WDF_INTERRUPT_CONFIG structure and sets its Size member to the structure's size. It also sets the structure's ShareVector member to WdfUseDefault and stores the specified callback function pointers.

 

结构:

typedef struct _WDF_INTERRUPT_CONFIG {
  ULONG  Size;
  WDFSPINLOCK  SpinLock;
  WDF_TRI_STATE  ShareVector;
  BOOLEAN  FloatingSave;
  BOOLEAN  AutomaticSerialization;
  PFN_WDF_INTERRUPT_ISR  EvtInterruptIsr;
  PFN_WDF_INTERRUPT_DPC  EvtInterruptDpc;
  PFN_WDF_INTERRUPT_ENABLE  EvtInterruptEnable;
  PFN_WDF_INTERRUPT_DISABLE  EvtInterruptDisable;
} WDF_INTERRUPT_CONFIG, *PWDF_INTERRUPT_CONFIG;

Members

Size

The size, in bytes, of this structure.

SpinLock

The handle to a framework spin-lock object, obtained by a previous call to WdfSpinLockCreate, or NULL. If this parameter is NULL, the framework uses an internal spin-lock object. The framework acquires the spin lock before it calls the driver's EvtInterruptSynchronize event callback function and when the driver calls WdfInterruptAcquireLock.

ShareVector

A WDF_TRI_STATE-typed value. If this value is WdfTrue, the interrupt vector can be shared. If the value is WdfFalse, the interrupt vector cannot be shared. If the value is WdfDefault, the PnP manager uses the bus driver's value.

FloatingSave

A Boolean value that, if TRUE, indicates that the system will save the processor's floating point and MMX state when the device interrupts. If FALSE, the system does not save the floating point and MMX state. A driver should set this value to TRUE only if its EvtInterruptIsr callback function must use floating point or MMX registers. For more information about saving floating point and MMX state, see Using Floating Point or MMX in a WDM Driver.

AutomaticSerialization

A Boolean value that, if TRUE, indicates that the framework will synchronize execution of the interrupt object's EvtInterruptDpc callback function with callback functions from other objects that are underneath the interrupt's parent device object. For more information, see the following Comments section.

EvtInterruptIsr

A pointer to the driver's EvtInterruptIsr callback function. This pointer cannot be NULL.

EvtInterruptDpc

A pointer to the driver's EvtInterruptDpc callback function, or NULL.

EvtInterruptEnable

A pointer to the driver's EvtInterruptEnable callback function, or NULL.

EvtInterruptDisable

A pointer to the driver's EvtInterruptDisable callback function, or NULL.

 

(2.2) WdfInterruptCreate

函数功能:creates a framework interrupt object.

NTSTATUS
  WdfInterruptCreate(
    IN WDFDEVICE  
Device,
    IN PWDF_INTERRUPT_CONFIG  
Configuration,
    IN OPTIONAL PWDF_OBJECT_ATTRIBUTES  
Attributes,
    OUT WDFINTERRUPT*  
Interrupt
    );

参数:

Device

A handle to a framework device object.

Configuration

A pointer to a WDF_INTERRUPT_CONFIG structure that was initialized by a call to WDF_INTERRUPT_CONFIG_INIT.

Attributes

A pointer to a WDF_OBJECT_ATTRIBUTES structure that specifies object attributes for the framework interrupt object. (The structure's ParentObject member must be NULL.) This parameter is optional and can be WDF_NO_OBJECT_ATTRIBUTES.

Interrupt

A pointer to a location that receives a handle to the new interrupt object.

 

评论:

Drivers typically call the WdfInterruptCreate method from an EvtDriverDeviceAdd callback function. Your driver must call WdfInterruptCreate once for each interrupt vector that its device requires. If the device supports message-signaled interrupts (MSI), the driver must create an interrupt object for each message that the device can support.

 

(2.3) WDF_DMA_ENABLER_CONFIG_INIT

函数功能:initializes a driver's WDF_DMA_ENABLER_CONFIG structure.

VOID FORCEINLINE
  
WDF_DMA_ENABLER_CONFIG_INIT(
    OUT PWDF_DMA_ENABLER_CONFIG  Config,
    IN WDF_DMA_PROFILE  
Profile,
    IN size_t  
MaximumLength
    );

Parameters

Config

A pointer to a driver-allocated WDF_DMA_ENABLER_CONFIG structure.

Profile

A value for the Profile member of the WDF_DMA_ENABLER_CONFIG structure.

MaximumLength

A value for the MaximumLength member of the WDF_DMA_ENABLER_CONFIG structure.

评论:

Drivers must call the WDF_DMA_ENABLER_CONFIG_INIT function before calling WdfDmaEnablerCreate.

 

typedef struct _WDF_DMA_ENABLER_CONFIG {
  ULONG  Size;
  WDF_DMA_PROFILE  Profile;
  size_t  MaximumLength;
  PFN_WDF_DMA_ENABLER_FILL  EvtDmaEnablerFill;
  PFN_WDF_DMA_ENABLER_FLUSH  EvtDmaEnablerFlush;
  PFN_WDF_DMA_ENABLER_DISABLE  EvtDmaEnablerDisable;
  PFN_WDF_DMA_ENABLER_ENABLE  EvtDmaEnablerEnable;
  PFN_WDF_DMA_ENABLER_SELFMANAGED_IO_START  EvtDmaEnablerSelfManagedIoStart;
  PFN_WDF_DMA_ENABLER_SELFMANAGED_IO_STOP  EvtDmaEnablerSelfManagedIoStop;
} WDF_DMA_ENABLER_CONFIG, *PWDF_DMA_ENABLER_CONFIG;

 

Members

Size

The size, in bytes, of this structure.

Profile

A WDF_DMA_PROFILE-typed value, which identifies the type of bus-master DMA operation that will be associated with the DMA enabler object.

MaximumLength

The default maximum size, in bytes, that the device can handle in a single DMA transfer. (Drivers can override this default value for individual DMA transactions by calling WdfDmaTransactionSetMaximumLength.) If your driver must run on versions of Microsoft Windows operating systems that support a maximum of 16 map registers, MaximumLength must be less than 65,536.

EvtDmaEnablerFill

A pointer to the driver's EvtDmaEnablerFill event callback function, or NULL.

EvtDmaEnablerFlush

A pointer to the driver's EvtDmaEnablerFlush event callback function, or NULL.

EvtDmaEnablerDisable

A pointer to the driver's EvtDmaEnablerDisable event callback function, or NULL.

EvtDmaEnablerEnable

A pointer to the driver's EvtDmaEnablerEnable event callback function, or NULL.

EvtDmaEnablerSelfManagedIoStart

A pointer to the driver's EvtDmaEnablerSelfManagedIoStart event callback function, or NULL.

EvtDmaEnablerSelfManagedIoStop

A pointer to the driver's EvtDmaEnablerSelfManagedIoStop event callback function, or NULL.

Comments

The WDF_DMA_ENABLER_CONFIG structure is used as an input parameter to the WdfDmaEnablerCreate method.Drivers must call WDF_DMA_ENABLER_CONFIG_INIT to initialize the WDF_DMA_ENABLER_CONFIG structure.

 

typedef enum _WDF_DMA_PROFILE {
  WdfDmaProfileInvalid = 0,
  WdfDmaProfilePacket,
  WdfDmaProfileScatterGather,
  WdfDmaProfilePacket64,
  WdfDmaProfileScatterGather64,
  WdfDmaProfileScatterGatherDuplex,
  WdfDmaProfileScatterGather64Duplex
} WDF_DMA_PROFILE;

Values

WdfDmaProfileInvalid

For internal use only.

WdfDmaProfilePacket

The device supports single-packet DMA operations, using 32-bit addressing.

WdfDmaProfileScatterGather

The device supports packet-based, scatter/gather DMA operations, using 32-bit addressing.

WdfDmaProfilePacket64

The device supports single-packet DMA operations, using 64-bit addressing.

WdfDmaProfileScatterGather64

The device supports packet-based, scatter/gather DMA operations, using 64-bit addressing.

WdfDmaProfileScatterGatherDuplex

The device supports packet-based, scatter/gather DMA operations, using 32-bit addressing. The device also supports duplex operation.

WdfDmaProfileScatterGather64Duplex

The device supports packet-based, scatter/gather DMA operations, using 64-bit addressing. The device also supports duplex operation.

Comments

WDF_DMA_PROFILE-typed values are used within the driver's WDF_DMA_ENABLER_CONFIG structure.

 

 

(2.4) WdfDeviceSetAlignmentRequirement

函数功能:The WdfDeviceSetAlignmentRequirement method sets a device's address alignment requirement for the data buffers that the device uses during memory transfer operations.

VOID
  
WdfDeviceSetAlignmentRequirement(
    IN WDFDEVICE  Device,
    IN ULONG  
AlignmentRequirement
    );

Parameters

Device

A handle to a framework device object.

AlignmentRequirement

The alignment requirement for a data buffer. This value must be one less than the alignment boundary. For example, you can specify 15 for a 16-byte alignment boundary and 31 for a 32-byte alignment boundary. You can also use one of the FILE_Xxxx_ALIGNMENT constants that are defined in Wdm.h.

 

(2.5) WdfDmaEnablerCreate

函数功能:creates a DMA enabler object.

NTSTATUS
  
WdfDmaEnablerCreate(
    IN WDFDEVICE  Device,
    IN PWDF_DMA_ENABLER_CONFIG  
Config,
    IN OPTIONAL PWDF_OBJECT_ATTRIBUTES  
Attributes,
    OUT WDFDMAENABLER*  
DmaEnablerHandle
    );

Parameters

Device

A handle to a framework device object.

Config

A pointer to a WDF_DMA_ENABLER_CONFIG structure. Drivers must initialize this structure by calling WDF_DMA_ENABLER_CONFIG_INIT.

Attributes

A pointer to a WDF_OBJECT_ATTRIBUTES structure that specifies object attributes for the new DMA enabler object. This parameter is optional and can be WDF_NO_OBJECT_ATTRIBUTES.

DmaEnablerHandle

A handle to a new DMA enabler object.

 

评论:

Framework-based drivers must call WdfDmaEnablerCreate before creating DMA transactions for a device.Before a driver calls WdfDmaEnablerCreate, it must call WdfDeviceSetAlignmentRequirement.

By default, the framework device object that the Device parameter of WdfDmaEnablerCreate specifies becomes the parent object for the new DMA enabler object. You can use the ParentObject member of the WDF_OBJECT_ATTRIBUTES structure to specify a different parent. The framework deletes the DMA enabler object when it deletes the parent object.

For more information about DMA enabler objects and WdfDmaEnablerCreate, see Enabling DMA Transactions.

 

(2.6) WdfDmaTransactionCreate

函数功能:creates a DMA transaction

NTSTATUS
  
WdfDmaTransactionCreate(
    IN WDFDMAENABLER  DmaEnabler,
    IN OPTIONAL WDF_OBJECT_ATTRIBUTES  *
Attributes,
    OUT WDFDMATRANSACTION  *
DmaTransaction
    );

参数:

Parameters

DmaEnabler

A handle to a DMA enabler object that the driver obtained from a previous call to WdfDmaEnablerCreate.

Attributes

A pointer to a WDF_OBJECT_ATTRIBUTES structure that specifies object attributes for the new DMA transaction object. (The structure's ParentObject member must be NULL.) This parameter is optional and can be WDF_NO_OBJECT_ATTRIBUTES.

DmaTransaction

A handle to a DMA transaction object.

 

Comments

After your driver calls WdfDmaTransactionCreate, it must call WdfDmaTransactionInitialize or WdfDmaTransactionInitializeUsingRequest before calling WdfDmaTransactionExecute.

The specified DMA enabler object becomes the parent of the new DMA transaction object. The driver cannot change this parent, and the ParentObject member or the WDF_OBJECT_ATTRIBUTES structure must be NULL.

 

(2.7) WdfCmResourceListGetCount (获取配置资源的个数)

函数功能:returns the number of resource descriptors that are contained in a specified resource list.

ULONG
  
WdfCmResourceListGetCount(
    IN WDFCMRESLIST  List
    );

Parameters

List

A handle to a framework resource-list object that represents a list of hardware resources for a device.

Return Value

WdfCmResourceListGetCount returns the number of resource descriptors that are contained in the resource list that the List parameter specifies.

A bug check occurs if the driver supplies an invalid object handle.

 

for (i = 0; i < WdfCmResourceListGetCount(ResourcesTranslated); i++) {

        desc = WdfCmResourceListGetDescriptor(
                                              ResourcesTranslated,
                                              i
                                              );
        switch (desc->Type) {
            case CmResourceTypeMemory:
                //
                // Handle memory resources here.
                //
                break;

            case CmResourceTypePort:
                //
                // Handle port resources here.
                //
                break;

            case CmResourceTypeInterrupt:
                //
                // Handle interrupt resources here.
                //
                break;
            default:
                //
                // Ignore all other descriptors.
                //
                break;
        }

(2.8) WdfCmResourceListGetDescriptor (获取该资源的描述符)

函数功能:returns a pointer to a resource descriptor that is contained in a specified resource list.

PCM_PARTIAL_RESOURCE_DESCRIPTOR
  
WdfCmResourceListGetDescriptor(
    IN WDFCMRESLIST  List,
    IN ULONG  
Index
    );

Parameters

List

A handle to a framework resource-list object that represents a list of hardware resources for a device.

Index

A zero-based value that is used as an index into the logical configuration that List specifies.

Return Value

WdfCmResourceListGetDescriptor returns a pointer to the CM_PARTIAL_RESOURCE_DESCRIPTOR structure that describes the hardware resource that the Index parameter identifies, if the operation succeeds. Otherwise, the method returns NULL.

A bug check occurs if the driver supplies an invalid object handle.

Comments

Your driver cannot modify the resource descriptor that WdfCmResourceListGetDescriptor retrieves.

 

 

(2.9) MmMapIoSpace

函数功能:将物理地址转换成系统内核模式的地址(maps the given physical address range to nonpaged system space.)

PVOID 
  
MmMapIoSpace(
    IN PHYSICAL_ADDRESS  PhysicalAddress,
    IN SIZE_T
  NumberOfBytes,
    IN MEMORY_CACHING_TYPE 
 CacheType
    );

Parameters

PhysicalAddress

Specifies the starting physical address of the I/O range to be mapped.

NumberOfBytes

Specifies a value greater than zero, indicating the number of bytes to be mapped.

CacheType

Specifies a MEMORY_CACHING_TYPE value, which indicates the cache attribute to use to map the physical address range.

 

评论:

A driver must call this routine during device start-up if it receives translated resources of type CmResourceTypeMemory in a CM_PARTIAL_RESOURCE_DESCRIPTOR structure. MmMapIoSpace maps the physical address returned in the resource list to a logical address through which the driver can access device registers.

For example, drivers of PIO devices that allocate long-term I/O buffers can call this routine to make such buffers accessible or to make device memory accessible.

For more information about using this routine, see Mapping Bus-Relative Addresses to Virtual Addresses.

 

(2.10) MmUnmapIoSpace

函数功能:MmUnmapIoSpace解除物理地址与系统内核模式地址的关联unmaps a specified range of physical addresses previously mapped by MmMapIoSpace.

VOID 
  
MmUnmapIoSpace(
    IN PVOID  BaseAddress,
    IN SIZE_T
  NumberOfBytes
    );

Parameters

BaseAddress

Pointer to the base virtual address to which the physical pages were mapped.

NumberOfBytes

Specifies the number of bytes that were mapped.

 

评论:

If a driver calls MmMapIoSpace during device start-up, it must call MmUnmapIoSpace when it receives a PnP stop-device or remove-device IRP for the same device object.

 

2.11WdfMemoryCopyToBuffer

函数功能:

copies the contents of a specified memory object's buffer into a specified destination buffer.

NTSTATUS
  
WdfMemoryCopyToBuffer(
    IN WDFMEMORY  SourceMemory,
    IN size_t  
SourceOffset,
    IN PVOID  
Buffer,
    IN size_t  
NumBytesToCopyTo
    );

Parameters

SourceMemory

A handle to a framework memory object that represents the source buffer.

SourceOffset

An offset, in bytes, from the beginning of the source buffer. The copy operation begins at the specified offset in the source buffer.

Buffer

A pointer to a destination buffer.

NumBytesToCopyTo

The number of bytes to copy from the source buffer to the destination buffer. This value must not be greater than the size of the source buffer

 

 //将应用程序的数据拷贝到CY7C09449RAM

 status = WdfMemoryCopyToBuffer(memory, 0, pRAM, length);

 

(2.12) WdfDmaTransactionInitializeUsingRequest

函数功能: initializes a specified DMA transaction by using the parameters of a specified I/O request.

NTSTATUS
  
WdfDmaTransactionInitializeUsingRequest(
    IN WDFDMATRANSACTION  DmaTransaction,
    IN WDFREQUEST  
Request,
    IN PFN_WDF_PROGRAM_DMA  
EvtProgramDmaFunction,
    IN WDF_DMA_DIRECTION  
DmaDirection
    );

Parameters

DmaTransaction

A handle to a DMA transaction object that the driver obtained from a previous call to WdfDmaTransactionCreate.

Request

A handle to a framework request object.

EvtProgramDmaFunction

A pointer to the driver's EvtProgramDma event callback function.

DmaDirection

A WDF_DMA_DIRECTION-typed value that specifies the direction of the DMA transfer.

The WdfDmaTransactionInitializeUsingRequest method prepares a DMA operation for execution, by performing initialization operations such as setting up a transfer's scatter/gather list. After your driver calls WdfDmaTransactionInitializeUsingRequest, the driver must call WdfDmaTransactionExecute.

 

(2.13) WdfDmaTransactionExecute

函数功能:

begins the execution of a specified DMA transaction.

NTSTATUS
  
WdfDmaTransactionExecute(
    IN WDFDMATRANSACTION  DmaTransaction,
    IN OPTIONAL PVOID  
Context
    );

Parameters

DmaTransaction

A handle to a DMA transaction object that the driver obtained from a previous call to WdfDmaTransactionCreate.

Context

Driver-defined context information. The framework passes the value specified for Context, which can be a pointer, to the driver's EvtProgramDma event callback function. This parameter is optional and can be NULL.

 

评论:

The WdfDmaTransactionExecute method initializes a transaction's scatter/gather list for the first DMA transfer that is associated with the specified DMA transaction. (For single-packet transfers, the scatter/gather list contains a single element.) Then, the method calls the driver's EvtProgramDma event callback function, and the callback function can program the device to begin the transfer.

 

(2.14) HalGetBusData

函数功能:This function retrieves configuration information about a specified slot or address on a I/O bus.

函数原型:

ULONG HalGetBusData( 
  BUS_DATA_TYPE BusDataType, 
  ULONG BusNumber, 
  ULONG SlotNumber, 
  PVOID Buffer, 
  ULONG Length 
);

参数:

BusDataType:该参数指定总线类型。HalGetBusData函数可以查询各个总线的情况,对于PCI总线,这里设置为PCIConfiguration;

BusNumber:该参数指定Bus总线号;

SlotNumber:该参数由Device号和功能号共同组成;

Buffer:该参数是得到的PCI配置空间的首地址;

Length:该参数是PCI配置空间的大小。

HalSetBusData设置的参数和HalGetBusData一样,它是在NT式的驱动中使用。

 

(2.15)WDM微软不推荐采用HalGetBusData,推荐使用PDO处理IRP_MN_START_DEVICE的结果。在处理完IRP_MN_START_DEVICE,驱动程序会将处理结果存储在IRP的设备堆栈中,从IO堆栈可以取出CM_FULL_RESOURCE_DESCRIPTOR数据结构,从CM_FULL_RESOURCE_DESCRIPTOR中可以取出CM_PARTIAL_RESOURCE_LIST数据结构,CM_PARTIAL_RESOURCE_LIST中又可以取出CM_PARTIAL_RESOURCE_DESCRIPTOR数据结构,而CM_PARTIAL_RESOURCE_DESCRIPTOR数据结构就是PDO帮助程序员从256字节的PCI配置空间中获取的有用信息。这其中包括中断号、设备物理内存、IO端口等信息。

 

(2.16) IoGetAttachedDeviceReference

函数功能:The IoGetAttachedDeviceReference routine returns a pointer to the highest level device object in a driver stack and increments the reference count on that object.(驱动栈中最上层的设备对象,并增加该对象的引用计数)

PDEVICE_OBJECT IoGetAttachedDeviceReference(

  __in  PDEVICE_OBJECT DeviceObject

);

参数:

DeviceObject [in]

Pointer to the device object for which the topmost attached device object is retrieved.

Return Value:

returns a pointer to the highest level device object in a stack of attached device objects after incrementing the reference count on the object.

 

Remarks

If the device object at DeviceObject has no device objects attached to it, DeviceObject and the returned pointer are equal.

 

(2.17)IoConnectInterrupt(中断操作)

函数功能:IoConnectInterrupt routine registers a device driver's InterruptService routine (ISR), so that it will be called when a device interrupts on any of a specified set of processors.

NTSTATUS IoConnectInterrupt(

  __out     PKINTERRUPT *InterruptObject,

  __in      PKSERVICE_ROUTINE ServiceRoutine,

  __in_opt  PVOID ServiceContext,

  __in_opt  PKSPIN_LOCK SpinLock,

  __in      ULONG Vector,

  __in      KIRQL Irql,

  __in      KIRQL SynchronizeIrql,

  __in      KINTERRUPT_MODE InterruptMode,

  __in      BOOLEAN ShareVector,

  __in      KAFFINITY ProcessorEnableMask,

  __in      BOOLEAN FloatingSave

);

Parameters

InterruptObject [out]

Pointer to the address of driver-supplied storage for a pointer to a set of interrupt objects. This pointer must be passed in subsequent calls to KeSynchronizeExecution.

得到一个Interrupt结构的中断内核对象。当设备停止或者退出时,需要将中断与中断号分离,这时需要调用IoDisconnectInterrupt.

ServiceRoutine [in]

Pointer to the entry point for the driver-supplied InterruptService routine.

驱动程序提供的中断例程,此服务例程运行在DIRQL上,所有分页的内存操作都不能再这个函数上使用。

ServiceContext [in, optional]

Pointer to the driver-determined context that will be supplied to the InterruptService routine when it is called. The ServiceContext area must be in resident memory: in the device extension of a driver-created device object, in the controller extension of a driver-created controller object, or in nonpaged pool allocated by the device driver. See Providing ISR Context Information for details.

中断服务例程的上下文参数。

SpinLock [in, optional]

Pointer to an initialized spin lock, for which the driver supplies the storage, that will be used to synchronize access to driver-determined data shared by other driver routines. This parameter is required if the ISR handles more than one vector or if the driver has more than one ISR. Otherwise, the driver need not allocate storage for an interrupt spin lock and the input pointer is NULL.

用于同步的自旋锁,可选参数,一般为NULL

Vector [in]

Specifies the interrupt vector passed in the interrupt resource at the u.Interrupt.Vector member of CM_PARTIAL_RESOURCE_DESCRIPTOR.

中断向量号,这个是PDO返回时可以得到的。

Irql [in]

Specifies the DIRQL passed in the interrupt resource at the u.Interrupt.Level member of CM_PARTIAL_RESOURCE_DESCRIPTOR.

IRQL,同样在PDO返回时可以得到。

SynchronizeIrql [in]

Specifies the DIRQL at which the ISR will run. If the ISR handles more than one interrupt vector or the driver has more than one ISR, this value must be the highest of the Irql values passed at u.Interrupt.Level in each interrupt resource. Otherwise, the Irql and SynchronizeIrql values are identical.

IRQL

InterruptMode [in]

Specifies whether the device interrupt is LevelSensitive or Latched.

中断的模式,主要是电平触发(Latched)和边缘触发(LevelSensitive),对于PCI设备,一般为电平触发。

ShareVector [in]

Specifies whether the interrupt vector is sharable.

指定是否容许与其它PCI设备共享中断。

ProcessorEnableMask [in]

Specifies a KAFFINITY value representing the set of processors on which device interrupts can occur in this platform. This value is passed in the interrupt resource at u.Interrupt.Affinity.

CPU屏蔽位。

FloatingSave [in]

Specifies whether to save the floating-point stack when the driver's device interrupts. For x86-based and IA64-based platforms, this value must be set to FALSE. For more information about saving floating point and MMX state, see Using Floating Point or MMX in a WDM Driver

 

Remarks

New drivers should use the IoConnectInterruptEx routine, which is easier to use. Drivers for devices that support message-signaled interrupts (MSI) must use IoConnectInterruptEx.

 

(2.18)操作设备物理内存

    对于物理内存,一般程序是无法读取的,一般程序所看到的内存都是虚拟内存,如果想操作物理内存,必须使用DDK提供的内核WRITE_REGISTER_XX系列函数和READ_REGISTER_XX系列函数。这些都是存储器访问。存储器地址空间现在达到了4GB,而Io地址空间为64kb,Io地址访问通过WRITE_PORT_XX系列函数和READ_PORT_XX系列函数。

 

另外DDK提供了内核函数MmAllocateContiguousMemory,他可以分配连续的物理内存,并映射成连续的虚拟内存。MmAllocateContiguousMemory返回的是虚拟内存地址,可以用MmGetPhysicalAddress得到连续的物理内存地址,然后用前面介绍的WRITE_REGISTER_XX系列函数和READ_REGISTER_XX系列函数进行读写。

 

这篇关于windows wdf 驱动开发总结(5)--PCI 驱动的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/599903

相关文章

关于C++中的虚拟继承的一些总结(虚拟继承,覆盖,派生,隐藏)

1.为什么要引入虚拟继承 虚拟继承是多重继承中特有的概念。虚拟基类是为解决多重继承而出现的。如:类D继承自类B1、B2,而类B1、B2都继承自类A,因此在类D中两次出现类A中的变量和函数。为了节省内存空间,可以将B1、B2对A的继承定义为虚拟继承,而A就成了虚拟基类。实现的代码如下: class A class B1:public virtual A; class B2:pu

十五.各设计模式总结与对比

1.各设计模式总结与对比 1.1.课程目标 1、 简要分析GoF 23种设计模式和设计原则,做整体认知。 2、 剖析Spirng的编程思想,启发思维,为之后深入学习Spring做铺垫。 3、 了解各设计模式之间的关联,解决设计模式混淆的问题。 1.2.内容定位 1、 掌握设计模式的"道" ,而不只是"术" 2、 道可道非常道,滴水石穿非一日之功,做好长期修炼的准备。 3、 不要为了

问题-windows-VPN不正确关闭导致网页打不开

为什么会发生这类事情呢? 主要原因是关机之前vpn没有关掉导致的。 至于为什么没关掉vpn会导致网页打不开,我猜测是因为vpn建立的链接没被更改。 正确关掉vpn的时候,会把ip链接断掉,如果你不正确关掉,ip链接没有断掉,此时你vpn又是没启动的,没有域名解析,所以就打不开网站。 你可以在打不开网页的时候,把vpn打开,你会发现网络又可以登录了。 方法一 注意:方法一虽然方便,但是可能会有

Windows/macOS/Linux 安装 Redis 和 Redis Desktop Manager 可视化工具

本文所有安装都在macOS High Sierra 10.13.4进行,Windows安装相对容易些,Linux安装与macOS类似,文中会做区分讲解 1. Redis安装 1.下载Redis https://redis.io/download 把下载的源码更名为redis-4.0.9-source,我喜欢跟maven、Tomcat放在一起,就放到/Users/zhan/Documents

Eclipse+ADT与Android Studio开发的区别

下文的EA指Eclipse+ADT,AS就是指Android Studio。 就编写界面布局来说AS可以边开发边预览(所见即所得,以及多个屏幕预览),这个优势比较大。AS运行时占的内存比EA的要小。AS创建项目时要创建gradle项目框架,so,创建项目时AS比较慢。android studio基于gradle构建项目,你无法同时集中管理和维护多个项目的源码,而eclipse ADT可以同时打开

人工智能机器学习算法总结神经网络算法(前向及反向传播)

1.定义,意义和优缺点 定义: 神经网络算法是一种模仿人类大脑神经元之间连接方式的机器学习算法。通过多层神经元的组合和激活函数的非线性转换,神经网络能够学习数据的特征和模式,实现对复杂数据的建模和预测。(我们可以借助人类的神经元模型来更好的帮助我们理解该算法的本质,不过这里需要说明的是,虽然名字是神经网络,并且结构等等也是借鉴了神经网络,但其原型以及算法本质上还和生物层面的神经网络运行原理存在

Java注解详细总结

什么是注解?         Java注解是代码中的特殊标记,比如@Override、@Test等,作用是:让其他程序根据注解信息决定怎么执行该程序。         注解不光可以用在方法上,还可以用在类上、变量上、构造器上等位置。 自定义注解  现在我们自定义一个MyTest注解 public @interface MyTest{String aaa();boolean bbb()

Python应用开发——30天学习Streamlit Python包进行APP的构建(9)

st.area_chart 显示区域图。 这是围绕 st.altair_chart 的语法糖。主要区别在于该命令使用数据自身的列和指数来计算图表的 Altair 规格。因此,在许多 "只需绘制此图 "的情况下,该命令更易于使用,但可定制性较差。 如果 st.area_chart 无法正确猜测数据规格,请尝试使用 st.altair_chart 指定所需的图表。 Function signa

Windows中,.net framework 3.5安装

安装.net framework,目前已知2种方法,如下: 一、在MSDN下载对应的安装包,安装,这种可能无法安装成功,概率很大,不成功使用第二种方法,基本上没问题。 二、win8/8.1/10 下安装 .net framework 3.5.1: 1. 打开 win8/8.1/10 安装盘(这里指系统安装镜像文件),提取 sources\sxs 文件夹到 X:\sources\sxs (X代

Windows 可变刷新率是什么?如何开启?

在现代计算设备中,显示屏的刷新率对用户体验起着至关重要的作用。随着显示技术的不断进步,固定刷新率显示器逐渐被支持可变刷新率(Variable Refresh Rate, VRR)技术的显示器所取代。 可变刷新率定义 可变刷新率是什么?可变刷新率(VRR)是一种显示技术,它允许显示器的刷新率动态调整,以匹配显卡输出的帧率。传统的显示器通常具有固定的刷新率(如60Hz、75Hz等),这意味着显示器