]> Zhao Yanbai Git Server - minix.git/commitdiff
Stubs for accessing the PCI driver
authorPhilip Homburg <philip@cs.vu.nl>
Fri, 2 Dec 2005 14:41:46 +0000 (14:41 +0000)
committerPhilip Homburg <philip@cs.vu.nl>
Fri, 2 Dec 2005 14:41:46 +0000 (14:41 +0000)
12 files changed:
lib/syslib/Makefile
lib/syslib/pci_attr_r32.c [new file with mode: 0644]
lib/syslib/pci_attr_r8.c [new file with mode: 0644]
lib/syslib/pci_attr_w32.c [new file with mode: 0644]
lib/syslib/pci_dev_name.c [new file with mode: 0644]
lib/syslib/pci_find_dev.c [new file with mode: 0644]
lib/syslib/pci_first_dev.c [new file with mode: 0644]
lib/syslib/pci_ids.c [new file with mode: 0644]
lib/syslib/pci_init.c [new file with mode: 0644]
lib/syslib/pci_next_dev.c [new file with mode: 0644]
lib/syslib/pci_reserve.c [new file with mode: 0644]
lib/syslib/pci_slot_name.c [new file with mode: 0644]

index c48edafaef46d79e00e1fa7edbd9b14600c477b4..5c9fd86d32e1dd32c10c28ab4d0879988fb5d800 100755 (executable)
@@ -41,5 +41,16 @@ libsys_OBJECTS       = \
        taskcall.o \
        sys_vm_setbuf.o \
        sys_vm_map.o \
+       pci_attr_r8.o \
+       pci_attr_r32.o \
+       pci_attr_w32.o \
+       pci_dev_name.o \
+       pci_find_dev.o \
+       pci_first_dev.o \
+       pci_ids.o \
+       pci_init.o \
+       pci_next_dev.o \
+       pci_reserve.o \
+       pci_slot_name.o \
 
 include ../Makefile.inc
diff --git a/lib/syslib/pci_attr_r32.c b/lib/syslib/pci_attr_r32.c
new file mode 100644 (file)
index 0000000..b9b53a6
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+pci_attr_r32.c
+*/
+
+#include "syslib.h"
+#include <minix/sysutil.h>
+
+/*===========================================================================*
+ *                             pci_attr_r32                                 *
+ *===========================================================================*/
+PUBLIC u32_t pci_attr_r32(devind, port)
+int devind;
+int port;
+{
+       int r;
+       message m;
+
+       m.m_type= BUSC_PCI_ATTR_R32;
+       m.m2_i1= devind;
+       m.m2_i2= port;
+
+       r= sendrec(PCI_PROC_NR, &m);
+       if (r != 0)
+               panic("pci", "pci_attr_r32: can't talk to PCI", r);
+
+       if (m.m_type != 0)
+               panic("pci", "pci_attr_r32: got bad reply from PCI", m.m_type);
+
+       return m.m2_l1;
+}
+
diff --git a/lib/syslib/pci_attr_r8.c b/lib/syslib/pci_attr_r8.c
new file mode 100644 (file)
index 0000000..616390a
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+pci_attr_r8.c
+*/
+
+#include "syslib.h"
+#include <minix/sysutil.h>
+
+/*===========================================================================*
+ *                             pci_attr_r8                                  *
+ *===========================================================================*/
+PUBLIC u8_t pci_attr_r8(devind, port)
+int devind;
+int port;
+{
+       int r;
+       message m;
+
+       m.m_type= BUSC_PCI_ATTR_R8;
+       m.m2_i1= devind;
+       m.m2_i2= port;
+
+       r= sendrec(PCI_PROC_NR, &m);
+       if (r != 0)
+               panic("pci", "pci_attr_r8: can't talk to PCI", r);
+
+       if (m.m_type != 0)
+               panic("pci", "pci_attr_r8: got bad reply from PCI", m.m_type);
+
+       return m.m2_l1;
+}
+
diff --git a/lib/syslib/pci_attr_w32.c b/lib/syslib/pci_attr_w32.c
new file mode 100644 (file)
index 0000000..bf1110a
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+pci_attr_w32.c
+*/
+
+#include "syslib.h"
+#include <minix/sysutil.h>
+
+/*===========================================================================*
+ *                             pci_attr_w32                                 *
+ *===========================================================================*/
+PUBLIC void pci_attr_w32(devind, port, value)
+int devind;
+int port;
+u32_t value;
+{
+       int r;
+       message m;
+
+       m.m_type= BUSC_PCI_ATTR_W32;
+       m.m2_i1= devind;
+       m.m2_i2= port;
+       m.m2_l1= value;
+
+       r= sendrec(PCI_PROC_NR, &m);
+       if (r != 0)
+               panic("pci", "pci_attr_w32: can't talk to PCI", r);
+
+       if (m.m_type != 0)
+               panic("pci", "pci_attr_w32: got bad reply from PCI", m.m_type);
+}
+
diff --git a/lib/syslib/pci_dev_name.c b/lib/syslib/pci_dev_name.c
new file mode 100644 (file)
index 0000000..5200e9f
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+pci_dev_name.c
+*/
+
+#include "syslib.h"
+#include <minix/sysutil.h>
+
+/*===========================================================================*
+ *                             pci_dev_name                                 *
+ *===========================================================================*/
+PUBLIC char *pci_dev_name(vid, did)
+u16_t vid;
+u16_t did;
+{
+       static char name[80];   /* We need a better interface for this */
+
+       int r;
+       message m;
+
+       m.m_type= BUSC_PCI_DEV_NAME;
+       m.m1_i1= vid;
+       m.m1_i2= did;
+       m.m1_i3= sizeof(name);
+       m.m1_p1= name;
+
+       r= sendrec(PCI_PROC_NR, &m);
+       if (r != 0)
+               panic("pci", "pci_dev_name: can't talk to PCI", r);
+
+       if (m.m_type == ENOENT)
+       {
+               printf("pci_dev_name: got no name\n");
+               return NULL;    /* No name for this device */
+       }
+       if (m.m_type != 0)
+               panic("pci", "pci_dev_name: got bad reply from PCI", m.m_type);
+
+       name[sizeof(name)-1]= '\0';     /* Make sure that the string is NUL
+                                        * terminated.
+                                        */
+
+       printf("pci_dev_name: got name %s\n", name);
+       return name;
+}
+
diff --git a/lib/syslib/pci_find_dev.c b/lib/syslib/pci_find_dev.c
new file mode 100644 (file)
index 0000000..0e64376
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+pci_find_dev.c
+*/
+
+#include "syslib.h"
+#include <minix/sysutil.h>
+
+/*===========================================================================*
+ *                             pci_find_dev                                 *
+ *===========================================================================*/
+PUBLIC int pci_find_dev(bus, dev, func, devindp)
+u8_t bus;
+u8_t dev;
+u8_t func;
+int *devindp;
+{
+       int r;
+       message m;
+
+       m.m_type= BUSC_PCI_FIND_DEV;
+       m.m1_i1= bus;
+       m.m1_i2= dev;
+       m.m1_i3= func;
+
+       r= sendrec(PCI_PROC_NR, &m);
+       if (r != 0)
+               panic("pci", "pci_find_dev: can't talk to PCI", r);
+
+       if (m.m_type == 1)
+       {
+               *devindp= m.m1_i1;
+               printf("pci_find_dev: got device %d for %d.%d.%d\n",
+                       *devindp, bus, dev, func);
+               return 1;
+       }
+       if (m.m_type != 0)
+               panic("pci", "pci_find_dev: got bad reply from PCI", m.m_type);
+
+       printf("pci_find_dev: got nothing\n");
+       return 0;
+}
+
diff --git a/lib/syslib/pci_first_dev.c b/lib/syslib/pci_first_dev.c
new file mode 100644 (file)
index 0000000..a6befe8
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+pci_first_dev.c
+*/
+
+#include "syslib.h"
+#include <minix/sysutil.h>
+
+/*===========================================================================*
+ *                             pci_first_dev                                *
+ *===========================================================================*/
+PUBLIC int pci_first_dev(devindp, vidp, didp)
+int *devindp;
+u16_t *vidp;
+u16_t *didp;
+{
+       int r;
+       message m;
+
+       m.m_type= BUSC_PCI_FIRST_DEV;
+       r= sendrec(PCI_PROC_NR, &m);
+       if (r != 0)
+               panic("pci", "pci_first_dev: can't talk to PCI", r);
+       if (m.m_type == 1)
+       {
+               *devindp= m.m1_i1;
+               *vidp= m.m1_i2;
+               *didp= m.m1_i3;
+               printf("pci_first_dev: got device %d, %04x/%04x\n", 
+                       *devindp, *vidp, *didp);
+               return 1;
+       }
+       if (m.m_type != 0)
+               panic("pci", "pci_first_dev: got bad reply from PCI", m.m_type);
+
+       printf("pci_first_dev: got nothing\n");
+       return 0;
+}
diff --git a/lib/syslib/pci_ids.c b/lib/syslib/pci_ids.c
new file mode 100644 (file)
index 0000000..c05e05a
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+pci_ids.c
+*/
+
+#include "syslib.h"
+#include <minix/sysutil.h>
+
+/*===========================================================================*
+ *                             pci_ids                                      *
+ *===========================================================================*/
+PUBLIC void pci_ids(devind, vidp, didp)
+int devind;
+u16_t *vidp;
+u16_t *didp;
+{
+       int r;
+       message m;
+
+       m.m_type= BUSC_PCI_IDS;
+       m.m1_i1= devind;
+
+       r= sendrec(PCI_PROC_NR, &m);
+       if (r != 0)
+               panic("pci", "pci_ids: can't talk to PCI", r);
+
+       if (m.m_type != 0)
+               panic("pci", "pci_ids: got bad reply from PCI", m.m_type);
+       *vidp= m.m1_i1;
+       *didp= m.m1_i2;
+       printf("pci_ids: %04x/%04x\n", *vidp, *didp);
+}
+
diff --git a/lib/syslib/pci_init.c b/lib/syslib/pci_init.c
new file mode 100644 (file)
index 0000000..2549752
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+pci_init.c
+*/
+
+#include "syslib.h"
+#include <minix/sysutil.h>
+
+/*===========================================================================*
+ *                             pci_init                                     *
+ *===========================================================================*/
+PUBLIC void pci_init()
+{
+       int r;
+       message m;
+
+       m.m_type= BUSC_PCI_INIT;
+       r= sendrec(PCI_PROC_NR, &m);
+       if (r != 0)
+               panic("pci", "pci_init: can't talk to PCI", r);
+       if (m.m_type != 0)
+               panic("pci", "pci_init: got bad reply from PCI", m.m_type);
+}
+
diff --git a/lib/syslib/pci_next_dev.c b/lib/syslib/pci_next_dev.c
new file mode 100644 (file)
index 0000000..2cb6d9f
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+pci_next_dev.c
+*/
+
+#include "syslib.h"
+#include <minix/sysutil.h>
+
+/*===========================================================================*
+ *                             pci_next_dev                                 *
+ *===========================================================================*/
+PUBLIC int pci_next_dev(devindp, vidp, didp)
+int *devindp;
+u16_t *vidp;
+u16_t *didp;
+{
+       int r;
+       message m;
+
+       m.m_type= BUSC_PCI_NEXT_DEV;
+       m.m1_i1= *devindp;
+
+       r= sendrec(PCI_PROC_NR, &m);
+       if (r != 0)
+               panic("pci", "pci_next_dev: can't talk to PCI", r);
+
+       if (m.m_type == 1)
+       {
+               *devindp= m.m1_i1;
+               *vidp= m.m1_i2;
+               *didp= m.m1_i3;
+#if 0
+               printf("pci_next_dev: got device %d, %04x/%04x\n", 
+                       *devindp, *vidp, *didp);
+#endif
+               return 1;
+       }
+       if (m.m_type != 0)
+               panic("pci", "pci_next_dev: got bad reply from PCI", m.m_type);
+
+       printf("pci_next_dev: got nothing\n");
+       return 0;
+}
+
diff --git a/lib/syslib/pci_reserve.c b/lib/syslib/pci_reserve.c
new file mode 100644 (file)
index 0000000..3cf6381
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+pci_reserve.c
+*/
+
+#include "syslib.h"
+#include <minix/sysutil.h>
+
+/*===========================================================================*
+ *                             pci_reserve                                  *
+ *===========================================================================*/
+PUBLIC void pci_reserve(devind)
+int devind;
+{
+       int r;
+       message m;
+
+       m.m_type= BUSC_PCI_RESERVE;
+       m.m1_i1= devind;
+
+       r= sendrec(PCI_PROC_NR, &m);
+       if (r != 0)
+               panic("pci", "pci_reserve: can't talk to PCI", r);
+
+       if (m.m_type != 0)
+               panic("pci", "pci_reserve: got bad reply from PCI", m.m_type);
+}
+
diff --git a/lib/syslib/pci_slot_name.c b/lib/syslib/pci_slot_name.c
new file mode 100644 (file)
index 0000000..0591d25
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+pci_slot_name.c
+*/
+
+#include "syslib.h"
+#include <minix/sysutil.h>
+
+/*===========================================================================*
+ *                             pci_slot_name                                *
+ *===========================================================================*/
+PUBLIC char *pci_slot_name(devind)
+int devind;
+{
+       static char name[80];   /* We need a better interface for this */
+
+       int r;
+       message m;
+
+       m.m_type= BUSC_PCI_SLOT_NAME;
+       m.m1_i1= devind;
+       m.m1_i2= sizeof(name);
+       m.m1_p1= name;
+
+       r= sendrec(PCI_PROC_NR, &m);
+       if (r != 0)
+               panic("pci", "pci_slot_name: can't talk to PCI", r);
+
+       if (m.m_type != 0)
+               panic("pci", "pci_slot_name: got bad reply from PCI", m.m_type);
+
+       name[sizeof(name)-1]= '\0';     /* Make sure that the string is NUL
+                                        * terminated.
+                                        */
+
+       printf("pci_slot_name: got name %s\n", name);
+       return name;
+}
+