📄 pci_unit_test.c
字号:
/*************************************************************************
*
* FILE NAME:
* pci_unit_test.c
*
* DESCRIPTION:
* SAMSUNG S3C2510 PCI Host driver unit test source file.
* The file has functions which will test PCI host driver.
*
*
*************************************************************************/
#include "stdio.h"
#include "drv/pci/pciConfigLib.h" /*Include pciConfigLib Library To Access and Find PCI configuration Header */
int main()
{
int pBusNo, pDevNo, pFunNo;
UINT8 pByteData,byteTemp;
UINT16 pWordData;
UINT32 pLongData;
STATUS pStatus;
/* For UT_01,UT_02,UT_03,UT_10,UT_11 */
pciDeviceShow();
/* For UT_01,UT_02,UT_03,UT_10,UT_11 */
pBusNo = pDevNo = pFunNo = 0;
if((pStatus = pciFindDevice(0x8086, 0x1229, 0, &pBusNo, &pDevNo, &pFunNo)) == OK)/* For Intel Ethernet card */
pciHeaderShow(pBusNo,pDevNo,pFunNo);
else
printf("\npci_unit_test.c: Error while finding device\n");
if((pStatus = pciFindDevice(0x8086, 0x1229, 1, &pBusNo, &pDevNo, &pFunNo)) == OK)/* For Intel Ethernet card */
pciHeaderShow(pBusNo,pDevNo,pFunNo);
else
printf("\npci_unit_test.c: Only one card on board\n");
/* For UT_04,UT_05,UT_06 */
if((pStatus = pciConfigInByte(pBusNo, pDevNo, pFunNo, PCI_CFG_CLASS, &pByteData)) == OK)
printf("\npci_unit_test.c: Class Code -> %x\n",(int)pByteData);
else
printf("\npci_unit_test.c: Error while reading Byte Data\n");
if((pStatus = pciConfigInWord(pBusNo, pDevNo, pFunNo, PCI_CFG_VENDOR_ID, &pWordData)) == OK)
printf("\npci_unit_test.c: Vendor ID -> %x\n",(int)pWordData);
else
printf("\npci_unit_test.c: Error while reading Word Data\n");
if((pStatus = pciConfigInLong(pBusNo, pDevNo, pFunNo, PCI_CFG_VENDOR_ID, &pLongData)) == OK)
printf("\npci_unit_test.c: Device ID & Vendor ID -> %lx\n",pLongData);
else
printf("\npci_unit_test.c: Error while reading Long Data\n");
/* For UT_07 */
byteTemp = pByteData = 0x10;
if((pStatus = pciConfigOutByte(pBusNo, pDevNo, pFunNo, PCI_CFG_CACHE_LINE_SIZE, pByteData)) == OK)
{
pByteData = 0x0;
pciConfigInByte(pBusNo, pDevNo, pFunNo, PCI_CFG_CACHE_LINE_SIZE, &pByteData);
printf("\npci_unit_test.c: Cache Line Size -> %x\n",(int)pByteData);
if(pByteData == byteTemp)
printf("Configuration Byte Write Successful\n");
else
printf("Configuration Byte Write Failed\n");
}
else
printf("\npci_unit_test.c: Error while Writing Byte Data\n");
return OK;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -