From 1058def8e7827e56ce4a70afb4aeacb5dc44148f Mon Sep 17 00:00:00 2001 From: Igor Pashev Date: Fri, 3 May 2013 21:08:42 +0400 Subject: Imported Upstream version 4.2-build2006 --- kernel/OS/VxWorks/module.inc | 127 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 127 insertions(+) create mode 100644 kernel/OS/VxWorks/module.inc (limited to 'kernel/OS/VxWorks/module.inc') diff --git a/kernel/OS/VxWorks/module.inc b/kernel/OS/VxWorks/module.inc new file mode 100644 index 0000000..31f17f0 --- /dev/null +++ b/kernel/OS/VxWorks/module.inc @@ -0,0 +1,127 @@ +#if DRIVER_TYPE == DRV_PCI +#include +#undef PCI_LATENCY_TIMER +#include + +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; +} -- cgit v1.2.3