447 |
|
0x4e, 0x75 // rts |
448 |
|
}; |
449 |
|
|
450 |
< |
#ifdef __linux__ |
450 |
> |
#if EMULATED_PPC |
451 |
> |
#define SERIAL_TRAMPOLINES 1 |
452 |
> |
static uint32 serial_nothing_tvect[2] = {POWERPC_NATIVE_OP_FUNC(NATIVE_SERIAL_NOTHING), 0}; |
453 |
> |
static uint32 serial_open_tvect[2] = {POWERPC_NATIVE_OP_FUNC(NATIVE_SERIAL_OPEN), 0}; |
454 |
> |
static uint32 serial_prime_in_tvect[2] = {POWERPC_NATIVE_OP_FUNC(NATIVE_SERIAL_PRIME_IN), 0}; |
455 |
> |
static uint32 serial_prime_out_tvect[2] = {POWERPC_NATIVE_OP_FUNC(NATIVE_SERIAL_PRIME_OUT), 0}; |
456 |
> |
static uint32 serial_control_tvect[2] = {POWERPC_NATIVE_OP_FUNC(NATIVE_SERIAL_CONTROL), 0}; |
457 |
> |
static uint32 serial_status_tvect[2] = {POWERPC_NATIVE_OP_FUNC(NATIVE_SERIAL_STATUS), 0}; |
458 |
> |
static uint32 serial_close_tvect[2] = {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}; |
474 |
|
0x00000000, 0x00000000, |
475 |
|
0xaafe0700, 0x00000000, |
476 |
|
0x00000000, 0x00179822, |
477 |
< |
#ifdef __linux__ |
477 |
> |
#ifdef SERIAL_TRAMPOLINES |
478 |
|
0x00010004, (uint32)serial_nothing_tvect, |
479 |
|
#else |
480 |
|
0x00010004, (uint32)SerialNothing, |
482 |
|
0x00000000, 0x00000000, |
483 |
|
0xaafe0700, 0x00000000, |
484 |
|
0x00000000, 0x00179822, |
485 |
< |
#ifdef __linux__ |
485 |
> |
#ifdef SERIAL_TRAMPOLINES |
486 |
|
0x00010004, (uint32)serial_prime_in_tvect, |
487 |
|
#else |
488 |
|
0x00010004, (uint32)SerialPrimeIn, |
490 |
|
0x00000000, 0x00000000, |
491 |
|
0xaafe0700, 0x00000000, |
492 |
|
0x00000000, 0x00179822, |
493 |
< |
#ifdef __linux__ |
493 |
> |
#ifdef SERIAL_TRAMPOLINES |
494 |
|
0x00010004, (uint32)serial_control_tvect, |
495 |
|
#else |
496 |
|
0x00010004, (uint32)SerialControl, |
498 |
|
0x00000000, 0x00000000, |
499 |
|
0xaafe0700, 0x00000000, |
500 |
|
0x00000000, 0x00179822, |
501 |
< |
#ifdef __linux__ |
501 |
> |
#ifdef SERIAL_TRAMPOLINES |
502 |
|
0x00010004, (uint32)serial_status_tvect, |
503 |
|
#else |
504 |
|
0x00010004, (uint32)SerialStatus, |
506 |
|
0x00000000, 0x00000000, |
507 |
|
0xaafe0700, 0x00000000, |
508 |
|
0x00000000, 0x00179822, |
509 |
< |
#ifdef __linux__ |
509 |
> |
#ifdef SERIAL_TRAMPOLINES |
510 |
|
0x00010004, (uint32)serial_nothing_tvect, |
511 |
|
#else |
512 |
|
0x00010004, (uint32)SerialNothing, |
521 |
|
0x00000000, 0x00000000, |
522 |
|
0xaafe0700, 0x00000000, |
523 |
|
0x00000000, 0x00179822, |
524 |
< |
#ifdef __linux__ |
524 |
> |
#ifdef SERIAL_TRAMPOLINES |
525 |
|
0x00010004, (uint32)serial_open_tvect, |
526 |
|
#else |
527 |
|
0x00010004, (uint32)SerialOpen, |
529 |
|
0x00000000, 0x00000000, |
530 |
|
0xaafe0700, 0x00000000, |
531 |
|
0x00000000, 0x00179822, |
532 |
< |
#ifdef __linux__ |
532 |
> |
#ifdef SERIAL_TRAMPOLINES |
533 |
|
0x00010004, (uint32)serial_prime_out_tvect, |
534 |
|
#else |
535 |
|
0x00010004, (uint32)SerialPrimeOut, |
537 |
|
0x00000000, 0x00000000, |
538 |
|
0xaafe0700, 0x00000000, |
539 |
|
0x00000000, 0x00179822, |
540 |
< |
#ifdef __linux__ |
540 |
> |
#ifdef SERIAL_TRAMPOLINES |
541 |
|
0x00010004, (uint32)serial_control_tvect, |
542 |
|
#else |
543 |
|
0x00010004, (uint32)SerialControl, |
545 |
|
0x00000000, 0x00000000, |
546 |
|
0xaafe0700, 0x00000000, |
547 |
|
0x00000000, 0x00179822, |
548 |
< |
#ifdef __linux__ |
548 |
> |
#ifdef SERIAL_TRAMPOLINES |
549 |
|
0x00010004, (uint32)serial_status_tvect, |
550 |
|
#else |
551 |
|
0x00010004, (uint32)SerialStatus, |
553 |
|
0x00000000, 0x00000000, |
554 |
|
0xaafe0700, 0x00000000, |
555 |
|
0x00000000, 0x00179822, |
556 |
< |
#ifdef __linux__ |
556 |
> |
#ifdef SERIAL_TRAMPOLINES |
557 |
|
0x00010004, (uint32)serial_close_tvect, |
558 |
|
#else |
559 |
|
0x00010004, (uint32)SerialClose, |
568 |
|
0x00000000, 0x00000000, |
569 |
|
0xaafe0700, 0x00000000, |
570 |
|
0x00000000, 0x00179822, |
571 |
< |
#ifdef __linux__ |
571 |
> |
#ifdef SERIAL_TRAMPOLINES |
572 |
|
0x00010004, (uint32)serial_nothing_tvect, |
573 |
|
#else |
574 |
|
0x00010004, (uint32)SerialNothing, |
576 |
|
0x00000000, 0x00000000, |
577 |
|
0xaafe0700, 0x00000000, |
578 |
|
0x00000000, 0x00179822, |
579 |
< |
#ifdef __linux__ |
579 |
> |
#ifdef SERIAL_TRAMPOLINES |
580 |
|
0x00010004, (uint32)serial_prime_in_tvect, |
581 |
|
#else |
582 |
|
0x00010004, (uint32)SerialPrimeIn, |
584 |
|
0x00000000, 0x00000000, |
585 |
|
0xaafe0700, 0x00000000, |
586 |
|
0x00000000, 0x00179822, |
587 |
< |
#ifdef __linux__ |
587 |
> |
#ifdef SERIAL_TRAMPOLINES |
588 |
|
0x00010004, (uint32)serial_control_tvect, |
589 |
|
#else |
590 |
|
0x00010004, (uint32)SerialControl, |
592 |
|
0x00000000, 0x00000000, |
593 |
|
0xaafe0700, 0x00000000, |
594 |
|
0x00000000, 0x00179822, |
595 |
< |
#ifdef __linux__ |
595 |
> |
#ifdef SERIAL_TRAMPOLINES |
596 |
|
0x00010004, (uint32)serial_status_tvect, |
597 |
|
#else |
598 |
|
0x00010004, (uint32)SerialStatus, |
600 |
|
0x00000000, 0x00000000, |
601 |
|
0xaafe0700, 0x00000000, |
602 |
|
0x00000000, 0x00179822, |
603 |
< |
#ifdef __linux__ |
603 |
> |
#ifdef SERIAL_TRAMPOLINES |
604 |
|
0x00010004, (uint32)serial_nothing_tvect, |
605 |
|
#else |
606 |
|
0x00010004, (uint32)SerialNothing, |
615 |
|
0x00000000, 0x00000000, |
616 |
|
0xaafe0700, 0x00000000, |
617 |
|
0x00000000, 0x00179822, |
618 |
< |
#ifdef __linux__ |
618 |
> |
#ifdef SERIAL_TRAMPOLINES |
619 |
|
0x00010004, (uint32)serial_open_tvect, |
620 |
|
#else |
621 |
|
0x00010004, (uint32)SerialOpen, |
623 |
|
0x00000000, 0x00000000, |
624 |
|
0xaafe0700, 0x00000000, |
625 |
|
0x00000000, 0x00179822, |
626 |
< |
#ifdef __linux__ |
626 |
> |
#ifdef SERIAL_TRAMPOLINES |
627 |
|
0x00010004, (uint32)serial_prime_out_tvect, |
628 |
|
#else |
629 |
|
0x00010004, (uint32)SerialPrimeOut, |
631 |
|
0x00000000, 0x00000000, |
632 |
|
0xaafe0700, 0x00000000, |
633 |
|
0x00000000, 0x00179822, |
634 |
< |
#ifdef __linux__ |
634 |
> |
#ifdef SERIAL_TRAMPOLINES |
635 |
|
0x00010004, (uint32)serial_control_tvect, |
636 |
|
#else |
637 |
|
0x00010004, (uint32)SerialControl, |
639 |
|
0x00000000, 0x00000000, |
640 |
|
0xaafe0700, 0x00000000, |
641 |
|
0x00000000, 0x00179822, |
642 |
< |
#ifdef __linux__ |
642 |
> |
#ifdef SERIAL_TRAMPOLINES |
643 |
|
0x00010004, (uint32)serial_status_tvect, |
644 |
|
#else |
645 |
|
0x00010004, (uint32)SerialStatus, |
647 |
|
0x00000000, 0x00000000, |
648 |
|
0xaafe0700, 0x00000000, |
649 |
|
0x00000000, 0x00179822, |
650 |
< |
#ifdef __linux__ |
650 |
> |
#ifdef SERIAL_TRAMPOLINES |
651 |
|
0x00010004, (uint32)serial_close_tvect, |
652 |
|
#else |
653 |
|
0x00010004, (uint32)SerialClose, |
1040 |
|
*lp = htonl(POWERPC_ILLEGAL); |
1041 |
|
|
1042 |
|
#if EMULATED_PPC |
1043 |
< |
// Install EMUL_RETURN, EXEC_RETURN and EMUL_OP opcodes |
1043 |
> |
// Install EMUL_RETURN, EXEC_RETURN, EXEC_NATIVE and EMUL_OP opcodes |
1044 |
|
lp = (uint32 *)(ROM_BASE + 0x380000 + (M68K_EMUL_RETURN << 3)); |
1045 |
|
*lp++ = htonl(POWERPC_EMUL_OP); |
1046 |
|
*lp++ = htonl(0x4bf66e80); // b 0x366084 |
1047 |
|
*lp++ = htonl(POWERPC_EMUL_OP | 1); |
1048 |
|
*lp++ = htonl(0x4bf66e78); // b 0x366084 |
1049 |
+ |
*lp++ = htonl(POWERPC_EMUL_OP | 2); |
1050 |
+ |
*lp++ = htonl(0x4bf66e70); // b 0x366084 |
1051 |
|
for (int i=0; i<OP_MAX; i++) { |
1052 |
< |
*lp++ = htonl(POWERPC_EMUL_OP | (i + 2)); |
1053 |
< |
*lp++ = htonl(0x4bf66e70 - i*8); // b 0x366084 |
1052 |
> |
*lp++ = htonl(POWERPC_EMUL_OP | (i + 3)); |
1053 |
> |
*lp++ = htonl(0x4bf66e68 - i*8); // b 0x366084 |
1054 |
|
} |
1055 |
|
#else |
1056 |
|
// Install EMUL_RETURN, EXEC_RETURN and EMUL_OP opcodes |
1059 |
|
*lp++ = htonl(0x4bf705fc); // b 0x36f800 |
1060 |
|
*lp++ = htonl(0x80000000 + XLM_EXEC_RETURN_PROC); // lwz r0,XLM_EXEC_RETURN_PROC |
1061 |
|
*lp++ = htonl(0x4bf705f4); // b 0x36f800 |
1062 |
+ |
*lp++ = htonl(0x00dead00); // Let SheepShaver crash, since |
1063 |
+ |
*lp++ = htonl(0x00beef00); // no native opcode is available |
1064 |
|
for (int i=0; i<OP_MAX; i++) { |
1065 |
|
*lp++ = htonl(0x38a00000 + i); // li r5,OP_* |
1066 |
< |
*lp++ = htonl(0x4bf705f4 - i*8); // b 0x36f808 |
1066 |
> |
*lp++ = htonl(0x4bf705ec - i*8); // b 0x36f808 |
1067 |
|
} |
1068 |
|
|
1069 |
|
// Extra routines for EMUL_RETURN/EXEC_RETURN/EMUL_OP |
2027 |
|
wp = (uint16 *)(ROM_BASE + base); |
2028 |
|
if (ROMType == ROMTYPE_ZANZIBAR) |
2029 |
|
*wp = htons(M68K_RTS); |
2030 |
< |
else |
2030 |
> |
else if (ntohs(wp[-4]) == 0x61ff) |
2031 |
> |
*wp = htons(M68K_RTS); |
2032 |
> |
else if (ntohs(wp[-2]) == 0x6700) |
2033 |
|
wp[-2] = htons(0x6000); // bra |
2034 |
|
|
2035 |
|
// Patch PowerOff() |
2151 |
|
M68kRegisters r; |
2152 |
|
uint8 pb[SIZEOF_IOParam]; |
2153 |
|
|
2154 |
+ |
#if DISABLE_SCSI && 0 |
2155 |
+ |
// Fake SCSIGlobals |
2156 |
+ |
static const uint8 fake_scsi_globals[32] = {0,}; |
2157 |
+ |
WriteMacInt32(0xc0c, (uint32)fake_scsi_globals); |
2158 |
+ |
#endif |
2159 |
+ |
|
2160 |
+ |
// Install floppy driver |
2161 |
+ |
if (ROMType == ROMTYPE_NEWWORLD) { |
2162 |
+ |
|
2163 |
+ |
// Force installation of floppy driver with NewWorld ROMs |
2164 |
+ |
r.a[0] = ROM_BASE + sony_offset; |
2165 |
+ |
r.d[0] = (uint32)SonyRefNum; |
2166 |
+ |
Execute68kTrap(0xa43d, &r); // DrvrInstallRsrvMem() |
2167 |
+ |
r.a[0] = ReadMacInt32(ReadMacInt32(0x11c) + ~SonyRefNum * 4); // Get driver handle from Unit Table |
2168 |
+ |
Execute68kTrap(0xa029, &r); // HLock() |
2169 |
+ |
uint32 dce = ReadMacInt32(r.a[0]); |
2170 |
+ |
WriteMacInt32(dce + dCtlDriver, ROM_BASE + sony_offset); |
2171 |
+ |
WriteMacInt16(dce + dCtlFlags, SonyDriverFlags); |
2172 |
+ |
} |
2173 |
+ |
|
2174 |
|
// Open .Sony driver |
2175 |
|
WriteMacInt8((uint32)pb + ioPermssn, 0); |
2176 |
|
WriteMacInt32((uint32)pb + ioNamePtr, (uint32)"\005.Sony"); |