From 73e5de63549b9e8b327cb0755759fe0c4b2bf092 Mon Sep 17 00:00:00 2001 From: Philip Homburg Date: Mon, 10 Jul 2006 12:17:16 +0000 Subject: [PATCH] Added sys_readbios. 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 | 1 + lib/syslib/pci_dev_name.c | 21 ++++++++++++++++----- lib/syslib/pci_slot_name.c | 17 +++++++++++++---- lib/syslib/sys_readbios.c | 15 +++++++++++++++ lib/sysutil/kputc.c | 8 ++++++++ 5 files changed, 53 insertions(+), 9 deletions(-) create mode 100644 lib/syslib/sys_readbios.c diff --git a/lib/syslib/Makefile.in b/lib/syslib/Makefile.in index 0b0736b7f..da50d08dc 100644 --- a/lib/syslib/Makefile.in +++ b/lib/syslib/Makefile.in @@ -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 \ diff --git a/lib/syslib/pci_dev_name.c b/lib/syslib/pci_dev_name.c index e5ae0475d..0bc6f552c 100644 --- a/lib/syslib/pci_dev_name.c +++ b/lib/syslib/pci_dev_name.c @@ -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); diff --git a/lib/syslib/pci_slot_name.c b/lib/syslib/pci_slot_name.c index d8dff2103..98c049b4c 100644 --- a/lib/syslib/pci_slot_name.c +++ b/lib/syslib/pci_slot_name.c @@ -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 index 000000000..286bb075e --- /dev/null +++ b/lib/syslib/sys_readbios.c @@ -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)); +} diff --git a/lib/sysutil/kputc.c b/lib/sysutil/kputc.c index f9d8db313..13226e3af 100644 --- a/lib/sysutil/kputc.c +++ b/lib/sysutil/kputc.c @@ -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