38 |
|
#include "debug.h" |
39 |
|
|
40 |
|
|
41 |
– |
// Breakpoint (offset into ROM) |
42 |
– |
uint32 ROMBreakpoint = 0; // 0 = disabled, 0x2310 = CritError |
43 |
– |
|
41 |
|
// Global variables |
42 |
< |
uint32 UniversalInfo; // ROM offset of UniversalInfo |
43 |
< |
uint32 PutScrapPatch; // Mac address of PutScrap() patch |
42 |
> |
uint32 UniversalInfo; // ROM offset of UniversalInfo |
43 |
> |
uint32 PutScrapPatch; // Mac address of PutScrap() patch |
44 |
> |
uint32 ROMBreakpoint = 0; // ROM offset of breakpoint (0 = disabled, 0x2310 = CritError) |
45 |
> |
bool PrintROMInfo = false; // Flag: print ROM information in PatchROM() |
46 |
|
|
47 |
|
static uint32 sony_offset; // ROM offset of .Sony driver |
48 |
|
static uint32 serd_offset; // ROM offset of SERD resource (serial drivers) |
140 |
|
|
141 |
|
|
142 |
|
/* |
143 |
+ |
* Print ROM information to stream, |
144 |
+ |
*/ |
145 |
+ |
|
146 |
+ |
static void list_rom_resources(void) |
147 |
+ |
{ |
148 |
+ |
printf("ROM Resources:\n"); |
149 |
+ |
printf("Offset\t Type\tID\tSize\tName\n"); |
150 |
+ |
printf("------------------------------------------------\n"); |
151 |
+ |
|
152 |
+ |
uint32 lp = ROMBaseMac + ReadMacInt32(ROMBaseMac + 0x1a); |
153 |
+ |
uint32 rsrc_ptr = ReadMacInt32(lp); |
154 |
+ |
|
155 |
+ |
for (;;) { |
156 |
+ |
lp = ROMBaseMac + rsrc_ptr; |
157 |
+ |
uint32 data = ReadMacInt32(lp + 12); |
158 |
+ |
|
159 |
+ |
char name[32]; |
160 |
+ |
int name_len = ReadMacInt8(lp + 23), i; |
161 |
+ |
for (i=0; i<name_len; i++) |
162 |
+ |
name[i] = ReadMacInt8(lp + 24 + i); |
163 |
+ |
name[i] = 0; |
164 |
+ |
|
165 |
+ |
printf("%08x %c%c%c%c\t%d\t%d\t%s\n", data, ReadMacInt8(lp + 16), ReadMacInt8(lp + 17), ReadMacInt8(lp + 18), ReadMacInt8(lp + 19), ReadMacInt16(lp + 20), ReadMacInt32(ROMBaseMac + data - 8), name); |
166 |
+ |
|
167 |
+ |
rsrc_ptr = ReadMacInt32(lp + 8); |
168 |
+ |
if (!rsrc_ptr) |
169 |
+ |
break; |
170 |
+ |
} |
171 |
+ |
printf("\n"); |
172 |
+ |
} |
173 |
+ |
|
174 |
+ |
// Mapping of Model IDs to Model names |
175 |
+ |
struct mac_desc { |
176 |
+ |
char *name; |
177 |
+ |
int32 id; |
178 |
+ |
}; |
179 |
+ |
|
180 |
+ |
static mac_desc MacDesc[] = { |
181 |
+ |
{"Classic" , 1}, |
182 |
+ |
{"Mac XL" , 2}, |
183 |
+ |
{"Mac 512KE" , 3}, |
184 |
+ |
{"Mac Plus" , 4}, |
185 |
+ |
{"Mac SE" , 5}, |
186 |
+ |
{"Mac II" , 6}, |
187 |
+ |
{"Mac IIx" , 7}, |
188 |
+ |
{"Mac IIcx" , 8}, |
189 |
+ |
{"Mac SE/030" , 9}, |
190 |
+ |
{"Mac Portable" , 10}, |
191 |
+ |
{"Mac IIci" , 11}, |
192 |
+ |
{"Mac IIfx" , 13}, |
193 |
+ |
{"Mac Classic" , 17}, |
194 |
+ |
{"Mac IIsi" , 18}, |
195 |
+ |
{"Mac LC" , 19}, |
196 |
+ |
{"Quadra 900" , 20}, |
197 |
+ |
{"PowerBook 170" , 21}, |
198 |
+ |
{"Quadra 700" , 22}, |
199 |
+ |
{"Classic II" , 23}, |
200 |
+ |
{"PowerBook 100" , 24}, |
201 |
+ |
{"PowerBook 140" , 25}, |
202 |
+ |
{"Quadra 950" , 26}, |
203 |
+ |
{"Mac LCIII/Performa 450", 27}, |
204 |
+ |
{"PowerBook Duo 210" , 29}, |
205 |
+ |
{"Centris 650" , 30}, |
206 |
+ |
{"PowerBook Duo 230" , 32}, |
207 |
+ |
{"PowerBook 180" , 33}, |
208 |
+ |
{"PowerBook 160" , 34}, |
209 |
+ |
{"Quadra 800" , 35}, |
210 |
+ |
{"Quadra 650" , 36}, |
211 |
+ |
{"Mac LCII" , 37}, |
212 |
+ |
{"PowerBook Duo 250" , 38}, |
213 |
+ |
{"Mac IIvi" , 44}, |
214 |
+ |
{"Mac IIvm/Performa 600", 45}, |
215 |
+ |
{"Mac IIvx" , 48}, |
216 |
+ |
{"Color Classic/Performa 250", 49}, |
217 |
+ |
{"PowerBook 165c" , 50}, |
218 |
+ |
{"Centris 610" , 52}, |
219 |
+ |
{"Quadra 610" , 53}, |
220 |
+ |
{"PowerBook 145" , 54}, |
221 |
+ |
{"Mac LC520" , 56}, |
222 |
+ |
{"Quadra/Centris 660AV" , 60}, |
223 |
+ |
{"Performa 46x" , 62}, |
224 |
+ |
{"PowerBook 180c" , 71}, |
225 |
+ |
{"PowerBook 520/520c/540/540c", 72}, |
226 |
+ |
{"PowerBook Duo 270c" , 77}, |
227 |
+ |
{"Quadra 840AV" , 78}, |
228 |
+ |
{"Performa 550" , 80}, |
229 |
+ |
{"PowerBook 165" , 84}, |
230 |
+ |
{"PowerBook 190" , 85}, |
231 |
+ |
{"Mac TV" , 88}, |
232 |
+ |
{"Mac LC475/Performa 47x", 89}, |
233 |
+ |
{"Mac LC575" , 92}, |
234 |
+ |
{"Quadra 605" , 94}, |
235 |
+ |
{"Quadra 630" , 98}, |
236 |
+ |
{"Mac LC580" , 99}, |
237 |
+ |
{"PowerBook Duo 280" , 102}, |
238 |
+ |
{"PowerBook Duo 280c" , 103}, |
239 |
+ |
{"PowerBook 150" , 115}, |
240 |
+ |
{"unknown", -1} |
241 |
+ |
}; |
242 |
+ |
|
243 |
+ |
static void print_universal_info(uint32 info) |
244 |
+ |
{ |
245 |
+ |
uint8 id = ReadMacInt8(info + 18); |
246 |
+ |
uint16 hwcfg = ReadMacInt16(info + 16); |
247 |
+ |
uint16 rom85 = ReadMacInt16(info + 20); |
248 |
+ |
|
249 |
+ |
// Find model name |
250 |
+ |
char *name = "unknown"; |
251 |
+ |
for (int i=0; MacDesc[i].id >= 0; i++) |
252 |
+ |
if (MacDesc[i].id == id + 6) { |
253 |
+ |
name = MacDesc[i].name; |
254 |
+ |
break; |
255 |
+ |
} |
256 |
+ |
|
257 |
+ |
printf("%08x %02x\t%04x\t%04x\t%s\n", info - ROMBaseMac, id, hwcfg, rom85, name); |
258 |
+ |
} |
259 |
+ |
|
260 |
+ |
static void list_universal_infos(void) |
261 |
+ |
{ |
262 |
+ |
uint32 ofs = 0x3000; |
263 |
+ |
for (int i=0; i<0x2000; i+=2, ofs+=2) |
264 |
+ |
if (ReadMacInt32(ROMBaseMac + ofs) == 0xdc000505) { |
265 |
+ |
ofs -= 16; |
266 |
+ |
uint32 q; |
267 |
+ |
for (q=ofs; q > 0 && ReadMacInt32(ROMBaseMac + q) != ofs - q; q-=4) ; |
268 |
+ |
if (q > 0) { |
269 |
+ |
printf("Universal Table at %08x:\n", q); |
270 |
+ |
printf("Offset\t ID\tHWCfg\tROM85\tModel\n"); |
271 |
+ |
printf("------------------------------------------------\n"); |
272 |
+ |
while (ofs = ReadMacInt32(ROMBaseMac + q)) { |
273 |
+ |
print_universal_info(ROMBaseMac + ofs + q); |
274 |
+ |
q += 4; |
275 |
+ |
} |
276 |
+ |
} |
277 |
+ |
break; |
278 |
+ |
} |
279 |
+ |
printf("\n"); |
280 |
+ |
} |
281 |
+ |
|
282 |
+ |
static void print_rom_info(void) |
283 |
+ |
{ |
284 |
+ |
printf("\nROM Info:\n"); |
285 |
+ |
printf("Checksum : %08x\n", ReadMacInt32(ROMBaseMac)); |
286 |
+ |
printf("Version : %04x\n", ROMVersion); |
287 |
+ |
printf("Sub Version : %04x\n", ReadMacInt16(ROMBaseMac + 18)); |
288 |
+ |
printf("Resource Map: %08x\n", ReadMacInt32(ROMBaseMac + 26)); |
289 |
+ |
printf("Trap Tables : %08x\n\n", ReadMacInt32(ROMBaseMac + 34)); |
290 |
+ |
if (ROMVersion == ROM_VERSION_32) { |
291 |
+ |
list_rom_resources(); |
292 |
+ |
list_universal_infos(); |
293 |
+ |
} |
294 |
+ |
} |
295 |
+ |
|
296 |
+ |
|
297 |
+ |
/* |
298 |
|
* Driver stubs |
299 |
|
*/ |
300 |
|
|
1596 |
|
|
1597 |
|
bool PatchROM(void) |
1598 |
|
{ |
1599 |
< |
// Print ROM info |
1600 |
< |
D(bug("ROM Info:\n")); |
1601 |
< |
D(bug("Checksum: %08lx\n", ReadMacInt32(ROMBaseMac))); |
1448 |
< |
D(bug("Version: %04x\n", ROMVersion)); |
1449 |
< |
D(bug("Sub Version: %04x\n", ReadMacInt16(ROMBaseMac + 18))); |
1599 |
> |
// Print some information about the ROM |
1600 |
> |
if (PrintROMInfo) |
1601 |
> |
print_rom_info(); |
1602 |
|
|
1603 |
|
// Patch ROM depending on version |
1604 |
|
switch (ROMVersion) { |