diff options
author | Martin Reindl <martin@cvs.openbsd.org> | 2005-02-20 18:08:09 +0000 |
---|---|---|
committer | Martin Reindl <martin@cvs.openbsd.org> | 2005-02-20 18:08:09 +0000 |
commit | a573ad2130428ac54ef19819ad8ca7da7255b96f (patch) | |
tree | 15667109e1e241be782ea2dd98c0464a9812250e | |
parent | 49c6e2d42da84e1c0204cfd80a45b8d0180be41a (diff) |
overhaul macrom code from NetBSD:
- simplify the asm constraints in mrg_aline_super()
- generate a SIGILL for user-mode A-line traps
- cleanup, KNF, whitespace nitpicking and minor other updates
ok miod@
-rw-r--r-- | sys/arch/mac68k/mac68k/macrom.c | 1032 | ||||
-rw-r--r-- | sys/arch/mac68k/mac68k/macrom.h | 91 | ||||
-rw-r--r-- | sys/arch/mac68k/mac68k/macromasm.s | 15 |
3 files changed, 477 insertions, 661 deletions
diff --git a/sys/arch/mac68k/mac68k/macrom.c b/sys/arch/mac68k/mac68k/macrom.c index fd299e0b70e..d758479ae79 100644 --- a/sys/arch/mac68k/mac68k/macrom.c +++ b/sys/arch/mac68k/mac68k/macrom.c @@ -1,5 +1,5 @@ -/* $OpenBSD: macrom.c,v 1.26 2004/11/26 21:21:28 miod Exp $ */ -/* $NetBSD: macrom.c,v 1.31 1997/03/01 17:20:34 scottr Exp $ */ +/* $OpenBSD: macrom.c,v 1.27 2005/02/20 18:08:08 martin Exp $ */ +/* $NetBSD: macrom.c,v 1.47 2000/11/15 07:15:36 scottr Exp $ */ /*- * Copyright (C) 1994 Bradley A. Grantham @@ -48,19 +48,20 @@ #include <sys/param.h> #include <sys/systm.h> -#include <sys/queue.h> #include <sys/lock.h> +#include <sys/malloc.h> +#include <sys/queue.h> #include <uvm/uvm_extern.h> -#include <machine/viareg.h> -#include "macrom.h" -#include <sys/malloc.h> #include <machine/cpu.h> - #include <machine/frame.h> +#include <machine/viareg.h> + +#include <arch/mac68k/mac68k/macrom.h> +#include <arch/mac68k/dev/adbvar.h> -/* trap modifiers (put it macrom.h) */ + /* trap modifiers (put it macrom.h) */ #define TRAP_TOOLBOX(a) ((a) & 0x800) #define TRAP_PASSA0(a) ((a) & 0x100) #define TRAP_NUM(a) (TRAP_TOOLBOX(a) ? (a) & 0x3ff : (a) & 0xff) @@ -68,7 +69,7 @@ #define TRAP_CLEAR(a) ((a) & 0x200) -/* Mac Rom Glue global variables */ + /* Mac Rom Glue global variables */ /* * ADB Storage. Is 512 bytes enough? Too much? */ @@ -104,24 +105,29 @@ u_int32_t mrg_AVInitEgretJT[] = { }; caddr_t mrg_romadbintr = (caddr_t)0; /* ROM ADB interrupt */ -caddr_t mrg_rompmintr = 0; /* ROM PM (?) interrupt */ -char *mrg_romident = NULL; /* ident string for ROMs */ -caddr_t mrg_ADBAlternateInit = 0; -caddr_t mrg_InitEgret = 0; -caddr_t mrg_InitPM = 0; +caddr_t mrg_rompmintr = 0; /* ROM PM (?) interrupt */ +char *mrg_romident = NULL; /* ident string for ROMs */ +caddr_t mrg_ADBAlternateInit = 0; +caddr_t mrg_InitEgret = 0; caddr_t mrg_ADBIntrPtr = (caddr_t)0x0; /* ADB interrupt taken from MacOS vector table*/ -caddr_t ROMResourceMap = 0; +caddr_t ROMResourceMap = 0; extern romvec_t *mrg_MacOSROMVectors; #if defined(MRG_TEST) || defined(MRG_DEBUG) -caddr_t ResHndls[] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; +caddr_t ResHndls[] = { + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0 +}; #else -caddr_t ResHndls[]={0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; +caddr_t ResHndls[] = { + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0 +}; #endif -void setup_egret(void); -void mrg_execute_deferred(void); -void mrg_DTInstall(void); - /* * Last straw functions; we didn't set them up, so freak out! * When someone sees these called, we can finally go back and @@ -132,35 +138,39 @@ int mrg_Delay() { #define TICK_DURATION 16625 - u_int32_t ticks; - __asm volatile (" movl a0, %0" /* get arguments */ - : "=g" (ticks) - : - : "a0" ); + __asm __volatile ("movl a0, %0" /* get arguments */ + : "=g" (ticks) + : + : "a0"); #if defined(MRG_DEBUG) printf("mrg: mrg_Delay(%d) = %d ms\n", ticks, ticks * 60); #endif delay(ticks * TICK_DURATION); - return(ticks); /* The number of ticks since startup should be - * returned here. Until someone finds a need for - * this, we just return the requested number - * of ticks */ + + /* + * The number of ticks since startup should be + * returned here. Until someone finds a need for + * this, we just return the requested number + * of ticks + */ + return (ticks); } /* * Handle the Deferred Task manager here + * */ -static caddr_t mrg_DTList = NULL; +static caddr_t mrg_DTList = NULL; void -mrg_DTInstall(void) +mrg_DTInstall() { caddr_t ptr, prev; - __asm(" movl a0, %0" : "=g" (ptr) ); + __asm __volatile ("movl a0, %0" : "=g" (ptr)); (caddr_t *)prev = &mrg_DTList; while (*prev != NULL) @@ -169,11 +179,11 @@ mrg_DTInstall(void) *(caddr_t *)prev = ptr; setsoftdtmgr(); - __asm(" clrl d0" : : : "d0"); + __asm __volatile ("clrl d0" : : : "d0"); } void -mrg_execute_deferred(void) +mrg_execute_deferred() { caddr_t ptr; int s; @@ -184,12 +194,13 @@ mrg_execute_deferred(void) mrg_DTList = *(caddr_t *)ptr; splx(s); - __asm(" moveml a0-a6/d1-d7,sp@- + __asm __volatile (" + moveml a0-a6/d1-d7,sp@- movl %0, a0 movl a0@(8), a2 movl a0@(12), a1 jsr a2@ - moveml sp@+,a0-a6/d1-d7" : : "g" (ptr) ); + moveml sp@+,a0-a6/d1-d7" : : "g" (ptr)); } } @@ -201,66 +212,59 @@ mrg_VBLQueue() #define vblAddr 6 #define vblCount 10 #define vblPhase 12 - caddr_t vbltask; caddr_t last_vbltask; - last_vbltask = (caddr_t) &VBLQueue_head; + last_vbltask = (caddr_t)&VBLQueue_head; vbltask = VBLQueue_head; - while (0 != vbltask) - { - if ( 0 != *((u_int16_t *)(vbltask + vblPhase)) ) - { - *((u_int16_t *)(vbltask + vblPhase)) -= 1; - } else - { - if ( 0 != *((u_int16_t *)(vbltask + vblCount)) ) - { - *((u_int16_t *)(vbltask + vblCount)) -= 1; - } else - { + while (0 != vbltask) { + if (0 != *((u_int16_t *)(vbltask + vblPhase))) + *((u_int16_t *)(vbltask + vblPhase)) -= 1; + else if (0 != *((u_int16_t *)(vbltask + vblCount))) + *((u_int16_t *)(vbltask + vblCount)) -= 1; + else { #if defined(MRG_DEBUG) -printf("mrg: mrg_VBLQueue: calling VBL task at 0x%x with VBLTask block at %p\n", - *((u_int32_t *)(vbltask + vblAddr)), vbltask); -#endif - __asm(" movml #0xfffe, sp@- - movl %0, a0 - movl %1, a1 - jbsr a1@ - movml sp@+, #0x7fff" - : - : "g" (vbltask), "g" (*((caddr_t)(vbltask + vblAddr))) - : "a0", "a1"); + printf("mrg: mrg_VBLQueue: calling VBL task at 0x%x with VBLTask block at %p\n", + *((u_int32_t *)(vbltask + vblAddr)), vbltask); +#endif + __asm __volatile(" + movml #0xfffe, sp@- + movl %0, a0 + movl %1, a1 + jbsr a1@ + movml sp@+, #0x7fff" + : : "g" (vbltask), + "g" (*((caddr_t)(vbltask + vblAddr))) + : "a0", "a1"); #if defined(MRG_DEBUG) - printf("mrg: mrg_VBLQueue: back from VBL task\n"); -#endif - if ( 0 == *((u_int16_t *)(vbltask + vblCount)) ) - { + printf("mrg: mrg_VBLQueue: back from VBL task\n"); +#endif + if (0 == *((u_int16_t *)(vbltask + vblCount))) { #if defined(MRG_DEBUG) - printf("mrg: mrg_VBLQueue: removing VBLTask block at %p\n", - vbltask); -#endif - *((u_int32_t *)(last_vbltask + qLink)) = *((u_int32_t *)(vbltask + qLink)); - /* can't free memory from VBLTask block as - * we don't know where it came from */ - if (vbltask == VBLQueue_tail) - { /* last task of do{}while */ - VBLQueue_tail = last_vbltask; + printf("mrg: mrg_VBLQueue: removing VBLTask block at %p\n", + vbltask); +#endif + *((u_int32_t *)(last_vbltask + qLink)) = + *((u_int32_t *)(vbltask + qLink)); + /* + * can't free memory from VBLTask block as + * we don't know where it came from + */ + if (vbltask == VBLQueue_tail) + VBLQueue_tail = last_vbltask; } - } } - } - last_vbltask = vbltask; - vbltask = (caddr_t) *((u_int32_t *)(vbltask + qLink)); - } /* while */ + last_vbltask = vbltask; + vbltask = (caddr_t) *((u_int32_t *)(vbltask + qLink)); + } } void mrg_init_stub_1() { - __asm("movml #0xffff, sp@-"); + __asm __volatile ("movml #0xffff, sp@-"); printf("mrg: hit mrg_init_stub_1\n"); - __asm("movml sp@+, #0xffff"); + __asm __volatile ("movml sp@+, #0xffff"); } void @@ -272,82 +276,83 @@ mrg_init_stub_2() short Count_Resources(u_int32_t rsrc_type) { - rsrc_t *rsrc = (rsrc_t *)ROMResourceMap; - short count = 0; + rsrc_t *rsrc = (rsrc_t *)ROMResourceMap; + short count = 0; #if defined(MRG_DEBUG) - printf("Count_Resources looking for 0x%08lx at 0x%08lx\n", - (long)rsrc_type, (long)rsrc); + printf("Count_Resources looking for 0x%08lx at 0x%08lx\n", + (long)rsrc_type, (long)rsrc); #endif -/* - * Return a Count of all the ROM Resouces of the requested type. - */ - if (ROMResourceMap == 0) - panic("Oops! Need ROM Resource Map ListHead address!"); + /* + * Return a Count of all the ROM Resouces of the requested type. + */ + if (ROMResourceMap == 0) + panic("Oops! Need ROM Resource Map ListHead address!"); - while (rsrc != 0) { + while (rsrc != 0) { #if defined(MRG_DEBUG) - if (rsrc_type == 0) - printf("0x%08lx: %04x %04x %04x %04x %08x %08x %08x %04x\n", - (long)rsrc, rsrc->unknown[0], rsrc->unknown[1], - rsrc->unknown[2], rsrc->unknown[3], rsrc->next, - rsrc->body, rsrc->name, rsrc->index); + if (rsrc_type == 0) + printf("0x%08lx: %04x %04x %04x %04x %08x %08x %08x %04x\n", + (long)rsrc, rsrc->unknown[0], rsrc->unknown[1], + rsrc->unknown[2], rsrc->unknown[3], rsrc->next, + rsrc->body, rsrc->name, rsrc->index); #endif - if (rsrc_type == 0 || (rsrc_type == rsrc->name)) - count++; - rsrc = rsrc->next == 0 ? 0 : (rsrc_t *)(rsrc->next + ROMBase); - } + if (rsrc_type == 0 || (rsrc_type == rsrc->name)) + count++; + rsrc = rsrc->next == 0 ? 0 : (rsrc_t *)(rsrc->next + ROMBase); + } + #if defined(MRG_DEBUG) - printf("Count_Resources found %d\n", count); + printf("Count_Resources found %d\n", count); #endif - return count; + return count; } caddr_t * Get_Ind_Resource(u_int32_t rsrc_type, u_int16_t rsrc_ind) { - rsrc_t *rsrc = (rsrc_t *)ROMResourceMap; - short i = 0; - -/* - * This routine return the "Handle" to a ROM Resource. Since few - * ROM Resources are called for in OpenBSD we keep a small table - * for the Handles we return. (Can't reuse the Handle without - * defeating the purpose for a Handle in the first place!) If - * we get more requests than we have space for, we panic. - */ + rsrc_t *rsrc = (rsrc_t *)ROMResourceMap; + short i = 0; - if (ROMResourceMap == 0) - panic("Oops! Need ROM Resource Map ListHead address!"); - - while (rsrc != 0) { - if (rsrc_type == rsrc->name) { - rsrc_ind--; - if (rsrc_ind == 0) { - for (i = 0;i < sizeof(ResHndls)/sizeof(caddr_t);i++) - if ((ResHndls[i] == 0) || - (ResHndls[i] == (caddr_t)(rsrc->next + ROMBase))) { - ResHndls[i] = (caddr_t)(rsrc->body + ROMBase); - return (caddr_t *)&ResHndls[i]; - } - panic("ResHndls table too small!"); - } - } - rsrc = rsrc->next == 0 ? 0 : (rsrc_t *)(rsrc->next + ROMBase); - } - return (caddr_t *) 0; + /* + * This routine return the "Handle" to a ROM Resource. Since few + * ROM Resources are called for in OpenBSD we keep a small table + * for the Handles we return. (Can't reuse the Handle without + * defeating the purpose for a Handle in the first place!) If + * we get more requests than we have space for, we panic. + */ + if (ROMResourceMap == 0) + panic("Oops! Need ROM Resource Map ListHead address!"); + + while (rsrc != 0) { + if (rsrc_type == rsrc->name) { + rsrc_ind--; + if (rsrc_ind == 0) { + for (i = 0; + i < sizeof(ResHndls) / sizeof(caddr_t); i++) + if ((ResHndls[i] == 0) || + (ResHndls[i] == (caddr_t)(rsrc->next + ROMBase))) { + ResHndls[i] = (caddr_t)(rsrc->body + ROMBase); + return (caddr_t *)&ResHndls[i]; + } + panic("ResHndls table too small!"); + } + } + rsrc = rsrc->next == 0 ? 0 : (rsrc_t *)(rsrc->next + ROMBase); + } + return (caddr_t *)0; } void mrg_FixDiv() { - panic("Oops! Need ROM address of _FixDiv for this system!"); + panic("Oops! Need ROM address of _FixDiv for this system!"); } void mrg_FixMul() { - panic("Oops! Need ROM address of _FixMul for this system!"); + panic("Oops! Need ROM address of _FixMul for this system!"); } void @@ -362,7 +367,7 @@ void mrg_lvl1dtpanic() /* Lvl1DT stopper */ { printf("Agh! I was called from Lvl1DT!!!\n"); -#if DDB +#ifdef DDB Debugger(); #endif } @@ -391,22 +396,23 @@ mrg_jkybdtaskpanic() /* JKybdTask stopper */ panic("Agh! Called JKybdTask!"); } -#ifdef MRG_ADB /* mrg_adbintr and mrg_pmintr are not defined - * here if we are using the MRG_ADB method to - * access the ADB/PRAM/RTC. They are - * defined in adb_direct.c */ +#ifdef MRG_ADB +/* + * mrg_adbintr() and mrg_pmintr() are defined in adb_direct.c if we + * not using the MRG method of accessing the ADB/PRAM/RTC. + */ + int mrg_adbintr() /* Call ROM ADB Interrupt */ { - if(mrg_romadbintr != NULL) - { + if (mrg_romadbintr != NULL) { #if defined(MRG_TRACE) tron(); #endif /* Gotta load a1 with VIA address. */ /* ADB int expects it from Mac intr routine. */ - __asm(" + __asm __volatile (" movml #0xffff, sp@- movl %0, a0 movl _VIA, a1 @@ -421,21 +427,20 @@ mrg_adbintr() /* Call ROM ADB Interrupt */ #endif } - return(1); + return (1); } -long +int mrg_pmintr() /* Call ROM PM Interrupt */ { - if(mrg_rompmintr != NULL) - { + if (mrg_rompmintr != NULL) { #if defined(MRG_TRACE) tron(); #endif /* Gotta load a1 with VIA address. */ /* ADB int expects it from Mac intr routine. */ - __asm(" + __asm __volatile (" movml #0xffff, sp@- movl %0, a0 movl _VIA, a1 @@ -449,9 +454,9 @@ mrg_pmintr() /* Call ROM PM Interrupt */ troff(); #endif } - return(1); + return (1); } -#endif /* ifdef MRG_ADB */ +#endif /* MRG_ADB */ void @@ -465,7 +470,7 @@ int myowntrap() { printf("Oooo! My Own Trap Routine!\n"); - return(50); + return (50); } int @@ -473,10 +478,10 @@ mrg_NewPtr() { int result = noErr; u_int numbytes; +/* u_int32_t trapword; */ caddr_t ptr; - __asm(" movw d0, %0" - : "=g" (numbytes) : : "d0"); + __asm __volatile ("movl d0, %0" : "=g" (numbytes) : : "d0"); #if defined(MRG_SHOWTRAPS) printf("mrg: NewPtr(%d bytes, ? clear, ? sys)", numbytes); @@ -487,22 +492,22 @@ mrg_NewPtr() /* We ignore "Sys;" where else would it come from? */ /* plus, (I think), malloc clears block for us */ - if(ptr == NULL){ + if (ptr == NULL) { result = memFullErr; #if defined(MRG_SHOWTRAPS) printf(" failed.\n"); #endif }else{ #if defined(MRG_SHOWTRAPS) - printf(" succeeded = %p.\n", ptr); + printf(" succeded = %p.\n", ptr); #endif *(u_int32_t *)ptr = numbytes; ptr += 4; bzero(ptr, numbytes); /* NewPtr, Clear ! */ } - __asm(" movl %0, a0" : : "g" (ptr) : "a0"); - return(result); + __asm __volatile("movl %0, a0" : : "g" (ptr) : "a0"); + return (result); } int @@ -511,19 +516,18 @@ mrg_DisposPtr() int result = noErr; caddr_t ptr; - __asm(" movl a0, %0" : "=g" (ptr) : : "a0"); + __asm __volatile("movl a0, %0" : "=g" (ptr) : : "a0"); #if defined(MRG_SHOWTRAPS) printf("mrg: DisposPtr(%p)\n", ptr); #endif - if(ptr == 0){ + if (ptr == 0) result = memWZErr; - }else{ + else free(ptr - 4, M_DEVBUF); - } - return(result); + return (result); } int @@ -531,16 +535,16 @@ mrg_GetPtrSize() { caddr_t ptr; - __asm(" movl a0, %0" : "=g" (ptr) : : "a0"); + __asm __volatile("movl a0, %0" : "=g" (ptr) : : "a0"); #if defined(MRG_SHOWTRAPS) printf("mrg: GetPtrSize(%p)\n", ptr); #endif - if(ptr == 0){ - return(memWZErr); - }else - return(*(int *)(ptr - 4)); + if (ptr == 0) + return (memWZErr); + else + return (*(int *)(ptr - 4)); } int @@ -549,7 +553,8 @@ mrg_SetPtrSize() caddr_t ptr; int newbytes; - __asm(" movl a0, %0 + __asm __volatile(" + movl a0, %0 movl d0, %1" : "=g" (ptr), "=g" (newbytes) : : "d0", "a0"); @@ -557,7 +562,7 @@ mrg_SetPtrSize() printf("mrg: SetPtrSize(%p, %d) failed\n", ptr, newbytes); #endif - return(memFullErr); /* How would I handle this, anyway? */ + return (memFullErr); /* How would I handle this, anyway? */ } int @@ -574,45 +579,29 @@ mrg_StripAddress() int mrg_SetTrapAddress() { - extern caddr_t mrg_OStraps[]; - caddr_t ptr; - int trap_num; + extern caddr_t mrg_OStraps[]; + caddr_t ptr; + int trap_num; - __asm(" movl a0, %0 - movl d0, %1" - : "=g" (ptr), "=g" (trap_num) : : "d0", "a0"); + __asm __volatile(" + movl a0, %0 + movl d0, %1" + : "=g" (ptr), "=g" (trap_num) : : "d0", "a0"); #if defined(MRG_DEBUG) - printf("mrg: trap 0x%x set to 0x%lx\n", trap_num, (long)ptr); + printf("mrg: trap 0x%x set to 0x%lx\n", trap_num, (long)ptr); #endif - mrg_OStraps[trap_num] = ptr; + mrg_OStraps[trap_num] = ptr; /* * If the Trap for Egret was changed, we'd better remember it! */ - if (trap_num == 0x92) { + if (trap_num == 0x92) { #if defined(MRG_DEBUG) - printf("mrg: reconfigured Egret address from 0x%lx to 0x%lx\n", - (long)jEgret, (long)ptr); + printf("mrg: reconfigured Egret address from 0x%lx to 0x%lx\n", + (long)jEgret, (long)ptr); #endif - jEgret = (void (*))ptr; - } - return 0; -} - -int -mrg_GetTrapAddress() -{ - extern caddr_t mrg_OStraps[]; - caddr_t ptr; - int trap_num; - - asm(" movl d0, %0" - : "=g" (trap_num) : : "d0"); - - ptr = mrg_OStraps[trap_num]; - - asm(" movl %0, a0" - : : "g" (ptr) : "a0"); + jEgret = (void (*))ptr; + } return 0; } @@ -637,7 +626,6 @@ caddr_t mrg_OStraps[256] = { (caddr_t)mrg_GetPtrSize, [0x2f] (caddr_t)mrg_PostEvent, [0x3b] (caddr_t)mrg_Delay, - [0x46] (caddr_t)mrg_GetTrapAddress, [0x47] (caddr_t)mrg_SetTrapAddress, [0x55] (caddr_t)mrg_StripAddress, [0x82] (caddr_t)mrg_DTInstall, @@ -665,7 +653,7 @@ mrg_aline_super(struct frame *frame) int trapnum; int a0passback; u_int32_t a0bucket, d0bucket; - int danprint=0; /* This shouldn't be necessary, but seems to be. */ + int danprint=0; /* This shouldn't be necessary, but seems to be. */ #if defined(MRG_DEBUG) printf("mrg: a super"); @@ -673,8 +661,8 @@ mrg_aline_super(struct frame *frame) trapword = *(u_short *)frame->f_pc; - if (trapword == 0xa71e) - danprint = 1; + if (trapword == 0xa71e) + danprint = 1; #if defined(MRG_DEBUG) printf(" wd 0x%lx", (long)trapword); @@ -690,7 +678,7 @@ mrg_aline_super(struct frame *frame) * A printf(""); is sufficient, but gcc -Wall is noisy about * it, so I figured backspace is harmless enough... */ - printf("\010"); printf("\010"); + printf(" "); printf("\010"); } #if defined(MRG_DEBUG) @@ -707,7 +695,7 @@ mrg_aline_super(struct frame *frame) printf(" got: d0 = 0x%8x, a0 = 0x%8x, called from: 0x%8x\n", frame->f_regs[0], frame->f_regs[8], frame->f_pc ); #endif - if(trapaddr == NULL){ + if (trapaddr == NULL) { printf("unknown %s trap 0x%x, no trap address available\n", isOStrap ? "OS" : "ToolBox", trapword); panic("mrg_aline_super()"); @@ -718,39 +706,33 @@ mrg_aline_super(struct frame *frame) tron(); #endif -/* - * put trapaddr in a2 - * put a0 in a0 - * put a1 in a1 - * put d0 in d0 - * put d1 in d1 - * save a6 - * call the damn routine - * restore a6 - * store d0 in d0bucket - * store a0 in d0bucket - * This will change a2,a1,d1,d0,a0 and possibly a6 - */ - - __asm(" - movl %2, d0 - movw %3, d1 - movl %4, a0 - movl %5, a1 - movl %6, a2 +/* put a0 in a0 */ +/* put a1 in a1 */ +/* put d0 in d0 */ +/* put d1 in d1 */ +/* put trapaddr in a2 */ +/* save a6 */ +/* call the damn routine */ +/* restore a6 */ +/* store d0 in d0bucket */ +/* store a0 in d0bucket */ +/* This will change a2,a1,d1,d0,a0 and possibly a6 */ + + __asm __volatile (" + movl %2@, d0 + movl %2@(4), d1 + movl %2@(32), a0 + movl %2@(36), a1 + movl %3, a2 jbsr a2@ movl a0, %0 movl d0, %1" : "=g" (a0bucket), "=g" (d0bucket) - : "m" (frame->f_regs[0]), "m" (frame->f_regs[1]), - "m" (frame->f_regs[8]), "m" (frame->f_regs[9]), - "g" (trapaddr) + : "a" (&frame->f_regs), "g" (trapaddr) - : "d0", "d1", "a0", "a1", "a2", "a6" - - ); + : "d0", "d1", "a0", "a1", "a2", "a6"); #if defined(MRG_TRACE) troff(); @@ -762,7 +744,7 @@ mrg_aline_super(struct frame *frame) #endif frame->f_regs[0] = d0bucket; - if(a0passback) + if (a0passback) frame->f_regs[8] = a0bucket; frame->f_pc += 2; /* skip offending instruction */ @@ -772,20 +754,6 @@ mrg_aline_super(struct frame *frame) #endif } - /* handle a user mode A-line trap */ -void -mrg_aline_user() -{ -#if 1 - /* send process a SIGILL; aline traps are illegal as yet */ -#else /* how to handle real Mac App A-lines */ - /* ignore for now */ - I have no idea! - maybe pass SIGALINE? - maybe put global information about aline trap? -#endif -} - extern u_int32_t traceloopstart[]; extern u_int32_t traceloopend; extern u_int32_t *traceloopptr; @@ -798,10 +766,9 @@ dumptrace() printf("instruction trace:\n"); traceindex = traceloopptr + 1; - while(traceindex != traceloopptr) - { + while (traceindex != traceloopptr) { printf(" %08x\n", *traceindex++); - if(traceindex == &traceloopend) + if (traceindex == &traceloopend) traceindex = &traceloopstart[0]; } #else @@ -813,7 +780,7 @@ dumptrace() int mrg_romready() { - return(mrg_romident != NULL); + return (mrg_romident != NULL); } extern unsigned long IOBase; @@ -842,51 +809,55 @@ mrg_init() #if defined(MRG_TEST) if (ROMResourceMap) { - printf("mrg: testing CountResources\n"); - __asm(" clrl sp@- - clrl sp@- - .word 0xa99c - movw sp@+, %0" - : "=g" (rcnt)); - printf("mrg: found %d resources in ROM\n", rcnt); - __asm(" clrl sp@- - movl #0x44525652, sp@- - .word 0xa99c - movw sp@+, %0" - : "=g" (rcnt)); - printf("mrg: %d are DRVR resources\n", rcnt); - if (rcnt == 0) - panic("Oops! No DRVR Resources found in ROM"); + printf("mrg: testing CountResources\n"); + __asm __volatile (" + clrl sp@- + clrl sp@- + .word 0xa99c + movw sp@+, %0" + : "=g" (rcnt)); + printf("mrg: found %d resources in ROM\n", rcnt); + __asm __volatile (" + clrl sp@- + movl #0x44525652, sp@- + .word 0xa99c + movw sp@+, %0" + : "=g" (rcnt)); + printf("mrg: %d are DRVR resources\n", rcnt); + if (rcnt == 0) + panic("Oops! No DRVR Resources found in ROM"); } #endif #if defined(MRG_TEST) if (ROMResourceMap) { - printf("mrg: testing GetIndResource\n"); - __asm(" clrl sp@- - movl #0x44525652, sp@- - movw #0x01, sp@- - .word 0xa99d - movl sp@+, %0" - : "=g" (handle)); - printf("Handle to first DRVR resource is 0x%08lx\n", (long)handle); - printf("DRVR: 0x%08lx -> 0x%08lx -> 0x%08lx\n", - (long)Get_Ind_Resource(0x44525652, 1), - (long)*Get_Ind_Resource(0x44525652, 1), - (long) *((u_int32_t *) *Get_Ind_Resource(0x44525652, 1))); - __asm(" clrl sp@- - movl #0x44525652, sp@- - movw #0x02, sp@- - .word 0xa99d - movl sp@+, %0" - : "=g" (handle)); - printf("Handle to second DRVR resource is 0x%08lx\n", (long)handle); - printf("DRVR: 0x%08lx -> 0x%08lx -> 0x%08lx\n", - (long)Get_Ind_Resource(0x44525652, 2), - (long)*Get_Ind_Resource(0x44525652, 2), - (long) *((u_int32_t *) *Get_Ind_Resource(0x44525652, 2))); + printf("mrg: testing GetIndResource\n"); + __asm __volatile (" + clrl sp@- + movl #0x44525652, sp@- + movw #0x01, sp@- + .word 0xa99d + movl sp@+, %0" + : "=g" (handle)); + printf("Handle to first DRVR resource is 0x%p\n", handle); + printf("DRVR: 0x%08lx -> 0x%08lx -> 0x%08lx\n", + (long)Get_Ind_Resource(0x44525652, 1), + (long)*Get_Ind_Resource(0x44525652, 1), + (long)*((u_int32_t *)*Get_Ind_Resource(0x44525652, 1))); + __asm __volatile (" + clrl sp@- + movl #0x44525652, sp@- + movw #0x02, sp@- + .word 0xa99d + movl sp@+, %0" + : "=g" (handle)); + printf("Handle to second DRVR resource is 0x%p\n", handle); + printf("DRVR: 0x%08lx -> 0x%08lx -> 0x%08lx\n", + (long)Get_Ind_Resource(0x44525652, 2), + (long)*Get_Ind_Resource(0x44525652, 2), + (long)*((u_int32_t *)*Get_Ind_Resource(0x44525652, 2))); } #endif - if(mrg_romready()){ + if (mrg_romready()) { printf("mrg: '%s' ROM glue", mrg_romident); #if defined(MRG_TRACE) @@ -922,12 +893,8 @@ mrg_init() #endif /* expected globals */ ExpandMem = &mrg_ExpandMem[0]; - - /* magic (word) */ - *((u_int16_t *)(mrg_ExpandMem + 0x00) ) = 0x0123; - /* Length of table (long) */ - *((u_int32_t *)(mrg_ExpandMem + 0x02) ) = 0x000001ea; - + *((u_int16_t *)(mrg_ExpandMem + 0x00) ) = 0x0123; /* magic (word) */ + *((u_int32_t *)(mrg_ExpandMem + 0x02) ) = 0x000001ea; /* Length of table (long) */ *((u_int32_t *)(mrg_ExpandMem + 0x1e0)) = (u_int32_t) &mrg_adbstore4[0]; *((u_int32_t *)(mrg_adbstore4 + 0x8)) = (u_int32_t) mrg_init_stub_1; @@ -945,9 +912,9 @@ mrg_init() Lo3Bytes = 0x00ffffff; VIA = (caddr_t)Via1Base; MMU32Bit = 1; /* ?means MMU is in 32 bit mode? */ - if(TimeDBRA == 0) + if (TimeDBRA == 0) TimeDBRA = 0xa3b; /* BARF default is Mac II */ - if(ROMBase == 0) + if (ROMBase == 0) panic("ROMBase not set in mrg_init()!"); strlcpy(FinderName + 1, findername, sizeof FinderName - 1); @@ -957,28 +924,29 @@ mrg_init() #endif /* Fake jump points */ - for(i = 0; i < 8; i++) /* Set up fake Lvl1DT */ + for (i = 0; i < 8; i++) /* Set up fake Lvl1DT */ Lvl1DT[i] = mrg_lvl1dtpanic; - for(i = 0; i < 8; i++) /* Set up fake Lvl2DT */ + for (i = 0; i < 8; i++) /* Set up fake Lvl2DT */ Lvl2DT[i] = mrg_lvl2dtpanic; Lvl1DT[0] = (void (*)(void))mrg_1sec_timer_tick; Lvl1DT[2] = (void (*)(void))mrg_romadbintr; Lvl1DT[4] = (void (*)(void))mrg_rompmintr; - JADBProc = mrg_jadbprocpanic; /* Fake JADBProc for the time being */ - jSwapMMU = mrg_jswapmmupanic; /* Fake jSwapMMU for the time being */ - JKybdTask = mrg_jkybdtaskpanic; /* Fake jSwapMMU for the time being */ + JADBProc = mrg_jadbprocpanic; /* Fake JADBProc for the time being */ + jSwapMMU = mrg_jswapmmupanic; /* Fake jSwapMMU for the time being */ + JKybdTask = mrg_jkybdtaskpanic; /* Fake JKybdTask for the time being */ + + /* probably very dangerous */ + jADBOp = (void (*)(void))mrg_OStraps[0x7c]; - jADBOp = (void (*)(void)) - mrg_OStraps[0x7c]; /* probably very dangerous */ mrg_VIA2 = (caddr_t)(Via1Base + VIA2 * 0x2000); /* see via.h */ - SCCRd = (caddr_t)(IOBase + sccA); /* ser.c ; we run before serinit */ + SCCRd = (caddr_t)sccA; /* ser.c ; we run before serinit */ - jDTInstall = (caddr_t) mrg_DTInstall; + jDTInstall = (caddr_t)mrg_DTInstall; /* AV ROMs want this low memory vector to point to a jump table */ InitEgretJTVec = (u_int32_t **)&mrg_AVInitEgretJT; - switch(mach_cputype()){ + switch (mach_cputype()) { case MACH_68020: CPUFlag = 2; break; case MACH_68030: CPUFlag = 3; break; case MACH_68040: CPUFlag = 4; break; @@ -997,8 +965,8 @@ mrg_init() DisposPtr((Ptr)ptr); printf("Free'd.\n"); - for(i = 0; i < 500000; i++) - if((i % 100000) == 0)printf("."); + for (i = 0; i < 500000; i++) + if ((i % 100000) == 0)printf("."); printf("\n"); mrg_ResErr = 0xdead; /* set an error we know */ @@ -1012,8 +980,8 @@ mrg_init() i = ResError(); printf("Result code (-192?) : %d\n", i); - for(i = 0; i < 500000; i++) - if((i % 100000) == 0)printf("."); + for (i = 0; i < 500000; i++) + if ((i % 100000) == 0)printf("."); printf("\n"); #if defined(MRG_TRACE) @@ -1025,8 +993,9 @@ mrg_init() dumptrace(); #endif /* MRG_TRACE */ - for(i = 0; i < 500000; i++) - if((i % 100000) == 0)printf("."); + for (i = 0; i < 500000; i++) + if ((i % 100000) == 0) + printf("."); printf("\n"); #endif /* MRG_TEST */ @@ -1051,29 +1020,21 @@ mrg_init() #endif pmap_map(0x50f00000, 0x50f00000, 0x50f00000 + 0x4000, VM_PROT_READ|VM_PROT_WRITE); - if ( (current_mac_model->class == MACH_CLASSPB) - || (current_mac_model->class == MACH_CLASSDUO)) { - /* CPU GLU */ - pmap_map(0x50080000, 0x50080000, 0x50080000 + 0x10000, - VM_PROT_READ|VM_PROT_WRITE); - /* Modem slot for PB500 */ - pmap_map(0xfb000000, 0xfb000000, 0xfb000000 + 0x10000, - VM_PROT_READ|VM_PROT_WRITE); - /* ??? */ - pmap_map(0x50f80000, 0x50f80000, 0x50f80000 + 0x40000, - VM_PROT_READ|VM_PROT_WRITE); - } } } -void +#ifdef MRG_ADB +static void setup_egret(void); + +static void setup_egret(void) { - if (0 != mrg_InitEgret){ + if (0 != mrg_InitEgret) { /* This initializes ADBState (mrg_ADBStore2) and enables interrupts */ - __asm(" movml a0-a2, sp@- + __asm __volatile (" + movml a0-a2, sp@- movl %1, a0 /* ADBState, mrg_adbstore2 */ movl %0, a1 jbsr a1@ @@ -1081,8 +1042,7 @@ setup_egret(void) : : "g" (mrg_InitEgret), "g" (ADBState) : "a0", "a1"); - /* may have been set in asm() */ - jEgret = (void (*)) mrg_OStraps[0x92]; + jEgret = (void (*)) mrg_OStraps[0x92]; /* may have been set in asm() */ } else printf("Help ... No vector for InitEgret!!\n"); @@ -1094,28 +1054,6 @@ setup_egret(void) (long) mrg_OStraps[0x92]); #endif } - -#ifdef MRG_ADB -static void setup_pm(void); - -static void -setup_pm(void) -{ - if (0 != mrg_InitPM){ - - /* This initializes the Power Manager system and - enables interrupts */ - asm(" - movml #0xffff, sp@- - moval %0, a0 - jbsr a0@ - movml sp@+, #0xffff" - : - : "g" (mrg_InitPM) - : "a0" - ); - } else printf("Help ... No vector for InitPM!!\n"); -} #endif void @@ -1123,10 +1061,9 @@ mrg_initadbintr() { if (mac68k_machine.do_graybars) printf("Got following HwCfgFlags: 0x%4x, 0x%8x, 0x%8x, 0x%8x\n", - HwCfgFlags, HwCfgFlags2, HwCfgFlags3, ADBReInit_JTBL); - - if ( (HwCfgFlags == 0) && (HwCfgFlags2 == 0) && (HwCfgFlags3 == 0) ){ + HwCfgFlags, HwCfgFlags2, HwCfgFlags3, ADBReInit_JTBL); + if ((HwCfgFlags == 0) && (HwCfgFlags2 == 0) && (HwCfgFlags3 == 0)) { printf("Caution: No HwCfgFlags from Booter, please " "use at least booter version 1.8.\n"); @@ -1143,10 +1080,7 @@ mrg_initadbintr() HwCfgFlags, HwCfgFlags2, HwCfgFlags3); } -#ifndef MRG_ADB /* Extra Egret setup not required for the - * MRG_ADB method. */ - printf("mrg: skipping egret setup\n"); -#else +#ifdef MRG_ADB /* * If we think there is an Egret in the machine, attempt to * set it up. If not, just enable the interrupts (only on @@ -1162,17 +1096,8 @@ mrg_initadbintr() if (mac68k_machine.do_graybars) printf("mrg: setup_egret: done.\n"); - } else if ( (current_mac_model->class == MACH_CLASSPB) - || (current_mac_model->class == MACH_CLASSDUO)) { - if (mac68k_machine.do_graybars) - printf("mrg: setup_pm:\n"); - - setup_pm(); - - if (mac68k_machine.do_graybars) - printf("mrg: setup_pm: done.\n"); - } else { + if (mac68k_machine.do_graybars) printf("mrg: Not setting up egret.\n"); @@ -1182,7 +1107,10 @@ mrg_initadbintr() if (mac68k_machine.do_graybars) printf("mrg: ADB interrupts enabled.\n"); } -#endif +#else + /* Extra Egret setup required only for MRG ADB functions. */ + printf("mrg: skipping egret setup\n"); +#endif /* MRG_ADB */ } /* @@ -1201,239 +1129,153 @@ mrg_fixupROMBase(obase, nbase) oldbase = (u_int32_t) obase; newbase = (u_int32_t) nbase; -/* - * Grab the pointer to the Mac ROM Glue Vector table - */ - rom = mrg_MacOSROMVectors; - - if (rom == NULL) - return; /* whoops! ROM vectors not defined! */ - - mrg_romident = rom->romident; - - if (0 != mrg_ADBIntrPtr) { - mrg_romadbintr = mrg_ADBIntrPtr; - printf("mrg_fixup: using ADBIntrPtr from booter: 0x%08lx\n", - (long)mrg_ADBIntrPtr); - } else - mrg_romadbintr = rom->adbintr == 0 ? - 0 : rom->adbintr - oldbase + newbase; - - mrg_rompmintr = rom->pmintr == 0 ? - 0 : rom->pmintr - oldbase + newbase; - mrg_ADBAlternateInit = rom->ADBAlternateInit == 0 ? - 0 : rom->ADBAlternateInit - oldbase + newbase; - - /* - * mrg_adbstore becomes ADBBase - */ - *((u_int32_t *)(mrg_adbstore + 0x130)) = rom->adb130intr == 0 ? - 0 : (u_int32_t) rom->adb130intr - oldbase + newbase; - - mrg_OStraps[0x77] = rom->CountADBs == 0 ? - 0 : rom->CountADBs - oldbase + newbase; - mrg_OStraps[0x78] = rom->GetIndADB == 0 ? - 0 : rom->GetIndADB - oldbase + newbase; - mrg_OStraps[0x79] = rom-> GetADBInfo == 0 ? - 0 : rom->GetADBInfo - oldbase + newbase; - mrg_OStraps[0x7a] = rom->SetADBInfo == 0 ? - 0 : rom->SetADBInfo - oldbase + newbase; - mrg_OStraps[0x7b] = rom->ADBReInit == 0 ? - 0 : rom->ADBReInit - oldbase + newbase; - mrg_OStraps[0x7c] = rom->ADBOp == 0 ? - 0 : rom->ADBOp - oldbase + newbase; - mrg_OStraps[0x85] = rom->PMgrOp == 0 ? - 0 : rom->PMgrOp - oldbase + newbase; - mrg_OStraps[0x51] = rom->ReadXPRam == 0 ? - 0 : rom->ReadXPRam - oldbase + newbase; - mrg_OStraps[0x38] = rom->WriteParam == 0 ? - 0 : rom->WriteParam - oldbase + newbase;/* WriteParam*/ - mrg_OStraps[0x3a] = rom->SetDateTime == 0 ? - 0 : rom->SetDateTime - oldbase + newbase;/*SetDateTime*/ - mrg_OStraps[0x3f] = rom->InitUtil == 0 ? - 0 : rom->InitUtil - oldbase + newbase; /* InitUtil */ - mrg_OStraps[0x51] = rom->ReadXPRam == 0 ? - 0 : rom->ReadXPRam - oldbase + newbase; /* ReadXPRam */ - mrg_OStraps[0x52] = rom->WriteXPRam == 0 ? - 0 : rom->WriteXPRam - oldbase + newbase;/* WriteXPRam */ - - if (rom->Egret == 0) { - jEgret = 0; - mrg_OStraps[0x92] = 0; - } - else { - jEgret = (void (*))rom->Egret - oldbase + newbase; - mrg_OStraps[0x92] = rom->Egret - oldbase + newbase; - } - mrg_InitEgret = rom->InitEgret == 0 ? - 0 : rom->InitEgret - oldbase + newbase; - - if ( (current_mac_model->class == MACH_CLASSPB) - || (current_mac_model->class == MACH_CLASSDUO)) { - switch( mac68k_machine.machineid ) { - case MACH_MACPB170: - mrg_InitPM = /* PMgrInit */ - (caddr_t)0x40888400 - oldbase + newbase; - jCacheFlush = (caddr_t)0x40809a7c - oldbase + newbase; - mrg_OStraps[0x33] = /* VInstall */ - (caddr_t)0x4082ea80 - oldbase + newbase; - mrg_OStraps[0x55] = /* MemoryDispatch */ - (caddr_t)0x4082eada - oldbase + newbase; - mrg_OStraps[0x5e] = /* NMInstall */ - (caddr_t)0x4082eafe - oldbase + newbase; - mrg_OStraps[0x5f] = /* NMRemove */ - (caddr_t)0x4082eb08 - oldbase + newbase; - mrg_OStraps[0x8d] = /* EnterSuperVisor */ - (caddr_t)0x4082914a - oldbase + newbase; - mrg_OStraps[0x9e] = /* FullProcessorSpeed */ - (caddr_t)0x40829868 - oldbase + newbase; - mrg_OStraps[0x9f] = /* PMgrDispatch */ - (caddr_t)0x408888d8 - oldbase + newbase; - break; - case MACH_MACPB140: - case MACH_MACPB145: - mrg_InitPM = /* PMgrInit (symbol undef.) */ - (caddr_t)0x40888400 - oldbase + newbase; - jCacheFlush = (caddr_t)0x40809a7c - oldbase + newbase; - mrg_OStraps[0x33] = /* VInstall */ - (caddr_t)0x4080a230 - oldbase + newbase; - mrg_OStraps[0x55] = /* _VM */ - (caddr_t)0x40805538 - oldbase + newbase; - mrg_OStraps[0x5e] = /* NMInstall */ - (caddr_t)0x4081d720 - oldbase + newbase; - mrg_OStraps[0x5f] = /* NMRemove */ - (caddr_t)0x4081d730 - oldbase + newbase; - break; - case MACH_MACPB160: - case MACH_MACPB165: - case MACH_MACPB165C: - case MACH_MACPB180: - case MACH_MACPB180C: - case MACH_MACPB210: - case MACH_MACPB230: - case MACH_MACPB250: - case MACH_MACPB270: - case MACH_MACPB280: - case MACH_MACPB280C: - mrg_InitPM = /* PMgrInit */ - (caddr_t)0x40888400 - oldbase + newbase; - jCacheFlush = (caddr_t)0x40809a7c - oldbase + newbase; - mrg_OStraps[0x33] = /* VInstall */ - (caddr_t)0x4080a230 - oldbase + newbase; - mrg_OStraps[0x55] = /* MemoryDispatch */ - (caddr_t)0x40805538 - oldbase + newbase; - mrg_OStraps[0x5e] = /* NMInstall */ - (caddr_t)0x4082eafe - oldbase + newbase; - mrg_OStraps[0x5f] = /* NMRemove */ - (caddr_t)0x4082eb08 - oldbase + newbase; - mrg_OStraps[0x8d] = /* EnterSuperVisor */ - (caddr_t)0x4082914a - oldbase + newbase; - mrg_OStraps[0x9e] = /* FullProcessorSpeed */ - (caddr_t)0x40829868 - oldbase + newbase; - mrg_OStraps[0x9f] = /* PMgrDispatch */ - (caddr_t)0x408888d8 - oldbase + newbase; - break; - case MACH_MACPB500: - mrg_InitPM = /* PMgrInit */ - (caddr_t)0x400d8800 - oldbase + newbase; - jCacheFlush = (caddr_t)0x40085030 - oldbase + newbase; - mrg_OStraps[0x33] = /* VInstall */ - (caddr_t)0x4000a230 - oldbase + newbase; - mrg_OStraps[0x5e] = /* NMInstall */ - (caddr_t)0x4002eafe - oldbase + newbase; - mrg_OStraps[0x5f] = /* NMRemove */ - (caddr_t)0x4002eb08 - oldbase + newbase; - mrg_OStraps[0x8d] = /* EnterSuperVisor */ - (caddr_t)0x4000a0f0 - oldbase + newbase; - mrg_OStraps[0x9e] = /* FullProcessorSpeed */ - (caddr_t)0x400da254 - oldbase + newbase; - mrg_OStraps[0x9f] = /* PMgrDispatch */ - (caddr_t)0x400d8fc0 - oldbase + newbase; - break; - } + + /* + * Grab the pointer to the Mac ROM Glue Vector table + */ + rom = mrg_MacOSROMVectors; + + if (rom == NULL) + return; /* whoops! ROM vectors not defined! */ + + mrg_romident = rom->romident; + + if (0 != mrg_ADBIntrPtr) { + mrg_romadbintr = mrg_ADBIntrPtr; + printf("mrg_fixup: using ADBIntrPtr from booter: 0x%08lx\n", + (long)mrg_ADBIntrPtr); + } else + mrg_romadbintr = rom->adbintr == 0 ? + 0 : rom->adbintr - oldbase + newbase; + + mrg_rompmintr = rom->pmintr == 0 ? + 0 : rom->pmintr - oldbase + newbase; + mrg_ADBAlternateInit = rom->ADBAlternateInit == 0 ? + 0 : rom->ADBAlternateInit - oldbase + newbase; + + /* + * mrg_adbstore becomes ADBBase + */ + *((u_int32_t *)(mrg_adbstore + 0x130)) = rom->adb130intr == 0 ? + 0 : (u_int32_t) rom->adb130intr - oldbase + newbase; + + mrg_OStraps[0x77] = rom->CountADBs == 0 ? + 0 : rom->CountADBs - oldbase + newbase; + mrg_OStraps[0x78] = rom->GetIndADB == 0 ? + 0 : rom->GetIndADB - oldbase + newbase; + mrg_OStraps[0x79] = rom-> GetADBInfo == 0 ? + 0 : rom->GetADBInfo - oldbase + newbase; + mrg_OStraps[0x7a] = rom->SetADBInfo == 0 ? + 0 : rom->SetADBInfo - oldbase + newbase; + mrg_OStraps[0x7b] = rom->ADBReInit == 0 ? + 0 : rom->ADBReInit - oldbase + newbase; + mrg_OStraps[0x7c] = rom->ADBOp == 0 ? + 0 : rom->ADBOp - oldbase + newbase; + mrg_OStraps[0x85] = rom->PMgrOp == 0 ? + 0 : rom->PMgrOp - oldbase + newbase; + mrg_OStraps[0x51] = rom->ReadXPRam == 0 ? + 0 : rom->ReadXPRam - oldbase + newbase; + mrg_OStraps[0x38] = rom->WriteParam == 0 ? + 0 : rom->WriteParam - oldbase + newbase;/* WriteParam*/ + mrg_OStraps[0x3a] = rom->SetDateTime == 0 ? + 0 : rom->SetDateTime - oldbase + newbase;/*SetDateTime*/ + mrg_OStraps[0x3f] = rom->InitUtil == 0 ? + 0 : rom->InitUtil - oldbase + newbase; /* InitUtil */ + mrg_OStraps[0x51] = rom->ReadXPRam == 0 ? + 0 : rom->ReadXPRam - oldbase + newbase; /* ReadXPRam */ + mrg_OStraps[0x52] = rom->WriteXPRam == 0 ? + 0 : rom->WriteXPRam - oldbase + newbase;/* WriteXPRam */ + + if (rom->Egret == 0) { + jEgret = 0; + mrg_OStraps[0x92] = 0; + } else { + jEgret = (void (*))(rom->Egret - oldbase + newbase); + mrg_OStraps[0x92] = rom->Egret - oldbase + newbase; } + mrg_InitEgret = rom->InitEgret == 0 ? + 0 : rom->InitEgret - oldbase + newbase; + + if (rom->jClkNoMem == 0) { + printf("WARNING: don't have a value for jClkNoMem, "); + printf("please contact: walter@ghpc8.ihf.rwth-aachen.de\n"); + printf("Can't read RTC without it. Using MacOS boot time.\n"); + jClkNoMem = 0; + } else + jClkNoMem = (void (*))(rom->jClkNoMem - oldbase + newbase); + /* + * Get the ToolBox Routines we may need. These are + * used in the ADB Initialization of some systems. + * If we don't have the ROM addresses for these routines + * we'll setup to catch the calls in our own dummy + * routines. That way we can politely tell the user + * what we'll need to complete initialization on the system. + */ + mrg_ToolBoxtraps[0x04d] = rom->FixDiv == 0 ? + (caddr_t)mrg_FixDiv : rom->FixDiv - oldbase + newbase; + mrg_ToolBoxtraps[0x068] = rom->FixMul == 0 ? + (caddr_t)mrg_FixMul : rom->FixMul - oldbase + newbase; - if (rom->jClkNoMem == 0) { - printf("WARNING: don't have a value for jClkNoMem, please "); - printf("contact: walter@ghpc8.ihf.rwth-aachen.de\n"); - printf("Can't read RTC without it. Using MacOS boot time.\n"); - jClkNoMem = 0; - } - else - jClkNoMem = (void (*)) rom->jClkNoMem - oldbase + newbase; - /* - * Get the ToolBox Routines we may need. These are - * used in the ADB Initialization of some systems. - * If we don't have the ROM addresses for these routines - * we'll setup to catch the calls in our own dummy - * routines. That way we can politely tell the user - * what we'll need to complete initialization on the system. - */ - mrg_ToolBoxtraps[0x04d] = rom->FixDiv == 0 ? - (caddr_t)mrg_FixDiv : rom->FixDiv - oldbase + newbase; - mrg_ToolBoxtraps[0x068] = rom->FixMul == 0 ? - (caddr_t)mrg_FixMul : rom->FixMul - oldbase + newbase; - - /* - * Some systems also require this to be setup for use in - * ADB Initialization. Use whatever address was provided - * to us in the romvec table for this system. This may - * cause a problem on some systems, and may need a better - * Trap handler in the future. - */ - ADBReInit_JTBL = rom->ADBReInit_JTBL == 0 ? - 0 : (u_int32_t)rom->ADBReInit_JTBL - oldbase + newbase; - - /* - * Setup to trap unexpected access to ADBProc which is used in - * ADB Initialization on some systems. If the correct entry - * point in the ADBInit code is selected, this address is - * re-configured by the ROM during initialization. This feature + /* + * Some systems also require this to be setup for use in + * ADB Initialization. Use whatever address was provided + * to us in the romvec table for this system. This may + * cause a problem on some systems, and may need a better + * Trap handler in the future. + */ + ADBReInit_JTBL = rom->ADBReInit_JTBL == 0 ? + 0 : (u_int32_t)rom->ADBReInit_JTBL - oldbase + newbase; + + /* + * Setup to trap unexpected access to ADBProc which is used in + * ADB Initialization on some systems. If the correct entry + * point in the ADBInit code is selected, this address is + * re-configured by the ROM during initialization. This feature * is not currently used by OpenBSD. - */ - JADBProc = mrg_jadbprocpanic; + */ + JADBProc = mrg_jadbprocpanic; - /* - * Get the address of the first (top) Resource in the ROM. - * This will be the head of a linked list of all Resources - * in the ROM which will be mapped in mrg_InitResources. - */ - ROMResourceMap = rom->ROMResourceMap == 0 ? - 0 : (void (*))rom->ROMResourceMap - oldbase + newbase; + /* + * Get the address of the first (top) Resource in the ROM. + * This will be the head of a linked list of all Resources + * in the ROM which will be mapped in mrg_InitResources. + */ + ROMResourceMap = rom->ROMResourceMap == 0 ? + 0 : (void (*))(rom->ROMResourceMap - oldbase + newbase); for (i = 0; i < sizeof(mrg_AVInitEgretJT) / sizeof(mrg_AVInitEgretJT[0]); i++) mrg_AVInitEgretJT[i] = mrg_AVInitEgretJT[i] == 0 ? 0 : mrg_AVInitEgretJT[i] - oldbase + newbase; #if defined(MRG_DEBUG) - printf("mrg: ROM adbintr 0x%08lx -> 0x%08lx\n", - (long)rom->adbintr, (long)mrg_romadbintr); - printf("mrg: ROM pmintr 0x%08lx -> 0x%08lx\n", - (long)rom->pmintr, (long)mrg_rompmintr); - printf("mrg: OS trap 0x77 (CountADBs) = 0x%08lx -> 0x%08lx\n", - (long)rom->CountADBs, (long)mrg_OStraps[0x77]); - printf("mrg: OS trap 0x78 (GetIndADB) = 0x%08lx -> 0x%08lx\n", - (long)rom->GetIndADB, (long)mrg_OStraps[0x78]); - printf("mrg: OS trap 0x79 (GetADBInfo) = 0x%08lx -> 0x%08lx\n", - (long)rom->GetADBInfo, (long)mrg_OStraps[0x79]); - printf("mrg: OS trap 0x7a (SetADBInfo) = 0x%08lx -> 0x%08lx\n", - (long)rom->SetADBInfo, (long)mrg_OStraps[0x7a]); - printf("mrg: OS trap 0x7b (ADBReInit) = 0x%08lx -> 0x%08lx\n", - (long)rom->ADBReInit, (long)mrg_OStraps[0x7b]); - printf("mrg: OS trap 0x7c (ADBOp) = 0x%08lx -> 0x%08lx\n", - (long)rom->ADBOp, (long)mrg_OStraps[0x7c]); - printf("mrg: OS trap 0x85 (PMgrOp) = 0x%08lx -> 0x%08lx\n", - (long)rom->PMgrOp, (long)mrg_OStraps[0x85]); - printf("mrg: OS trap 0x92 (Egret) = 0x%08lx -> 0x%08lx\n", - (long)rom->Egret, (long)mrg_OStraps[0x92]); - printf("mrg: ROM ADBAltInit 0x%08lx -> 0x%08lx\n", - (long)rom->ADBAlternateInit, (long)mrg_ADBAlternateInit); - printf("mrg: ROM ADBReInit_JTBL 0x%08lx -> 0x%08lx\n", - (long)rom->ADBReInit_JTBL, (long)ADBReInit_JTBL); - printf("mrg: ROM InitEgret 0x%08lx -> 0x%08lx\n", - (long)rom->InitEgret, (long)mrg_InitEgret); - printf("mrg: ROM Resource list-head 0x%08lx -> 0x%08lx\n", - (long)rom->ROMResourceMap, (long)ROMResourceMap); + printf("mrg: ROM adbintr 0x%08lx -> 0x%08lx\n", + (long)rom->adbintr, (long)mrg_romadbintr); + printf("mrg: ROM pmintr 0x%08lx -> 0x%08lx\n", + (long)rom->pmintr, (long)mrg_rompmintr); + printf("mrg: OS trap 0x77 (CountADBs) = 0x%08lx -> 0x%08lx\n", + (long)rom->CountADBs, (long)mrg_OStraps[0x77]); + printf("mrg: OS trap 0x78 (GetIndADB) = 0x%08lx -> 0x%08lx\n", + (long)rom->GetIndADB, (long)mrg_OStraps[0x78]); + printf("mrg: OS trap 0x79 (GetADBInfo) = 0x%08lx -> 0x%08lx\n", + (long)rom->GetADBInfo, (long)mrg_OStraps[0x79]); + printf("mrg: OS trap 0x7a (SetADBInfo) = 0x%08lx -> 0x%08lx\n", + (long)rom->SetADBInfo, (long)mrg_OStraps[0x7a]); + printf("mrg: OS trap 0x7b (ADBReInit) = 0x%08lx -> 0x%08lx\n", + (long)rom->ADBReInit, (long)mrg_OStraps[0x7b]); + printf("mrg: OS trap 0x7c (ADBOp) = 0x%08lx -> 0x%08lx\n", + (long)rom->ADBOp, (long)mrg_OStraps[0x7c]); + printf("mrg: OS trap 0x85 (PMgrOp) = 0x%08lx -> 0x%08lx\n", + (long)rom->PMgrOp, (long)mrg_OStraps[0x85]); + printf("mrg: OS trap 0x92 (Egret) = 0x%08lx -> 0x%08lx\n", + (long)rom->Egret, (long)mrg_OStraps[0x92]); + printf("mrg: ROM ADBAltInit 0x%08lx -> 0x%08lx\n", + (long)rom->ADBAlternateInit, (long)mrg_ADBAlternateInit); + printf("mrg: ROM ADBReInit_JTBL 0x%08lx -> 0x%08lx\n", + (long)rom->ADBReInit_JTBL, (long)ADBReInit_JTBL); + printf("mrg: ROM InitEgret 0x%08lx -> 0x%08lx\n", + (long)rom->InitEgret, (long)mrg_InitEgret); + printf("mrg: ROM Resource list-head 0x%08lx -> 0x%08lx\n", + (long)rom->ROMResourceMap, (long)ROMResourceMap); #endif } @@ -1441,10 +1283,10 @@ mrg_fixupROMBase(obase, nbase) void ADBAlternateInit(void) { - if (0 == mrg_ADBAlternateInit){ + if (0 == mrg_ADBAlternateInit) { ADBReInit(); } else { - __asm(" + __asm __volatile (" movml a0-a6/d0-d7, sp@- movl %0, a1 movl %1, a3 @@ -1455,4 +1297,4 @@ ADBAlternateInit(void) : "a1", "a3"); } } -#endif +#endif /* MRG_ADB */ diff --git a/sys/arch/mac68k/mac68k/macrom.h b/sys/arch/mac68k/mac68k/macrom.h index dd8eec3d9ad..76c8aa97b27 100644 --- a/sys/arch/mac68k/mac68k/macrom.h +++ b/sys/arch/mac68k/mac68k/macrom.h @@ -1,5 +1,5 @@ -/* $OpenBSD: macrom.h,v 1.11 2004/11/26 21:21:28 miod Exp $ */ -/* $NetBSD: macrom.h,v 1.9 1996/05/25 14:45:35 briggs Exp $ */ +/* $OpenBSD: macrom.h,v 1.12 2005/02/20 18:08:08 martin Exp $ */ +/* $NetBSD: macrom.h,v 1.12 2000/11/15 07:15:36 scottr Exp $ */ /*- * Copyright (C) 1994 Bradley A. Grantham @@ -78,12 +78,10 @@ extern caddr_t ExpandMem; /* pointer to Expanded Memory used by */ extern u_int16_t VBLQueue; /* Vertical blanking Queue, unused ? */ extern caddr_t VBLQueue_head; /* Vertical blanking Queue, head */ extern caddr_t VBLQueue_tail; /* Vertical blanking Queue, tail */ -extern caddr_t jDTInstall; /* short-cut to deferred task mgr */ - /* trap handler */ +extern caddr_t jDTInstall; /* Deferred task mgr trap handler */ extern u_int32_t **InitEgretJTVec; /* pointer to a jump table for */ /* InitEgret on AV machines */ -extern caddr_t jCacheFlush; /* pointer to CacheFlush */ /* Types */ @@ -106,62 +104,37 @@ typedef struct { /* Trap Flesh; these functions are C, not Pascal */ /* trap tests */ -int MyOwnTrap( - void); -void KnownRTS( - void); +int MyOwnTrap(void); +void KnownRTS(void); -#ifdef MRG_ADB /* These routines are defined here - * if using the MRG_ADB method for accessing - * the ADB/PRAM/RTC. They are - * defined in adb_direct.h */ +#ifdef MRG_ADB +/* + * These functions are defined in adb_direct.c if we are not using + * the MRG method of accessing the ADB/PRAM/RTC. + */ /* ADB Manager */ -int SetADBInfo( - ADBSetInfoBlock *info, - int adbAddr); -int CountADBs( - void); -int GetIndADB( - ADBDataBlock *info, - int index); -int GetADBInfo( - ADBDataBlock *info, - int adbAddr); -void ADBReInit( - void); -int ADBOp( - Ptr buffer, /* note different order of parameters */ - Ptr compRout, - Ptr data, - short commandNum); -void ADBAlternateInit( - void); +int SetADBInfo(ADBSetInfoBlock *info, int adbAddr); +int CountADBs(void); +int GetIndADB(ADBDataBlock *info, int index); +int GetADBInfo(ADBDataBlock *info, int adbAddr); +void ADBReInit(void); + /* note different order of parameters */ +int ADBOp(Ptr buffer, Ptr compRout, Ptr data, short commandNum); +void ADBAlternateInit(void); #endif /* Memory Manager */ -Ptr NewPtr( - int size); -int DisposPtr( - Ptr ptr); -int GetPtrSize( - Ptr ptr); -int SetPtrSize( - Ptr ptr, - int newbytes); +Ptr NewPtr(int size); +int DisposPtr(Ptr ptr); +int GetPtrSize(Ptr ptr); +int SetPtrSize(Ptr ptr, int newbytes); /* Resource Manager */ -Handle GetResource( - u_int theType, - short theID); -short ResError( - void); -short mrg_CountResources( - u_int32_t type); -short Count_Resources( - u_int32_t rsrc_type); -caddr_t *mrg_GetIndResource( - u_int16_t index, - u_int32_t type); +Handle GetResource(u_int theType, short theID); +short ResError(void); +short mrg_CountResources(u_int32_t type); +short Count_Resources(u_int32_t rsrc_type); +caddr_t *mrg_GetIndResource(u_int16_t index, u_int32_t type); /* Mac ROM Glue globals for BSD kernel */ @@ -180,7 +153,7 @@ extern u_char mrg_ResError[]; /* Dump instruction trace */ -void dumptrace(void); +void dumptrace(void); /* Stuff for configuring ROM Glue */ @@ -235,6 +208,8 @@ int mrg_adbintr(void); int mrg_pmintr(void); void mrg_fixupROMBase(caddr_t, caddr_t); int mrg_Delay(void); +void mrg_DTInstall(void); +void mrg_execute_deferred(void); void mrg_VBLQueue(void); void mrg_init_stub_1(void); void mrg_init_stub_2(void); @@ -251,11 +226,9 @@ int mrg_DisposPtr(void); int mrg_GetPtrSize(void); int mrg_SetPtrSize(void); int mrg_PostEvent(void); -int mrg_GetTrapAddress(void); int mrg_SetTrapAddress(void); void mrg_StripAddress(void); void mrg_aline_super(struct frame *); -void mrg_aline_user(void); void mrg_init(void); void mrg_FixDiv(void); void mrg_FixMul(void); @@ -267,6 +240,6 @@ int mach_cputype(void); /* trace all instructions, not just flow changes. */ #define tron() \ - __asm("movw sr, d0 ; orw #0x8000, d0 ; movw d0, sr" : : : "d0") + asm("movw sr, d0 ; orw #0x8000, d0 ; movw d0, sr" : : : "d0") #define troff() \ - __asm("movw sr, d0 ; andw #0x3fff, d0 ; movw d0, sr" : : : "d0") + asm("movw sr, d0 ; andw #0x3fff, d0 ; movw d0, sr" : : : "d0") diff --git a/sys/arch/mac68k/mac68k/macromasm.s b/sys/arch/mac68k/mac68k/macromasm.s index b465fb5e7db..fe996f8561d 100644 --- a/sys/arch/mac68k/mac68k/macromasm.s +++ b/sys/arch/mac68k/mac68k/macromasm.s @@ -1,5 +1,5 @@ -/* $OpenBSD: macromasm.s,v 1.8 1997/04/14 18:48:04 gene Exp $ */ -/* $NetBSD: macromasm.s,v 1.11 1996/05/25 14:45:37 briggs Exp $ */ +/* $OpenBSD: macromasm.s,v 1.9 2005/02/20 18:08:08 martin Exp $ */ +/* $NetBSD: macromasm.s,v 1.18 2000/11/15 07:15:36 scottr Exp $ */ /*- * Copyright (C) 1994 Bradley A. Grantham @@ -37,6 +37,8 @@ #include "assym.h" +#include <machine/asm.h> +#include <machine/trap.h> /* Define this symbol as global with (v) value */ @@ -104,8 +106,7 @@ loglob(VBLQueue, 0x160) /* Vertical blanking Queue, unused ? */ loglob(VBLQueue_head, 0x162) /* Vertical blanking Queue, head */ loglob(VBLQueue_tail, 0x166) /* Vertical blanking Queue, tail */ - loglob(jDTInstall, 0xD9C) /* short-cut to deferred task mgr */ - /* trap handler */ + loglob(jDTInstall, 0xd9c) /* Deferred task mgr trap handler */ loglob(InitEgretJTVec, 0x2010) /* pointer to a jump table for */ /* InitEgret on AV machines */ @@ -425,7 +426,6 @@ LGR_enter: * 1010 line emulator; A-line trap * (we fake MacOS traps from here) */ - .global _mrg_aline_user .global _mrg_aline_super .global _mrg_ToolBoxtraps .global _alinetrap @@ -437,8 +437,9 @@ _alinetrap: movw sp@(FR_HW + 4), d0 | retrieve status register andw #PSL_S, d0 | supervisor state? bne Lalnosup | branch if supervisor - jbsr _mrg_aline_user | user a-line trap - bra Lalrts + addql #4, sp | pop frame ptr + movql #T_ILLINST, d0 | user-mode fault + jra _ASM_LABEL(fault) Lalnosup: #define FR_PC (FR_HW+2) movl sp@(FR_PC + 4), a0 | retrieve PC |