ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/SheepShaver/src/rsrc_patches.cpp
(Generate patch)

Comparing SheepShaver/src/rsrc_patches.cpp (file contents):
Revision 1.8 by gbeauche, 2003-12-27T09:08:51Z vs.
Revision 1.13 by gbeauche, 2004-12-19T09:26:30Z

# Line 1 | Line 1
1   /*
2   *  rsrc_patches.cpp - Resource patches
3   *
4 < *  SheepShaver (C) 1997-2002 Christian Bauer and Marc Hellwig
4 > *  SheepShaver (C) 1997-2004 Christian Bauer and Marc Hellwig
5   *
6   *  This program is free software; you can redistribute it and/or modify
7   *  it under the terms of the GNU General Public License as published by
# Line 117 | Line 117 | void CheckLoad(uint32 type, int16 id, ui
117          D(bug("vCheckLoad %c%c%c%c (%08x) ID %d, data %p, size %d\n", type >> 24, (type >> 16) & 0xff, (type >> 8) & 0xff, type & 0xff, type, id, p, size));
118  
119          // Don't modify resources in ROM
120 <        if ((uintptr)p >= ROM_BASE && (uintptr)p <= (ROM_BASE + ROM_SIZE))
120 >        if ((uintptr)p >= (uintptr)ROMBaseHost && (uintptr)p <= (uintptr)(ROMBaseHost + ROM_SIZE))
121                  return;
122  
123          if (type == FOURCC('b','o','o','t') && id == 3) {
# Line 136 | Line 136 | void CheckLoad(uint32 type, int16 id, ui
136                                  // Check when ntrb 17 is installed (for native Resource Manager patch) (7.6, 7.6.1, 8.0, 8.1)
137                                  p[7] = htons(M68K_EMUL_OP_NTRB_17_PATCH);
138                                  D(bug(" patch 3 applied\n"));
139 <                        } else if (PM(0,0x3f2a) && PM(1,0x0006) && PM(2,0x3f2a) && PM(3,0x0002) && PM(4,0x61ff)) {
139 >                        } else if (PM(0,0x3f2a) && PM(1,0x0006) && PM(2,0x3f2a) && PM(3,0x0002) && PM(4,0x61ff) && PM(8,0x245f)) {
140                                  // Check when ntrb 17 is installed (for native Resource Manager patch) (8.5, 8.6)
141                                  p[8] = htons(M68K_EMUL_OP_NTRB_17_PATCH);
142                                  D(bug(" patch 4 applied\n"));
143 +                        } else if (PM(0,0x3f2a) && PM(1,0x0006) && PM(2,0x3f2a) && PM(3,0x0002) && PM(4,0x61ff) && PM(7,0x301f)) {
144 +                                // Check when ntrb 17 is installed (for native Resource Manager patch) (9.0)
145 +                                p[7] = htons(M68K_EMUL_OP_NTRB_17_PATCH4);
146 +                                p[8] = htons(ntohs(p[8]) & 0xf0ff); // bra
147 +                                D(bug(" patch 8 applied\n"));
148                          } else if (PM(0,0x0c39) && PM(1,0x0001) && PM(2,0xf800) && PM(3,0x0008) && PM(4,0x6f00)) {
149                                  // Don't read from 0xf8000008 (8.5 with Zanzibar ROM, 8.6)
150                                  p[0] = htons(M68K_NOP);
# Line 179 | Line 184 | void CheckLoad(uint32 type, int16 id, ui
184                          D(bug(" patch 1 applied\n"));
185                  }
186  
187 +        } else if (type == FOURCC('p','t','c','h') && id == 156) {
188 +                D(bug("ptch 156 found\n"));
189 +                size >>= 1;
190 +                while (size--) {
191 +                        if (PM(0,0x4e56) && PM(1,0xfffa) && PM(2,0x48e7) && PM(3,0x1f18) && PM(4,0x7800) && PM(5,0x267c) && PM(6,0x6900) && PM(7,0x0000)) {
192 +                                // Don't call FE0A opcode (9.0)
193 +                                p[0] = htons(0x7000);           // moveq #0,d0
194 +                                p[1] = htons(M68K_RTS);
195 +                                D(bug(" patch 1 applied\n"));
196 +                                break;
197 +                        }
198 +                        p++;
199 +                }
200 +
201          } else if (type == FOURCC('p','t','c','h') && id == 420) {
202                  D(bug("ptch 420 found\n"));
203                  size >>= 1;
# Line 432 | Line 451 | void CheckLoad(uint32 type, int16 id, ui
451                          p[(0x378 + 0x6c0) >> 1] = htons(0x4e80);                // blr
452                          p[(0x37a + 0x6c0) >> 1] = htons(0x0020);
453                          D(bug(" patch 2 applied\n"));
454 +                } else if (p[(0x374 + 0x510) >> 1] == htons(0x7c08) && p[(0x376 + 0x510) >> 1] == htons(0x02a6)) {
455 +                        // Don't overwrite our serial drivers (9.0)
456 +                        p[(0x374 + 0x510) >> 1] = htons(0x4e80);                // blr
457 +                        p[(0x376 + 0x510) >> 1] = htons(0x0020);
458 +                        D(bug(" patch 3 applied\n"));
459                  }
460  
461          } else if (type == FOURCC('c','i','t','t') && id == 45) {
# Line 449 | Line 473 | void CheckLoad(uint32 type, int16 id, ui
473  
474          } else if (type == FOURCC('t','h','n','g')) {
475                  // Collect info about used audio sifters
476 <                uint32 thing = (uintptr)p;
476 >                uint32 thing = Host2MacAddr((uint8 *)p);
477                  uint32 c_type = ReadMacInt32(thing);
478                  uint32 sub_type = ReadMacInt32(thing + 4);
479                  if (c_type == FOURCC('s','d','e','v') && sub_type == FOURCC('s','i','n','g')) {
# Line 507 | Line 531 | void CheckLoad(uint32 type, int16 id, ui
531                          p16[1] = htons(M68K_RTS);
532                          D(bug(" patch 1 applied\n"));
533                  }
534 +
535 +        } else if (type == FOURCC('N','O','b','j') && id == 100) {
536 +                D(bug("NObj 100 found\n"));
537 +
538 +                // Don't access VIA registers in MacBench 5.0
539 +                static const uint8 dat1[] = {0x7c, 0x08, 0x02, 0xa6, 0xbf, 0x01, 0xff, 0xe0, 0x90, 0x01, 0x00, 0x08};
540 +                base = find_rsrc_data((uint8 *)p, size, dat1, sizeof(dat1));
541 +                if (base) {
542 +                        p[(base + 0x00) >> 1] = htons(0x3860);          // li r3,0
543 +                        p[(base + 0x02) >> 1] = htons(0x0000);
544 +                        p[(base + 0x04) >> 1] = htons(0x4e80);          // blr
545 +                        p[(base + 0x06) >> 1] = htons(0x0020);
546 +                        D(bug(" patch 1 applied\n"));
547 +                }
548 +                static const uint8 dat2[] = {0x7c, 0x6c, 0x1b, 0x78, 0x7c, 0x8b, 0x23, 0x78, 0x38, 0xc0, 0x3f, 0xfd};
549 +                base = find_rsrc_data((uint8 *)p, size, dat2, sizeof(dat2));
550 +                if (base) {
551 +                        p[(base + 0x00) >> 1] = htons(0x3860);          // li r3,0
552 +                        p[(base + 0x02) >> 1] = htons(0x0000);
553 +                        p[(base + 0x04) >> 1] = htons(0x4e80);          // blr
554 +                        p[(base + 0x06) >> 1] = htons(0x0020);
555 +                        D(bug(" patch 2 applied\n"));
556 +                }
557          }
558   }
559  
# Line 529 | Line 576 | void check_load_invoc(uint32 type, int16
576                  return;
577          uint32 size = ReadMacInt32(p - 2 * 4) & 0xffffff;
578  
579 <        CheckLoad(type, id, (uint16 *)p, size);
579 >        CheckLoad(type, id, (uint16 *)Mac2HostAddr(p), size);
580   }
581  
582   #ifdef __BEOS__
# Line 714 | Line 761 | void PatchNativeResourceManager(void)
761          uint32 upp = ReadMacInt32(0x1480);
762          if ((upp & 0xffc00000) == ROM_BASE)
763                  return;
764 <        uint32 *tvec = (uint32 *)ReadMacInt32(upp + 5 * 4);
765 <        D(bug(" GetResource() entry %08x, TOC %08x\n", ntohl(tvec[0]), ntohl(tvec[1])));
766 <        *(uint32 *)XLM_RES_LIB_TOC = tvec[1];
767 <        *(uint32 *)XLM_GET_RESOURCE = tvec[0];
764 >        uint32 tvec = ReadMacInt32(upp + 5 * 4);
765 >        D(bug(" GetResource() entry %08x, TOC %08x\n", ReadMacInt32(tvec), ReadMacInt32(tvec + 4)));
766 >        WriteMacInt32(XLM_RES_LIB_TOC, ReadMacInt32(tvec + 4));
767 >        WriteMacInt32(XLM_GET_RESOURCE, ReadMacInt32(tvec));
768   #if EMULATED_PPC
769 <        tvec[0] = htonl(NativeFunction(NATIVE_GET_RESOURCE));
769 >        WriteMacInt32(tvec, NativeFunction(NATIVE_GET_RESOURCE));
770   #else
771   #ifdef __BEOS__
772          uint32 *tvec2 = (uint32 *)get_resource;
773 <        tvec[0] = tvec2[0];
774 <        tvec[1] = tvec2[1];
773 >        WriteMacInt32(tvec, tvec2[0]);
774 >        WriteMacInt32(tvec + 4, tvec2[1]);
775   #else
776 <        tvec[0] = (uint32)get_resource;
776 >        WriteMacInt32(tvec, (uint32)get_resource);
777   #endif
778   #endif
779  
780          // Patch native Get1Resource()
781          upp = ReadMacInt32(0x0e7c);
782 <        tvec = (uint32 *)ReadMacInt32(upp + 5 * 4);
783 <        D(bug(" Get1Resource() entry %08x, TOC %08x\n", ntohl(tvec[0]), ntohl(tvec[1])));
784 <        *(uint32 *)XLM_GET_1_RESOURCE = tvec[0];
782 >        tvec = ReadMacInt32(upp + 5 * 4);
783 >        D(bug(" Get1Resource() entry %08x, TOC %08x\n", ReadMacInt32(tvec), ReadMacInt32(tvec + 4)));
784 >        WriteMacInt32(XLM_GET_1_RESOURCE, ReadMacInt32(tvec));
785   #if EMULATED_PPC
786 <        tvec[0] = htonl(NativeFunction(NATIVE_GET_1_RESOURCE));
786 >        WriteMacInt32(tvec, NativeFunction(NATIVE_GET_1_RESOURCE));
787   #else
788   #ifdef __BEOS__
789          tvec2 = (uint32 *)get_1_resource;
790 <        tvec[0] = tvec2[0];
791 <        tvec[1] = tvec2[1];
790 >        WriteMacInt32(tvec, tvec2[0]);
791 >        WriteMacInt32(tvec + 4, tvec2[1]);
792   #else
793 <        tvec[0] = (uint32)get_1_resource;
793 >        WriteMacInt32(tvec, (uint32)get_1_resource);
794   #endif
795   #endif
796  
797          // Patch native GetIndResource()
798          upp = ReadMacInt32(0x1474);
799 <        tvec = (uint32 *)ReadMacInt32(upp + 5 * 4);
800 <        D(bug(" GetIndResource() entry %08x, TOC %08x\n", ntohl(tvec[0]), ntohl(tvec[1])));
801 <        *(uint32 *)XLM_GET_IND_RESOURCE = tvec[0];
799 >        tvec = ReadMacInt32(upp + 5 * 4);
800 >        D(bug(" GetIndResource() entry %08x, TOC %08x\n", ReadMacInt32(tvec), ReadMacInt32(tvec + 4)));
801 >        WriteMacInt32(XLM_GET_IND_RESOURCE, ReadMacInt32(tvec));
802   #if EMULATED_PPC
803 <        tvec[0] = htonl(NativeFunction(NATIVE_GET_IND_RESOURCE));
803 >        WriteMacInt32(tvec, NativeFunction(NATIVE_GET_IND_RESOURCE));
804   #else
805   #ifdef __BEOS__
806          tvec2 = (uint32 *)get_ind_resource;
807 <        tvec[0] = tvec2[0];
808 <        tvec[1] = tvec2[1];
807 >        WriteMacInt32(tvec, tvec2[0]);
808 >        WriteMacInt32(tvec + 4, tvec2[1]);
809   #else
810 <        tvec[0] = (uint32)get_ind_resource;
810 >        WriteMacInt32(tvec, (uint32)get_ind_resource);
811   #endif
812   #endif
813  
814          // Patch native Get1IndResource()
815          upp = ReadMacInt32(0x0e38);
816 <        tvec = (uint32 *)ReadMacInt32(upp + 5 * 4);
817 <        D(bug(" Get1IndResource() entry %08x, TOC %08x\n", ntohl(tvec[0]), ntohl(tvec[1])));
818 <        *(uint32 *)XLM_GET_1_IND_RESOURCE = tvec[0];
816 >        tvec = ReadMacInt32(upp + 5 * 4);
817 >        D(bug(" Get1IndResource() entry %08x, TOC %08x\n", ReadMacInt32(tvec), ReadMacInt32(tvec + 4)));
818 >        WriteMacInt32(XLM_GET_1_IND_RESOURCE, ReadMacInt32(tvec));
819   #if EMULATED_PPC
820 <        tvec[0] = htonl(NativeFunction(NATIVE_GET_1_IND_RESOURCE));
820 >        WriteMacInt32(tvec, NativeFunction(NATIVE_GET_1_IND_RESOURCE));
821   #else
822   #ifdef __BEOS__
823          tvec2 = (uint32 *)get_1_ind_resource;
824 <        tvec[0] = tvec2[0];
825 <        tvec[1] = tvec2[1];
824 >        WriteMacInt32(tvec, tvec2[0]);
825 >        WriteMacInt32(tvec + 4, tvec2[1]);
826   #else
827 <        tvec[0] = (uint32)get_1_ind_resource;
827 >        WriteMacInt32(tvec, (uint32)get_1_ind_resource);
828   #endif
829   #endif
830  
831          // Patch native RGetResource()
832          upp = ReadMacInt32(0x0e30);
833 <        tvec = (uint32 *)ReadMacInt32(upp + 5 * 4);
834 <        D(bug(" RGetResource() entry %08x, TOC %08x\n", ntohl(tvec[0]), ntohl(tvec[1])));
835 <        *(uint32 *)XLM_R_GET_RESOURCE = tvec[0];
833 >        tvec = ReadMacInt32(upp + 5 * 4);
834 >        D(bug(" RGetResource() entry %08x, TOC %08x\n", ReadMacInt32(tvec), ReadMacInt32(tvec + 4)));
835 >        WriteMacInt32(XLM_R_GET_RESOURCE, ReadMacInt32(tvec));
836   #if EMULATED_PPC
837 <        tvec[0] = htonl(NativeFunction(NATIVE_R_GET_RESOURCE));
837 >        WriteMacInt32(tvec, NativeFunction(NATIVE_R_GET_RESOURCE));
838   #else
839   #ifdef __BEOS__
840          tvec2 = (uint32 *)r_get_resource;
841 <        tvec[0] = tvec2[0];
842 <        tvec[1] = tvec2[1];
841 >        WriteMacInt32(tvec, tvec2[0]);
842 >        WriteMacInt32(tvec + 4, tvec2[1]);
843   #else
844 <        tvec[0] = (uint32)r_get_resource;
844 >        WriteMacInt32(tvec, (uint32)r_get_resource);
845   #endif
846   #endif
847   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines