diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2004-01-24 21:10:34 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2004-01-24 21:10:34 +0000 |
commit | 20f5ee26366d5d03115112636b80a685a25a30c0 (patch) | |
tree | e6d2d6394fd7430af0187862146d01fbc9187700 /sys/arch/mvmeppc/dev | |
parent | cd40f9b9d69d27c8a91aebf09941e82b60e28015 (diff) |
Preserve SPRG0-SPRG3 around BUG calls, as required in the PPC1Bug UM;
reminded by drahn@, thanks!
Diffstat (limited to 'sys/arch/mvmeppc/dev')
-rw-r--r-- | sys/arch/mvmeppc/dev/bugio.c | 78 |
1 files changed, 68 insertions, 10 deletions
diff --git a/sys/arch/mvmeppc/dev/bugio.c b/sys/arch/mvmeppc/dev/bugio.c index 7986e25dba7..d3ee34ca413 100644 --- a/sys/arch/mvmeppc/dev/bugio.c +++ b/sys/arch/mvmeppc/dev/bugio.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bugio.c,v 1.3 2002/06/08 15:48:01 miod Exp $ */ +/* $OpenBSD: bugio.c,v 1.4 2004/01/24 21:10:29 miod Exp $ */ /* * bug routines -- assumes that the necessary sections of memory @@ -13,16 +13,54 @@ int bugenvsz(void); +/* + * BUG register preserving + */ + +register_t sprg0, sprg1, sprg2, sprg3; +register_t bugsprg3; + +#define BUGCTXT() \ + do { \ + sprg0 = ppc_mfsprg0(); \ + sprg1 = ppc_mfsprg1(); \ + sprg2 = ppc_mfsprg2(); \ + sprg3 = ppc_mfsprg3(); \ + ppc_mtsprg3(bugsprg3); \ + } while (0) + +#define OSCTXT() \ + do { \ + ppc_mtsprg0(sprg0); \ + ppc_mtsprg1(sprg1); \ + ppc_mtsprg2(sprg2); \ + ppc_mtsprg3(sprg3); \ + } while (0) + +/* Invoke the BUG */ +#define MVMEPROM_CALL(x) \ + __asm__ __volatile__ ( __CONCAT("addi %r10,%r0,",__STRING(x)) ); \ + __asm__ __volatile__ ("sc"); + +void +buginit() +{ + bugsprg3 = ppc_mfsprg3(); +} + + /* BUG - query board routines */ void mvmeprom_brdid(id) struct mvmeprom_brdid *id; { unsigned long omsr = ppc_get_msr(); - ppc_set_msr(((omsr | PSL_IP) &~ PSL_EE)); + BUGCTXT(); + ppc_set_msr(((omsr | PSL_IP) &~ PSL_EE)); MVMEPROM_CALL(MVMEPROM_BRD_ID); asm volatile ("mr %0, 3": "=r" (id):); + OSCTXT(); ppc_set_msr(omsr); } @@ -32,10 +70,12 @@ mvmeprom_getchar() { int ret; unsigned long omsr = ppc_get_msr(); - ppc_set_msr(((omsr | PSL_IP) &~ PSL_EE)); + BUGCTXT(); + ppc_set_msr(((omsr | PSL_IP) &~ PSL_EE)); MVMEPROM_CALL(MVMEPROM_INCHR); asm volatile ("mr %0, 3" : "=r" (ret)); + OSCTXT(); ppc_set_msr(omsr); return ret; } @@ -46,10 +86,12 @@ mvmeprom_instat() { int ret; unsigned long omsr = ppc_get_msr(); - ppc_set_msr(((omsr | PSL_IP) &~ PSL_EE)); + BUGCTXT(); + ppc_set_msr(((omsr | PSL_IP) &~ PSL_EE)); MVMEPROM_CALL(MVMEPROM_INSTAT); asm volatile ("mr %0, 3" : "=r" (ret)); + OSCTXT(); ppc_set_msr(omsr); return (!(ret & 0x4)); } @@ -59,10 +101,13 @@ mvmeprom_outln(start, end) char *start, *end; { unsigned long omsr = ppc_get_msr(); + + BUGCTXT(); ppc_set_msr(((omsr | PSL_IP) &~ PSL_EE)); asm volatile ("mr 3, %0": : "r" (start)); asm volatile ("mr 4, %0": : "r" (end)); MVMEPROM_CALL(MVMEPROM_OUTLN); + OSCTXT(); ppc_set_msr(omsr); } @@ -71,10 +116,13 @@ mvmeprom_outstr(start, end) char *start, *end; { unsigned long omsr = ppc_get_msr(); + + BUGCTXT(); ppc_set_msr(((omsr | PSL_IP) &~ PSL_EE)); asm volatile ("mr 3, %0": : "r" (start)); asm volatile ("mr 4, %0": : "r" (end)); MVMEPROM_CALL(MVMEPROM_OUTSTR); + OSCTXT(); ppc_set_msr(omsr); } @@ -83,9 +131,12 @@ mvmeprom_outchar(c) int c; { unsigned long omsr = ppc_get_msr(); + + BUGCTXT(); ppc_set_msr(((omsr | PSL_IP) &~ PSL_EE)); asm volatile ("mr 3, %0" :: "r" (c)); MVMEPROM_CALL(MVMEPROM_OUTCHR); + OSCTXT(); ppc_set_msr(omsr); } @@ -94,8 +145,11 @@ void mvmeprom_return() { unsigned long omsr = ppc_get_msr(); + + BUGCTXT(); ppc_set_msr(((omsr | PSL_IP) &~ PSL_EE)); MVMEPROM_CALL(MVMEPROM_RETURN); + OSCTXT(); ppc_set_msr(omsr); /*NOTREACHED*/ } @@ -109,6 +163,7 @@ mvmeprom_rtc_rd(ptime) ppc_set_msr(((omsr | PSL_IP) &~ PSL_EE)); asm volatile ("mr 3, %0": : "r" (ptime)); MVMEPROM_CALL(MVMEPROM_RTC_RD); + OSCTXT(); ppc_set_msr(omsr); } @@ -119,13 +174,15 @@ bugenvsz(void) char tmp[1]; void *ptr = tmp; unsigned long omsr = ppc_get_msr(); + + BUGCTXT(); ppc_set_msr(((omsr | PSL_IP) &~ PSL_EE)); - 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_set_msr(omsr); return(ret); @@ -189,7 +246,6 @@ mvmeprom_envrd(void) int env_size = 0; int pkt_typ, pkt_len; unsigned long omsr = ppc_get_msr(); - ppc_set_msr(((omsr | PSL_IP) &~ PSL_EE)); env_size = bugenvsz(); bzero(&bugenviron, sizeof(struct bugenviron)); @@ -198,16 +254,19 @@ mvmeprom_envrd(void) if (ptr != NULL) { + ppc_set_msr(((omsr | PSL_IP) &~ PSL_EE)); + BUGCTXT(); 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_set_msr(omsr); - if (ret) { /* scram if we have an error */ - ppc_set_msr(omsr); + if (ret) return NULL; - } + ptr_end = ptr + env_size; while (ptr <= ptr_end) { pkt_typ = *ptr++; @@ -258,6 +317,5 @@ mvmeprom_envrd(void) ptr += pkt_len; } } - ppc_set_msr(omsr); return NULL; } |