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.12 by gbeauche, 2003-10-05T23:38:07Z vs.
Revision 1.18 by gbeauche, 2003-12-04T17:26:35Z

# 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 + 28);
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 2030 | Line 1962 | static bool patch_68k(void)
1962          memcpy((void *)(ROM_BASE + sony_offset + 0x200), cdrom_driver, sizeof(cdrom_driver));
1963  
1964          // Install serial drivers
1965 <        memcpy_powerpc_code((void *)(ROM_BASE + sony_offset + 0x300), ain_driver, sizeof(ain_driver));
1966 <        memcpy_powerpc_code((void *)(ROM_BASE + sony_offset + 0x400), aout_driver, sizeof(aout_driver));
1967 <        memcpy_powerpc_code((void *)(ROM_BASE + sony_offset + 0x500), bin_driver, sizeof(bin_driver));
1968 <        memcpy_powerpc_code((void *)(ROM_BASE + sony_offset + 0x600), bout_driver, sizeof(bout_driver));
1965 >        gen_ain_driver( ROM_BASE + sony_offset + 0x300);
1966 >        gen_aout_driver(ROM_BASE + sony_offset + 0x400);
1967 >        gen_bin_driver( ROM_BASE + sony_offset + 0x500);
1968 >        gen_bout_driver(ROM_BASE + sony_offset + 0x600);
1969  
1970          // Copy icons to ROM
1971          SonyDiskIconAddr = ROM_BASE + sony_offset + 0x800;
# Line 2235 | Line 2167 | void InstallDrivers(void)
2167   {
2168          D(bug("Installing drivers...\n"));
2169          M68kRegisters r;
2170 <        uint8 pb[SIZEOF_IOParam];
2170 >        SheepArray<SIZEOF_IOParam> pb_var;
2171 >        const uintptr pb = pb_var.addr();
2172  
2173          // Install floppy driver
2174 <        if (ROMType == ROMTYPE_NEWWORLD) {
2174 >        if (ROMType == ROMTYPE_NEWWORLD || ROMType == ROMTYPE_GOSSAMER) {
2175  
2176 <                // Force installation of floppy driver with NewWorld ROMs
2176 >                // Force installation of floppy driver with NewWorld and Gossamer ROMs
2177                  r.a[0] = ROM_BASE + sony_offset;
2178                  r.d[0] = (uint32)SonyRefNum;
2179                  Execute68kTrap(0xa43d, &r);             // DrvrInstallRsrvMem()
# Line 2258 | Line 2191 | void InstallDrivers(void)
2191   #endif
2192  
2193          // Open .Sony driver
2194 <        WriteMacInt8((uint32)pb + ioPermssn, 0);
2195 <        WriteMacInt32((uint32)pb + ioNamePtr, (uint32)"\005.Sony");
2196 <        r.a[0] = (uint32)pb;
2194 >        SheepString sony_str("\005.Sony");
2195 >        WriteMacInt8(pb + ioPermssn, 0);
2196 >        WriteMacInt32(pb + ioNamePtr, sony_str.addr());
2197 >        r.a[0] = pb;
2198          Execute68kTrap(0xa000, &r);             // Open()
2199  
2200          // Install disk driver
# Line 2274 | Line 2208 | void InstallDrivers(void)
2208          WriteMacInt16(dce + dCtlFlags, DiskDriverFlags);
2209  
2210          // Open disk driver
2211 <        WriteMacInt32((uint32)pb + ioNamePtr, (uint32)"\005.Disk");
2212 <        r.a[0] = (uint32)pb;
2211 >        SheepString disk_str("\005.Disk");
2212 >        WriteMacInt32(pb + ioNamePtr, disk_str.addr());
2213 >        r.a[0] = pb;
2214          Execute68kTrap(0xa000, &r);             // Open()
2215  
2216          // Install CD-ROM driver unless nocdrom option given
# Line 2292 | Line 2227 | void InstallDrivers(void)
2227                  WriteMacInt16(dce + dCtlFlags, CDROMDriverFlags);
2228  
2229                  // Open CD-ROM driver
2230 <                WriteMacInt32((uint32)pb + ioNamePtr, (uint32)"\010.AppleCD");
2231 <                r.a[0] = (uint32)pb;
2230 >                SheepString apple_cd("\010.AppleCD");
2231 >                WriteMacInt32(pb + ioNamePtr, apple_cd.addr());
2232 >                r.a[0] = pb;
2233                  Execute68kTrap(0xa000, &r);             // Open()
2234          }
2235  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines