Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/i386 add a function to read from the BIOS vm86



details:   https://anonhg.NetBSD.org/src/rev/8f0aff8bb82c
branches:  trunk
changeset: 533901:8f0aff8bb82c
user:      drochner <drochner%NetBSD.org@localhost>
date:      Wed Jul 10 19:09:35 2002 +0000

description:
add a function to read from the BIOS vm86
(most of it is already mapped to KVM, but it appears easier to me
to do it this way instead of a lot of range checks)

diffstat:

 sys/arch/i386/i386/kvm86.c    |  35 +++++++++++++++++++++++++++++++++--
 sys/arch/i386/include/kvm86.h |   3 ++-
 2 files changed, 35 insertions(+), 3 deletions(-)

diffs (87 lines):

diff -r 648dcc5b9921 -r 8f0aff8bb82c sys/arch/i386/i386/kvm86.c
--- a/sys/arch/i386/i386/kvm86.c        Wed Jul 10 19:08:43 2002 +0000
+++ b/sys/arch/i386/i386/kvm86.c        Wed Jul 10 19:09:35 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kvm86.c,v 1.1 2002/07/07 12:56:34 drochner Exp $ */
+/* $NetBSD: kvm86.c,v 1.2 2002/07/10 19:09:35 drochner Exp $ */
 
 /*
  * Copyright (c) 2002
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kvm86.c,v 1.1 2002/07/07 12:56:34 drochner Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kvm86.c,v 1.2 2002/07/10 19:09:35 drochner Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -65,6 +65,8 @@
 void *bioscallscratchpage;
 /* where this page is mapped in the vm86 */
 #define BIOSCALLSCRATCHPAGE_VMVA 0x1000
+/* a virtual page to map in vm86 memory temporarily */
+vaddr_t bioscalltmpva;
 
 #define KVM86_IOPL3 /* not strictly necessary, saves a lot of traps */
 
@@ -114,6 +116,7 @@
        kvm86_map(vmd, vtophys((vaddr_t)bioscallscratchpage),
                  BIOSCALLSCRATCHPAGE_VMVA);
        bioscallvmd = vmd;
+       bioscalltmpva = uvm_km_valloc(kernel_map, NBPG);
 }
 
 /*
@@ -192,6 +195,34 @@
        free(kva, M_DEVBUF);
 }
 
+size_t
+kvm86_bios_read(vmva, buf, len)
+       u_int32_t vmva;
+       char *buf;
+       size_t len;
+{
+       size_t todo, now;
+       paddr_t vmpa;
+
+       todo = len;
+       while (todo > 0) {
+               now = min(todo, NBPG - (vmva & (NBPG - 1)));
+
+               if (!bioscallvmd->pgtbl[vmva >> 12])
+                       break;
+               vmpa = bioscallvmd->pgtbl[vmva >> 12] & ~(NBPG - 1);
+               pmap_kenter_pa(bioscalltmpva, vmpa, VM_PROT_READ);
+               pmap_update(pmap_kernel());
+
+               memcpy(buf, (void *)(bioscalltmpva + (vmva & (NBPG - 1))),
+                      now);
+               buf += now;
+               todo -= now;
+               vmva += now;
+       }
+       return (len - todo);
+}
+
 int
 kvm86_bioscall(intno, tf)
        int intno;
diff -r 648dcc5b9921 -r 8f0aff8bb82c sys/arch/i386/include/kvm86.h
--- a/sys/arch/i386/include/kvm86.h     Wed Jul 10 19:08:43 2002 +0000
+++ b/sys/arch/i386/include/kvm86.h     Wed Jul 10 19:09:35 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kvm86.h,v 1.1 2002/07/07 12:56:34 drochner Exp $ */
+/* $NetBSD: kvm86.h,v 1.2 2002/07/10 19:09:36 drochner Exp $ */
 
 void kvm86_init(void);
 void kvm86_gpfault(struct trapframe *);
@@ -6,6 +6,7 @@
 
 void *kvm86_bios_addpage(u_int32_t);
 void kvm86_bios_delpage(u_int32_t, void *);
+size_t kvm86_bios_read(u_int32_t, char *, size_t);
 int kvm86_bioscall(int, struct trapframe *);
 
 /* for migration from bioscall() */



Home | Main Index | Thread Index | Old Index