diff --git a/sys/arch/powerpc/include/oea/bat.h b/sys/arch/powerpc/include/oea/bat.h index 08520504d300..d6f819e1803b 100644 --- a/sys/arch/powerpc/include/oea/bat.h +++ b/sys/arch/powerpc/include/oea/bat.h @@ -1,4 +1,4 @@ -/* $NetBSD: bat.h,v 1.3 2003/02/05 07:35:31 matt Exp $ */ +/* $NetBSD: bat.h,v 1.4 2003/02/06 23:02:33 matt Exp $ */ /*- * Copyright (c) 1999 The NetBSD Foundation, Inc. @@ -180,6 +180,7 @@ struct bat { #ifdef _KERNEL void oea_batinit(paddr_t, ...); void oea_iobat_add(paddr_t, register_t); +void oea_iobat_remove(paddr_t); extern struct bat battable[]; #endif diff --git a/sys/arch/powerpc/oea/oea_machdep.c b/sys/arch/powerpc/oea/oea_machdep.c index 7e09749ce525..d44390c30bc9 100644 --- a/sys/arch/powerpc/oea/oea_machdep.c +++ b/sys/arch/powerpc/oea/oea_machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: oea_machdep.c,v 1.2 2003/02/05 07:05:20 matt Exp $ */ +/* $NetBSD: oea_machdep.c,v 1.3 2003/02/06 23:02:34 matt Exp $ */ /* * Copyright (C) 2002 Matt Thomas @@ -151,7 +151,7 @@ oea_init(void (*handler)(void)) /* * Set up trap vectors. Don't assume vectors are on 0x100. */ - for (exc = EXC_RST; exc <= EXC_LAST; exc += 0x100) { + for (exc = 0; exc <= EXC_LAST; exc += 0x100) { switch (exc) { default: size = (size_t)&trapsize; @@ -373,6 +373,48 @@ oea_iobat_add(paddr_t pa, register_t len) } } +void +oea_iobat_remove(paddr_t pa) +{ + register_t batu; + int i, n; + + n = pa >> ADDR_SR_SHFT; + if (!BAT_VA_MATCH_P(battable[n].batu, pa) || + !BAT_VALID_P(battable[n].batu, PSL_PR)) + return; + battable[n].batl = 0; + battable[n].batu = 0; +#define BAT_RESET(n) \ + __asm __volatile("mtdbatu %0,%1; mtdbatl %0,%1" :: "n"(n), "r"(0)) +#define BATU_GET(n, r) __asm __volatile("mfdbatu %0,%1" : "=r"(r) : "n"(n)) + + for (i=1 ; i<4 ; i++) { + switch (i) { + case 1: + BATU_GET(1, batu); + if (BAT_VA_MATCH_P(batu, pa) && + BAT_VALID_P(batu, PSL_PR)) + BAT_RESET(1); + break; + case 2: + BATU_GET(2, batu); + if (BAT_VA_MATCH_P(batu, pa) && + BAT_VALID_P(batu, PSL_PR)) + BAT_RESET(2); + break; + case 3: + BATU_GET(3, batu); + if (BAT_VA_MATCH_P(batu, pa) && + BAT_VALID_P(batu, PSL_PR)) + BAT_RESET(3); + break; + default: + break; + } + } +} + void oea_batinit(paddr_t pa, ...) {