Have working bus_peek(), and drivers use it.

This commit is contained in:
gwr 1994-12-13 18:37:22 +00:00
parent 10e46730cf
commit ee61fc716b

View File

@ -1,4 +1,4 @@
/* $NetBSD: autoconf.c,v 1.17 1994/12/12 18:59:56 gwr Exp $ */ /* $NetBSD: autoconf.c,v 1.18 1994/12/13 18:37:22 gwr Exp $ */
/* /*
* Copyright (c) 1994 Gordon W. Ross * Copyright (c) 1994 Gordon W. Ross
@ -49,13 +49,15 @@
#include <sys/dmap.h> #include <sys/dmap.h>
#include <sys/reboot.h> #include <sys/reboot.h>
#include <machine/autoconf.h> #include <vm/vm.h>
#include <machine/vmparam.h> #include <vm/vm_kern.h>
#include <machine/cpu.h> #include <vm/vm_map.h>
#include <machine/pte.h>
#include <machine/isr.h>
#include <setjmp.h> #include <machine/autoconf.h>
#include <machine/cpu.h>
#include <machine/isr.h>
#include <machine/pte.h>
#include <machine/pmap.h>
extern int soft1intr(); extern int soft1intr();
@ -207,69 +209,76 @@ bus_print(args, name)
/* /*
* Read addr with size len (1,2,4) into val. * Read addr with size len (1,2,4) into val.
* If this generates a bus error, return non-zero. * If this generates a bus error, return -1
* *
* Create a temporary mapping, * Create a temporary mapping,
* Prepare for bus-error with setjmp, * Try the access using fu{byte,sword,word}
* Try the access,
* Clean up temp. mapping * Clean up temp. mapping
*/ */
extern caddr_t vmempage; extern vm_offset_t tmp_vpages[];
int bus_peek(ca, off, len, val) extern int fubyte(), fusword(), fuword();
struct confargs *ca; int bus_peek(bustype, paddr, sz)
int off, len; int bustype, paddr, sz;
int *val;
{ {
#if 0 /* XXX - Not yet. */ int off, pte, rv, s;
int rv, x, ptype; vm_offset_t pgva;
vm_offset_t va, pa; caddr_t va;
switch (ca->ca_bustype) { off = paddr & PGOFSET;
paddr -= off;
pte = PA_PGNUM(paddr);
/*
* The temporary mapping has user-accessibility
* because fubyte et. al. do the access using
* an explicit switch to user space...
* (XXX -Should see if fubyte still needs that.)
*/
#define PG_PEEK PG_VALID | PG_WRITE | PG_NC
switch (bustype) {
case BUS_OBMEM: case BUS_OBMEM:
ptype = PMAP_NC; pte |= (PG_PEEK | PGT_OBMEM);
break; break;
case BUS_OBIO: case BUS_OBIO:
ptype = PMAP_NC | PMAP_OBIO; pte |= (PG_PEEK | PGT_OBIO);
break; break;
case BUS_VME16: case BUS_VME16:
ptype = PMAP_NC | PMAP_VME16; pte |= (PG_PEEK | PGT_VME_D16);
break; break;
case BUS_VME32: case BUS_VME32:
ptype = PMAP_NC | PMAP_VME32; pte |= (PG_PEEK | PGT_VME_D32);
break; break;
default: default:
return (-1); return (-1);
} }
#undef PG_PEEK
pa = ca->ca_paddr + off; s = splvm();
off = pa & PGOFSET;
pa -= off;
pa |= ptype;
va = vmempage + off;
pmap_enter(kernel_pmap, vmempage, pa, pgva = tmp_vpages[0];
VM_PROT_WRITE, TRUE); va = (caddr_t)pgva + off;
set_pte(pgva, pte);
/* /*
* OK, try the access using one of the assembly routines * OK, try the access using one of the assembly routines
* that will set pcb_onfault and catch any bus errors. * that will set pcb_onfault and catch any bus errors.
*/ */
switch (len) { switch (sz) {
case 1: case 1:
rv = peekb(va, &x); rv = fubyte(va);
break; break;
case 2: case 2:
rv = peeks(va, &x); rv = fusword(va);
break; break;
case 4: case 4:
rv = peekl(va, &x); rv = fuword(va);
break; break;
default: default:
rv = -1; rv = -1;
} }
pmap_remove(kernel_pmap, vmempage, vmempage + NBPG); set_pte(pgva, PG_INVAL);
splx(s);
#endif return rv;
return 0;
} }