📄 btviddebug.c
字号:
{
printf("Bit %d Set\n",i);
}
ulBit = ulBit << 1;
}
}
void ShowPCISlotData(PCI_SLOT_ENTRY_S *psPciSlot)
{
int i;
printf("PCI Bus Number: %d\n",psPciSlot->byBusNo);
printf("PCI Device Number: %d\n",psPciSlot->byDevNo);
for(i=0; i<4; i++)
{
printf("Interrupt %c Info ------\n",i+'A');
printf("Link Value for INT%c: 0x%x\n",i+'A',psPciSlot->AtoDSlotInfo[i].byLinkValue);
printf("IRQ Bitmap for INT%c: 0x%x\n",i+'A',psPciSlot->AtoDSlotInfo[i].wIRQBitmap);
}
printf("PCI Slot Number %d\n",psPciSlot->bySlotNo);
}
void ShowPCIIntRoutingTable(PCI_ROUTING_TABLE_S *psRoutingTable)
{
int iNumSlots;
int i;
printf("Routing Table Information:\n");
printf("Location: Address - 0x%x\n",psRoutingTable);
printf("Signature: 0x%4x\n",psRoutingTable->dwSignature);
printf("Version: 0x%2x\n",psRoutingTable->wVersion);
printf("Table Size: %d bytes\n",psRoutingTable->wTableSize);
printf("PCI Int Router's Bus: %d\n",psRoutingTable->byIntRouterBus);
printf("PCI Int Router's DevFunc: %x Decoded: Device %d Function %d\n",psRoutingTable->byIntRouterDevFunc,
psRoutingTable->byIntRouterDevFunc>>3,
psRoutingTable->byIntRouterDevFunc & (Bit0 | Bit1 | Bit2) );
printf("PCI Exclusive IRQ's: %x\n",psRoutingTable->wExclusiveIRQs);
printf("Compatable PCI Interrupt Router: %8x\n",psRoutingTable->dwCompatableIntRouterDevID);
printf("Miniport Data: %d\n",psRoutingTable->dwIrqMiniport);
iNumSlots = (psRoutingTable->wTableSize-32)/16;
for(i=0; i<iNumSlots; i++)
{
printf("Slot %d Information -----------------\n",i+1);
ShowPCISlotData(&psRoutingTable->sPciSlot[i]);
printf("\n");
}
}
unsigned char VerifyPCIIntRoutingTable(unsigned int *pIntRoutingTableAddr)
{
PCI_ROUTING_TABLE_S *psRoutingTable;
unsigned char *pbyCheckByte;
int i;
unsigned char checksum=0;
psRoutingTable = (PCI_ROUTING_TABLE_S *)pIntRoutingTableAddr;
if(psRoutingTable->wVersion == 0x100) /* make sure this is version 1 */
{
if(psRoutingTable->wTableSize > 32 && !(psRoutingTable->wTableSize%16))
{
pbyCheckByte = (unsigned char *)pIntRoutingTableAddr;
for(i=0; i<psRoutingTable->wTableSize; i++)
{
checksum += *pbyCheckByte;
pbyCheckByte++; /* move to the next address */
}
if(checksum == 0)
{
return TRUE; /* this is a valid routing table */
}
}
}
return FALSE; /* invalid routing table */
}
int findAndDecodePCIInterruptRoutingTable(void) {
unsigned int *i;
unsigned int entry = 0;
unsigned char bFound = 0;
for(i = (unsigned int *) 0x000F0000; i < (unsigned int *) 0x100000; i += 4) {
entry = *i;
if (entry == PCI_ROUTING_TABLE_SIGNATURE) {
if(VerifyPCIIntRoutingTable(i))
{
printf("Found tables signature 0x%x at 0x%x value = 0x%x \n",
PCI_ROUTING_TABLE_SIGNATURE,
i,
entry);
ShowPCIIntRoutingTable(i);
bFound = 1;
}
}
}
if(!bFound)
{
printf("Error - no configuration table found\n");
return ERROR;
}
return OK;
}
/* -----------------------------------------------------------------------
Parameters: bDontInitPciDev - TRUE if no re-init of pci dev required
FALSE if re-init of pci dev is required
Returns
Fills in IRQRouteStatusTable with status of southbridge and video card IRQ routing
*/
int decodePIRQxRouteControlRegister(/*unsigned char bDontInitPciDev*/ void) {
int pciBusNo;
int pciDevNo;
int pciFuncNo;
unsigned int longword;
unsigned char interrupt_pin_A;
unsigned char interrupt_pin_B;
unsigned char interrupt_pin_C;
unsigned char interrupt_pin_D;
unsigned char ucVidCaptureIntPin;
unsigned char byNewIntPin=0;
initializePCI_DEV();
pciBusNo = PCI_DEV[SOUTH_BRIDGE].busNo;
pciDevNo = PCI_DEV[SOUTH_BRIDGE].deviceNo;
pciFuncNo = PCI_DEV[SOUTH_BRIDGE].funcNo;
pciConfigInLong(pciBusNo, pciDevNo, pciFuncNo, PCI_CFG_IRQ_ROUTING, &longword);
printf("Intel SB controller IRQ Routing Reg = 0x%x\n", longword);
pciConfigInByte(pciBusNo, pciDevNo, pciFuncNo, PCI_CFG_IRQ_ROUTING_INTERRUPT_PIN_A, &interrupt_pin_A);
pciConfigInByte(pciBusNo, pciDevNo, pciFuncNo, PCI_CFG_IRQ_ROUTING_INTERRUPT_PIN_B, &interrupt_pin_B);
pciConfigInByte(pciBusNo, pciDevNo, pciFuncNo, PCI_CFG_IRQ_ROUTING_INTERRUPT_PIN_C, &interrupt_pin_C);
pciConfigInByte(pciBusNo, pciDevNo, pciFuncNo, PCI_CFG_IRQ_ROUTING_INTERRUPT_PIN_D, &interrupt_pin_D);
printf("Intel SB controller PIRQx ROUTE CONTROL REGISTER PIN A = 0x%x \n", interrupt_pin_A);
printf("Intel SB controller PIRQx ROUTE CONTROL REGISTER PIN B = 0x%x \n", interrupt_pin_B);
printf("Intel SB controller PIRQx ROUTE CONTROL REGISTER PIN C = 0x%x \n", interrupt_pin_C);
printf("Intel SB controller PIRQx ROUTE CONTROL REGISTER PIN D = 0x%x \n", interrupt_pin_D);
if(PCI_DEV[CAPTURE_VIDEO_CARD1].Found == OK)
{
pciBusNo = PCI_DEV[CAPTURE_VIDEO_CARD1].busNo;
pciDevNo = PCI_DEV[CAPTURE_VIDEO_CARD1].deviceNo;
pciFuncNo = PCI_DEV[CAPTURE_VIDEO_CARD1].funcNo;
pciConfigInByte(pciBusNo, pciDevNo, pciFuncNo, PCI_CFG_DEV_INT_PIN, &ucVidCaptureIntPin);
/* see page 223 of Shanley */
printf("Video Capture card using interrupt pin 0x%x or INT%c\n",ucVidCaptureIntPin,'A'+ucVidCaptureIntPin-1);
/* note: this should always return IntA, see bt878 spec for details, p103 (pdf 115) */
if(!PCI_CFG_IRQ_ROUTING_ENABLED(interrupt_pin_A))
{
printf("IRQ Routing for INTA not enabled on Southbridge.. this is a problem.\n");
printf("Should be enabled for IRQ %d\n",BT878INT);
pciConfigOutByte(SOUTH_BRIDGE_PCIDEV.busNo,SOUTH_BRIDGE_PCIDEV.deviceNo,SOUTH_BRIDGE_PCIDEV.funcNo,
PCI_CFG_IRQ_ROUTING_INTERRUPT_PIN_A,BT878INT);
pciConfigInByte(SOUTH_BRIDGE_PCIDEV.busNo,SOUTH_BRIDGE_PCIDEV.deviceNo,SOUTH_BRIDGE_PCIDEV.funcNo,
PCI_CFG_IRQ_ROUTING_INTERRUPT_PIN_A,&interrupt_pin_A);
printf("Fixed Southbridge INTA to map to IRQ %d\n",interrupt_pin_A);
}
else if(PCI_CFG_IRQ_LINE_TO_IRQ(interrupt_pin_A) != BT878INT)
{
printf("IRQ Routing for INTA routed to wrong IRQ on Southbridge..\n needs to be routed to IRQ%d,but is routed to IRQ%d\n",
BT878INT,PCI_CFG_IRQ_LINE_TO_IRQ(interrupt_pin_A));
pciConfigOutByte(SOUTH_BRIDGE_PCIDEV.busNo,SOUTH_BRIDGE_PCIDEV.deviceNo,SOUTH_BRIDGE_PCIDEV.funcNo,
PCI_CFG_IRQ_ROUTING_INTERRUPT_PIN_A,BT878INT);
pciConfigInByte(SOUTH_BRIDGE_PCIDEV.busNo,SOUTH_BRIDGE_PCIDEV.deviceNo,SOUTH_BRIDGE_PCIDEV.funcNo,
PCI_CFG_IRQ_ROUTING_INTERRUPT_PIN_A,&interrupt_pin_A);
printf("Fixed Southbridge INTA to map to IRQ %d\n",interrupt_pin_A);
}
}
printf("More Descriptive:\n");
if(PCI_CFG_IRQ_ROUTING_ENABLED(interrupt_pin_A))
printf("Interrupt pin A is enabled and routed to IRQ%i \n", PCI_CFG_IRQ_LINE_TO_IRQ(interrupt_pin_A));
else
printf("Interrupt pin A routing has been disabled \n");
if(PCI_CFG_IRQ_ROUTING_ENABLED(interrupt_pin_B))
printf("Interrupt pin B is enabled and routed to IRQ%i \n", PCI_CFG_IRQ_LINE_TO_IRQ(interrupt_pin_B));
else
printf("Interrupt pin B routing has been disabled \n");
if(PCI_CFG_IRQ_ROUTING_ENABLED(interrupt_pin_C))
printf("Interrupt pin C is enabled and routed to IRQ%i \n", PCI_CFG_IRQ_LINE_TO_IRQ(interrupt_pin_C));
else
printf("Interrupt pin C routing has been disabled \n");
if(PCI_CFG_IRQ_ROUTING_ENABLED(interrupt_pin_D))
printf("Interrupt pin D is enabled and routed to IRQ%i \n", PCI_CFG_IRQ_LINE_TO_IRQ(interrupt_pin_D));
else
printf("Interrupt pin D routing has been disabled \n");
}
/* Only works for a specific target */
/*int dumpPCIFunctionsConfigurationHeader(void) {
pciDeviceShow(0);
printf("\n");
pciHeaderShow(0, 0x00, 0);
printf("\n");
pciHeaderShow(0, 0x07, 0);
printf("\n");
pciHeaderShow(0, 0x0b, 0);
printf("\n");
pciHeaderShow(0, 0x11, 0);
return 0;
} */
int dumpPCIStatusAndCommand(void) {
int pciBusNo = PCI_DEV[NORTH_BRIDGE].busNo;
int pciDevNo = PCI_DEV[NORTH_BRIDGE].deviceNo;
int pciFuncNo = PCI_DEV[NORTH_BRIDGE].funcNo;
unsigned short command_reg, status_reg;
logFdAdd(1);
pciConfigInWord(pciBusNo, pciDevNo, pciFuncNo, PCI_CFG_COMMAND, &command_reg);
pciConfigInWord(pciBusNo, pciDevNo, pciFuncNo, PCI_CFG_STATUS, &status_reg);
logMsg("Command Status NB: 0x%x 0x%x\n", command_reg, status_reg,0,0,0,0);
pciBusNo = PCI_DEV[SOUTH_BRIDGE].busNo;
pciDevNo = PCI_DEV[SOUTH_BRIDGE].deviceNo;
pciFuncNo = PCI_DEV[SOUTH_BRIDGE].funcNo;
pciConfigInWord(pciBusNo, pciDevNo, pciFuncNo, PCI_CFG_COMMAND, &command_reg);
pciConfigInWord(pciBusNo, pciDevNo, pciFuncNo, PCI_CFG_STATUS, &status_reg);
logMsg("Command Status SB: 0x%x 0x%x\n", command_reg, status_reg,0,0,0,0);
pciBusNo = PCI_DEV[CAPTURE_VIDEO_CARD1].busNo;
pciDevNo = PCI_DEV[CAPTURE_VIDEO_CARD1].deviceNo;
pciFuncNo = PCI_DEV[CAPTURE_VIDEO_CARD1].funcNo;
pciConfigInWord(pciBusNo, pciDevNo, pciFuncNo, PCI_CFG_COMMAND, &command_reg);
pciConfigInWord(pciBusNo, pciDevNo, pciFuncNo, PCI_CFG_STATUS, &status_reg);
logMsg("Command Status CP: 0x%x 0x%x\n", command_reg, status_reg,0,0,0,0);
return 0;
}
int pci_probe(void)
{
int deviceNo;
int devices;
ushort_t vendorId;
ushort_t deviceId;
union
{
int classCode;
char array[4];
} u;
int busNo = 0;
if (pciLibInitStatus != OK) /* sanity check */
{
if (pciConfigLibInit (PCI_MECHANISM_1, 0xCF8, 0xCFC, 0) != OK)
{
printf("PCI lib config error\n");
return (ERROR);
}
}
if (pciConfigMech == PCI_MECHANISM_1)
devices = 0x1f;
else
devices = 0x1f;
printf("Bus #, Device#, vendorID, deviceID, u.classCode\n");
for(busNo=0; busNo<100; busNo++)
{
for (deviceNo=0; deviceNo <= devices; deviceNo++)
{
pciConfigInWord (busNo, deviceNo, 0, PCI_CFG_VENDOR_ID, &vendorId);
pciConfigInWord (busNo, deviceNo, 0, PCI_CFG_DEVICE_ID, &deviceId);
pciConfigInByte (busNo, deviceNo, 0, PCI_CFG_PROGRAMMING_IF,
&u.array[3]);
pciConfigInByte (busNo, deviceNo, 0, PCI_CFG_SUBCLASS, &u.array[2]);
pciConfigInByte (busNo, deviceNo, 0, PCI_CFG_CLASS, &u.array[1]);
u.array[0] = 0;
if (vendorId != 0xffff)
printf ("Bus:%.8x Device:%.8x %.8x VenID:%.8x DevID:%.8x class:%.8x\n",
busNo, deviceNo, 0, vendorId, deviceId, u.classCode);
}
}
return (OK);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -