diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2004-01-25 22:13:37 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2004-01-25 22:13:37 +0000 |
commit | 7dd72db1b66dd37627fce05b0b174a4ca34e2940 (patch) | |
tree | c42e570597aeea2e3124a1ed862a0d773236f5ed /sys/arch/mvmeppc/dev | |
parent | d610c9c5445dd472b76d2f1f195ad35a0759ef89 (diff) |
Put the msr fiddling in the CTXT macros, and unset PSL_IR and PSL_DR while
invoking the PPC1Bug. From drahn@ in a previous life.
Diffstat (limited to 'sys/arch/mvmeppc/dev')
-rw-r--r-- | sys/arch/mvmeppc/dev/bugio.c | 90 |
1 files changed, 38 insertions, 52 deletions
diff --git a/sys/arch/mvmeppc/dev/bugio.c b/sys/arch/mvmeppc/dev/bugio.c index 8cb2c12aabd..6e86d313d04 100644 --- a/sys/arch/mvmeppc/dev/bugio.c +++ b/sys/arch/mvmeppc/dev/bugio.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bugio.c,v 1.5 2004/01/25 21:41:26 miod Exp $ */ +/* $OpenBSD: bugio.c,v 1.6 2004/01/25 22:13:36 miod Exp $ */ /* * bug routines -- assumes that the necessary sections of memory @@ -20,21 +20,25 @@ int bugenvsz(void); register_t sprg0, sprg1, sprg2, sprg3; register_t bugsprg3; -#define BUGCTXT() \ +#define BUGCTXT(msr) \ do { \ + msr = ppc_mfmsr(); \ sprg0 = ppc_mfsprg0(); \ sprg1 = ppc_mfsprg1(); \ sprg2 = ppc_mfsprg2(); \ sprg3 = ppc_mfsprg3(); \ ppc_mtsprg3(bugsprg3); \ + ppc_mtmsr(((msr | PSL_IP) & ~(PSL_EE | PSL_IR | PSL_DR))); \ } while (0) -#define OSCTXT() \ +#define OSCTXT(msr) \ do { \ + bugsprg3 = ppc_mfsprg3(); \ ppc_mtsprg0(sprg0); \ ppc_mtsprg1(sprg1); \ ppc_mtsprg2(sprg2); \ ppc_mtsprg3(sprg3); \ + ppc_mtmsr(msr); \ } while (0) /* Invoke the BUG */ @@ -54,14 +58,12 @@ void mvmeprom_brdid(id) struct mvmeprom_brdid *id; { - unsigned long omsr = ppc_mfmsr(); + unsigned long msr; - BUGCTXT(); - ppc_mtmsr(((omsr | PSL_IP) & ~PSL_EE)); + BUGCTXT(msr); MVMEPROM_CALL(MVMEPROM_BRD_ID); asm volatile ("mr %0, 3": "=r" (id):); - OSCTXT(); - ppc_mtmsr(omsr); + OSCTXT(msr); } /* returns 0 if no characters ready to read */ @@ -69,14 +71,12 @@ int mvmeprom_getchar() { int ret; - unsigned long omsr = ppc_mfmsr(); + unsigned long msr; - BUGCTXT(); - ppc_mtmsr(((omsr | PSL_IP) & ~PSL_EE)); + BUGCTXT(msr); MVMEPROM_CALL(MVMEPROM_INCHR); asm volatile ("mr %0, 3" : "=r" (ret)); - OSCTXT(); - ppc_mtmsr(omsr); + OSCTXT(msr); return ret; } @@ -85,14 +85,12 @@ int mvmeprom_instat() { int ret; - unsigned long omsr = ppc_mfmsr(); + unsigned long msr; - BUGCTXT(); - ppc_mtmsr(((omsr | PSL_IP) & ~PSL_EE)); + BUGCTXT(msr); MVMEPROM_CALL(MVMEPROM_INSTAT); asm volatile ("mr %0, 3" : "=r" (ret)); - OSCTXT(); - ppc_mtmsr(omsr); + OSCTXT(msr); return (!(ret & 0x4)); } @@ -100,57 +98,49 @@ void mvmeprom_outln(start, end) char *start, *end; { - unsigned long omsr = ppc_mfmsr(); + unsigned long msr; - BUGCTXT(); - ppc_mtmsr(((omsr | PSL_IP) & ~PSL_EE)); + BUGCTXT(msr); asm volatile ("mr 3, %0": : "r" (start)); asm volatile ("mr 4, %0": : "r" (end)); MVMEPROM_CALL(MVMEPROM_OUTLN); - OSCTXT(); - ppc_mtmsr(omsr); + OSCTXT(msr); } void mvmeprom_outstr(start, end) char *start, *end; { - unsigned long omsr = ppc_mfmsr(); + unsigned long msr; - BUGCTXT(); - ppc_mtmsr(((omsr | PSL_IP) & ~PSL_EE)); + BUGCTXT(msr); asm volatile ("mr 3, %0": : "r" (start)); asm volatile ("mr 4, %0": : "r" (end)); MVMEPROM_CALL(MVMEPROM_OUTSTR); - OSCTXT(); - ppc_mtmsr(omsr); + OSCTXT(msr); } void mvmeprom_outchar(c) int c; { - unsigned long omsr = ppc_mfmsr(); + unsigned long msr; - BUGCTXT(); - ppc_mtmsr(((omsr | PSL_IP) & ~PSL_EE)); + BUGCTXT(msr); asm volatile ("mr 3, %0" :: "r" (c)); MVMEPROM_CALL(MVMEPROM_OUTCHR); - OSCTXT(); - ppc_mtmsr(omsr); + OSCTXT(msr); } /* BUG - return to bug routine */ void mvmeprom_return() { - unsigned long omsr = ppc_mfmsr(); + unsigned long msr; - BUGCTXT(); - ppc_mtmsr(((omsr | PSL_IP) & ~PSL_EE)); + BUGCTXT(msr); MVMEPROM_CALL(MVMEPROM_RETURN); - OSCTXT(); - ppc_mtmsr(omsr); + OSCTXT(msr); /*NOTREACHED*/ } @@ -159,12 +149,12 @@ void mvmeprom_rtc_rd(ptime) struct mvmeprom_time *ptime; { - unsigned long omsr = ppc_mfmsr(); - ppc_mtmsr(((omsr | PSL_IP) & ~PSL_EE)); + unsigned long msr; + + BUGCTXT(msr); asm volatile ("mr 3, %0": : "r" (ptime)); MVMEPROM_CALL(MVMEPROM_RTC_RD); - OSCTXT(); - ppc_mtmsr(omsr); + OSCTXT(msr); } int @@ -173,17 +163,15 @@ bugenvsz(void) register int ret; char tmp[1]; void *ptr = tmp; - unsigned long omsr = ppc_mfmsr(); + unsigned long msr; - BUGCTXT(); - ppc_mtmsr(((omsr | PSL_IP) & ~PSL_EE)); + BUGCTXT(msr); asm volatile ("mr 3, %0": : "r" (ptr)); asm volatile ("li 5, 0x1"); asm volatile ("li 5, 0x0"); /* get size */ MVMEPROM_CALL(MVMEPROM_ENVIRON); asm volatile ("mr %0, 3" : "=r" (ret)); - OSCTXT(); - ppc_mtmsr(omsr); + OSCTXT(msr); return(ret); } @@ -245,7 +233,7 @@ mvmeprom_envrd(void) char *ptr, *dptr, *ptr_end; int env_size = 0; int pkt_typ, pkt_len; - unsigned long omsr = ppc_mfmsr(); + unsigned long msr; env_size = bugenvsz(); bzero(&bugenviron, sizeof(struct bugenviron)); @@ -254,15 +242,13 @@ mvmeprom_envrd(void) if (ptr != NULL) { - ppc_mtmsr(((omsr | PSL_IP) & ~PSL_EE)); - BUGCTXT(); + BUGCTXT(msr); asm volatile ("mr 3, %0": : "r" (ptr)); asm volatile ("mr 4, %0": : "r" (env_size)); asm volatile ("li 5, 0x2"); MVMEPROM_CALL(MVMEPROM_ENVIRON); asm volatile ("mr %0, 3" : "=r" (ret)); - OSCTXT(); - ppc_mtmsr(omsr); + OSCTXT(msr); if (ret) return NULL; |