Some updates from Bob Nestor <rnestor@metronet.com> to get the Performa 550

working again.  I broke it when I moved the ROM mapping so it was no
longer mapped on a friendly address boundary.  Some cleanup.
This commit is contained in:
briggs 1996-05-14 04:00:48 +00:00
parent ce096d50d5
commit df2dde6eb0
5 changed files with 496 additions and 381 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: macglobals.s,v 1.2 1995/08/16 13:18:24 briggs Exp $ */
/* $NetBSD: macglobals.s,v 1.3 1996/05/14 04:00:48 briggs Exp $ */
/* Copyright 1994 by Bradley A. Grantham, All rights reserved */
@ -8,8 +8,12 @@
*/
.text
.space 0xF00 /* did I miss something? this is a bad fix for
.space 0x2a00 /* did I miss something? this is a bad fix for
someone who is writing over low mem */
/* changed from 0xf00 to 0x2a00 as some routine running before ADBReInit
chooses to write to 0x1fb8. With the trap table from 0x0 to 0x3ff,
this additional space of 0x2a00 should be sufficient (WRU) */
/*
* This has not been included for some time and things seem to still
* be working.

View File

@ -1,4 +1,4 @@
/* $NetBSD: machdep.c,v 1.100 1996/05/10 20:53:31 briggs Exp $ */
/* $NetBSD: machdep.c,v 1.101 1996/05/14 04:00:53 briggs Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@ -1550,7 +1550,24 @@ getenv(str)
}
/*
*ROM Vector information for calling drivers in ROMs
* ROM Vector information for calling drivers in ROMs
*
* Egret, ADBReInit_JTBL and ROMResourceMap were added to these
* tables. Egret probably isn't used anyplace anymore, but I was
* inspired by the default value that was used in "macrom.c". That
* value was most likely non-functional for all but a few systems,
* so putting it here will hopefully localize system-specific ROM
* addresses. Likewise ADBReInit_JTBL and ROMResourceMap are
* currently used on only a few systems, but changes in the Booter
* and changes in ROM Mapping were causing problems. Hopefully
* those problems will be eliminated by having the proper addresses
* for those machines in this table.
*
* What we probably need is a little MacOS Utility that can suck all
* these addresses from the System, tell the user if his/er system
* is currently supported via the romvec tables, and provide a
* formatted output file for inclusion here if it isn't.
* Bob Nestor - <rnestor@metronet.com>
*/
static romvec_t romvecs[] =
{
@ -1558,7 +1575,7 @@ static romvec_t romvecs[] =
{ /* 0 */
"Mac II class ROMs",
(caddr_t) 0x40807002, /* where does ADB interrupt */
0, /* PM interrupt (?) */
(caddr_t) 0x0, /* PM interrupt (?) */
(caddr_t) 0x4080a4d8, /* ADBBase + 130 interrupt; whatzit? */
(caddr_t) 0x40807778, /* CountADBs */
(caddr_t) 0x40807792, /* GetIndADB */
@ -1566,15 +1583,18 @@ static romvec_t romvecs[] =
(caddr_t) 0x408077c4, /* SetADBInfo */
(caddr_t) 0x40807704, /* ADBReInit */
(caddr_t) 0x408072fa, /* ADBOp */
0, /* PMgrOp */
(caddr_t) 0x0, /* PMgrOp */
(caddr_t) 0x4080d6d0, /* WriteParam */
(caddr_t) 0x4080d6fa, /* SetDateTime */
(caddr_t) 0x4080dbe8, /* InitUtil */
(caddr_t) 0x4080dd78, /* ReadXPRam */
(caddr_t) 0x4080dd82, /* WriteXPRam */
(caddr_t) 0x4080ddd6, /* jClkNoMem */
0, /* ADBAlternateInit */
0, /* InitEgret */
(caddr_t) 0x0, /* ADBAlternateInit */
(caddr_t) 0x0, /* Egret */
(caddr_t) 0x0, /* InitEgret */
(caddr_t) 0x0, /* ADBReInit_JTBL */
(caddr_t) 0x0, /* ROMResourceMap List Head */
(caddr_t) 0x40814c58, /* FixDiv */
(caddr_t) 0x40814b64, /* FixMul */
},
@ -1601,7 +1621,10 @@ static romvec_t romvecs[] =
(caddr_t) 0x4080b190, /* WriteXPRam */
(caddr_t) 0x4080b1e4, /* jClkNoMem */
(caddr_t) 0x4080a818, /* ADBAlternateInit */
(caddr_t) 0x40814800, /* Egret */
(caddr_t) 0x408147c4, /* InitEgret */
(caddr_t) 0x0, /* ADBReInit_JTBL */
(caddr_t) 0x0, /* ROMResourceMap List Head */
(caddr_t) 0x4081c406, /* FixDiv */
(caddr_t) 0x4081c312, /* FixMul */
},
@ -1611,7 +1634,7 @@ static romvec_t romvecs[] =
{ /* 2 */
"Mac IIsi class ROMs",
(caddr_t) 0x40814912, /* ADB interrupt */
(caddr_t) 0, /* PM ADB interrupt */
(caddr_t) 0x0, /* PM ADB interrupt */
(caddr_t) 0x408150f0, /* ADBBase + 130 interrupt; whatzit? */
(caddr_t) 0x4080a360, /* CountADBs */
(caddr_t) 0x4080a37a, /* GetIndADB */
@ -1619,7 +1642,7 @@ static romvec_t romvecs[] =
(caddr_t) 0x4080a3ac, /* SetADBInfo */
(caddr_t) 0x4080a752, /* ADBReInit */
(caddr_t) 0x4080a3dc, /* ADBOp */
(caddr_t) 0, /* PMgrOp */
(caddr_t) 0x0, /* PMgrOp */
(caddr_t) 0x4080c05c, /* WriteParam */
(caddr_t) 0x4080c086, /* SetDateTime */
(caddr_t) 0x4080c5cc, /* InitUtil */
@ -1627,7 +1650,10 @@ static romvec_t romvecs[] =
(caddr_t) 0x4080b190, /* WriteXPRam */
(caddr_t) 0x4080b1e4, /* jClkNoMem */
(caddr_t) 0x4080a818, /* ADBAlternateInit */
(caddr_t) 0x40814800, /* Egret */
(caddr_t) 0x408147c4, /* InitEgret */
(caddr_t) 0x0, /* ADBReInit_JTBL */
(caddr_t) 0x0, /* ROMResourceMap List Head */
(caddr_t) 0x4081c406, /* FixDiv */
(caddr_t) 0x4081c312, /* FixMul */
},
@ -1638,7 +1664,7 @@ static romvec_t romvecs[] =
{ /* 3 */
"Mac Classic II ROMs",
(caddr_t) 0x40a14912, /* ADB interrupt */
(caddr_t) 0, /* PM ADB interrupt */
(caddr_t) 0x0, /* PM ADB interrupt */
(caddr_t) 0x40a150f0, /* ADBBase + 130 interrupt; whatzit? */
(caddr_t) 0x40a0a360, /* CountADBs */
(caddr_t) 0x40a0a37a, /* GetIndADB */
@ -1646,7 +1672,7 @@ static romvec_t romvecs[] =
(caddr_t) 0x40a0a3ac, /* SetADBInfo */
(caddr_t) 0x40a0a752, /* ADBReInit */
(caddr_t) 0x40a0a3dc, /* ADBOp */
(caddr_t) 0, /* PMgrOp */
(caddr_t) 0x0, /* PMgrOp */
(caddr_t) 0x40a0c05c, /* WriteParam */
(caddr_t) 0x40a0c086, /* SetDateTime */
(caddr_t) 0x40a0c5cc, /* InitUtil */
@ -1654,7 +1680,10 @@ static romvec_t romvecs[] =
(caddr_t) 0x40a0b190, /* WriteXPRam */
(caddr_t) 0x40ab39b6, /* jClkNoMem */
(caddr_t) 0x40a0a818, /* ADBAlternateInit */
(caddr_t) 0x40814800, /* Egret */
(caddr_t) 0x40a147c4, /* InitEgret */
(caddr_t) 0x0, /* ADBReInit_JTBL */
(caddr_t) 0x0, /* ROMResourceMap List Head */
(caddr_t) 0x40a1c406, /* FixDiv, wild guess */
(caddr_t) 0x40a1c312, /* FixMul, wild guess */
},
@ -1664,7 +1693,7 @@ static romvec_t romvecs[] =
{ /* 4 */
"Mac IIci/Q700 ROMs",
(caddr_t) 0x4080a700, /* ADB interrupt */
(caddr_t) 0, /* PM ADB interrupt */
(caddr_t) 0x0, /* PM ADB interrupt */
(caddr_t) 0x4080a5aa, /* ADBBase + 130 interrupt; whatzit? */
(caddr_t) 0x4080a360, /* CountADBs */
(caddr_t) 0x4080a37a, /* GetIndADB */
@ -1672,7 +1701,7 @@ static romvec_t romvecs[] =
(caddr_t) 0x4080a3ac, /* SetADBInfo */
(caddr_t) 0x4080a752, /* ADBReInit */
(caddr_t) 0x4080a3dc, /* ADBOp */
(caddr_t) 0, /* PMgrOp */
(caddr_t) 0x0, /* PMgrOp */
(caddr_t) 0x4080c05c, /* WriteParam */
(caddr_t) 0x4080c086, /* SetDateTime */
(caddr_t) 0x4080c5cc, /* InitUtil */
@ -1680,7 +1709,10 @@ static romvec_t romvecs[] =
(caddr_t) 0x4080b190, /* WriteXPRam */
(caddr_t) 0x4080b1e4, /* jClkNoMem */
(caddr_t) 0x4080a818, /* ADBAlternateInit */
(caddr_t) 0x0, /* Egret */
(caddr_t) 0x408147c4, /* InitEgret */
(caddr_t) 0x0, /* ADBReInit_JTBL */
(caddr_t) 0x0, /* ROMResourceMap List Head */
(caddr_t) 0x4081c406, /* FixDiv */
(caddr_t) 0x4081c312, /* FixMul */
},
@ -1707,7 +1739,10 @@ static romvec_t romvecs[] =
(caddr_t) 0x4080b190, /* WriteXPRam */
(caddr_t) 0x408b39b2, /* jClkNoMem */ /* From PB180 */
(caddr_t) 0x4080a818, /* ADBAlternateInit */
(caddr_t) 0x40814800, /* Egret */
(caddr_t) 0x40888400, /* InitPwrMgr */ /* From PB180 */
(caddr_t) 0x0, /* ADBReInit_JTBL */
(caddr_t) 0x0, /* ROMResourceMap List Head */
(caddr_t) 0x4081c406, /* FixDiv, wild guess */
(caddr_t) 0x4081c312, /* FixMul, wild guess */
},
@ -1717,7 +1752,7 @@ static romvec_t romvecs[] =
{ /* 6 */
"Quadra/Centris ROMs",
(caddr_t) 0x408b2dea, /* ADB int */
0, /* PM intr */
(caddr_t) 0x0, /* PM intr */
(caddr_t) 0x408b2c72, /* ADBBase + 130 */
(caddr_t) 0x4080a360, /* CountADBs */
(caddr_t) 0x4080a37a, /* GetIndADB */
@ -1733,7 +1768,10 @@ static romvec_t romvecs[] =
(caddr_t) 0x4080b190, /* WriteXPRam */
(caddr_t) 0x408b39b6, /* jClkNoMem */
(caddr_t) 0x4080a818, /* ADBAlternateInit */
(caddr_t) 0x40814800, /* Egret */
(caddr_t) 0x408147c4, /* InitEgret */
(caddr_t) 0x0, /* ADBReInit_JTBL */
(caddr_t) 0x0, /* ROMResourceMap List Head */
(caddr_t) 0x4081c406, /* FixDiv, wild guess */
(caddr_t) 0x4081c312, /* FixMul, wild guess */
},
@ -1744,23 +1782,26 @@ static romvec_t romvecs[] =
{ /* 7 */
"Quadra AV ROMs",
(caddr_t) 0x4080cac6, /* ADB int */
0, /* PM int */
/* !?! */ 0, /* ADBBase + 130 */
(caddr_t) 0x0, /* PM int */
(caddr_t) 0x0, /* ADBBase + 130 */
(caddr_t) 0x40839600, /* CountADBs */
(caddr_t) 0x4083961a, /* GetIndADB */
(caddr_t) 0x40839646, /* GetADBInfo */
(caddr_t) 0x4083964c, /* SetADBInfo */
(caddr_t) 0x408397b8, /* ADBReInit */
(caddr_t) 0x4083967c, /* ADBOp */
0, /* PMgrOp */
(caddr_t) 0x0, /* WriteParam */
(caddr_t) 0x0, /* SetDateTime */
(caddr_t) 0x0, /* InitUtil */
(caddr_t) 0x0, /* ReadXPRam */
(caddr_t) 0x0, /* WriteXPRam */
(caddr_t) 0x0, /* jClkNoMem */
0, /* ADBAlternateInit */
0, /* InitEgret */
(caddr_t) 0x0, /* PMgrOp */
(caddr_t) 0x0, /* WriteParam */
(caddr_t) 0x0, /* SetDateTime */
(caddr_t) 0x0, /* InitUtil */
(caddr_t) 0x0, /* ReadXPRam */
(caddr_t) 0x0, /* WriteXPRam */
(caddr_t) 0x0, /* jClkNoMem */
(caddr_t) 0x0, /* ADBAlternateInit */
(caddr_t) 0x0, /* Egret */
(caddr_t) 0x0, /* InitEgret */
(caddr_t) 0x0, /* ADBReInit_JTBL */
(caddr_t) 0x0, /* ROMResourceMap List Head */
(caddr_t) 0x4081c406, /* FixDiv, wild guess */
(caddr_t) 0x4081c312, /* FixMul, wild guess */
},
@ -1772,22 +1813,25 @@ static romvec_t romvecs[] =
"68040 PowerBook ROMs",
(caddr_t) 0x400b2efc, /* ADB int */
(caddr_t) 0x400d8e66, /* PM int */
/* !?! */ 0, /* ADBBase + 130 */
(caddr_t) 0x0, /* ADBBase + 130 */
(caddr_t) 0x4000a360, /* CountADBs */
(caddr_t) 0x4000a37a, /* GetIndADB */
(caddr_t) 0x4000a3a6, /* GetADBInfo */
(caddr_t) 0x4000a3ac, /* SetADBInfo */
(caddr_t) 0x4000a752, /* ADBReInit */
(caddr_t) 0x4000a3dc, /* ADBOp */
/* !?! */ 0, /* PmgrOp */
(caddr_t) 0x0, /* PmgrOp */
(caddr_t) 0x4000c05c, /* WriteParam */
(caddr_t) 0x4000c086, /* SetDateTime */
(caddr_t) 0x4000c5cc, /* InitUtil */
(caddr_t) 0x4000b186, /* ReadXPRam */
(caddr_t) 0x4000b190, /* WriteXPRam */
(caddr_t) 0x0, /* jClkNoMem */
(caddr_t) 0x0, /* jClkNoMem */
(caddr_t) 0x4000a818, /* ADBAlternateInit */
(caddr_t) 0x40814800, /* Egret */
(caddr_t) 0x400147c4, /* InitEgret */
(caddr_t) 0x0, /* ADBReInit_JTBL */
(caddr_t) 0x0, /* ROMResourceMap List Head */
(caddr_t) 0x4001c406, /* FixDiv, wild guess */
(caddr_t) 0x4001c312, /* FixMul, wild guess */
},
@ -1797,7 +1841,7 @@ static romvec_t romvecs[] =
{ /* 9 */
"Quadra/Centris 605 ROMs",
(caddr_t) 0x408a9b56, /* ADB int */
0, /* PM int */
(caddr_t) 0x0, /* PM int */
(caddr_t) 0x408a99de, /* ADBBase + 130 */
(caddr_t) 0x4080a360, /* CountADBs */
(caddr_t) 0x4080a37a, /* GetIndADB */
@ -1805,15 +1849,18 @@ static romvec_t romvecs[] =
(caddr_t) 0x4080a3ac, /* SetADBInfo */
(caddr_t) 0x4080a752, /* ADBReInit */
(caddr_t) 0x4080a3dc, /* ADBOp */
0, /* PmgrOp */
(caddr_t) 0x0, /* PmgrOp */
(caddr_t) 0x4080c05c, /* WriteParam */
(caddr_t) 0x4080c086, /* SetDateTime */
(caddr_t) 0x4080c5cc, /* InitUtil */
(caddr_t) 0x4080b186, /* ReadXPRam */
(caddr_t) 0x4080b190, /* WriteXPRam */
(caddr_t) 0x0, /* jClkNoMem */
(caddr_t) 0x0, /* jClkNoMem */
(caddr_t) 0x4080a818, /* ADBAlternateInit */
(caddr_t) 0x40814800, /* Egret */
(caddr_t) 0x408147c4, /* InitEgret */
(caddr_t) 0x0, /* ADBReInit_JTBL */
(caddr_t) 0x0, /* ROMResourceMap List Head */
(caddr_t) 0x4081c406, /* FixDiv, wild guess */
(caddr_t) 0x4081c312, /* FixMul, wild guess */
},
@ -1839,7 +1886,10 @@ static romvec_t romvecs[] =
(caddr_t) 0x4080b190, /* WriteXPRam */
(caddr_t) 0x408b3bf8, /* jClkNoMem */ /* from PB 150 */
(caddr_t) 0x4080a818, /* ADBAlternateInit */
(caddr_t) 0x40814800, /* Egret */
(caddr_t) 0x408147c4, /* InitEgret */
(caddr_t) 0x0, /* ADBReInit_JTBL */
(caddr_t) 0x0, /* ROMResourceMap List Head */
(caddr_t) 0x4081c406, /* FixDiv, wild guess */
(caddr_t) 0x4081c312, /* FixMul, wild guess */
},
@ -1849,23 +1899,26 @@ static romvec_t romvecs[] =
{ /* 11 */
"P/LC 550 ROMs",
(caddr_t) 0x408d16d6, /* ADB interrupt */
(caddr_t) 0x0, /* PB ADB interrupt */
(caddr_t) 0x0, /* PB ADB interrupt */
(caddr_t) 0x408b2f84, /* ADBBase + 130 interrupt; whatzit? */
(caddr_t) 0x4080a360, /* CountADBs */
(caddr_t) 0x4080a37a, /* GetIndADB */ /* not verified */
(caddr_t) 0x4080a37a, /* GetIndADB */
(caddr_t) 0x4080a3a6, /* GetADBInfo */
(caddr_t) 0x4080a3ac, /* SetADBInfo */
(caddr_t) 0x4080a752, /* ADBReInit */
(caddr_t) 0x4080a3dc, /* ADBOp */
(caddr_t) 0x0, /* PMgrOp */
(caddr_t) 0x4080c05c, /* WriteParam */
(caddr_t) 0x4080c086, /* SetDateTime */ /* not verified */
(caddr_t) 0x4080c086, /* SetDateTime */
(caddr_t) 0x4080c5cc, /* InitUtil */
(caddr_t) 0x4080b186, /* ReadXPRam */
(caddr_t) 0x4080b190, /* WriteXPRam */
(caddr_t) 0x408b3c04, /* jClkNoMem */
(caddr_t) 0x4080a818, /* ADBAlternateInit */
(caddr_t) 0x408d1450, /* Egret */
(caddr_t) 0x408147c4, /* InitEgret */
(caddr_t) 0x408d24a4, /* ADBReInit_JTBL */
(caddr_t) 0x4087eb90, /* ROMResourceMap List Head */
(caddr_t) 0x4081c406, /* FixDiv for P550 */
(caddr_t) 0x4081c312, /* FixMul for P550 */
},
@ -1875,7 +1928,7 @@ static romvec_t romvecs[] =
{ /* 12 */
"MacTV ROMs",
(caddr_t) 0x40acfed6, /* ADB interrupt */
(caddr_t) 0x0, /* PB ADB interrupt */
(caddr_t) 0x0, /* PB ADB interrupt */
(caddr_t) 0x40ab2f84, /* ADBBase + 130 interrupt; whatzit? */
(caddr_t) 0x40a0a360, /* CountADBs */
(caddr_t) 0x40a0a37a, /* GetIndADB */
@ -1885,13 +1938,16 @@ static romvec_t romvecs[] =
(caddr_t) 0x40a0a3dc, /* ADBOp */
(caddr_t) 0x0, /* PMgrOp */
(caddr_t) 0x40a0c05c, /* WriteParam */
(caddr_t) 0x40a0c086, /* SetDateTime */ /* not verified */
(caddr_t) 0x40a0c086, /* SetDateTime */
(caddr_t) 0x40a0c5cc, /* InitUtil */
(caddr_t) 0x40a0b186, /* ReadXPRam */
(caddr_t) 0x40a0b190, /* WriteXPRam */
(caddr_t) 0x40ab3bf4, /* jClkNoMem */
(caddr_t) 0x40a0a818, /* ADBAlternateInit */
(caddr_t) 0x40ad1450, /* Egret */
(caddr_t) 0x40a147c4, /* InitEgret */
(caddr_t) 0x0, /* ADBReInit_JTBL */
(caddr_t) 0x0, /* ROMResourceMap List Head */
(caddr_t) 0x40a1c406, /* FixDiv */
(caddr_t) 0x40a1c312, /* FixMul */
},
@ -2129,6 +2185,7 @@ getenvvars()
}
struct cpu_model_info *current_mac_model;
romvec_t *mrg_MacOSROMVectors = 0;
/*
* Sets a bunch of machine-specific variables
@ -2158,10 +2215,13 @@ setmachdep()
return;
/*
* Set up current ROM Glue vectors
* Set up current ROM Glue vectors. Actually now all we do
* is save the address of the ROM Glue Vector table. This gets
* used later when we re-map the vectors from MacOS Address
* Space to NetBSD Address Space.
*/
if ((mac68k_machine.serial_console & 0x01) == 0)
mrg_setvectors(cpui->rom_vectors);
mrg_MacOSROMVectors = cpui->rom_vectors;
/*
* Set up any machine specific stuff that we have to before
@ -2499,7 +2559,7 @@ get_mapping(void)
if (!get_physical(addr, &phys)) {
continue;
}
len = nblen[nbnumranges - 1];
len = nbnumranges == 0 ? 0 : nblen[nbnumranges - 1];
/* printf ("0x%x --> 0x%x\n", addr, phys); */
if (nbnumranges > 0
@ -2508,10 +2568,10 @@ get_mapping(void)
nblen[nbnumranges - 1] += 32768;
same = 1;
} else {
if (nbnumranges > 0
if ((nbnumranges > 0)
&& !same
&& addr == nblog[nbnumranges - 1] + len
&& phys == nbphys[nbnumranges - 1] + len) {
&& (addr == nblog[nbnumranges - 1] + len)
&& (phys == nbphys[nbnumranges - 1] + len)) {
nblen[nbnumranges - 1] += 32768;
} else {
if (same) {
@ -2561,17 +2621,19 @@ get_mapping(void)
}
if (i == nbnumranges) {
if (0x60000000 <= videoaddr && videoaddr < 0x70000000) {
printf("Checking for Internal Video ");
/*
* Kludge for IIvx internal video (60b0 0000).
* PB 520 (6000 0000)
*/
check_video("IIvx/PB kludge", 1 * 1024 * 1024,
check_video("PB/IIvx (0x60?00000)", 1 * 1024 * 1024,
1 * 1024 * 1024);
} else if (0x50F40000 <= videoaddr && videoaddr < 0x50FBFFFF) {
/*
* Kludge for LC internal video
*/
check_video("LC video kludge", 512 * 1024, 512 * 1024);
check_video("LC video (0x50f40000)",
512 * 1024, 512 * 1024);
} else {
mac68k_vidphys = videoaddr;
printf( " no internal video at address 0 -- "

View File

@ -1,4 +1,4 @@
/* $NetBSD: macrom.c,v 1.22 1996/05/05 06:18:36 briggs Exp $ */
/* $NetBSD: macrom.c,v 1.23 1996/05/14 04:00:58 briggs Exp $ */
/*-
* Copyright (C) 1994 Bradley A. Grantham
@ -80,17 +80,19 @@ u_char mrg_ExpandMem[512]; /* 0x1ea Bytes minimum */
u_char mrg_adbstore4[32]; /* 0x16 bytes was the largest I found yet */
u_char mrg_adbstore5[80]; /* 0x46 bytes minimum */
caddr_t mrg_romadbintr = (caddr_t)0x40807002; /* ROM ADB interrupt */
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_ADBIntrPtr = (caddr_t)0x0; /* ADB interrupt taken from MacOS vector table*/
caddr_t *rsrc_handle; /* Variables for ROM resource map */
caddr_t *rsrc_header;
u_int32_t nr_of_rsrcs;
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};
#else
caddr_t ResHndls[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
#endif
/*
* Last straw functions; we didn't set them up, so freak out!
@ -120,140 +122,6 @@ mrg_Delay()
}
int
is_resource(caddr_t rp)
{
/* Heuristic to locate resources in the ROM.
* rp+8 builds a linked list, but where does it start?
*/
if ( (0x00000000 == ( *((u_int32_t *) rp ) & 0x00ffffff)) /* magic numbers */
&& (0x00000000 == *((u_int32_t *) (rp+0x04)) ) /* magic numbers */
&& ( 0 == ( *((u_int32_t *) (rp+0x08)) & 0x0f ) ) /* on paragraph boundary */
&& ( 0 == ( *((u_int32_t *) (rp+0x0c)) & 0x0f ) ) /* on paragraph boundary */
&& ( 0 == ( ((u_int32_t) rp) & 0x0f ) ) /* on paragraph boundary */
&& (256 > ( *((u_int32_t *) (rp+0x0c)) - ((u_int32_t)rp & 0x0fffff) ))
/* point to someplace near rp */
)
return 1;
else return 0;
}
int
count_all_resources(caddr_t rombase, u_int32_t romlen)
{
caddr_t romptr;
u_int32_t nr_of_rsrcs = 0;
for (romptr = rombase + romlen; romptr >= rombase; romptr -= 0x10)
{
if (is_resource(romptr))
nr_of_rsrcs++;
}
return nr_of_rsrcs;
}
void
w_build_resource_list(caddr_t rombase, u_int32_t romlen)
{
caddr_t romptr;
u_int32_t rsrc_no = 0;
#ifdef MRG_DEBUG
char rsrc_name[5];
printf("mrg: Resources found:\n");
#endif
nr_of_rsrcs = count_all_resources(rombase, romlen);
if(0 == (rsrc_header = (caddr_t *) malloc(nr_of_rsrcs * sizeof(caddr_t), M_TEMP, M_NOWAIT)))
panic("mrg: Can't malloc memory for rsrc_header list\n");
if(0 == (rsrc_handle = (caddr_t *) malloc(nr_of_rsrcs * sizeof(caddr_t), M_TEMP, M_NOWAIT)))
panic("mrg: Can't malloc memory for rsrc_handle list\n");
for (romptr = rombase + romlen; romptr >= rombase; romptr -= 0x10)
{
if (is_resource(romptr))
if (rsrc_no < nr_of_rsrcs)
{
rsrc_header[rsrc_no] = romptr;
rsrc_handle[rsrc_no] = (caddr_t) (ROMBase + *((u_int32_t *)(romptr + 0x0c)));
rsrc_no++;
#ifdef MRG_DEBUG
strncpy(rsrc_name, (char *) (romptr + 0x10), 4);
rsrc_name[4] = '\0';
printf("%4s 0x%2x ", rsrc_name, *((u_int16_t *) (romptr + 0x14)) );
#endif
}
}
#ifdef MRG_DEBUG
printf("\n");
#endif
}
int
w_count_resources(u_int32_t rsrc_type)
{
u_int32_t rsrc_no = 0;
u_int32_t rsrc_count = 0;
#ifdef MRG_DEBUG
char rsrc_name[5];
strncpy(rsrc_name, (char *) (&rsrc_type), 4);
rsrc_name[4] = '\0';
printf("mrg: w_count_resources called for resource %4s : ", rsrc_name);
#endif
while (rsrc_no < nr_of_rsrcs)
{
if (rsrc_type == *((u_int32_t *) (rsrc_header[rsrc_no] + 0x10)) )
rsrc_count++;
rsrc_no++;
}
#ifdef MRG_DEBUG
printf("found %d resources of requested type!\n", rsrc_count);
#endif
return rsrc_count;
}
caddr_t *
w_get_ind_resource(u_int32_t rsrc_type, u_int16_t rsrc_ind)
{
u_int32_t rsrc_no = 0;
#ifdef MRG_DEBUG
char rsrc_name[5];
strncpy(rsrc_name, (char *) (&rsrc_type), 4);
rsrc_name[4] = '\0';
printf("mrg: w_get_int_resource called for resource %4s, no. %d : ", rsrc_name, rsrc_ind);
#endif
while (rsrc_ind > 0)
{
while ( (rsrc_no < nr_of_rsrcs)
&& (rsrc_type != *((u_int32_t *) (rsrc_header[rsrc_no] + 0x10)) )
)
{
rsrc_no++;
}
rsrc_ind--;
rsrc_no++;
}
rsrc_no--;
if (rsrc_no == nr_of_rsrcs)
{ /* Error */
#ifdef MRG_DEBUG
printf("not found!\n");
#endif
return (caddr_t *) 0;
}
else
{
#ifdef MRG_DEBUG
printf("found at addr 0x%x -> 0x%x\n", &rsrc_handle[rsrc_no], rsrc_handle[rsrc_no]);
#endif
return (caddr_t *) &rsrc_handle[rsrc_no];
}
}
void
mrg_VBLQueue()
{
@ -281,7 +149,7 @@ mrg_VBLQueue()
} else
{
#if defined(MRG_DEBUG)
printf("mrg: mrg_VBLQueue: calling VBL task at 0x%x with VBLTask block at 0x%x\n",
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@- /* better save all registers! */
@ -297,7 +165,7 @@ mrg_VBLQueue()
if ( 0 == *((u_int16_t *)(vbltask + vblCount)) )
{
#if defined(MRG_DEBUG)
printf("mrg: mrg_VBLQueue: removing VBLTask block at 0x%x\n",
printf("mrg: mrg_VBLQueue: removing VBLTask block at %p\n",
vbltask);
#endif
*((u_int32_t *)(last_vbltask + qLink)) = *((u_int32_t *)(vbltask + qLink));
@ -329,6 +197,87 @@ mrg_init_stub_2()
panic("mrg: hit mrg_init_stub_2\n");
}
short
Count_Resources(u_int32_t rsrc_type)
{
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);
#endif
/*
* Return a Count of all the ROM Resouces of the requested type.
*/
if (ROMResourceMap == 0)
panic("Oops! Need ROM Resource Map ListHead address!\n");
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);
#endif
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);
#endif
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 NetBSD 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!\n");
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 to small!\n");
}
}
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!\n");
}
void
mrg_FixMul()
{
panic("Oops! Need ROM address of _FixMul for this system!\n");
}
void
mrg_1sec_timer_tick()
{
@ -547,11 +496,44 @@ mrg_StripAddress()
{
}
int
mrg_SetTrapAddress()
{
extern caddr_t mrg_OStraps[];
caddr_t ptr;
int trap_num;
asm(" movl a0, %0
movl d0, %1"
: "=g" (ptr), "=g" (trap_num));
#if defined(MRG_DEBUG)
printf("mrg: trap 0x%x set to 0x%lx\n", trap_num, (long)ptr);
#endif
mrg_OStraps[trap_num] = ptr;
/*
* If the Trap for Egret was changed, we'd better remember it!
*/
if (trap_num == 0x92) {
#if defined(MRG_DEBUG)
printf("mrg: reconfigured Egret address from 0x%lx to 0x%lx\n",
(long)jEgret, (long)ptr);
#endif
jEgret = (void (*))ptr;
}
return 0;
}
/*
* trap jump address tables (different per machine?)
* Can I just use the tables stored in the ROMs?
* *Is* there a table stored in the ROMs?
* (BTW, this table is initialized for Mac II.)
* We only initialize the A-Traps for the routines we have
* provided ourselves. The routines we will be trying to
* use out of the MacROMs will be initialized at run-time.
* I did this to make the code easier to follow and to keep
* from taking an unexpected side trip into the MacROMs on
* those systems we don't have fully decoded.
*/
caddr_t mrg_OStraps[256] = {
#ifdef __GNUC__
@ -563,16 +545,8 @@ caddr_t mrg_OStraps[256] = {
(caddr_t)mrg_GetPtrSize,
[0x2f] (caddr_t)mrg_PostEvent,
[0x3b] (caddr_t)mrg_Delay,
[0x47] (caddr_t)mrg_SetOSTrapAddress,
[0x47] (caddr_t)mrg_SetTrapAddress,
[0x55] (caddr_t)mrg_StripAddress,
[0x77] (caddr_t)0x40807778, /* CountADBs */
(caddr_t)0x40807792, /* GetIndADB */
(caddr_t)0x408077be, /* GetADBInfo */
(caddr_t)0x408077c4, /* SetADBInfo */
(caddr_t)0x40807704, /* ADBReInit */
(caddr_t)0x408072fa, /* ADBOp */
[0x85] 0, /* PMgrOp (not on II) */
[0x92] (caddr_t)0x40814800, /* Egret */
#else
#error "Using a GNU C extension."
#endif
@ -585,29 +559,6 @@ caddr_t mrg_ToolBoxtraps[1024] = {
[0x1af] (caddr_t)mrg_ResError,
};
int
mrg_SetOSTrapAddress()
{
int result = noErr;
u_int trapnumber;
u_int trapaddress;
u_int32_t trapword;
asm(" movl d1, %0
movl d0, %1
movl a0, %2"
: "=g" (trapword), "=g" (trapnumber), "=g" (trapaddress));
#if defined(MRG_SHOWTRAPS)
printf("mrg: SetOSTrapAddress(Trap: 0x%x, Address: 0x%8x)", trapnumber,
trapaddress);
#endif
mrg_OStraps[trapnumber] = (caddr_t) trapaddress;
return(result);
}
/*
* Handle a supervisor mode A-line trap.
*/
@ -632,16 +583,21 @@ mrg_aline_super(struct frame *frame)
danprint = 1;
#if defined(MRG_DEBUG)
printf(" wd 0x%x", trapword);
printf(" wd 0x%lx", (long)trapword);
#endif
isOStrap = ! TRAP_TOOLBOX(trapword);
trapnum = TRAP_NUM(trapword);
if (danprint)
{
/* Without these print statements, ADBReInit fails on IIsi */
printf(""); printf("");
}
if (danprint) {
/*
* Without these print statements, ADBReInit fails on IIsi
* It is unclear why--perhaps a compiler bug? delay()s do not
* work, nor does some assembly similar to the printf calls.
* A printf(""); is sufficient, but gcc -Wall is noisy about
* it, so I figured backspace is harmless enough...
*/
printf("\010"); printf("\010");
}
#if defined(MRG_DEBUG)
printf(" %s # 0x%x", isOStrap? "OS" :
@ -653,7 +609,7 @@ mrg_aline_super(struct frame *frame)
trapaddr = mrg_OStraps[trapnum];
#if defined(MRG_DEBUG)
printf(" addr 0x%x\n", trapaddr);
printf(" addr 0x%lx\n", (long)trapaddr);
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
@ -752,73 +708,6 @@ dumptrace()
#else
printf("mrg: no trace functionality enabled\n");
#endif
}
/* Set ROM Vectors */
void
mrg_setvectors(rom)
romvec_t *rom;
{
if (rom == NULL)
return; /* whoops! ROM vectors not defined! */
mrg_romident = rom->romident;
if (0 != mrg_ADBIntrPtr) {
mrg_romadbintr = mrg_ADBIntrPtr;
printf("mrg_setvectors: using ADBIntrPtr from booter: %p\n",
mrg_ADBIntrPtr);
} else
mrg_romadbintr = rom->adbintr;
mrg_rompmintr = rom->pmintr;
mrg_ADBAlternateInit = rom->ADBAlternateInit;
mrg_InitEgret = rom->InitEgret;
/*
* mrg_adbstore becomes ADBBase
*/
*((u_int32_t *)(mrg_adbstore + 0x130)) = (u_int32_t) rom->adb130intr;
jEgret = (void (*))0x40814800;
mrg_OStraps[0x77] = rom->CountADBs;
mrg_OStraps[0x78] = rom->GetIndADB;
mrg_OStraps[0x79] = rom->GetADBInfo;
mrg_OStraps[0x7a] = rom->SetADBInfo;
mrg_OStraps[0x7b] = rom->ADBReInit;
mrg_OStraps[0x7c] = rom->ADBOp;
mrg_OStraps[0x85] = rom->PMgrOp;
mrg_OStraps[0x51] = rom->ReadXPRam;
mrg_OStraps[0x38] = rom->WriteParam; /* WriteParam */
mrg_OStraps[0x3a] = rom->SetDateTime; /* SetDateTime */
mrg_OStraps[0x3f] = rom->InitUtil; /* InitUtil */
mrg_OStraps[0x51] = rom->ReadXPRam; /* ReadXPRam */
mrg_OStraps[0x52] = rom->WriteXPRam; /* WriteXPRam */
jClkNoMem = (void (*)) rom->jClkNoMem;
if (0 == jClkNoMem) {
printf("WARNING: don't have a value for jClkNoMem, please contact: walter@ghpc8.ihf.rwth-aachen.de\n");
printf("Can't read RTC without it. Using MacOS boot time.\n");
}
mrg_ToolBoxtraps[0x04d] = rom->FixDiv;
mrg_ToolBoxtraps[0x068] = rom->FixMul;
#if defined(MRG_DEBUG)
printf("mrg: ROM adbintr 0x%08x\n", mrg_romadbintr);
printf("mrg: ROM pmintr 0x%08x\n", mrg_rompmintr);
printf("mrg: OS trap 0x77 (CountADBs) = 0x%08x\n", mrg_OStraps[0x77]);
printf("mrg: OS trap 0x78 (GetIndADB) = 0x%08x\n", mrg_OStraps[0x78]);
printf("mrg: OS trap 0x79 (GetADBInfo) = 0x%08x\n", mrg_OStraps[0x79]);
printf("mrg: OS trap 0x7a (SetADBInfo) = 0x%08x\n", mrg_OStraps[0x7a]);
printf("mrg: OS trap 0x7b (ADBReInit) = 0x%08x\n", mrg_OStraps[0x7b]);
printf("mrg: OS trap 0x7c (ADBOp) = 0x%08x\n", mrg_OStraps[0x7c]);
printf("mrg: OS trap 0x85 (PMgrOp) = 0x%08x\n", mrg_OStraps[0x85]);
printf("mrg: ROM ADBAltInit 0x%08x\n", mrg_ADBAlternateInit);
printf("mrg: ROM InitEgret 0x%08x\n", mrg_InitEgret);
#endif
}
/* To find out if we're okay calling ROM vectors */
@ -835,15 +724,66 @@ extern volatile u_char *sccA;
void
mrg_init()
{
int i;
char *findername = "MacBSD FakeFinder";
w_build_resource_list(ROMBase, 0x00100000); /* search one MB */
int i;
#if defined(MRG_TEST)
caddr_t ptr;
short rcnt;
int sizeptr;
extern short mrg_ResErr;
caddr_t *handle;
#endif
VBLQueue = (u_int16_t) 0; /* No vertical blanking routines in the queue */
VBLQueue_head = (caddr_t) 0; /* Let's hope that this init happens
VBLQueue_tail = (caddr_t) 0; * before the RTC interrupts are enabled */
#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\n");
}
#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)));
}
#endif
if(mrg_romready()){
printf("mrg: '%s' ROM glue", mrg_romident);
@ -939,7 +879,7 @@ mrg_init()
#if defined(MRG_TEST)
printf("Allocating a pointer...\n");
ptr = (caddr_t)NewPtr(1024);
printf("Result is 0x%x.\n", ptr);
printf("Result is 0x%lx.\n", (long)ptr);
sizeptr = GetPtrSize((Ptr)ptr);
printf("Pointer size is %d\n", sizeptr);
printf("Freeing the pointer...\n");
@ -954,9 +894,9 @@ mrg_init()
printf("Getting error code...\n");
i = ResError();
printf("Result code (0xdeadbaaf): %x\n", i);
printf("Getting a Resource...\n");
handle = GetResource('ADBS', 2);
printf("Handle result from GetResource: 0x%x\n", handle);
printf("Getting an ADBS Resource...\n");
handle = GetResource(0x41244253, 2);
printf("Handle result from GetResource: 0x%lx\n", (long)handle);
printf("Getting error code...\n");
i = ResError();
printf("Result code (-192?) : %d\n", i);
@ -1083,60 +1023,167 @@ mrg_initadbintr()
}
}
#define IS_ROM_ADDR(addr) ( ((u_int) (addr)) > oldbase \
&& ((u_int) (addr)) < oldbase + ROMLEN)
/*
* NOTE: By eliminating the setvectors routine and moving it's function
* to here we only have to deal with re-locating MacOS Addresses
* once and all in one place.
*/
void
mrg_fixupROMBase(obase, nbase)
caddr_t obase;
caddr_t nbase;
{
int i;
u_int32_t temp, *p, oldbase, newbase;
u_int32_t oldbase, newbase;
romvec_t *rom;
oldbase = (u_int32_t) obase;
newbase = (u_int32_t) nbase;
for (i=0 ; i<256 ; i++)
if (IS_ROM_ADDR(mrg_OStraps[i])) {
temp = (u_int) mrg_OStraps[i];
temp = (temp - oldbase) + newbase;
mrg_OStraps[i] = (caddr_t) temp;
}
for (i=0 ; i<1024 ; i++)
if (IS_ROM_ADDR(mrg_ToolBoxtraps[i])) {
temp = (u_int) mrg_ToolBoxtraps[i];
temp = (temp - oldbase) + newbase;
mrg_ToolBoxtraps[i] = (caddr_t) temp;
}
p = (u_int32_t *) mrg_adbstore;
for (i=0 ; i<512/4 ; i++)
if (IS_ROM_ADDR(p[i]))
p[i] = (p[i] - oldbase) + newbase;
/*
* Grab the pointer to the Mac ROM Glue Vector table
*/
rom = mrg_MacOSROMVectors;
if (IS_ROM_ADDR(jEgret))
jEgret = (void (*)) ((((u_int) jEgret) - oldbase) + newbase);
if (rom == NULL)
return; /* whoops! ROM vectors not defined! */
if (IS_ROM_ADDR(mrg_romadbintr))
mrg_romadbintr = mrg_romadbintr - oldbase + newbase;
mrg_romident = rom->romident;
if (IS_ROM_ADDR(mrg_rompmintr))
mrg_rompmintr = mrg_rompmintr - oldbase + newbase;
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;
if (IS_ROM_ADDR(mrg_romident))
mrg_romident = mrg_romident - oldbase + newbase;
mrg_rompmintr = rom->pmintr == 0 ?
0 : rom->pmintr - oldbase + newbase;
mrg_ADBAlternateInit = rom->ADBAlternateInit == 0 ?
0 : rom->ADBAlternateInit - oldbase + newbase;
if (IS_ROM_ADDR(jClkNoMem))
jClkNoMem = jClkNoMem - oldbase + newbase;
/*
* mrg_adbstore becomes ADBBase
*/
*((u_int32_t *)(mrg_adbstore + 0x130)) = rom->adb130intr == 0 ?
0 : (u_int32_t) rom->adb130intr - oldbase + newbase;
if (IS_ROM_ADDR(mrg_ADBAlternateInit))
mrg_ADBAlternateInit = mrg_ADBAlternateInit - 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 (IS_ROM_ADDR(mrg_InitEgret))
mrg_InitEgret = mrg_InitEgret - oldbase + newbase;
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 (IS_ROM_ADDR(ADBReInit_JTBL))
ADBReInit_JTBL = ADBReInit_JTBL - oldbase + newbase;
}
if (rom->jClkNoMem == 0) {
printf("WARNING: don't have a value for jClkNoMem, please contac
t: 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
* is not currently used by NetBSD.
*/
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;
#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);
#endif
}
void
ADBAlternateInit(void)

View File

@ -1,4 +1,4 @@
/* $NetBSD: macrom.h,v 1.7 1996/05/05 06:18:39 briggs Exp $ */
/* $NetBSD: macrom.h,v 1.8 1996/05/14 04:01:01 briggs Exp $ */
/*-
* Copyright (C) 1994 Bradley A. Grantham
@ -143,14 +143,13 @@ Handle GetResource(
short theID);
short ResError(
void);
void mrg_CountResources(
void);
void mrg_GetIndResource(
void);
/* Trap management */
int mrg_SetOSTrapAddress(
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 */
@ -173,6 +172,14 @@ void dumptrace(void);
/* Stuff for configuring ROM Glue */
typedef struct rsrc_s {
u_int16_t unknown[4]; /* ???? */
u_int32_t next; /* pointer to next resoure in list */
u_int32_t body; /* pointer to resource body? */
u_int32_t name; /* resource name */
u_int16_t index; /* ???? */
} rsrc_t;
typedef struct romvec_s {
char *romident; /* just to print it out */
caddr_t adbintr; /* where is ADB interrupt */
@ -195,7 +202,10 @@ typedef struct romvec_s {
caddr_t WriteXPRam;
caddr_t jClkNoMem;
caddr_t ADBAlternateInit; /* more fundamental than ABDReInit */
caddr_t Egret;
caddr_t InitEgret; /* Set up Buffer for Egret routines */
caddr_t ADBReInit_JTBL;
caddr_t ROMResourceMap; /* Address of first Resource in linked list */
caddr_t FixDiv;
caddr_t FixMul;
} romvec_t;
@ -207,16 +217,12 @@ typedef struct romvec_s {
/* macrom.c */
void mrg_setvectors __P((romvec_t *rom_vectors));
int mrg_romready __P((void));
caddr_t *Get_Ind_Resource __P((u_int32_t, u_int16_t));
void mrg_initadbintr __P((void));
long mrg_adbintr __P((void));
long mrg_pmintr __P((void));
void mrg_fixupROMBase __P((caddr_t, caddr_t));
int mrg_Delay __P((void));
int is_resource __P((caddr_t));
int count_all_resources __P((caddr_t, u_int32_t));
void w_build_resource_list __P((caddr_t, u_int32_t));
int w_count_resources __P((u_int32_t));
caddr_t *w_get_ind_resource __P((u_int32_t, u_int16_t));
void mrg_VBLQueue __P((void));
void mrg_init_stub_1 __P((void));
void mrg_init_stub_2 __P((void));
@ -233,10 +239,13 @@ int mrg_DisposPtr __P((void));
int mrg_GetPtrSize __P((void));
int mrg_SetPtrSize __P((void));
int mrg_PostEvent __P((void));
int mrg_SetTrapAddress __P((void));
void mrg_StripAddress __P((void));
void mrg_aline_super __P((struct frame *));
void mrg_aline_user __P((void));
void mrg_init __P((void));
void mrg_FixDiv __P((void));
void mrg_FixMul __P((void));
/* machdep.c */
int mach_cputype __P((void));

View File

@ -1,4 +1,4 @@
/* $NetBSD: macromasm.s,v 1.9 1996/02/28 04:14:20 briggs Exp $ */
/* $NetBSD: macromasm.s,v 1.10 1996/05/14 04:01:04 briggs Exp $ */
/*-
* Copyright (C) 1994 Bradley A. Grantham
@ -357,40 +357,33 @@ LRE_enter:
function(mrg_CountResources)
/* WRU: 960120
* sp@(4) u_int32_t rsrc_type
* sp@(8) u_int16_t nr_of_rsrcs
*/
function(mrg_CountResources)
/* Original from WRU: 960120
* sp@(4) u_int32_t rsrc_type
* sp@(8) u_int16_t nr_of_rsrcs
*/
movl sp@(4), d0
movl d0, sp@-
jbsr _w_count_resources
addl #4, sp /* pop C params */
movw d0, sp@(8) /* store result */
movl sp@+, a0 /* get PC */
addl #4, sp /* pop params */
jra a0@ /* return */
jbsr _Count_Resources
addl #4, sp | pop C params
movw d0, sp@(8) | store result
pascalret(4)
function(mrg_GetIndResource)
/* WRU: 960120
* sp@(4) u_int16_t rsrc_index
* sp@(6) u_int32_t rsrc_type
* sp@(10) caddr_t *rsrc_handle
*/
function(mrg_GetIndResource)
/* Original from WRU: 960120
* sp@(4) u_int16_t rsrc_index
* sp@(6) u_int32_t rsrc_type
* sp@(10) caddr_t *rsrc_handle
*/
movl sp@(6), a0
clrl d0
movw sp@(4), d0
movl d0, sp@-
movl a0, sp@-
jbsr _w_get_ind_resource
addl #8, sp /* pop C params */
movl d0, sp@(10) /* store result */
movl sp@+, a0 /* get PC */
addl #6, sp /* pop params */
jra a0@ /* return */
jbsr _Get_Ind_Resource
addl #8, sp | pop C params
movl d0, sp@(10) | store result
pascalret(6)
/*
* I'd like to take a moment here to talk about the calling convention