]> Zhao Yanbai Git Server - minix.git/commitdiff
Added sys_readbios.
authorPhilip Homburg <philip@cs.vu.nl>
Mon, 10 Jul 2006 12:17:16 +0000 (12:17 +0000)
committerPhilip Homburg <philip@cs.vu.nl>
Mon, 10 Jul 2006 12:17:16 +0000 (12:17 +0000)
Changed pci_dev_name and pci_slot_name to use safecopies.
Mae it possible to disable the use of safecopies in kputc for debugging.

lib/syslib/Makefile.in
lib/syslib/pci_dev_name.c
lib/syslib/pci_slot_name.c
lib/syslib/sys_readbios.c [new file with mode: 0644]
lib/sysutil/kputc.c

index 0b0736b7f59f1a4c9dd5f2a05529eb9f5a0483d2..da50d08dc37b6e4a5378e65bf47c2b9c2c01919b 100644 (file)
@@ -41,6 +41,7 @@ libsys_FILES=" \
        sys_nice.c \
        sys_out.c \
        sys_physcopy.c \
+       sys_readbios.c \
        sys_safecopy.c \
        sys_vsafecopy.c \
        sys_sdevio.c \
index e5ae0475de54d523655e052ee34e683f30c27ce7..0bc6f552c35d259f70d6728220b3041753035497 100644 (file)
@@ -16,15 +16,26 @@ u16_t did;
        static char name[80];   /* We need a better interface for this */
 
        int r;
+       cp_grant_id_t gid;
        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;
+       gid= cpf_grant_direct(pci_procnr, (vir_bytes)name, sizeof(name),
+               CPF_WRITE);
+       if (gid == -1)
+       {
+               printf("pci_dev_name: cpf_grant_direct failed: %d\n",
+                       errno);
+               return NULL;
+       }
+
+       m.m_type= BUSC_PCI_DEV_NAME_S;
+       m.m7_i1= vid;
+       m.m7_i2= did;
+       m.m7_i3= sizeof(name);
+       m.m7_i4= gid;
 
        r= sendrec(pci_procnr, &m);
+       cpf_revoke(gid);
        if (r != 0)
                panic("pci", "pci_dev_name: can't talk to PCI", r);
 
index d8dff2103623ce219794aa96c702ad223b749e87..98c049b4c04e91c0af578f481f2eff3b2d58648a 100644 (file)
@@ -15,14 +15,25 @@ int devind;
        static char name[80];   /* We need a better interface for this */
 
        int r;
+       cp_grant_id_t gid;
        message m;
 
-       m.m_type= BUSC_PCI_SLOT_NAME;
+       gid= cpf_grant_direct(pci_procnr, (vir_bytes)name, sizeof(name),
+               CPF_WRITE);
+       if (gid == -1)
+       {
+               printf("pci_dev_name: cpf_grant_direct failed: %d\n",
+                       errno);
+               return NULL;
+       }
+
+       m.m_type= BUSC_PCI_SLOT_NAME_S;
        m.m1_i1= devind;
        m.m1_i2= sizeof(name);
-       m.m1_p1= name;
+       m.m1_i3= gid;
 
        r= sendrec(pci_procnr, &m);
+       cpf_revoke(gid);
        if (r != 0)
                panic("pci", "pci_slot_name: can't talk to PCI", r);
 
@@ -32,8 +43,6 @@ int devind;
        name[sizeof(name)-1]= '\0';     /* Make sure that the string is NUL
                                         * terminated.
                                         */
-
-       printf("pci_slot_name: got name %s\n", name);
        return name;
 }
 
diff --git a/lib/syslib/sys_readbios.c b/lib/syslib/sys_readbios.c
new file mode 100644 (file)
index 0000000..286bb07
--- /dev/null
@@ -0,0 +1,15 @@
+#include "syslib.h"
+
+PUBLIC int sys_readbios(address, buf, size)
+phys_bytes address;            /* Absolute memory address */
+void *buf;                     /* Buffer to store the results */
+size_t size;                   /* Amount of data to read */
+{
+/* Read data from BIOS locations */
+  message m;
+
+  m.RDB_SIZE = size;
+  m.RDB_ADDR = address;
+  m.RDB_BUF = buf;
+  return(_taskcall(SYSTASK, SYS_READBIOS, &m));
+}
index f9d8db313a72a1630b5e6d86b4120e3e8b85f604..13226e3af04a3dd8ca1f59574d0549a8281ec606 100644 (file)
@@ -11,6 +11,8 @@
 
 static char print_buf[80];     /* output is buffered here */
 
+int kputc_use_private_grants= 0;
+
 /*===========================================================================*
  *                             kputc                                        *
  *===========================================================================*/
@@ -28,6 +30,12 @@ int c;
        static cp_grant_id_t printgrants[PRINTPROCS];
        int p;
 
+       if (kputc_use_private_grants)
+       {
+               for (p= 0; p<PRINTPROCS; p++)
+                       printgrants[p]= GRANT_INVALID;
+               firstprint= 0;
+       }
        if(firstprint) {
                for(p = 0; procs[p] != NONE; p++) {
                        printgrants[p] = GRANT_INVALID;