--- BasiliskII/src/rom_patches.cpp 1999/10/26 16:28:27 1.10 +++ BasiliskII/src/rom_patches.cpp 1999/10/27 16:59:38 1.11 @@ -38,12 +38,11 @@ #include "debug.h" -// Breakpoint (offset into ROM) -uint32 ROMBreakpoint = 0; // 0 = disabled, 0x2310 = CritError - // Global variables -uint32 UniversalInfo; // ROM offset of UniversalInfo -uint32 PutScrapPatch; // Mac address of PutScrap() patch +uint32 UniversalInfo; // ROM offset of UniversalInfo +uint32 PutScrapPatch; // Mac address of PutScrap() patch +uint32 ROMBreakpoint = 0; // ROM offset of breakpoint (0 = disabled, 0x2310 = CritError) +bool PrintROMInfo = false; // Flag: print ROM information in PatchROM() static uint32 sony_offset; // ROM offset of .Sony driver static uint32 serd_offset; // ROM offset of SERD resource (serial drivers) @@ -141,6 +140,161 @@ again: /* + * Print ROM information to stream, + */ + +static void list_rom_resources(void) +{ + printf("ROM Resources:\n"); + printf("Offset\t Type\tID\tSize\tName\n"); + printf("------------------------------------------------\n"); + + uint32 lp = ROMBaseMac + ReadMacInt32(ROMBaseMac + 0x1a); + uint32 rsrc_ptr = ReadMacInt32(lp); + + for (;;) { + lp = ROMBaseMac + rsrc_ptr; + uint32 data = ReadMacInt32(lp + 12); + + char name[32]; + int name_len = ReadMacInt8(lp + 23), i; + for (i=0; i= 0; i++) + if (MacDesc[i].id == id + 6) { + name = MacDesc[i].name; + break; + } + + printf("%08x %02x\t%04x\t%04x\t%s\n", info - ROMBaseMac, id, hwcfg, rom85, name); +} + +static void list_universal_infos(void) +{ + uint32 ofs = 0x3000; + for (int i=0; i<0x2000; i+=2, ofs+=2) + if (ReadMacInt32(ROMBaseMac + ofs) == 0xdc000505) { + ofs -= 16; + uint32 q; + for (q=ofs; q > 0 && ReadMacInt32(ROMBaseMac + q) != ofs - q; q-=4) ; + if (q > 0) { + printf("Universal Table at %08x:\n", q); + printf("Offset\t ID\tHWCfg\tROM85\tModel\n"); + printf("------------------------------------------------\n"); + while (ofs = ReadMacInt32(ROMBaseMac + q)) { + print_universal_info(ROMBaseMac + ofs + q); + q += 4; + } + } + break; + } + printf("\n"); +} + +static void print_rom_info(void) +{ + printf("\nROM Info:\n"); + printf("Checksum : %08x\n", ReadMacInt32(ROMBaseMac)); + printf("Version : %04x\n", ROMVersion); + printf("Sub Version : %04x\n", ReadMacInt16(ROMBaseMac + 18)); + printf("Resource Map: %08x\n", ReadMacInt32(ROMBaseMac + 26)); + printf("Trap Tables : %08x\n\n", ReadMacInt32(ROMBaseMac + 34)); + if (ROMVersion == ROM_VERSION_32) { + list_rom_resources(); + list_universal_infos(); + } +} + + +/* * Driver stubs */ @@ -1442,11 +1596,9 @@ static bool patch_rom_32(void) bool PatchROM(void) { - // Print ROM info - D(bug("ROM Info:\n")); - D(bug("Checksum: %08lx\n", ReadMacInt32(ROMBaseMac))); - D(bug("Version: %04x\n", ROMVersion)); - D(bug("Sub Version: %04x\n", ReadMacInt16(ROMBaseMac + 18))); + // Print some information about the ROM + if (PrintROMInfo) + print_rom_info(); // Patch ROM depending on version switch (ROMVersion) {