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

来源:互联网 发布:中兴软件开发待遇 编辑:程序博客网 时间:2024/05/18 14:14

PCI驱动相关(CY7C09449)AMCC5933

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

2.1WDF_INTERRUPT_CONFIG_INIT

函数功能:initializes aWDF_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 aWDF_INTERRUPT_CONFIG structure.

EvtInterruptIsr

A pointer to the driver'sEvtInterruptIsr callback function.

EvtInterruptDpc

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

Comments

The WDF_INTERRUPT_CONFIG_INIT function zeros the specified WDF_INTERRUPT_CONFIG structure and sets itsSize member to the structure's size. It also sets the structure'sShareVector 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 toWdfSpinLockCreate, 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'sEvtInterruptSynchronize event callback function and when the driver callsWdfInterruptAcquireLock.

ShareVector

AWDF_TRI_STATE-typed value. If this value is WdfTrue, the interrupt vector can be shared. If the value isWdfFalse, the interrupt vector cannot be shared. If the value isWdfDefault, 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 itsEvtInterruptIsr callback function must use floating point or MMX registers. For more information about saving floating point and MMX state, seeUsing 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'sEvtInterruptDpc 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'sEvtInterruptIsr callback function. This pointer cannot be NULL.

EvtInterruptDpc

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

EvtInterruptEnable

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

EvtInterruptDisable

A pointer to the driver'sEvtInterruptDisable 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 aWDF_INTERRUPT_CONFIG structure that was initialized by a call to WDF_INTERRUPT_CONFIG_INIT.

Attributes

A pointer to aWDF_OBJECT_ATTRIBUTES structure that specifies object attributes for the framework interrupt object. (The structure'sParentObject 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 theWdfInterruptCreate method from an EvtDriverDeviceAdd callback function. Your driver must callWdfInterruptCreate 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'sWDF_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-allocatedWDF_DMA_ENABLER_CONFIG structure.

Profile

A value for theProfile member of the WDF_DMA_ENABLER_CONFIG structure.

MaximumLength

A value for theMaximumLength member of the WDF_DMA_ENABLER_CONFIG structure.

评论:

Drivers must call theWDF_DMA_ENABLER_CONFIG_INIT function before callingWdfDmaEnablerCreate.

 

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

AWDF_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'sEvtDmaEnablerFill event callback function, or NULL.

EvtDmaEnablerFlush

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

EvtDmaEnablerDisable

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

EvtDmaEnablerEnable

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

EvtDmaEnablerSelfManagedIoStart

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

EvtDmaEnablerSelfManagedIoStop

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

Comments

The WDF_DMA_ENABLER_CONFIG structure is used as an input parameter to theWdfDmaEnablerCreate 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'sWDF_DMA_ENABLER_CONFIG structure.

 

 

(2.4)WdfDeviceSetAlignmentRequirement

函数功能:TheWdfDeviceSetAlignmentRequirement 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 inWdm.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 aWDF_DMA_ENABLER_CONFIG structure. Drivers must initialize this structure by callingWDF_DMA_ENABLER_CONFIG_INIT.

Attributes

A pointer to aWDF_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 callWdfDmaEnablerCreate before creating DMA transactions for a device.Before a driver calls WdfDmaEnablerCreate, it must call WdfDeviceSetAlignmentRequirement.

By default, the framework device object that theDevice 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 andWdfDmaEnablerCreate, 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 toWdfDmaEnablerCreate.

Attributes

A pointer to aWDF_OBJECT_ATTRIBUTES structure that specifies object attributes for the new DMA transaction object. (The structure'sParentObject 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 callsWdfDmaTransactionCreate, it must callWdfDmaTransactionInitialize or WdfDmaTransactionInitializeUsingRequest before callingWdfDmaTransactionExecute.

The specified DMA enabler object becomes the parent of the new DMA transaction object. The driver cannot change this parent, and theParentObject 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 theList 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 thatList specifies.

Return Value

WdfCmResourceListGetDescriptor returns a pointer to the CM_PARTIAL_RESOURCE_DESCRIPTOR structure that describes the hardware resource that theIndex 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 thatWdfCmResourceListGetDescriptor 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 aMEMORY_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 typeCmResourceTypeMemory 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 callsMmMapIoSpace 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 toWdfDmaTransactionCreate.

Request

A handle to a framework request object.

EvtProgramDmaFunction

A pointer to the driver'sEvtProgramDma event callback function.

DmaDirection

AWDF_DMA_DIRECTION-typed value that specifies the direction of the DMA transfer.

TheWdfDmaTransactionInitializeUsingRequest method prepares a DMA operation for execution, by performing initialization operations such as setting up a transfer's scatter/gather list. After your driver callsWdfDmaTransactionInitializeUsingRequest, 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 toWdfDmaTransactionCreate.

Context

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

 

评论:

TheWdfDmaTransactionExecute 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'sEvtProgramDma 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

函数功能:TheIoGetAttachedDeviceReference 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 atDeviceObject 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 toKeSynchronizeExecution.

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

ServiceRoutine [in]

Pointer to the entry point for the driver-suppliedInterruptService routine.

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

ServiceContext [in, optional]

Pointer to the driver-determined context that will be supplied to theInterruptService routine when it is called. TheServiceContext 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. SeeProviding 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 theu.Interrupt.Vector member ofCM_PARTIAL_RESOURCE_DESCRIPTOR.

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

Irql [in]

Specifies the DIRQL passed in the interrupt resource at theu.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 theIrql values passed atu.Interrupt.Level in each interrupt resource. Otherwise, theIrql andSynchronizeIrql values are identical.

IRQL

InterruptMode [in]

Specifies whether the device interrupt isLevelSensitive orLatched.

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

ShareVector [in]

Specifies whether the interrupt vector is sharable.

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

ProcessorEnableMask [in]

Specifies aKAFFINITY 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 theIoConnectInterruptEx 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系列函数进行读写。

 

原创粉丝点击