📄 devmap.cpp
字号:
DebugPrintf(
TEXT(" InterruptLine = 0x%2.2X, InterruptPin = 0x%2.2X, BridgeControl = 0x%4.4X\r\n"),
pPciConfig->u.type1.InterruptLine, pPciConfig->u.type1.InterruptPin,
pPciConfig->u.type1.BridgeControl);
break;
}
}
#endif /* ENABLE_PCI */
#endif /* 0 */
/*============================================================================
* Function: MapPhysicalDevice
* Description: Scan PCI bus and map MQ200 device frame buffer and MMIO space
*===========================================================================*/
int MQGC::MapPhysicalDevice(void)
{
DEBUGMSG(GPE_ZONE_LINE,(TEXT("MQGC::MapPhysicalDevice\r\n")));
if((m_nMQFlag & PROCESSOR_MASK) == IS_PCI) // are we on a PCI based system
{ // yes, search PCI bus for an MQ200 card
int bus, device, function;
int length;
PCI_SLOT_NUMBER slotNumber;
PCI_COMMON_CONFIG pciConfig;
BOOL bFoundIt = FALSE;
// HKEY hKey = NULL;
// DWORD Disposition;
// TCHAR RegString[25];
// if (RegCreateKeyEx (HKEY_LOCAL_MACHINE, DRIVER_REGISTRY_STRING, 0, L"", 0, 0, NULL, &hKey, &Disposition) != ERROR_SUCCESS)
// {
// RETAILMSG(1, (L"Couldn't Create HKLM\\Drivers\\Display\\MQ200 registry key\r\n"));
// return 1; // return error
// }
for (bus = 0; bus < PCI_MAX_BUS; bus++)
{
for (device = 0; device < PCI_MAX_DEVICES; device++)
{
slotNumber.u.bits.DeviceNumber = device;
for (function = 0; function < PCI_MAX_FUNCTION; function++)
{
slotNumber.u.bits.FunctionNumber = function;
length = HalGetBusData(PCIConfiguration,
bus,
slotNumber.u.AsULONG,
&pciConfig,
sizeof(pciConfig) - sizeof(pciConfig.DeviceSpecific));
if (length == 0 || pciConfig.VendorID == 0xFFFF)
{
break;
}
if (pciConfig.VendorID == MQVEN &&
pciConfig.DeviceID == MQDEV)
{
// HKEY hKeyDevice;
// DWORD DeviceDisposition;
// wsprintf (RegString, L"Bus%2.2xDevice%2.2xFunction%2.2x", bus, device, function);
// if(Disposition != REG_CREATED_NEW_KEY) // key existed, see if this card is spoken for
// {
// if(RegOpenKeyEx (hKey, RegString, 0, 0, &hKeyDevice) == ERROR_SUCCESS) // reg key exists, this card is taken
// {
// RETAILMSG (1, (L"Card in use already\n"));
// RegCloseKey (hKeyDevice);
// break; // Leave "function" for loop, do next iteration of "device" loop
// }
// }
// if (RegCreateKeyEx (hKey, RegString, 0, L"", 0, 0, NULL, &hKeyDevice, &DeviceDisposition) != ERROR_SUCCESS)
// {
// RETAILMSG(1, (L"Couldn't Create %s registry key\r\n", RegString));
// return 1; // return error
// }
// RegCloseKey (hKeyDevice);
bFoundIt = TRUE;
}
if (bFoundIt || (function == 0 && !(pciConfig.HeaderType & 0x80)))
{
break;
}
} // for (function ...
// check for bailout conditions
if (bFoundIt || length == 0)
{
break;
}
} // for (device ...
// check for bailout conditions
if (bFoundIt || (length == 0 && device == 0))
{
break;
}
} // for (bus ...
// RegCloseKey (hKey);
if (!bFoundIt)
{
// Couldn't find an MQ200 card, what to do now?
RETAILMSG (1, (L"No available MQ200 card found\r\n"));
return 1; // return error
}
if((pciConfig.Command & 7) == 0)
{
// make sure card is enabled for access
USHORT newCommand = pciConfig.Command | 0x07;
HalSetBusDataByOffset (PCIConfiguration, bus, slotNumber.u.AsULONG, &newCommand, 0x04, 0x02);
}
m_nIOPhysical = pciConfig.u.type0.BaseAddresses[0];
m_nLAWPhysical = pciConfig.u.type0.BaseAddresses[1];
}
else
{ // no PCI, use Registry values
if(ulFBBase == 0)
{
RETAILMSG(1, (TEXT("MQGC::MapPhysicalDevice - no Base Address specified in registry\r\n")));
return 1; // return error
}
m_nLAWPhysical = ulFBBase;
m_nIOPhysical = ulFBBase + 0x600000L;
}
m_nMMIOMemorySize = MMIO_SIZE;
m_nVideoMemorySize = FB_SIZE;
RETAILMSG (1, (L"MQGC::MapPhysicalDevice - m_nLAWPhysical = %8.8x m_nVideoMemorySize = %8.8x m_nIOPhysical = %8.8x m_nMMIOMemorySize = %8.8x\r\n", m_nLAWPhysical, m_nVideoMemorySize, m_nIOPhysical, m_nMMIOMemorySize));
return 0;
#if 0
#ifndef ENABLE_PCI
#else /* ENABLE_PCI */
int bus,device;
int function;
int length;
PCI_COMMON_CONFIG pciConfig;
PCI_SLOT_NUMBER slotNumber;
for (bus = 0; bus < PCI_MAX_BUS; bus++)
{
for (device = 0; device < PCI_MAX_DEVICES; device++)
{
slotNumber.u.bits.DeviceNumber = device;
for (function = 0; function < PCI_MAX_FUNCTION; function++)
{
slotNumber.u.bits.FunctionNumber = function;
length = HalGetBusData(
PCIConfiguration, bus, slotNumber.u.AsULONG,
&pciConfig, sizeof(pciConfig) - sizeof(pciConfig.DeviceSpecific));
if (length == 0 || pciConfig.VendorID == 0xFFFF)
{
break;
}
if (pciConfig.VendorID == 0x4d51)
{
//Print device configuration
#ifdef MIPS_NEC
if (1)
#else
if (pciConfig.Command == (USHORT)0x00 &&
pciConfig.u.type0.BaseAddresses[0] == 0x00 &&
pciConfig.u.type0.BaseAddresses[0] == 0x00)
#endif
{
pciConfig.Command = (USHORT)0x02;
#ifdef CEPC
pciConfig.u.type0.BaseAddresses[0]= 0xFF800000;
pciConfig.u.type0.BaseAddresses[1]= 0xFF400000;
#else
#ifdef FALCON
pciConfig.u.type0.BaseAddresses[0]= 0x11400000;
pciConfig.u.type0.BaseAddresses[1]= 0x11000000;
#endif
#endif
HalSetBusData(PCIConfiguration, bus, slotNumber.u.AsULONG,
&pciConfig, sizeof(pciConfig) - sizeof(pciConfig.DeviceSpecific));
}
DumpPciConfig(bus, device, function, &pciConfig);
#ifdef FALCON
pciConfig.u.type0.BaseAddresses[0]+= 0xA0000000;
pciConfig.u.type0.BaseAddresses[1]+= 0xA0000000;
#endif
//Map Memory to acess IO & FB, mainly by GPE
m_nIOPhysical = pciConfig.u.type0.BaseAddresses[0];
m_nLAWPhysical = pciConfig.u.type0.BaseAddresses[1];
#ifdef READ_PCI_DEVSIZE
//Read device MMIO and Memory sizes
pciConfig.u.type0.BaseAddresses[0]= 0xFFFFFFFF;
pciConfig.u.type0.BaseAddresses[1]= 0xFFFFFFFF;
HalSetBusData(PCIConfiguration, bus, slotNumber.u.AsULONG,
&pciConfig, sizeof(pciConfig) - sizeof(pciConfig.DeviceSpecific));
#endif /* READ_PCI_DEVSIZE */
//Map Memory to acess IO & FB, mainly by GPE
m_nMMIOMemorySize = MMIO_SIZE;
m_nVideoMemorySize = FB_SIZE;
return 0; // okay return status
}
if (function == 0 && !(pciConfig.HeaderType & 0x80))
{
break;
}
}
if (length == 0)
{
break;
}
}
if (length == 0 && device == 0)
{
break;
}
}
#endif /* ENABLE_PCI */
#endif /* 0 */
return 1; // can't find device return status
}
#pragma optimize("",on)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -