hi. everyone!
I’m porting and rewrite device driver source code AMDXRC II Lite for vxworks to qnx6.30
//PCI 9080
I have problem in this part of source code:
version: vxworks
static unsigned long pci_bar_addresses[]={
PCI_CFG_BASE_ADDRESS_0,
PCI_CFG_BASE_ADDRESS_1,
PCI_CFG_BASE_ADDRESS_2,
PCI_CFG_BASE_ADDRESS_3,
PCI_CFG_BASE_ADDRESS_4,
PCI_CFG_BASE_ADDRESS_5,
0
};
typedef struct _pci_dev {
os_uint16 vendor;
os_uint16 device;
os_uint16 subsystem_vendor;
os_uint16 subsystem_device;
int irq;
char rev;
struct {
os_uint32 start;
os_uint32 end;
os_uint32 flags;
} resource[DEVICE_COUNT_RESOURCE];
} pci_dev;
#define PCI_FIND_DEVICE pciFindDevice
#define PCI_CONFIG_IN_BYTE pciConfigInByte
#define PCI_CONFIG_IN_WORD pciConfigInWord
#define PCI_CONFIG_IN_LONG pciConfigInLong
#define PCI_CONFIG_OUT_LONG pciConfigOutLong
------------------------------------------------------------
int i=0;
int index=0;
int instance;
int bus=0,dev=0,fun=0,curr,mask,size;
short vid,did;
int j;
char irql,rev;
pci_dev pci_device;
os_dbgprint(0, ("pci_reg_devices: entered\n"));
if (PCI_FIND_DEVICE(vendor, device, instance, &bus, &dev, &fun)!= ERROR)
{
instance ++;
#ifdef FRC690
bus = LONSWAP(bus);
dev = LONSWAP(dev);
fun = LONSWAP(fun);
#endif
pciConfigInWord(bus, dev,);
PCI_CONFIG_IN_WORD( bus, dev, fun,PCI_CFG_SUB_VENDER_ID,&vid);
PCI_CONFIG_IN_WORD( bus, dev, fun, PCI_CFG_SUB_SYSTEM_ID,&did );
if ((vid==subvendor)&&(did==subdevice))
{
/* Found Device*/
pci_device.vendor = pci_tbl[i].vendor;
pci_device.device = pci_tbl[i].device;
pci_device.subsystem_vendor=vid;
pci_device.subsystem_device=did;
for (j=0;pci_bar_addresses[j];j++)
{
int lock;
PCI_CONFIG_IN_LONG( bus, dev, fun, pci_bar_addresses[j], &curr );
lock=intLock();
PCI_CONFIG_OUT_LONG( bus, dev, fun, pci_bar_addresses[j], ~0 );
PCI_CONFIG_IN_LONG( bus, dev, fun, pci_bar_addresses[j], &mask );
PCI_CONFIG_OUT_LONG( bus, dev, fun, pci_bar_addresses[j], curr);
intUnlock(lock);
if (!mask)
continue;
if (curr & PCI_BASE_IO)
{
pci_device.resource[j].flags = 1;
curr &= PCI_IOBASE_MASK;
mask &=PCI_IOBASE_MASK;
}
else
{
pci_device.resource[j].flags = 0;
curr &= PCI_MEMBASE_MASK;
mask&=PCI_MEMBASE_MASK;
}
#ifdef MCP750
curr+=PCI_MSTR_MEM_LOCAL - PCI_MSTR_MEM_BUS;
#endif
pci_device.resource[j].start = curr;
pci_device.resource[j].end = curr+(~mask+1)-1;
}
PCI_CONFIG_IN_BYTE( bus, dev, fun, PCI_CFG_DEV_INT_LINE, &irql );
pci_device.irq = (int) irql;
os_dbgprint(0, ("irql: i=%d\n",pci_device.irq));
PCI_CONFIG_IN_BYTE( bus, dev, fun, PCI_CFG_REVISION, &rev );
pci_device.rev = (int) rev;
PCI_CONFIG_IN_LONG( bus, dev, fun, 4, &curr );
printf("PCI Command/Status = %8x\n",curr);
// init_board(&pci_device,index,XRC_ON_PCI_BUS);
index++;
}
my version
static unsigned long pci_bar_addresses[]={
0x10 ,
0x14 ,
0x18 ,
0x1c ,
0x20 ,
0x24 ,
0
};
#define PCI_FIND_DEVICE pci_find_device
#define PCI_CONFIG_IN_BYTE pci_read_config8
#define PCI_CONFIG_IN_WORD pci_read_config16
#define PCI_CONFIG_IN_LONG pci_read_config32
#define PCI_CONFIG_OUT_LONG pci_write_config32
-----------------------------------------------------------
int i=0;
int index=0;
int instance;
uint32_t bus,dev,fun,curr,mask,size,dev_fun;
short vid,did;
int j;
uint8_t irql,rev;
pci_dev pci_device;
bus= 0; dev= 0; fun= 0; curr= 0; mask= 0; size= 0; dev_fun = 0;
os_dbgprint(0, ("pci_reg_devices: entered\n"));
instance=0;
if( PCI_FIND_DEVICE(pci_tbl[i].device, pci_tbl[i].vendor, instance,&bus, &dev_fun)!=PCI_DEVICE_NOT_FOUND)
{
instance++;
PCI_CONFIG_IN_WORD( bus, dev_fun, 0x2E, 1 , &did ); //sub system ID
PCI_CONFIG_IN_WORD( bus, dev_fun, 0x2C, 1 , &vid ); //sub system vendor ID
dev = (dev_fun&0xf8 )>>3 ;
fun = dev_fun&0x07 ;
if ( (vid==subvendor)&&(did==subdevice) )
{
/* Found Device*/
os_dbgprint(0, ("Found Device \n"));
pci_device.vendor = pci_tbl[i].vendor;
pci_device.device = pci_tbl[i].device;
pci_device.subsystem_vendor=vid;
pci_device.subsystem_device=did;
for (j=0;pci_bar_addresses[j];j++)
{
PCI_CONFIG_IN_LONG( bus, dev_fun, pci_bar_addresses[j], 1,&curr );
data = ~data;
PCI_CONFIG_OUT_LONG( bus, dev_fun, pci_bar_addresses[j], 1 , &data );
PCI_CONFIG_IN_LONG( bus, dev_fun, pci_bar_addresses[j], 1 , &mask );
PCI_CONFIG_OUT_LONG( bus, dev_fun, pci_bar_addresses[j], 1, &curr);
if (!mask)
continue;
/* if (curr & PCI_BASE_IO) <----???
{
pci_device.resource[j].flags = 1;
curr &= PCI_IOBASE_MASK; <-----??
mask &=PCI_IOBASE_MASK;
}
else
{
pci_device.resource[j].flags = 0;
curr &= PCI_MEMBASE_MASK; <-----???
mask&=PCI_MEMBASE_MASK;
}
*/
#ifdef MCP750
curr+=PCI_MSTR_MEM_LOCAL - PCI_MSTR_MEM_BUS;
#endif
pci_device.resource[j].start = curr;
pci_device.resource[j].end = curr+(~mask+1)-1;
}
PCI_CONFIG_IN_BYTE( bus, dev_fun, 0x3C,1, &irql ); //Interrupt Line
pci_device.irq = (int)irql;
os_dbgprint(0, ("irql: i=%d\n",pci_device.irq));
PCI_CONFIG_IN_BYTE( bus, dev_fun, 0x08,1, &rev ); //Revision ID
pci_device.rev = (int) rev;
PCI_CONFIG_IN_LONG( inf.BusNumber, inf.DevFunc, 0x4, 1, &curr ); //Command
os_dbgprint(0 ,("PCI Command/Status = %8x\n",curr) );
// init_board(&pci_device,index,XRC_ON_PCI_BUS);
index++;
}
}
my problem is in this part:
/* if (curr & PCI_BASE_IO)
{
pci_device.resource[j].flags = 1;
curr &= PCI_IOBASE_MASK;
mask &=PCI_IOBASE_MASK;
}
else
{
pci_device.resource[j].flags = 0;
curr &= PCI_MEMBASE_MASK;
mask&=PCI_MEMBASE_MASK;
}
*/
PCI_BASE_IO ???
PCI_IOBASE_MASK ???
PCI_MEMBASE_MASK ???
can you tell me what can i do?, or what are the values of these PCI_BASE …
help me please!!
thanks!.
i’m sorry if my english is bad, i’m learning.