88 |
|
#include "macos_util.h" |
89 |
|
#include "rom_patches.h" |
90 |
|
#include "user_strings.h" |
91 |
+ |
#include "thunks.h" |
92 |
|
|
93 |
|
#include "sheep_driver.h" |
94 |
|
|
117 |
|
const char RAM_AREA_NAME[] = "Macintosh RAM"; |
118 |
|
const char ROM_AREA_NAME[] = "Macintosh ROM"; |
119 |
|
const char DR_CACHE_AREA_NAME[] = "Macintosh DR Cache"; |
120 |
+ |
const char SHEEP_AREA_NAME[] = "SheepShaver Virtual Stack"; |
121 |
|
|
122 |
|
const uint32 SIG_STACK_SIZE = 8192; // Size of signal stack |
123 |
|
|
220 |
|
|
221 |
|
static void *sig_stack = NULL; // Stack for signal handlers |
222 |
|
static void *extra_stack = NULL; // Stack for SIGSEGV inside interrupt handler |
223 |
+ |
static uintptr SheepMem::base; // Address of SheepShaver data |
224 |
+ |
static uintptr SheepMem::top; // Top of SheepShaver data (stack like storage) |
225 |
+ |
static area_id SheepMemArea; // SheepShaver data area ID |
226 |
|
|
227 |
|
|
228 |
|
// Prototypes |
399 |
|
} |
400 |
|
D(bug("Kernel Data 2 area %ld at %p\n", kernel_area2, kernel_data2)); |
401 |
|
|
402 |
+ |
// Create area for SheepShaver data |
403 |
+ |
if (!SheepMem::Init()) { |
404 |
+ |
sprintf(str, GetString(STR_NO_SHEEP_MEM_AREA_ERR)); |
405 |
+ |
ErrorAlert(str); |
406 |
+ |
PostMessage(B_QUIT_REQUESTED); |
407 |
+ |
return; |
408 |
+ |
} |
409 |
+ |
|
410 |
|
// Create area for Mac RAM |
411 |
|
RAMSize = PrefsFindInt32("ramsize") & 0xfff00000; // Round down to 1MB boundary |
412 |
|
if (RAMSize < 8*1024*1024) { |
476 |
|
boot_globs[1] = htonl(RAMSize); |
477 |
|
boot_globs[2] = htonl((uint32)-1); // End of bank table |
478 |
|
|
479 |
+ |
// Init thunks |
480 |
+ |
if (!InitThunks()) { |
481 |
+ |
PostMessage(B_QUIT_REQUESTED); |
482 |
+ |
return; |
483 |
+ |
} |
484 |
+ |
|
485 |
|
// Init drivers |
486 |
|
SonyInit(); |
487 |
|
DiskInit(); |
674 |
|
DiskExit(); |
675 |
|
SonyExit(); |
676 |
|
|
677 |
+ |
// Delete SheepShaver globals |
678 |
+ |
SheepMem::Exit(); |
679 |
+ |
|
680 |
|
// Delete DR Cache area |
681 |
|
if (dr_cache_area >= 0) |
682 |
|
delete_area(dr_cache_area); |
1270 |
|
|
1271 |
|
void ExecutePPC(void (*func)()) |
1272 |
|
{ |
1273 |
< |
RoutineDescriptor desc = BUILD_PPC_ROUTINE_DESCRIPTOR(0, func); |
1273 |
> |
SheepRoutineDescriptor desc(0, (uint32)func); |
1274 |
|
M68kRegisters r; |
1275 |
|
Execute68k((uint32)&desc, &r); |
1276 |
|
} |
2074 |
|
} |
2075 |
|
|
2076 |
|
|
2077 |
+ |
/* |
2078 |
+ |
* Helpers to share 32-bit addressable data with MacOS |
2079 |
+ |
*/ |
2080 |
+ |
|
2081 |
+ |
bool SheepMem::Init(void) |
2082 |
+ |
{ |
2083 |
+ |
// Delete old area |
2084 |
+ |
area_id old_sheep_area = find_area(SHEEP_AREA_NAME); |
2085 |
+ |
if (old_sheep_area > 0) |
2086 |
+ |
delete_area(old_sheep_area); |
2087 |
+ |
|
2088 |
+ |
// Create area for SheepShaver data |
2089 |
+ |
base = 0x60000000; |
2090 |
+ |
SheepMemArea = create_area(SHEEP_AREA_NAME, (void **)&base, B_BASE_ADDRESS, size, B_NO_LOCK, B_READ_AREA | B_WRITE_AREA); |
2091 |
+ |
if (SheepMemArea < 0) |
2092 |
+ |
return false; |
2093 |
+ |
|
2094 |
+ |
D(bug("SheepShaver area %ld at %p\n", SheepMemArea, base)); |
2095 |
+ |
top = base + size; |
2096 |
+ |
return true; |
2097 |
+ |
} |
2098 |
+ |
|
2099 |
+ |
void SheepMem::Exit(void) |
2100 |
+ |
{ |
2101 |
+ |
if (SheepMemArea >= 0) |
2102 |
+ |
delete_area(SheepMemArea); |
2103 |
+ |
} |
2104 |
+ |
|
2105 |
+ |
|
2106 |
|
/* |
2107 |
|
* Display error alert |
2108 |
|
*/ |