1 |
|
/* |
2 |
|
* main_beos.cpp - Emulation core, BeOS implementation |
3 |
|
* |
4 |
< |
* SheepShaver (C) 1997-2002 Christian Bauer and Marc Hellwig |
4 |
> |
* SheepShaver (C) 1997-2004 Christian Bauer and Marc Hellwig |
5 |
|
* |
6 |
|
* This program is free software; you can redistribute it and/or modify |
7 |
|
* it under the terms of the GNU General Public License as published by |
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 DR_EMULATOR_AREA_NAME[] = "Macintosh DR Emulator"; |
121 |
|
const char SHEEP_AREA_NAME[] = "SheepShaver Virtual Stack"; |
122 |
|
|
123 |
|
const uint32 SIG_STACK_SIZE = 8192; // Size of signal stack |
143 |
|
// Initialize other variables |
144 |
|
sheep_fd = -1; |
145 |
|
emulator_data = NULL; |
146 |
< |
kernel_area = kernel_area2 = rom_area = ram_area = dr_cache_area = -1; |
146 |
> |
kernel_area = kernel_area2 = rom_area = ram_area = dr_cache_area = dr_emulator_area = -1; |
147 |
|
emul_thread = nvram_thread = tick_thread = -1; |
148 |
|
ReadyForSignals = false; |
149 |
|
AllowQuitting = true; |
191 |
|
area_id rom_area; // ROM area ID |
192 |
|
area_id ram_area; // RAM area ID |
193 |
|
area_id dr_cache_area; // DR Cache area ID |
194 |
+ |
area_id dr_emulator_area; // DR Emulator area ID |
195 |
|
|
196 |
|
struct sigaction sigusr1_action; // Interrupt signal (of emulator thread) |
197 |
|
struct sigaction sigsegv_action; // Data access exception signal (of emulator thread) |
215 |
|
uint32 KernelDataAddr; // Address of Kernel Data |
216 |
|
uint32 BootGlobsAddr; // Address of BootGlobs structure at top of Mac RAM |
217 |
|
uint32 DRCacheAddr; // Address of DR Cache |
218 |
+ |
uint32 DREmulatorAddr; // Address of DR Emulator |
219 |
|
uint32 PVR; // Theoretical PVR |
220 |
|
int64 CPUClockSpeed; // Processor clock speed (Hz) |
221 |
|
int64 BusClockSpeed; // Bus clock speed (Hz) |
223 |
|
|
224 |
|
static void *sig_stack = NULL; // Stack for signal handlers |
225 |
|
static void *extra_stack = NULL; // Stack for SIGSEGV inside interrupt handler |
226 |
+ |
uint32 SheepMem::page_size; // Size of a native page |
227 |
|
uintptr SheepMem::zero_page = 0; // Address of ro page filled in with zeros |
228 |
|
uintptr SheepMem::base; // Address of SheepShaver data |
229 |
|
uintptr SheepMem::top; // Top of SheepShaver data (stack like storage) |
316 |
|
area_id old_dr_cache_area = find_area(DR_CACHE_AREA_NAME); |
317 |
|
if (old_dr_cache_area > 0) |
318 |
|
delete_area(old_dr_cache_area); |
319 |
+ |
area_id old_dr_emulator_area = find_area(DR_EMULATOR_AREA_NAME); |
320 |
+ |
if (old_dr_emulator_area > 0) |
321 |
+ |
delete_area(old_dr_emulator_area); |
322 |
|
|
323 |
|
// Read preferences |
324 |
|
int argc = 0; |
409 |
|
|
410 |
|
// Create area for SheepShaver data |
411 |
|
if (!SheepMem::Init()) { |
412 |
< |
sprintf(str, GetString(STR_NO_SHEEP_MEM_AREA_ERR)); |
412 |
> |
sprintf(str, GetString(STR_NO_SHEEP_MEM_AREA_ERR), strerror(SheepMemArea), SheepMemArea); |
413 |
|
ErrorAlert(str); |
414 |
|
PostMessage(B_QUIT_REQUESTED); |
415 |
|
return; |
464 |
|
} |
465 |
|
D(bug("DR Cache area %ld at %p\n", dr_cache_area, DRCacheAddr)); |
466 |
|
|
467 |
+ |
// Create area for DR Emulator |
468 |
+ |
DREmulatorAddr = DR_EMULATOR_BASE; |
469 |
+ |
dr_emulator_area = create_area(DR_EMULATOR_AREA_NAME, (void **)&DREmulatorAddr, B_EXACT_ADDRESS, DR_EMULATOR_SIZE, B_NO_LOCK, B_READ_AREA | B_WRITE_AREA); |
470 |
+ |
if (dr_emulator_area < 0) { |
471 |
+ |
sprintf(str, GetString(STR_NO_KERNEL_DATA_ERR), strerror(dr_emulator_area), dr_emulator_area); |
472 |
+ |
ErrorAlert(str); |
473 |
+ |
PostMessage(B_QUIT_REQUESTED); |
474 |
+ |
return; |
475 |
+ |
} |
476 |
+ |
D(bug("DR Emulator area %ld at %p\n", dr_emulator_area, DREmulatorAddr)); |
477 |
+ |
|
478 |
|
// Load NVRAM |
479 |
|
XPRAMInit(); |
480 |
|
|
700 |
|
// Delete SheepShaver globals |
701 |
|
SheepMem::Exit(); |
702 |
|
|
703 |
+ |
// Delete DR Emulator area |
704 |
+ |
if (dr_emulator_area >= 0) |
705 |
+ |
delete_area(dr_emulator_area); |
706 |
+ |
|
707 |
|
// Delete DR Cache area |
708 |
|
if (dr_cache_area >= 0) |
709 |
|
delete_area(dr_cache_area); |
748 |
|
|
749 |
|
void SheepShaver::init_rom(void) |
750 |
|
{ |
751 |
+ |
// Size of a native page |
752 |
+ |
page_size = B_PAGE_SIZE; |
753 |
+ |
|
754 |
|
// Create area for ROM |
755 |
|
void *rom_addr = (void *)ROM_BASE; |
756 |
|
rom_area = create_area(ROM_AREA_NAME, &rom_addr, B_EXACT_ADDRESS, ROM_AREA_SIZE, B_NO_LOCK, B_READ_AREA | B_WRITE_AREA); |