⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 winpciconfiglib.h

📁 一个关于PCI CAN开发板的windows下的驱动程序,用DDK做的,希望对做PCI CAN板的朋友有用
💻 H
字号:

/*
** winpciConfigLib.h -- header files defined some useful macros functions and so on.
** author: linbirg.
** date: 2009-03-26
*/

#ifndef _WINPCICONFIGLIB_H
#define _WINPCICONFIGLIB_H

#include "PeliCanDef.h"

/* PCI base address mask bits */
#define PCI_MEMBASE_MASK	~0xf	/* mask for memory base address */
#define PCI_IOBASE_MASK		~0x3	/* mask for IO base address */
#define PCI_BASE_IO		0x1	/* IO space indicator */
#define PCI_BASE_BELOW_1M	0x2	/* memory locate below 1MB */
#define PCI_BASE_IN_64BITS	0x4	/* memory locate anywhere in 64 bits */
#define PCI_BASE_PREFETCH	0x8	/* memory prefetchable */

/* Standard device configuration register offsets */
/* Note that only modulo-4 addresses are written to the address register */
#define	PCI_CFG_BASE_ADDRESS_0	0x10
#define	PCI_CFG_BASE_ADDRESS_1	0x14
#define	PCI_CFG_BASE_ADDRESS_2	0x18
#define	PCI_CFG_BASE_ADDRESS_3	0x1C
#define	PCI_CFG_DEV_INT_LINE	0x3c


/* PCI设备索引。bus/dev/func 共16位,为了方便处理可放在一个WORD中 */
#define PDI_BUS_SHIFT   8
#define PDI_BUS_SIZE    8
#define PDI_BUS_MAX     0xFF
#define PDI_BUS_MASK    0xFF00
#define PDI_DEVICE_SHIFT   3
#define PDI_DEVICE_SIZE    5
#define PDI_DEVICE_MAX     0x1F
#define PDI_DEVICE_MASK    0x00F8
#define PDI_FUNCTION_SHIFT   0
#define PDI_FUNCTION_SIZE    3
#define PDI_FUNCTION_MAX     0x7
#define PDI_FUNCTION_MASK    0x0007
#define PCI_VENID_MASK	     0xFFFF

#define MK_PDI(bus,dev,func) (WORD)((bus&PDI_BUS_MAX)<<PDI_BUS_SHIFT | (dev&PDI_DEVICE_MAX)<<PDI_DEVICE_SHIFT | (func&PDI_FUNCTION_MAX) )

/* PCI配置空间寄存器 */
#define PCI_CONFIG_ADDRESS      0xCF8
#define PCI_CONFIG_DATA         0xCFC
/* 填充PCI_CONFIG_ADDRESS */
#define MK_PCICFGADDR(bus,dev,func) (DWORD)(0x80000000L | (DWORD)MK_PDI(bus,dev,func)<<8)



/*
pciFindDevice( ) - find the nth device with the given device & vendor ID

STATUS pciFindDevice
    (
    int   vendorId,           // vendor ID 
    int   deviceId,           // device ID 
    int   index,              // desired instance of device 
    int * pBusNo,             // bus number 
    int * pDeviceNo,          // device number 
    int * pFuncNo             // function number 
    )
    
DESCRIPTION
This routine finds the nth device with the given device & vendor ID. 
RETURNS
OK, or ERROR if the deviceId and vendorId didn't match. 
*/
int pciFindDevice(int vendorId, int deviceId, int index, int * pBusNo, int * pDeviceNo, int * pFuncNo);

int pciConfigInLong(int busNo, int deviceNo, int funcNo, int address,UINT32 * pData);
int pciConfigInByte(int busNo, int deviceNo, int funcNo, int address,UINT8 * pData);

#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -