420 |
|
|
421 |
|
} else if (type == FOURCC('n','s','r','d') && id == 1) { |
422 |
|
D(bug("nsrd 1 found\n")); |
423 |
< |
if (p[(0x378 + 0x570) >> 1] == 0x7c08 && p[(0x37a + 0x570) >> 1] == 0x02a6) { |
423 |
> |
if (p[(0x378 + 0x570) >> 1] == htons(0x7c08) && p[(0x37a + 0x570) >> 1] == htons(0x02a6)) { |
424 |
|
// Don't overwrite our serial drivers (8.0, 8.1) |
425 |
< |
p[(0x378 + 0x570) >> 1] = 0x4e80; // blr |
426 |
< |
p[(0x37a + 0x570) >> 1] = 0x0020; |
425 |
> |
p[(0x378 + 0x570) >> 1] = htons(0x4e80); // blr |
426 |
> |
p[(0x37a + 0x570) >> 1] = htons(0x0020); |
427 |
|
D(bug(" patch 1 applied\n")); |
428 |
< |
} else if (p[(0x378 + 0x6c0) >> 1] == 0x7c08 && p[(0x37a + 0x6c0) >> 1] == 0x02a6) { |
428 |
> |
} else if (p[(0x378 + 0x6c0) >> 1] == htons(0x7c08) && p[(0x37a + 0x6c0) >> 1] == htons(0x02a6)) { |
429 |
|
// Don't overwrite our serial drivers (8.5, 8.6) |
430 |
< |
p[(0x378 + 0x6c0) >> 1] = 0x4e80; // blr |
431 |
< |
p[(0x37a + 0x6c0) >> 1] = 0x0020; |
430 |
> |
p[(0x378 + 0x6c0) >> 1] = htons(0x4e80); // blr |
431 |
> |
p[(0x37a + 0x6c0) >> 1] = htons(0x0020); |
432 |
|
D(bug(" patch 2 applied\n")); |
433 |
|
} |
434 |
|
|
438 |
|
while (size--) { |
439 |
|
if (PM(0,0x203c) && PM(1,0x0100) && PM(2,0x0000) && PM(3,0xc0ae) && PM(4,0xfffc)) { |
440 |
|
// Don't replace SCSI Manager (8.1, 8.5, 8.6) |
441 |
< |
p[5] = htons((p[5] & 0xff) | 0x6000); // beq |
441 |
> |
p[5] = htons((ntohs(p[5]) & 0xff) | 0x6000); // beq |
442 |
|
D(bug(" patch 1 applied\n")); |
443 |
|
break; |
444 |
|
} |
447 |
|
|
448 |
|
} else if (type == FOURCC('t','h','n','g')) { |
449 |
|
// Collect info about used audio sifters |
450 |
< |
uint32 c_type = 0[(uint32 *)p]; |
451 |
< |
uint32 sub_type = 1[(uint32 *)p]; |
450 |
> |
uint32 c_type = ntohl(0[(uint32 *)p]); |
451 |
> |
uint32 sub_type = ntohl(1[(uint32 *)p]); |
452 |
|
if (c_type == FOURCC('s','d','e','v') && sub_type == FOURCC('s','i','n','g')) { |
453 |
< |
1[(uint32 *)p] = FOURCC('a','w','g','c'); |
453 |
> |
1[(uint32 *)p] = htonl(FOURCC('a','w','g','c')); |
454 |
|
D(bug("thng %d, type %c%c%c%c (%08x), sub type %c%c%c%c (%08x), data %p\n", id, c_type >> 24, (c_type >> 16) & 0xff, (c_type >> 8) & 0xff, c_type & 0xff, c_type, sub_type >> 24, (sub_type >> 16) & 0xff, (sub_type >> 8) & 0xff, sub_type & 0xff, sub_type, p)); |
455 |
< |
AddSifter(*(uint32 *)(((uintptr)p)+20), p[12]); |
456 |
< |
if (p[28]) // componentPFCount |
457 |
< |
AddSifter(*(uint32 *)(((uintptr)p)+62), p[33]); |
455 |
> |
AddSifter(ReadMacInt32(((uintptr)p)+20), ntohs(p[12])); |
456 |
> |
if (ntohs(p[28])) // componentPFCount |
457 |
> |
AddSifter(ReadMacInt32(((uintptr)p)+62), ntohs(p[33])); |
458 |
|
} |
459 |
|
|
460 |
|
} else if (type == FOURCC('s','i','f','t') || type == FOURCC('n','i','f','t')) { |
517 |
|
#else |
518 |
|
extern "C" |
519 |
|
#endif |
520 |
< |
void check_load_invoc(uint32 type, int16 id, uint16 **h) |
520 |
> |
void check_load_invoc(uint32 type, int16 id, uint32 h) |
521 |
|
{ |
522 |
< |
if (h == NULL) |
522 |
> |
if (h == 0) |
523 |
|
return; |
524 |
< |
uint16 *p = *h; |
525 |
< |
if (p == NULL) |
524 |
> |
uint32 p = ReadMacInt32(h); |
525 |
> |
if (p == 0) |
526 |
|
return; |
527 |
< |
uint32 size = ((uint32 *)p)[-2] & 0xffffff; |
527 |
> |
uint32 size = ReadMacInt32(p - 2 * 4) & 0xffffff; |
528 |
|
|
529 |
< |
CheckLoad(type, id, p, size); |
529 |
> |
CheckLoad(type, id, (uint16 *)p, size); |
530 |
|
} |
531 |
|
|
532 |
|
#ifdef __BEOS__ |
708 |
|
D(bug("PatchNativeResourceManager\n")); |
709 |
|
|
710 |
|
// Patch native GetResource() |
711 |
< |
uint32 **upp = (uint32 **)(uintptr)ReadMacInt32(0x1480); |
712 |
< |
if (((uint32)upp & 0xffc00000) == ROM_BASE) |
711 |
> |
uint32 upp = ReadMacInt32(0x1480); |
712 |
> |
if ((upp & 0xffc00000) == ROM_BASE) |
713 |
|
return; |
714 |
< |
uint32 *tvec = upp[5]; |
715 |
< |
D(bug(" GetResource() entry %08x, TOC %08x\n", tvec[0], tvec[1])); |
714 |
> |
uint32 *tvec = (uint32 *)ReadMacInt32(upp + 5 * 4); |
715 |
> |
D(bug(" GetResource() entry %08x, TOC %08x\n", ntohl(tvec[0]), ntohl(tvec[1]))); |
716 |
|
*(uint32 *)XLM_RES_LIB_TOC = tvec[1]; |
717 |
|
*(uint32 *)XLM_GET_RESOURCE = tvec[0]; |
718 |
|
#if EMULATED_PPC |
719 |
< |
tvec[0] = POWERPC_NATIVE_OP_FUNC(NATIVE_GET_RESOURCE); |
719 |
> |
tvec[0] = htonl(POWERPC_NATIVE_OP_FUNC(NATIVE_GET_RESOURCE)); |
720 |
|
#else |
721 |
|
#ifdef __BEOS__ |
722 |
|
uint32 *tvec2 = (uint32 *)get_resource; |
728 |
|
#endif |
729 |
|
|
730 |
|
// Patch native Get1Resource() |
731 |
< |
upp = *(uint32 ***)0xe7c; |
732 |
< |
tvec = upp[5]; |
733 |
< |
D(bug(" Get1Resource() entry %08x, TOC %08x\n", tvec[0], tvec[1])); |
731 |
> |
upp = ReadMacInt32(0x0e7c); |
732 |
> |
tvec = (uint32 *)ReadMacInt32(upp + 5 * 4); |
733 |
> |
D(bug(" Get1Resource() entry %08x, TOC %08x\n", ntohl(tvec[0]), ntohl(tvec[1]))); |
734 |
|
*(uint32 *)XLM_GET_1_RESOURCE = tvec[0]; |
735 |
|
#if EMULATED_PPC |
736 |
< |
tvec[0] = POWERPC_NATIVE_OP_FUNC(NATIVE_GET_1_RESOURCE); |
736 |
> |
tvec[0] = htonl(POWERPC_NATIVE_OP_FUNC(NATIVE_GET_1_RESOURCE)); |
737 |
|
#else |
738 |
|
#ifdef __BEOS__ |
739 |
|
tvec2 = (uint32 *)get_1_resource; |
745 |
|
#endif |
746 |
|
|
747 |
|
// Patch native GetIndResource() |
748 |
< |
upp = *(uint32 ***)0x1474; |
749 |
< |
tvec = upp[5]; |
750 |
< |
D(bug(" GetIndResource() entry %08x, TOC %08x\n", tvec[0], tvec[1])); |
748 |
> |
upp = ReadMacInt32(0x1474); |
749 |
> |
tvec = (uint32 *)ReadMacInt32(upp + 5 * 4); |
750 |
> |
D(bug(" GetIndResource() entry %08x, TOC %08x\n", ntohl(tvec[0]), ntohl(tvec[1]))); |
751 |
|
*(uint32 *)XLM_GET_IND_RESOURCE = tvec[0]; |
752 |
|
#if EMULATED_PPC |
753 |
< |
tvec[0] = POWERPC_NATIVE_OP_FUNC(NATIVE_GET_IND_RESOURCE); |
753 |
> |
tvec[0] = htonl(POWERPC_NATIVE_OP_FUNC(NATIVE_GET_IND_RESOURCE)); |
754 |
|
#else |
755 |
|
#ifdef __BEOS__ |
756 |
|
tvec2 = (uint32 *)get_ind_resource; |
762 |
|
#endif |
763 |
|
|
764 |
|
// Patch native Get1IndResource() |
765 |
< |
upp = *(uint32 ***)0xe38; |
766 |
< |
tvec = upp[5]; |
767 |
< |
D(bug(" Get1IndResource() entry %08x, TOC %08x\n", tvec[0], tvec[1])); |
765 |
> |
upp = ReadMacInt32(0x0e38); |
766 |
> |
tvec = (uint32 *)ReadMacInt32(upp + 5 * 4); |
767 |
> |
D(bug(" Get1IndResource() entry %08x, TOC %08x\n", ntohl(tvec[0]), ntohl(tvec[1]))); |
768 |
|
*(uint32 *)XLM_GET_1_IND_RESOURCE = tvec[0]; |
769 |
|
#if EMULATED_PPC |
770 |
< |
tvec[0] = POWERPC_NATIVE_OP_FUNC(NATIVE_GET_1_IND_RESOURCE); |
770 |
> |
tvec[0] = htonl(POWERPC_NATIVE_OP_FUNC(NATIVE_GET_1_IND_RESOURCE)); |
771 |
|
#else |
772 |
|
#ifdef __BEOS__ |
773 |
|
tvec2 = (uint32 *)get_1_ind_resource; |
779 |
|
#endif |
780 |
|
|
781 |
|
// Patch native RGetResource() |
782 |
< |
upp = *(uint32 ***)0xe30; |
783 |
< |
tvec = upp[5]; |
784 |
< |
D(bug(" RGetResource() entry %08x, TOC %08x\n", tvec[0], tvec[1])); |
782 |
> |
upp = ReadMacInt32(0x0e30); |
783 |
> |
tvec = (uint32 *)ReadMacInt32(upp + 5 * 4); |
784 |
> |
D(bug(" RGetResource() entry %08x, TOC %08x\n", ntohl(tvec[0]), ntohl(tvec[1]))); |
785 |
|
*(uint32 *)XLM_R_GET_RESOURCE = tvec[0]; |
786 |
|
#if EMULATED_PPC |
787 |
< |
tvec[0] = POWERPC_NATIVE_OP_FUNC(NATIVE_R_GET_RESOURCE); |
787 |
> |
tvec[0] = htonl(POWERPC_NATIVE_OP_FUNC(NATIVE_R_GET_RESOURCE)); |
788 |
|
#else |
789 |
|
#ifdef __BEOS__ |
790 |
|
tvec2 = (uint32 *)r_get_resource; |