1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
|
#if DRIVER_TYPE == DRV_PCI
#include <drv/pci/pciConfigLib.h>
#undef PCI_LATENCY_TIMER
#include <oss_pci.h>
int
oss_pci_read_config_byte (oss_device_t * osdev, offset_t where,
unsigned char *val)
{
oss_pci_device_t *pd = osdev->dip;
return pciConfigInByte (pd->bus, pd->dev, pd->func, where, val);
}
int
oss_pci_read_config_irq (oss_device_t * osdev, offset_t where,
unsigned char *val)
{
oss_pci_device_t *pd = osdev->dip;
return pciConfigInByte (pd->bus, pd->dev, pd->func, where, val);
}
int
oss_pci_read_config_word (oss_device_t * osdev, offset_t where,
unsigned short *val)
{
oss_pci_device_t *pd = osdev->dip;
if (osdev == NULL)
{
cmn_err (CE_CONT, "oss_pci_read_config_word: osdev==NULL\n");
return PCIBIOS_FAILED;
}
return pciConfigInWord (pd->bus, pd->dev, pd->func, where, val);
}
int
oss_pci_read_config_dword (oss_device_t * osdev, offset_t where,
unsigned int *val)
{
oss_pci_device_t *pd = osdev->dip;
return pciConfigInLong (pd->bus, pd->dev, pd->func, where, val);
}
int
oss_pci_write_config_byte (oss_device_t * osdev, offset_t where,
unsigned char val)
{
oss_pci_device_t *pd = osdev->dip;
return pciConfigOutByte (pd->bus, pd->dev, pd->func, where, val);
}
int
oss_pci_write_config_word (oss_device_t * osdev, offset_t where,
unsigned short val)
{
oss_pci_device_t *pd = osdev->dip;
return pciConfigOutWord (pd->bus, pd->dev, pd->func, where, val);
}
int
oss_pci_write_config_dword (oss_device_t * osdev, offset_t where,
unsigned int val)
{
oss_pci_device_t *pd = osdev->dip;
return pciConfigOutLong (pd->bus, pd->dev, pd->func, where, val);
}
#endif
int
DRIVER_NAME(void)
{
#if DRIVER_TYPE == DRV_PCI
int i;
int bus, dev, func;
unsigned int d, vendor_id, dev_id;
static int instance = 0;
if (id_table[0] == 0)
{
cmn_err (CE_WARN, DRIVER_NICK ": ID table is empty\n");
return OSS_EIO;
}
i=0;
while ((d=id_table[i]) != 0)
{
int index=0;
vendor_id = (d >> 16) & 0xffff;
dev_id = d & 0xffff;
while (pciFindDevice(vendor_id, dev_id, instance,&bus, &dev, &func) == OK)
{
oss_pci_device_t *pcidev = malloc(sizeof(*pcidev));
oss_device_t *osdev;
cmn_err(CE_CONT, "Found pci device %08x / %d : b=%d, d=%d, f=%d\n", d, index, bus, dev, func);
pcidev->bus = bus;
pcidev->dev = dev;
pcidev->func = func;
if ((osdev =
osdev_create ((dev_info_t*)pcidev, DRIVER_TYPE, instance++, DRIVER_NICK,
NULL)) == NULL)
{
return OSS_ENOMEM;
}
index++;
}
i++;
}
#endif
return 0;
}
|