I am currently developing a PCI camera driver for Windows CE 5.0 on an AMD
Geode GX2 processor. I used ceddk to enumerate the PCI devices and was able
to find a match for the PID and VID, I was even able to read the
configuration space.
However, when I remapped the address of the Base Address Registers(BAR0-5),
using HalTranslateBusAddress() and MmMapIoSpace(), and tried accessing the
returned virtual address, I can't seem to get the values I am expecting, base
on the datasheet of the PCI Camera.
below is a snippet of my code for your review. :)
//========
//remap the Base Address Registers (memory)
for(iCtr=0; iCtr<=3; iCtr++)
{
ioPhysicalBase.HighPart = 0;
ioPhysicalBase.LowPart = pciConfig.u.type0.BaseAddresses[iCtr];
// Camera Configuration
switch(iCtr)
{
case 0:
iSize = SMARTCAM_DMA_SIZE;
break;
case 1:
iSize = 0x7C;
break;
case 2:
iSize = 0x3FC;
break;
case 3:
iSize = 0xFC;
break;
}
//
// Map address
//
if (HalTranslateBusAddress(
PCIBus,
bus,
ioPhysicalBase,
&inIoSpace,
&ioPhysicalBase))
{
printf(":::: %d\n", inIoSpace);
if (!inIoSpace)
{
if ((SmartCamAddress =
(PULONG)MmMapIoSpace(ioPhysicalBase, iSize, FALSE)) == 0x00)
{
printf("smart camera: Error mapping
Smart Camera I/O Ports.\r\n");
return FALSE;
}
}
else
{
SmartCamAddress = (ULONG
*)ioPhysicalBase.LowPart;
}
}
else
{
printf("smart camera: Error translating Smart Camera I/O
Ports.\r\n");
return FALSE;
}
printf("BAR%d: [0x%8.8x]-[0x%8.8x]\r\n",
iCtr,
pciConfig.u.type0.BaseAddresses[iCtr],
SmartCamAddress);
}
testing = READ_REGISTER_ULONG(SmartCamAddress); // get first four bytes of
BAR3
printf("Value: 0x%8.8x\n", testing);
/======
i got the value of the pciConfig variable from HalGetBusData() function.
the values i got from MmMapIoSpace() functions are 0x46E00000, 0x00060008,
0x00070008, and 0x00080E01, respectively.
Am i going the right way? Also, how will i know and confirm if i got a
correct virtual address.
Please advice.
Thanks in advance and more power.
-----
Franz