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.10 by gbeauche, 2004-01-26T22:04:01Z vs.
Revision 1.14 by gbeauche, 2005-01-30T17:39:44Z

# 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 530 | Line 554 | void CheckLoad(uint32 type, int16 id, ui
554                          p[(base + 0x06) >> 1] = htons(0x0020);
555                          D(bug(" patch 2 applied\n"));
556                  }
557 +
558 +        } else if (type == FOURCC('C','O','D','E') && id == 27 && size == 25024) {
559 +                D(bug("CODE 27 found [Apple Personal Diagnostics]\n"));
560 +
561 +                // Don't access FCBs directly in Apple Personal Diagnostics (MacOS 9)
562 +                // FIXME: this should not be called in the first place, use UTResolveFCB?
563 +                static const uint8 dat[] = {0x2d, 0x78, 0x03, 0x4e, 0xff, 0xf8, 0x20, 0x6e, 0xff, 0xf8};
564 +                base = find_rsrc_data((uint8 *)p, size, dat, sizeof(dat));
565 +                if (base
566 +                        && ReadMacInt16(0x3f6) == 4 /* FSFCBLen */
567 +                        && p[(base + 0x1a) >> 1] == htons(0x605e)
568 +                        && p[(base + 0x80) >> 1] == htons(0x7000))
569 +                {
570 +                        p[(base + 0x1a) >> 1] = htons(0x6064);
571 +                        D(bug(" patch1 applied\n"));
572 +                }
573          }
574   }
575  
# Line 552 | Line 592 | void check_load_invoc(uint32 type, int16
592                  return;
593          uint32 size = ReadMacInt32(p - 2 * 4) & 0xffffff;
594  
595 <        CheckLoad(type, id, (uint16 *)p, size);
595 >        CheckLoad(type, id, (uint16 *)Mac2HostAddr(p), size);
596   }
597  
598   #ifdef __BEOS__
# Line 737 | Line 777 | void PatchNativeResourceManager(void)
777          uint32 upp = ReadMacInt32(0x1480);
778          if ((upp & 0xffc00000) == ROM_BASE)
779                  return;
780 <        uint32 *tvec = (uint32 *)ReadMacInt32(upp + 5 * 4);
781 <        D(bug(" GetResource() entry %08x, TOC %08x\n", ntohl(tvec[0]), ntohl(tvec[1])));
782 <        *(uint32 *)XLM_RES_LIB_TOC = tvec[1];
783 <        *(uint32 *)XLM_GET_RESOURCE = tvec[0];
780 >        uint32 tvec = ReadMacInt32(upp + 5 * 4);
781 >        D(bug(" GetResource() entry %08x, TOC %08x\n", ReadMacInt32(tvec), ReadMacInt32(tvec + 4)));
782 >        WriteMacInt32(XLM_RES_LIB_TOC, ReadMacInt32(tvec + 4));
783 >        WriteMacInt32(XLM_GET_RESOURCE, ReadMacInt32(tvec));
784   #if EMULATED_PPC
785 <        tvec[0] = htonl(NativeFunction(NATIVE_GET_RESOURCE));
785 >        WriteMacInt32(tvec, NativeFunction(NATIVE_GET_RESOURCE));
786   #else
787   #ifdef __BEOS__
788          uint32 *tvec2 = (uint32 *)get_resource;
789 <        tvec[0] = tvec2[0];
790 <        tvec[1] = tvec2[1];
789 >        WriteMacInt32(tvec, tvec2[0]);
790 >        WriteMacInt32(tvec + 4, tvec2[1]);
791   #else
792 <        tvec[0] = (uint32)get_resource;
792 >        WriteMacInt32(tvec, (uint32)get_resource);
793   #endif
794   #endif
795  
796          // Patch native Get1Resource()
797          upp = ReadMacInt32(0x0e7c);
798 <        tvec = (uint32 *)ReadMacInt32(upp + 5 * 4);
799 <        D(bug(" Get1Resource() entry %08x, TOC %08x\n", ntohl(tvec[0]), ntohl(tvec[1])));
800 <        *(uint32 *)XLM_GET_1_RESOURCE = tvec[0];
798 >        tvec = ReadMacInt32(upp + 5 * 4);
799 >        D(bug(" Get1Resource() entry %08x, TOC %08x\n", ReadMacInt32(tvec), ReadMacInt32(tvec + 4)));
800 >        WriteMacInt32(XLM_GET_1_RESOURCE, ReadMacInt32(tvec));
801   #if EMULATED_PPC
802 <        tvec[0] = htonl(NativeFunction(NATIVE_GET_1_RESOURCE));
802 >        WriteMacInt32(tvec, NativeFunction(NATIVE_GET_1_RESOURCE));
803   #else
804   #ifdef __BEOS__
805          tvec2 = (uint32 *)get_1_resource;
806 <        tvec[0] = tvec2[0];
807 <        tvec[1] = tvec2[1];
806 >        WriteMacInt32(tvec, tvec2[0]);
807 >        WriteMacInt32(tvec + 4, tvec2[1]);
808   #else
809 <        tvec[0] = (uint32)get_1_resource;
809 >        WriteMacInt32(tvec, (uint32)get_1_resource);
810   #endif
811   #endif
812  
813          // Patch native GetIndResource()
814          upp = ReadMacInt32(0x1474);
815 <        tvec = (uint32 *)ReadMacInt32(upp + 5 * 4);
816 <        D(bug(" GetIndResource() entry %08x, TOC %08x\n", ntohl(tvec[0]), ntohl(tvec[1])));
817 <        *(uint32 *)XLM_GET_IND_RESOURCE = tvec[0];
815 >        tvec = ReadMacInt32(upp + 5 * 4);
816 >        D(bug(" GetIndResource() entry %08x, TOC %08x\n", ReadMacInt32(tvec), ReadMacInt32(tvec + 4)));
817 >        WriteMacInt32(XLM_GET_IND_RESOURCE, ReadMacInt32(tvec));
818   #if EMULATED_PPC
819 <        tvec[0] = htonl(NativeFunction(NATIVE_GET_IND_RESOURCE));
819 >        WriteMacInt32(tvec, NativeFunction(NATIVE_GET_IND_RESOURCE));
820   #else
821   #ifdef __BEOS__
822          tvec2 = (uint32 *)get_ind_resource;
823 <        tvec[0] = tvec2[0];
824 <        tvec[1] = tvec2[1];
823 >        WriteMacInt32(tvec, tvec2[0]);
824 >        WriteMacInt32(tvec + 4, tvec2[1]);
825   #else
826 <        tvec[0] = (uint32)get_ind_resource;
826 >        WriteMacInt32(tvec, (uint32)get_ind_resource);
827   #endif
828   #endif
829  
830          // Patch native Get1IndResource()
831          upp = ReadMacInt32(0x0e38);
832 <        tvec = (uint32 *)ReadMacInt32(upp + 5 * 4);
833 <        D(bug(" Get1IndResource() entry %08x, TOC %08x\n", ntohl(tvec[0]), ntohl(tvec[1])));
834 <        *(uint32 *)XLM_GET_1_IND_RESOURCE = tvec[0];
832 >        tvec = ReadMacInt32(upp + 5 * 4);
833 >        D(bug(" Get1IndResource() entry %08x, TOC %08x\n", ReadMacInt32(tvec), ReadMacInt32(tvec + 4)));
834 >        WriteMacInt32(XLM_GET_1_IND_RESOURCE, ReadMacInt32(tvec));
835   #if EMULATED_PPC
836 <        tvec[0] = htonl(NativeFunction(NATIVE_GET_1_IND_RESOURCE));
836 >        WriteMacInt32(tvec, NativeFunction(NATIVE_GET_1_IND_RESOURCE));
837   #else
838   #ifdef __BEOS__
839          tvec2 = (uint32 *)get_1_ind_resource;
840 <        tvec[0] = tvec2[0];
841 <        tvec[1] = tvec2[1];
840 >        WriteMacInt32(tvec, tvec2[0]);
841 >        WriteMacInt32(tvec + 4, tvec2[1]);
842   #else
843 <        tvec[0] = (uint32)get_1_ind_resource;
843 >        WriteMacInt32(tvec, (uint32)get_1_ind_resource);
844   #endif
845   #endif
846  
847          // Patch native RGetResource()
848          upp = ReadMacInt32(0x0e30);
849 <        tvec = (uint32 *)ReadMacInt32(upp + 5 * 4);
850 <        D(bug(" RGetResource() entry %08x, TOC %08x\n", ntohl(tvec[0]), ntohl(tvec[1])));
851 <        *(uint32 *)XLM_R_GET_RESOURCE = tvec[0];
849 >        tvec = ReadMacInt32(upp + 5 * 4);
850 >        D(bug(" RGetResource() entry %08x, TOC %08x\n", ReadMacInt32(tvec), ReadMacInt32(tvec + 4)));
851 >        WriteMacInt32(XLM_R_GET_RESOURCE, ReadMacInt32(tvec));
852   #if EMULATED_PPC
853 <        tvec[0] = htonl(NativeFunction(NATIVE_R_GET_RESOURCE));
853 >        WriteMacInt32(tvec, NativeFunction(NATIVE_R_GET_RESOURCE));
854   #else
855   #ifdef __BEOS__
856          tvec2 = (uint32 *)r_get_resource;
857 <        tvec[0] = tvec2[0];
858 <        tvec[1] = tvec2[1];
857 >        WriteMacInt32(tvec, tvec2[0]);
858 >        WriteMacInt32(tvec + 4, tvec2[1]);
859   #else
860 <        tvec[0] = (uint32)r_get_resource;
860 >        WriteMacInt32(tvec, (uint32)r_get_resource);
861   #endif
862   #endif
863   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines