summaryrefslogtreecommitdiff
path: root/kernel/OS/VxWorks/module.inc
diff options
context:
space:
mode:
authorIgor Pashev <pashev.igor@gmail.com>2013-05-03 21:08:42 +0400
committerIgor Pashev <pashev.igor@gmail.com>2013-05-03 21:08:42 +0400
commit1058def8e7827e56ce4a70afb4aeacb5dc44148f (patch)
tree4495d23e7b54ab5700e3839081e797c1eafe0db9 /kernel/OS/VxWorks/module.inc
downloadoss4-upstream.tar.gz
Imported Upstream version 4.2-build2006upstream/4.2-build2006upstream
Diffstat (limited to 'kernel/OS/VxWorks/module.inc')
-rw-r--r--kernel/OS/VxWorks/module.inc127
1 files changed, 127 insertions, 0 deletions
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 <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;
+}