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

Comparing SheepShaver/src/rom_patches.cpp (file contents):
Revision 1.11 by gbeauche, 2003-10-05T23:05:03Z vs.
Revision 1.19 by gbeauche, 2003-12-05T12:37:14Z

# Line 40 | Line 40
40   #include "audio_defs.h"
41   #include "serial.h"
42   #include "macos_util.h"
43 + #include "thunks.h"
44  
45   #define DEBUG 0
46   #include "debug.h"
# Line 58 | Line 59
59  
60  
61   // Other ROM addresses
62 < const uint32 CHECK_LOAD_PATCH_SPACE = 0x2f7f00;
63 < const uint32 PUT_SCRAP_PATCH_SPACE = 0x2f7f80;
64 < const uint32 GET_SCRAP_PATCH_SPACE = 0x2f7fc0;
65 < const uint32 ADDR_MAP_PATCH_SPACE = 0x2f8000;
62 > const uint32 CHECK_LOAD_PATCH_SPACE = 0x2fcf00;
63 > const uint32 PUT_SCRAP_PATCH_SPACE = 0x2fcf80;
64 > const uint32 GET_SCRAP_PATCH_SPACE = 0x2fcfc0;
65 > const uint32 ADDR_MAP_PATCH_SPACE = 0x2fd000;
66  
67   // Global variables
68   int ROMType;                            // ROM type
# Line 131 | Line 132 | void decode_parcels(const uint8 *src, ui
132                            (parcel_type >> 8) & 0xff, parcel_type & 0xff, &parcel_data[6]));
133                  if (parcel_type == FOURCC('r','o','m',' ')) {
134                          uint32 lzss_offset  = ntohl(parcel_data[2]);
135 <                        uint32 lzss_size = ((uint32)src + parcel_offset) - ((uint32)parcel_data + lzss_offset);
135 >                        uint32 lzss_size = ((uintptr)src + next_offset) - ((uintptr)parcel_data + lzss_offset);
136                          decode_lzss((uint8 *)parcel_data + lzss_offset, dest, lzss_size);
137                  }
138                  parcel_offset = next_offset;
# Line 447 | Line 448 | static const uint8 cdrom_driver[] = {  //
448          0x4e, 0x75                                                      //  rts
449   };
450  
451 < #if EMULATED_PPC
451 < #define SERIAL_TRAMPOLINES 1
452 < static uint32 serial_nothing_tvect[2] = {tswap32(POWERPC_NATIVE_OP_FUNC(NATIVE_SERIAL_NOTHING)), 0};
453 < static uint32 serial_open_tvect[2] = {tswap32(POWERPC_NATIVE_OP_FUNC(NATIVE_SERIAL_OPEN)), 0};
454 < static uint32 serial_prime_in_tvect[2] = {tswap32(POWERPC_NATIVE_OP_FUNC(NATIVE_SERIAL_PRIME_IN)), 0};
455 < static uint32 serial_prime_out_tvect[2] = {tswap32(POWERPC_NATIVE_OP_FUNC(NATIVE_SERIAL_PRIME_OUT)), 0};
456 < static uint32 serial_control_tvect[2] = {tswap32(POWERPC_NATIVE_OP_FUNC(NATIVE_SERIAL_CONTROL)), 0};
457 < static uint32 serial_status_tvect[2] = {tswap32(POWERPC_NATIVE_OP_FUNC(NATIVE_SERIAL_STATUS)), 0};
458 < static uint32 serial_close_tvect[2] = {tswap32(POWERPC_NATIVE_OP_FUNC(NATIVE_SERIAL_CLOSE)), 0};
459 < #elif defined(__linux__)
460 < #define SERIAL_TRAMPOLINES 1
461 < static uint32 serial_nothing_tvect[2] = {(uint32)SerialNothing, 0};
462 < static uint32 serial_open_tvect[2] = {(uint32)SerialOpen, 0};
463 < static uint32 serial_prime_in_tvect[2] = {(uint32)SerialPrimeIn, 0};
464 < static uint32 serial_prime_out_tvect[2] = {(uint32)SerialPrimeOut, 0};
465 < static uint32 serial_control_tvect[2] = {(uint32)SerialControl, 0};
466 < static uint32 serial_status_tvect[2] = {(uint32)SerialStatus, 0};
467 < static uint32 serial_close_tvect[2] = {(uint32)SerialClose, 0};
468 < #endif
451 > static uint32 long_ptr;
452  
453 < static const uint32 ain_driver[] = {    // .AIn driver header
454 <        0x4d000000, 0x00000000,
455 <        0x00200040, 0x00600080,
456 <        0x00a0042e, 0x41496e00,
457 <        0x00000000, 0x00000000,
458 <        0xaafe0700, 0x00000000,
459 <        0x00000000, 0x00179822,
460 < #ifdef SERIAL_TRAMPOLINES
461 <        0x00010004, (uint32)serial_nothing_tvect,
462 < #else
463 <        0x00010004, (uint32)SerialNothing,
464 < #endif
465 <        0x00000000, 0x00000000,
466 <        0xaafe0700, 0x00000000,
467 <        0x00000000, 0x00179822,
468 < #ifdef SERIAL_TRAMPOLINES
469 <        0x00010004, (uint32)serial_prime_in_tvect,
470 < #else
471 <        0x00010004, (uint32)SerialPrimeIn,
472 < #endif
473 <        0x00000000, 0x00000000,
474 <        0xaafe0700, 0x00000000,
475 <        0x00000000, 0x00179822,
476 < #ifdef SERIAL_TRAMPOLINES
477 <        0x00010004, (uint32)serial_control_tvect,
478 < #else
479 <        0x00010004, (uint32)SerialControl,
480 < #endif
481 <        0x00000000, 0x00000000,
482 <        0xaafe0700, 0x00000000,
483 <        0x00000000, 0x00179822,
484 < #ifdef SERIAL_TRAMPOLINES
485 <        0x00010004, (uint32)serial_status_tvect,
486 < #else
487 <        0x00010004, (uint32)SerialStatus,
488 < #endif
489 <        0x00000000, 0x00000000,
490 <        0xaafe0700, 0x00000000,
491 <        0x00000000, 0x00179822,
492 < #ifdef SERIAL_TRAMPOLINES
510 <        0x00010004, (uint32)serial_nothing_tvect,
511 < #else
512 <        0x00010004, (uint32)SerialNothing,
513 < #endif
514 <        0x00000000, 0x00000000,
453 > static void SetLongBase(uint32 addr)
454 > {
455 >        long_ptr = addr;
456 > }
457 >
458 > static void Long(uint32 value)
459 > {
460 >        WriteMacInt32(long_ptr, value);
461 >        long_ptr += 4;
462 > }
463 >
464 > static void gen_ain_driver(uintptr addr)
465 > {
466 >        SetLongBase(addr);
467 >
468 >        // .AIn driver header
469 >        Long(0x4d000000); Long(0x00000000);
470 >        Long(0x00200040); Long(0x00600080);
471 >        Long(0x00a0042e); Long(0x41496e00);
472 >        Long(0x00000000); Long(0x00000000);
473 >        Long(0xaafe0700); Long(0x00000000);
474 >        Long(0x00000000); Long(0x00179822);
475 >        Long(0x00010004); Long(NativeTVECT(NATIVE_SERIAL_NOTHING));
476 >        Long(0x00000000); Long(0x00000000);
477 >        Long(0xaafe0700); Long(0x00000000);
478 >        Long(0x00000000); Long(0x00179822);
479 >        Long(0x00010004); Long(NativeTVECT(NATIVE_SERIAL_PRIME_IN));
480 >        Long(0x00000000); Long(0x00000000);
481 >        Long(0xaafe0700); Long(0x00000000);
482 >        Long(0x00000000); Long(0x00179822);
483 >        Long(0x00010004); Long(NativeTVECT(NATIVE_SERIAL_CONTROL));
484 >        Long(0x00000000); Long(0x00000000);
485 >        Long(0xaafe0700); Long(0x00000000);
486 >        Long(0x00000000); Long(0x00179822);
487 >        Long(0x00010004); Long(NativeTVECT(NATIVE_SERIAL_STATUS));
488 >        Long(0x00000000); Long(0x00000000);
489 >        Long(0xaafe0700); Long(0x00000000);
490 >        Long(0x00000000); Long(0x00179822);
491 >        Long(0x00010004); Long(NativeTVECT(NATIVE_SERIAL_NOTHING));
492 >        Long(0x00000000); Long(0x00000000);
493   };
494  
495 < static const uint32 aout_driver[] = {   // .AOut driver header
496 <        0x4d000000, 0x00000000,
497 <        0x00200040, 0x00600080,
498 <        0x00a0052e, 0x414f7574,
499 <        0x00000000, 0x00000000,
500 <        0xaafe0700, 0x00000000,
501 <        0x00000000, 0x00179822,
502 < #ifdef SERIAL_TRAMPOLINES
503 <        0x00010004, (uint32)serial_open_tvect,
504 < #else
505 <        0x00010004, (uint32)SerialOpen,
506 < #endif
507 <        0x00000000, 0x00000000,
508 <        0xaafe0700, 0x00000000,
509 <        0x00000000, 0x00179822,
510 < #ifdef SERIAL_TRAMPOLINES
511 <        0x00010004, (uint32)serial_prime_out_tvect,
512 < #else
513 <        0x00010004, (uint32)SerialPrimeOut,
514 < #endif
515 <        0x00000000, 0x00000000,
516 <        0xaafe0700, 0x00000000,
517 <        0x00000000, 0x00179822,
518 < #ifdef SERIAL_TRAMPOLINES
519 <        0x00010004, (uint32)serial_control_tvect,
520 < #else
521 <        0x00010004, (uint32)SerialControl,
522 < #endif
523 <        0x00000000, 0x00000000,
546 <        0xaafe0700, 0x00000000,
547 <        0x00000000, 0x00179822,
548 < #ifdef SERIAL_TRAMPOLINES
549 <        0x00010004, (uint32)serial_status_tvect,
550 < #else
551 <        0x00010004, (uint32)SerialStatus,
552 < #endif
553 <        0x00000000, 0x00000000,
554 <        0xaafe0700, 0x00000000,
555 <        0x00000000, 0x00179822,
556 < #ifdef SERIAL_TRAMPOLINES
557 <        0x00010004, (uint32)serial_close_tvect,
558 < #else
559 <        0x00010004, (uint32)SerialClose,
560 < #endif
561 <        0x00000000, 0x00000000,
495 > static void gen_aout_driver(uintptr addr)
496 > {
497 >        SetLongBase(addr);
498 >
499 >        // .AOut driver header
500 >        Long(0x4d000000); Long(0x00000000);
501 >        Long(0x00200040); Long(0x00600080);
502 >        Long(0x00a0052e); Long(0x414f7574);
503 >        Long(0x00000000); Long(0x00000000);
504 >        Long(0xaafe0700); Long(0x00000000);
505 >        Long(0x00000000); Long(0x00179822);
506 >        Long(0x00010004); Long(NativeTVECT(NATIVE_SERIAL_OPEN));
507 >        Long(0x00000000); Long(0x00000000);
508 >        Long(0xaafe0700); Long(0x00000000);
509 >        Long(0x00000000); Long(0x00179822);
510 >        Long(0x00010004); Long(NativeTVECT(NATIVE_SERIAL_PRIME_OUT));
511 >        Long(0x00000000); Long(0x00000000);
512 >        Long(0xaafe0700); Long(0x00000000);
513 >        Long(0x00000000); Long(0x00179822);
514 >        Long(0x00010004); Long(NativeTVECT(NATIVE_SERIAL_CONTROL));
515 >        Long(0x00000000); Long(0x00000000);
516 >        Long(0xaafe0700); Long(0x00000000);
517 >        Long(0x00000000); Long(0x00179822);
518 >        Long(0x00010004); Long(NativeTVECT(NATIVE_SERIAL_STATUS));
519 >        Long(0x00000000); Long(0x00000000);
520 >        Long(0xaafe0700); Long(0x00000000);
521 >        Long(0x00000000); Long(0x00179822);
522 >        Long(0x00010004); Long(NativeTVECT(NATIVE_SERIAL_CLOSE));
523 >        Long(0x00000000); Long(0x00000000);
524   };
525  
526 < static const uint32 bin_driver[] = {    // .BIn driver header
527 <        0x4d000000, 0x00000000,
528 <        0x00200040, 0x00600080,
529 <        0x00a0042e, 0x42496e00,
530 <        0x00000000, 0x00000000,
531 <        0xaafe0700, 0x00000000,
532 <        0x00000000, 0x00179822,
533 < #ifdef SERIAL_TRAMPOLINES
534 <        0x00010004, (uint32)serial_nothing_tvect,
535 < #else
536 <        0x00010004, (uint32)SerialNothing,
537 < #endif
538 <        0x00000000, 0x00000000,
539 <        0xaafe0700, 0x00000000,
540 <        0x00000000, 0x00179822,
541 < #ifdef SERIAL_TRAMPOLINES
542 <        0x00010004, (uint32)serial_prime_in_tvect,
543 < #else
544 <        0x00010004, (uint32)SerialPrimeIn,
545 < #endif
546 <        0x00000000, 0x00000000,
547 <        0xaafe0700, 0x00000000,
548 <        0x00000000, 0x00179822,
549 < #ifdef SERIAL_TRAMPOLINES
550 <        0x00010004, (uint32)serial_control_tvect,
551 < #else
552 <        0x00010004, (uint32)SerialControl,
553 < #endif
554 <        0x00000000, 0x00000000,
593 <        0xaafe0700, 0x00000000,
594 <        0x00000000, 0x00179822,
595 < #ifdef SERIAL_TRAMPOLINES
596 <        0x00010004, (uint32)serial_status_tvect,
597 < #else
598 <        0x00010004, (uint32)SerialStatus,
599 < #endif
600 <        0x00000000, 0x00000000,
601 <        0xaafe0700, 0x00000000,
602 <        0x00000000, 0x00179822,
603 < #ifdef SERIAL_TRAMPOLINES
604 <        0x00010004, (uint32)serial_nothing_tvect,
605 < #else
606 <        0x00010004, (uint32)SerialNothing,
607 < #endif
608 <        0x00000000, 0x00000000,
526 > static void gen_bin_driver(uintptr addr)
527 > {
528 >        SetLongBase(addr);
529 >
530 >        // .BIn driver header
531 >        Long(0x4d000000); Long(0x00000000);
532 >        Long(0x00200040); Long(0x00600080);
533 >        Long(0x00a0042e); Long(0x42496e00);
534 >        Long(0x00000000); Long(0x00000000);
535 >        Long(0xaafe0700); Long(0x00000000);
536 >        Long(0x00000000); Long(0x00179822);
537 >        Long(0x00010004); Long(NativeTVECT(NATIVE_SERIAL_NOTHING));
538 >        Long(0x00000000); Long(0x00000000);
539 >        Long(0xaafe0700); Long(0x00000000);
540 >        Long(0x00000000); Long(0x00179822);
541 >        Long(0x00010004); Long(NativeTVECT(NATIVE_SERIAL_PRIME_IN));
542 >        Long(0x00000000); Long(0x00000000);
543 >        Long(0xaafe0700); Long(0x00000000);
544 >        Long(0x00000000); Long(0x00179822);
545 >        Long(0x00010004); Long(NativeTVECT(NATIVE_SERIAL_CONTROL));
546 >        Long(0x00000000); Long(0x00000000);
547 >        Long(0xaafe0700); Long(0x00000000);
548 >        Long(0x00000000); Long(0x00179822);
549 >        Long(0x00010004); Long(NativeTVECT(NATIVE_SERIAL_STATUS));
550 >        Long(0x00000000); Long(0x00000000);
551 >        Long(0xaafe0700); Long(0x00000000);
552 >        Long(0x00000000); Long(0x00179822);
553 >        Long(0x00010004); Long(NativeTVECT(NATIVE_SERIAL_NOTHING));
554 >        Long(0x00000000); Long(0x00000000);
555   };
556  
557 < static const uint32 bout_driver[] = {   // .BOut driver header
558 <        0x4d000000, 0x00000000,
559 <        0x00200040, 0x00600080,
560 <        0x00a0052e, 0x424f7574,
561 <        0x00000000, 0x00000000,
562 <        0xaafe0700, 0x00000000,
563 <        0x00000000, 0x00179822,
564 < #ifdef SERIAL_TRAMPOLINES
565 <        0x00010004, (uint32)serial_open_tvect,
566 < #else
567 <        0x00010004, (uint32)SerialOpen,
568 < #endif
569 <        0x00000000, 0x00000000,
570 <        0xaafe0700, 0x00000000,
571 <        0x00000000, 0x00179822,
572 < #ifdef SERIAL_TRAMPOLINES
573 <        0x00010004, (uint32)serial_prime_out_tvect,
574 < #else
575 <        0x00010004, (uint32)SerialPrimeOut,
576 < #endif
577 <        0x00000000, 0x00000000,
578 <        0xaafe0700, 0x00000000,
579 <        0x00000000, 0x00179822,
580 < #ifdef SERIAL_TRAMPOLINES
581 <        0x00010004, (uint32)serial_control_tvect,
582 < #else
583 <        0x00010004, (uint32)SerialControl,
584 < #endif
585 <        0x00000000, 0x00000000,
640 <        0xaafe0700, 0x00000000,
641 <        0x00000000, 0x00179822,
642 < #ifdef SERIAL_TRAMPOLINES
643 <        0x00010004, (uint32)serial_status_tvect,
644 < #else
645 <        0x00010004, (uint32)SerialStatus,
646 < #endif
647 <        0x00000000, 0x00000000,
648 <        0xaafe0700, 0x00000000,
649 <        0x00000000, 0x00179822,
650 < #ifdef SERIAL_TRAMPOLINES
651 <        0x00010004, (uint32)serial_close_tvect,
652 < #else
653 <        0x00010004, (uint32)SerialClose,
654 < #endif
655 <        0x00000000, 0x00000000,
557 > static void gen_bout_driver(uintptr addr)
558 > {
559 >        SetLongBase(addr);
560 >
561 >        // .BOut driver header
562 >        Long(0x4d000000); Long(0x00000000);
563 >        Long(0x00200040); Long(0x00600080);
564 >        Long(0x00a0052e); Long(0x424f7574);
565 >        Long(0x00000000); Long(0x00000000);
566 >        Long(0xaafe0700); Long(0x00000000);
567 >        Long(0x00000000); Long(0x00179822);
568 >        Long(0x00010004); Long(NativeTVECT(NATIVE_SERIAL_OPEN));
569 >        Long(0x00000000); Long(0x00000000);
570 >        Long(0xaafe0700); Long(0x00000000);
571 >        Long(0x00000000); Long(0x00179822);
572 >        Long(0x00010004); Long(NativeTVECT(NATIVE_SERIAL_PRIME_OUT));
573 >        Long(0x00000000); Long(0x00000000);
574 >        Long(0xaafe0700); Long(0x00000000);
575 >        Long(0x00000000); Long(0x00179822);
576 >        Long(0x00010004); Long(NativeTVECT(NATIVE_SERIAL_CONTROL));
577 >        Long(0x00000000); Long(0x00000000);
578 >        Long(0xaafe0700); Long(0x00000000);
579 >        Long(0x00000000); Long(0x00179822);
580 >        Long(0x00010004); Long(NativeTVECT(NATIVE_SERIAL_STATUS));
581 >        Long(0x00000000); Long(0x00000000);
582 >        Long(0xaafe0700); Long(0x00000000);
583 >        Long(0x00000000); Long(0x00179822);
584 >        Long(0x00010004); Long(NativeTVECT(NATIVE_SERIAL_CLOSE));
585 >        Long(0x00000000); Long(0x00000000);
586   };
587  
588   static const uint8 adbop_patch[] = {    // Call ADBOp() completion procedure
# Line 725 | Line 655 | bool PatchROM(void)
655          else
656                  return false;
657  
658 +        // Check that other ROM addresses point to really free regions
659 +        if (ntohl(*(uint32 *)(ROM_BASE + CHECK_LOAD_PATCH_SPACE)) != 0x6b636b63)
660 +                return false;
661 +        if (ntohl(*(uint32 *)(ROM_BASE + PUT_SCRAP_PATCH_SPACE)) != 0x6b636b63)
662 +                return false;
663 +        if (ntohl(*(uint32 *)(ROM_BASE + GET_SCRAP_PATCH_SPACE)) != 0x6b636b63)
664 +                return false;
665 +        if (ntohl(*(uint32 *)(ROM_BASE + ADDR_MAP_PATCH_SPACE)) != 0x6b636b63)
666 +                return false;
667 +
668          // Apply patches
669          if (!patch_nanokernel_boot()) return false;
670          if (!patch_68k_emul()) return false;
# Line 1099 | Line 1039 | static bool patch_68k_emul(void)
1039          lp = (uint32 *)(ROM_BASE + 0x36f900);
1040          *lp++ = htonl(0x7c2903a6);                                      // mtctr        r1
1041   #if EMULATED_PPC
1042 <        *lp++ = POWERPC_NATIVE_OP(NATIVE_DISABLE_INTERRUPT);
1042 >        *lp++ = htonl(NativeOpcode(NATIVE_DISABLE_INTERRUPT));
1043   #else
1044          *lp++ = htonl(0x80200000 + XLM_IRQ_NEST);       // lwz          r1,XLM_IRQ_NEST
1045          *lp++ = htonl(0x38210001);                                      // addi         r1,r1,1
# Line 1133 | Line 1073 | static bool patch_68k_emul(void)
1073          lp = (uint32 *)(ROM_BASE + 0x36fa00);
1074          *lp++ = htonl(0x7c2903a6);                                      // mtctr        r1
1075   #if EMULATED_PPC
1076 <        *lp++ = POWERPC_NATIVE_OP(NATIVE_DISABLE_INTERRUPT);
1076 >        *lp++ = htonl(NativeOpcode(NATIVE_DISABLE_INTERRUPT));
1077   #else
1078          *lp++ = htonl(0x80200000 + XLM_IRQ_NEST);       // lwz          r1,XLM_IRQ_NEST
1079          *lp++ = htonl(0x38210001);                                      // addi         r1,r1,1
# Line 1167 | Line 1107 | static bool patch_68k_emul(void)
1107          lp = (uint32 *)(ROM_BASE + 0x36fb00);
1108          *lp++ = htonl(0x7c2903a6);                                      // mtctr        r1
1109   #if EMULATED_PPC
1110 <        *lp++ = POWERPC_NATIVE_OP(NATIVE_DISABLE_INTERRUPT);
1110 >        *lp++ = htonl(NativeOpcode(NATIVE_DISABLE_INTERRUPT));
1111   #else
1112          *lp++ = htonl(0x80200000 + XLM_IRQ_NEST);       // lwz          r1,XLM_IRQ_NEST
1113          *lp++ = htonl(0x38210001);                                      // addi         r1,r1,1
# Line 1201 | Line 1141 | static bool patch_68k_emul(void)
1141          lp = (uint32 *)(ROM_BASE + 0x36fc00);
1142          *lp++ = htonl(0x7c2903a6);                                      // mtctr        r1
1143   #if EMULATED_PPC
1144 <        *lp++ = POWERPC_NATIVE_OP(NATIVE_DISABLE_INTERRUPT);
1144 >        *lp++ = htonl(NativeOpcode(NATIVE_DISABLE_INTERRUPT));
1145   #else
1146          *lp++ = htonl(0x80200000 + XLM_IRQ_NEST);       // lwz          r1,XLM_IRQ_NEST
1147          *lp++ = htonl(0x38210001);                                      // addi         r1,r1,1
# Line 1342 | Line 1282 | static bool patch_nanokernel(void)
1282  
1283          lp = (uint32 *)(ROM_BASE + 0x318000);
1284   #if EMULATED_PPC
1285 <        *lp++ = POWERPC_NATIVE_OP(NATIVE_ENABLE_INTERRUPT);
1285 >        *lp++ = htonl(NativeOpcode(NATIVE_ENABLE_INTERRUPT));
1286          *lp = htonl(0x48000000 + ((xlp - 0x8004) & 0x03fffffc));        // b            ROM_BASE+0x312c2c
1287   #else
1288          *lp++ = htonl(0x81400000 + XLM_IRQ_NEST);       // lwz  r10,XLM_IRQ_NEST
# Line 1842 | Line 1782 | static bool patch_68k(void)
1782          *wp = htons(M68K_RTS);
1783  
1784          // Don't install Time Manager task for 60Hz interrupt (Enable60HzInts, via 0x2b8)
1785 <        if (ROMType == ROMTYPE_NEWWORLD) {
1785 >        if (ROMType == ROMTYPE_NEWWORLD || ROMType == ROMTYPE_GOSSAMER) {
1786                  static const uint8 tm_task_dat[] = {0x30, 0x3c, 0x4e, 0x2b, 0xa9, 0xc9};
1787 <                if ((base = find_rom_data(0x2e0, 0x320, tm_task_dat, sizeof(tm_task_dat))) == 0) return false;
1787 >                if ((base = find_rom_data(0x2a0, 0x320, tm_task_dat, sizeof(tm_task_dat))) == 0) return false;
1788                  D(bug("tm_task %08lx\n", base));
1789 <                wp = (uint16 *)(ROM_BASE + base + 28); // FIXME: this is not right for all nw ROMs
1789 >                wp = (uint16 *)(ROM_BASE + base + 28);
1790                  *wp++ = htons(M68K_NOP);
1791                  *wp++ = htons(M68K_NOP);
1792                  *wp++ = htons(M68K_NOP);
1793                  *wp++ = htons(M68K_NOP);
1794                  *wp++ = htons(M68K_NOP);
1795                  *wp = htons(M68K_NOP);
1856        } else if (ROMType == ROMTYPE_GOSSAMER) {
1857                static const uint8 tm_task_dat[] = {0x30, 0x3c, 0x4e, 0x2b, 0xa9, 0xc9};
1858                if ((base = find_rom_data(0x2a0, 0x2e0, tm_task_dat, sizeof(tm_task_dat))) == 0) return false;
1859                D(bug("tm_task %08lx\n", base));
1860                wp = (uint16 *)(ROM_BASE + base + 22);
1861                *wp++ = htons(M68K_NOP);
1862                *wp++ = htons(M68K_NOP);
1863                *wp++ = htons(M68K_NOP);
1796          } else {
1797                  static const uint8 tm_task_dat[] = {0x20, 0x3c, 0x73, 0x79, 0x73, 0x61};
1798                  if ((base = find_rom_data(0x280, 0x300, tm_task_dat, sizeof(tm_task_dat))) == 0) return false;
# Line 1907 | Line 1839 | static bool patch_68k(void)
1839                  *lp = htonl(0x38600000);                // li   r3,0
1840          }
1841  
1842 +        // FIXME: Fake reading from [HpChk]+4 (the callchain reports some function from DriverServicesLib)
1843 +        if (1) {
1844 +                uint32 hpchk_offset = find_rom_resource(FOURCC('n','l','i','b'), 10);
1845 +                static const uint8 hpchk_dat[] = {0x80, 0x80, 0x03, 0x16, 0x94, 0x21, 0xff, 0xb0, 0x83, 0xc4, 0x00, 0x04};
1846 +                if ((base = find_rom_data(hpchk_offset, hpchk_offset + 0x3000, hpchk_dat, sizeof(hpchk_dat))) == 0) return false;
1847 +                D(bug("hpchk %08lx\n", base));
1848 +                lp = (uint32 *)(ROM_BASE + base);
1849 +                *lp = htonl(0x80800000 + XLM_ZERO_PAGE);                // lwz  r4,(zero page)
1850 +        }
1851 +
1852          // Patch Name Registry
1853          static const uint8 name_reg_dat[] = {0x70, 0xff, 0xab, 0xeb};
1854          if ((base = find_rom_data(0x300, 0x380, name_reg_dat, sizeof(name_reg_dat))) == 0) return false;
# Line 2030 | Line 1972 | static bool patch_68k(void)
1972          memcpy((void *)(ROM_BASE + sony_offset + 0x200), cdrom_driver, sizeof(cdrom_driver));
1973  
1974          // Install serial drivers
1975 <        memcpy_powerpc_code((void *)(ROM_BASE + sony_offset + 0x300), ain_driver, sizeof(ain_driver));
1976 <        memcpy_powerpc_code((void *)(ROM_BASE + sony_offset + 0x400), aout_driver, sizeof(aout_driver));
1977 <        memcpy_powerpc_code((void *)(ROM_BASE + sony_offset + 0x500), bin_driver, sizeof(bin_driver));
1978 <        memcpy_powerpc_code((void *)(ROM_BASE + sony_offset + 0x600), bout_driver, sizeof(bout_driver));
1975 >        gen_ain_driver( ROM_BASE + sony_offset + 0x300);
1976 >        gen_aout_driver(ROM_BASE + sony_offset + 0x400);
1977 >        gen_bin_driver( ROM_BASE + sony_offset + 0x500);
1978 >        gen_bout_driver(ROM_BASE + sony_offset + 0x600);
1979  
1980          // Copy icons to ROM
1981          SonyDiskIconAddr = ROM_BASE + sony_offset + 0x800;
# Line 2235 | Line 2177 | void InstallDrivers(void)
2177   {
2178          D(bug("Installing drivers...\n"));
2179          M68kRegisters r;
2180 <        uint8 pb[SIZEOF_IOParam];
2180 >        SheepArray<SIZEOF_IOParam> pb_var;
2181 >        const uintptr pb = pb_var.addr();
2182  
2183          // Install floppy driver
2184 <        if (ROMType == ROMTYPE_NEWWORLD) {
2184 >        if (ROMType == ROMTYPE_NEWWORLD || ROMType == ROMTYPE_GOSSAMER) {
2185  
2186 <                // Force installation of floppy driver with NewWorld ROMs
2186 >                // Force installation of floppy driver with NewWorld and Gossamer ROMs
2187                  r.a[0] = ROM_BASE + sony_offset;
2188                  r.d[0] = (uint32)SonyRefNum;
2189                  Execute68kTrap(0xa43d, &r);             // DrvrInstallRsrvMem()
# Line 2253 | Line 2196 | void InstallDrivers(void)
2196  
2197   #if DISABLE_SCSI && 0
2198          // Fake SCSIGlobals
2199 <        static const uint8 fake_scsi_globals[32] = {0,};
2257 <        WriteMacInt32(0xc0c, (uint32)fake_scsi_globals);
2199 >        WriteMacInt32(0xc0c, SheepMem::ZeroPage());
2200   #endif
2201  
2202          // Open .Sony driver
2203 <        WriteMacInt8((uint32)pb + ioPermssn, 0);
2204 <        WriteMacInt32((uint32)pb + ioNamePtr, (uint32)"\005.Sony");
2205 <        r.a[0] = (uint32)pb;
2203 >        SheepString sony_str("\005.Sony");
2204 >        WriteMacInt8(pb + ioPermssn, 0);
2205 >        WriteMacInt32(pb + ioNamePtr, sony_str.addr());
2206 >        r.a[0] = pb;
2207          Execute68kTrap(0xa000, &r);             // Open()
2208  
2209          // Install disk driver
# Line 2274 | Line 2217 | void InstallDrivers(void)
2217          WriteMacInt16(dce + dCtlFlags, DiskDriverFlags);
2218  
2219          // Open disk driver
2220 <        WriteMacInt32((uint32)pb + ioNamePtr, (uint32)"\005.Disk");
2221 <        r.a[0] = (uint32)pb;
2220 >        SheepString disk_str("\005.Disk");
2221 >        WriteMacInt32(pb + ioNamePtr, disk_str.addr());
2222 >        r.a[0] = pb;
2223          Execute68kTrap(0xa000, &r);             // Open()
2224  
2225          // Install CD-ROM driver unless nocdrom option given
# Line 2292 | Line 2236 | void InstallDrivers(void)
2236                  WriteMacInt16(dce + dCtlFlags, CDROMDriverFlags);
2237  
2238                  // Open CD-ROM driver
2239 <                WriteMacInt32((uint32)pb + ioNamePtr, (uint32)"\010.AppleCD");
2240 <                r.a[0] = (uint32)pb;
2239 >                SheepString apple_cd("\010.AppleCD");
2240 >                WriteMacInt32(pb + ioNamePtr, apple_cd.addr());
2241 >                r.a[0] = pb;
2242                  Execute68kTrap(0xa000, &r);             // Open()
2243          }
2244  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines