127 |
|
#include "debug.h" |
128 |
|
|
129 |
|
|
130 |
+ |
#ifdef HAVE_DIRENT_H |
131 |
+ |
#include <dirent.h> |
132 |
+ |
#endif |
133 |
+ |
|
134 |
+ |
#ifdef USE_SDL |
135 |
+ |
#include <SDL.h> |
136 |
+ |
#endif |
137 |
+ |
|
138 |
+ |
#ifndef USE_SDL_VIDEO |
139 |
|
#include <X11/Xlib.h> |
140 |
+ |
#endif |
141 |
|
|
142 |
|
#ifdef ENABLE_GTK |
143 |
|
#include <gtk/gtk.h> |
174 |
|
const char ROM_FILE_NAME[] = "ROM"; |
175 |
|
const char ROM_FILE_NAME2[] = "Mac OS ROM"; |
176 |
|
|
177 |
+ |
#if REAL_ADDRESSING |
178 |
|
const uintptr RAM_BASE = 0x20000000; // Base address of RAM |
179 |
+ |
#else |
180 |
+ |
// FIXME: needs to be >= 0x04000000 |
181 |
+ |
const uintptr RAM_BASE = 0x10000000; // Base address of RAM |
182 |
+ |
#endif |
183 |
|
const uint32 SIG_STACK_SIZE = 0x10000; // Size of signal stack |
184 |
|
|
185 |
|
|
284 |
|
uint32 PVR; // Theoretical PVR |
285 |
|
int64 CPUClockSpeed; // Processor clock speed (Hz) |
286 |
|
int64 BusClockSpeed; // Bus clock speed (Hz) |
287 |
+ |
int64 TimebaseSpeed; // Timebase clock speed (Hz) |
288 |
+ |
uint8 *RAMBaseHost; // Base address of Mac RAM (host address space) |
289 |
+ |
uint8 *ROMBaseHost; // Base address of Mac ROM (host address space) |
290 |
|
|
291 |
|
|
292 |
|
// Global variables |
293 |
+ |
#ifndef USE_SDL_VIDEO |
294 |
|
char *x_display_name = NULL; // X11 display name |
295 |
|
Display *x_display = NULL; // X11 display handle |
296 |
|
#ifdef X11_LOCK_TYPE |
297 |
|
X11_LOCK_TYPE x_display_lock = X11_LOCK_INIT; // X11 display lock |
298 |
|
#endif |
299 |
+ |
#endif |
300 |
|
|
301 |
|
static int zero_fd = 0; // FD of /dev/zero |
302 |
|
static bool lm_area_mapped = false; // Flag: Low Memory area mmap()ped |
311 |
|
static uint8 last_xpram[XPRAM_SIZE]; // Buffer for monitoring XPRAM changes |
312 |
|
|
313 |
|
static bool nvram_thread_active = false; // Flag: NVRAM watchdog installed |
314 |
+ |
static volatile bool nvram_thread_cancel; // Flag: Cancel NVRAM thread |
315 |
|
static pthread_t nvram_thread; // NVRAM watchdog |
316 |
|
static bool tick_thread_active = false; // Flag: MacOS thread installed |
317 |
+ |
static volatile bool tick_thread_cancel; // Flag: Cancel 60Hz thread |
318 |
|
static pthread_t tick_thread; // 60Hz thread |
319 |
|
static pthread_t emul_thread; // MacOS thread |
320 |
|
|
347 |
|
extern void emul_ppc(uint32 start); |
348 |
|
extern void init_emul_ppc(void); |
349 |
|
extern void exit_emul_ppc(void); |
350 |
+ |
sigsegv_return_t sigsegv_handler(sigsegv_address_t, sigsegv_address_t); |
351 |
|
#else |
352 |
|
static void sigusr2_handler(int sig, siginfo_t *sip, void *scp); |
353 |
|
static void sigsegv_handler(int sig, siginfo_t *sip, void *scp); |
438 |
|
int main(int argc, char **argv) |
439 |
|
{ |
440 |
|
char str[256]; |
418 |
– |
uint32 *boot_globs; |
441 |
|
int16 i16; |
442 |
|
int rom_fd; |
443 |
|
FILE *proc_file; |
472 |
|
for (int i=1; i<argc; i++) { |
473 |
|
if (strcmp(argv[i], "--help") == 0) { |
474 |
|
usage(argv[0]); |
475 |
+ |
#ifndef USE_SDL_VIDEO |
476 |
|
} else if (strcmp(argv[i], "--display") == 0) { |
477 |
|
i++; |
478 |
|
if (i < argc) |
479 |
|
x_display_name = strdup(argv[i]); |
480 |
+ |
#endif |
481 |
|
} else if (argv[i][0] == '-') { |
482 |
|
fprintf(stderr, "Unrecognized option '%s'\n", argv[i]); |
483 |
|
usage(argv[0]); |
484 |
|
} |
485 |
|
} |
486 |
|
|
487 |
+ |
#ifdef USE_SDL |
488 |
+ |
// Initialize SDL system |
489 |
+ |
int sdl_flags = 0; |
490 |
+ |
#ifdef USE_SDL_VIDEO |
491 |
+ |
sdl_flags |= SDL_INIT_VIDEO; |
492 |
+ |
#endif |
493 |
+ |
#ifdef USE_SDL_AUDIO |
494 |
+ |
sdl_flags |= SDL_INIT_AUDIO; |
495 |
+ |
#endif |
496 |
+ |
assert(sdl_flags != 0); |
497 |
+ |
if (SDL_Init(sdl_flags) == -1) { |
498 |
+ |
char str[256]; |
499 |
+ |
sprintf(str, "Could not initialize SDL: %s.\n", SDL_GetError()); |
500 |
+ |
ErrorAlert(str); |
501 |
+ |
goto quit; |
502 |
+ |
} |
503 |
+ |
atexit(SDL_Quit); |
504 |
+ |
#endif |
505 |
+ |
|
506 |
+ |
#ifndef USE_SDL_VIDEO |
507 |
|
// Open display |
508 |
|
x_display = XOpenDisplay(x_display_name); |
509 |
|
if (x_display == NULL) { |
517 |
|
// Fork out, so we can return from fullscreen mode when things get ugly |
518 |
|
XF86DGAForkApp(DefaultScreen(x_display)); |
519 |
|
#endif |
520 |
+ |
#endif |
521 |
|
|
522 |
|
#ifdef ENABLE_MON |
523 |
|
// Initialize mon |
524 |
|
mon_init(); |
525 |
|
#endif |
526 |
|
|
527 |
+ |
#if !EMULATED_PPC |
528 |
+ |
// Create and install stacks for signal handlers |
529 |
+ |
for (int i = 0; i < SIG_STACK_COUNT; i++) { |
530 |
+ |
void *sig_stack = malloc(SIG_STACK_SIZE); |
531 |
+ |
D(bug("Signal stack %d at %p\n", i, sig_stack)); |
532 |
+ |
if (sig_stack == NULL) { |
533 |
+ |
ErrorAlert(GetString(STR_NOT_ENOUGH_MEMORY_ERR)); |
534 |
+ |
goto quit; |
535 |
+ |
} |
536 |
+ |
sig_stacks[i].ss_sp = sig_stack; |
537 |
+ |
sig_stacks[i].ss_flags = 0; |
538 |
+ |
sig_stacks[i].ss_size = SIG_STACK_SIZE; |
539 |
+ |
} |
540 |
+ |
sig_stack_id = 0; |
541 |
+ |
if (sigaltstack(&sig_stacks[0], NULL) < 0) { |
542 |
+ |
sprintf(str, GetString(STR_SIGALTSTACK_ERR), strerror(errno)); |
543 |
+ |
ErrorAlert(str); |
544 |
+ |
goto quit; |
545 |
+ |
} |
546 |
+ |
#endif |
547 |
+ |
|
548 |
+ |
#if !EMULATED_PPC |
549 |
+ |
// Install SIGSEGV and SIGBUS handlers |
550 |
+ |
sigemptyset(&sigsegv_action.sa_mask); // Block interrupts during SEGV handling |
551 |
+ |
sigaddset(&sigsegv_action.sa_mask, SIGUSR2); |
552 |
+ |
sigsegv_action.sa_sigaction = sigsegv_handler; |
553 |
+ |
sigsegv_action.sa_flags = SA_ONSTACK | SA_SIGINFO; |
554 |
+ |
#ifdef HAVE_SIGNAL_SA_RESTORER |
555 |
+ |
sigsegv_action.sa_restorer = NULL; |
556 |
+ |
#endif |
557 |
+ |
if (sigaction(SIGSEGV, &sigsegv_action, NULL) < 0) { |
558 |
+ |
sprintf(str, GetString(STR_SIGSEGV_INSTALL_ERR), strerror(errno)); |
559 |
+ |
ErrorAlert(str); |
560 |
+ |
goto quit; |
561 |
+ |
} |
562 |
+ |
if (sigaction(SIGBUS, &sigsegv_action, NULL) < 0) { |
563 |
+ |
sprintf(str, GetString(STR_SIGSEGV_INSTALL_ERR), strerror(errno)); |
564 |
+ |
ErrorAlert(str); |
565 |
+ |
goto quit; |
566 |
+ |
} |
567 |
+ |
#else |
568 |
+ |
// Install SIGSEGV handler for CPU emulator |
569 |
+ |
if (!sigsegv_install_handler(sigsegv_handler)) { |
570 |
+ |
sprintf(str, GetString(STR_SIGSEGV_INSTALL_ERR), strerror(errno)); |
571 |
+ |
ErrorAlert(str); |
572 |
+ |
goto quit; |
573 |
+ |
} |
574 |
+ |
#endif |
575 |
+ |
|
576 |
+ |
// Initialize VM system |
577 |
+ |
vm_init(); |
578 |
+ |
|
579 |
|
// Get system info |
580 |
|
PVR = 0x00040000; // Default: 604 |
581 |
|
CPUClockSpeed = 100000000; // Default: 100MHz |
582 |
|
BusClockSpeed = 100000000; // Default: 100MHz |
583 |
+ |
TimebaseSpeed = 25000000; // Default: 25MHz |
584 |
|
#if EMULATED_PPC |
585 |
|
PVR = 0x000c0000; // Default: 7400 (with AltiVec) |
586 |
+ |
#elif defined(__APPLE__) && defined(__MACH__) |
587 |
+ |
proc_file = popen("ioreg -c IOPlatformDevice", "r"); |
588 |
+ |
if (proc_file) { |
589 |
+ |
char line[256]; |
590 |
+ |
bool powerpc_node = false; |
591 |
+ |
while (fgets(line, sizeof(line) - 1, proc_file)) { |
592 |
+ |
// Read line |
593 |
+ |
int len = strlen(line); |
594 |
+ |
if (len == 0) |
595 |
+ |
continue; |
596 |
+ |
line[len - 1] = 0; |
597 |
+ |
|
598 |
+ |
// Parse line |
599 |
+ |
if (strstr(line, "o PowerPC,")) |
600 |
+ |
powerpc_node = true; |
601 |
+ |
else if (powerpc_node) { |
602 |
+ |
uint32 value; |
603 |
+ |
char head[256]; |
604 |
+ |
if (sscanf(line, "%[ |]\"cpu-version\" = <%x>", head, &value) == 2) |
605 |
+ |
PVR = value; |
606 |
+ |
else if (sscanf(line, "%[ |]\"clock-frequency\" = <%x>", head, &value) == 2) |
607 |
+ |
CPUClockSpeed = value; |
608 |
+ |
else if (sscanf(line, "%[ |]\"bus-frequency\" = <%x>", head, &value) == 2) |
609 |
+ |
BusClockSpeed = value; |
610 |
+ |
else if (sscanf(line, "%[ |]\"timebase-frequency\" = <%x>", head, &value) == 2) |
611 |
+ |
TimebaseSpeed = value; |
612 |
+ |
else if (strchr(line, '}')) |
613 |
+ |
powerpc_node = false; |
614 |
+ |
} |
615 |
+ |
} |
616 |
+ |
fclose(proc_file); |
617 |
+ |
} else { |
618 |
+ |
sprintf(str, GetString(STR_PROC_CPUINFO_WARN), strerror(errno)); |
619 |
+ |
WarningAlert(str); |
620 |
+ |
} |
621 |
|
#else |
622 |
|
proc_file = fopen("/proc/cpuinfo", "r"); |
623 |
|
if (proc_file) { |
624 |
+ |
// CPU specs from Linux kernel |
625 |
+ |
// TODO: make it more generic with features (e.g. AltiVec) and |
626 |
+ |
// cache information and friends for NameRegistry |
627 |
+ |
static const struct { |
628 |
+ |
uint32 pvr_mask; |
629 |
+ |
uint32 pvr_value; |
630 |
+ |
const char *cpu_name; |
631 |
+ |
} |
632 |
+ |
cpu_specs[] = { |
633 |
+ |
{ 0xffff0000, 0x00010000, "601" }, |
634 |
+ |
{ 0xffff0000, 0x00030000, "603" }, |
635 |
+ |
{ 0xffff0000, 0x00060000, "603e" }, |
636 |
+ |
{ 0xffff0000, 0x00070000, "603ev" }, |
637 |
+ |
{ 0xffff0000, 0x00040000, "604" }, |
638 |
+ |
{ 0xfffff000, 0x00090000, "604e" }, |
639 |
+ |
{ 0xffff0000, 0x00090000, "604r" }, |
640 |
+ |
{ 0xffff0000, 0x000a0000, "604ev" }, |
641 |
+ |
{ 0xffffffff, 0x00084202, "740/750" }, |
642 |
+ |
{ 0xfffff000, 0x00083000, "745/755" }, |
643 |
+ |
{ 0xfffffff0, 0x00080100, "750CX" }, |
644 |
+ |
{ 0xfffffff0, 0x00082200, "750CX" }, |
645 |
+ |
{ 0xfffffff0, 0x00082210, "750CXe" }, |
646 |
+ |
{ 0xffffff00, 0x70000100, "750FX" }, |
647 |
+ |
{ 0xffffffff, 0x70000200, "750FX" }, |
648 |
+ |
{ 0xffff0000, 0x70000000, "750FX" }, |
649 |
+ |
{ 0xffff0000, 0x70020000, "750GX" }, |
650 |
+ |
{ 0xffff0000, 0x00080000, "740/750" }, |
651 |
+ |
{ 0xffffffff, 0x000c1101, "7400 (1.1)" }, |
652 |
+ |
{ 0xffff0000, 0x000c0000, "7400" }, |
653 |
+ |
{ 0xffff0000, 0x800c0000, "7410" }, |
654 |
+ |
{ 0xffffffff, 0x80000200, "7450" }, |
655 |
+ |
{ 0xffffffff, 0x80000201, "7450" }, |
656 |
+ |
{ 0xffff0000, 0x80000000, "7450" }, |
657 |
+ |
{ 0xffffff00, 0x80010100, "7455" }, |
658 |
+ |
{ 0xffffffff, 0x80010200, "7455" }, |
659 |
+ |
{ 0xffff0000, 0x80010000, "7455" }, |
660 |
+ |
{ 0xffff0000, 0x80020000, "7457" }, |
661 |
+ |
{ 0xffff0000, 0x80030000, "7447A" }, |
662 |
+ |
{ 0x7fff0000, 0x00810000, "82xx" }, |
663 |
+ |
{ 0x7fff0000, 0x00820000, "8280" }, |
664 |
+ |
{ 0xffff0000, 0x00400000, "Power3 (630)" }, |
665 |
+ |
{ 0xffff0000, 0x00410000, "Power3 (630+)" }, |
666 |
+ |
{ 0xffff0000, 0x00360000, "I-star" }, |
667 |
+ |
{ 0xffff0000, 0x00370000, "S-star" }, |
668 |
+ |
{ 0xffff0000, 0x00350000, "Power4" }, |
669 |
+ |
{ 0xffff0000, 0x00390000, "PPC970" }, |
670 |
+ |
{ 0, 0, 0 } |
671 |
+ |
}; |
672 |
+ |
|
673 |
|
char line[256]; |
674 |
|
while(fgets(line, 255, proc_file)) { |
675 |
|
// Read line |
682 |
|
int i; |
683 |
|
char value[256]; |
684 |
|
if (sscanf(line, "cpu : %[0-9A-Za-a]", value) == 1) { |
685 |
< |
if (strcmp(value, "601") == 0) |
686 |
< |
PVR = 0x00010000; |
687 |
< |
else if (strcmp(value, "603") == 0) |
688 |
< |
PVR = 0x00030000; |
689 |
< |
else if (strcmp(value, "604") == 0) |
690 |
< |
PVR = 0x00040000; |
691 |
< |
else if (strcmp(value, "603e") == 0) |
692 |
< |
PVR = 0x00060000; |
693 |
< |
else if (strcmp(value, "603ev") == 0) |
694 |
< |
PVR = 0x00070000; |
513 |
< |
else if (strcmp(value, "604e") == 0) |
514 |
< |
PVR = 0x00090000; |
515 |
< |
else if (strcmp(value, "604ev5") == 0) |
516 |
< |
PVR = 0x000a0000; |
517 |
< |
else if (strcmp(value, "750") == 0) |
518 |
< |
PVR = 0x00080000; |
519 |
< |
else if (strcmp(value, "821") == 0) |
520 |
< |
PVR = 0x00320000; |
521 |
< |
else if (strcmp(value, "860") == 0) |
522 |
< |
PVR = 0x00500000; |
523 |
< |
else if (strcmp(value, "7400") == 0) |
524 |
< |
PVR = 0x000c0000; |
525 |
< |
else if (strcmp(value, "7410") == 0) |
526 |
< |
PVR = 0x800c0000; |
527 |
< |
else |
685 |
> |
// Search by name |
686 |
> |
const char *cpu_name = NULL; |
687 |
> |
for (int i = 0; cpu_specs[i].pvr_mask != 0; i++) { |
688 |
> |
if (strcmp(cpu_specs[i].cpu_name, value) == 0) { |
689 |
> |
cpu_name = cpu_specs[i].cpu_name; |
690 |
> |
PVR = cpu_specs[i].pvr_value; |
691 |
> |
break; |
692 |
> |
} |
693 |
> |
} |
694 |
> |
if (cpu_name == NULL) |
695 |
|
printf("WARNING: Unknown CPU type '%s', assuming 604\n", value); |
696 |
+ |
else |
697 |
+ |
printf("Found a PowerPC %s processor\n", cpu_name); |
698 |
|
} |
699 |
|
if (sscanf(line, "clock : %dMHz", &i) == 1) |
700 |
|
CPUClockSpeed = BusClockSpeed = i * 1000000; |
713 |
|
BusClockSpeed = value.l; |
714 |
|
fclose(proc_file); |
715 |
|
} |
716 |
+ |
|
717 |
+ |
// Get actual timebase frequency |
718 |
+ |
TimebaseSpeed = BusClockSpeed / 4; |
719 |
+ |
DIR *cpus_dir; |
720 |
+ |
if ((cpus_dir = opendir("/proc/device-tree/cpus")) != NULL) { |
721 |
+ |
struct dirent *cpu_entry; |
722 |
+ |
while ((cpu_entry = readdir(cpus_dir)) != NULL) { |
723 |
+ |
if (strstr(cpu_entry->d_name, "PowerPC,") == cpu_entry->d_name) { |
724 |
+ |
char timebase_freq_node[256]; |
725 |
+ |
sprintf(timebase_freq_node, "/proc/device-tree/cpus/%s/timebase-frequency", cpu_entry->d_name); |
726 |
+ |
proc_file = fopen(timebase_freq_node, "r"); |
727 |
+ |
if (proc_file) { |
728 |
+ |
union { uint8 b[4]; uint32 l; } value; |
729 |
+ |
if (fread(value.b, sizeof(value), 1, proc_file) == 1) |
730 |
+ |
TimebaseSpeed = value.l; |
731 |
+ |
fclose(proc_file); |
732 |
+ |
} |
733 |
+ |
} |
734 |
+ |
} |
735 |
+ |
closedir(cpus_dir); |
736 |
+ |
} |
737 |
|
#endif |
738 |
+ |
// Remap any newer G4/G5 processor to plain G4 for compatibility |
739 |
+ |
switch (PVR >> 16) { |
740 |
+ |
case 0x8000: // 7450 |
741 |
+ |
case 0x8001: // 7455 |
742 |
+ |
case 0x8002: // 7457 |
743 |
+ |
case 0x0039: // 970 |
744 |
+ |
PVR = 0x000c0000; // 7400 |
745 |
+ |
break; |
746 |
+ |
} |
747 |
|
D(bug("PVR: %08x (assumed)\n", PVR)); |
748 |
|
|
749 |
|
// Init system routines |
769 |
|
|
770 |
|
#ifndef PAGEZERO_HACK |
771 |
|
// Create Low Memory area (0x0000..0x3000) |
772 |
< |
if (vm_acquire_fixed((char *)0, 0x3000) < 0) { |
772 |
> |
if (vm_acquire_fixed((char *)NATMEM_OFFSET, 0x3000) < 0) { |
773 |
|
sprintf(str, GetString(STR_LOW_MEM_MMAP_ERR), strerror(errno)); |
774 |
|
ErrorAlert(str); |
775 |
|
goto quit; |
784 |
|
ErrorAlert(str); |
785 |
|
goto quit; |
786 |
|
} |
787 |
< |
if (shmat(kernel_area, (void *)KERNEL_DATA_BASE, 0) < 0) { |
787 |
> |
if (shmat(kernel_area, (void *)(KERNEL_DATA_BASE + NATMEM_OFFSET), 0) < 0) { |
788 |
|
sprintf(str, GetString(STR_KD_SHMAT_ERR), strerror(errno)); |
789 |
|
ErrorAlert(str); |
790 |
|
goto quit; |
791 |
|
} |
792 |
< |
if (shmat(kernel_area, (void *)KERNEL_DATA2_BASE, 0) < 0) { |
792 |
> |
if (shmat(kernel_area, (void *)(KERNEL_DATA2_BASE + NATMEM_OFFSET), 0) < 0) { |
793 |
|
sprintf(str, GetString(STR_KD2_SHMAT_ERR), strerror(errno)); |
794 |
|
ErrorAlert(str); |
795 |
|
goto quit; |
796 |
|
} |
797 |
< |
kernel_data = (KernelData *)KERNEL_DATA_BASE; |
797 |
> |
kernel_data = (KernelData *)(KERNEL_DATA_BASE + NATMEM_OFFSET); |
798 |
|
emulator_data = &kernel_data->ed; |
799 |
|
KernelDataAddr = KERNEL_DATA_BASE; |
800 |
< |
D(bug("Kernel Data at %p, Emulator Data at %p\n", kernel_data, emulator_data)); |
800 |
> |
D(bug("Kernel Data at %p (%08x)\n", kernel_data, KERNEL_DATA_BASE)); |
801 |
> |
D(bug("Emulator Data at %p (%08x)\n", emulator_data, KERNEL_DATA_BASE + offsetof(KernelData, ed))); |
802 |
|
|
803 |
|
// Create area for DR Cache |
804 |
< |
if (vm_acquire_fixed((void *)DR_EMULATOR_BASE, DR_EMULATOR_SIZE) < 0) { |
804 |
> |
if (vm_acquire_fixed((void *)(DR_EMULATOR_BASE + NATMEM_OFFSET), DR_EMULATOR_SIZE) < 0) { |
805 |
|
sprintf(str, GetString(STR_DR_EMULATOR_MMAP_ERR), strerror(errno)); |
806 |
|
ErrorAlert(str); |
807 |
|
goto quit; |
808 |
|
} |
809 |
|
dr_emulator_area_mapped = true; |
810 |
< |
if (vm_acquire_fixed((void *)DR_CACHE_BASE, DR_CACHE_SIZE) < 0) { |
810 |
> |
if (vm_acquire_fixed((void *)(DR_CACHE_BASE + NATMEM_OFFSET), DR_CACHE_SIZE) < 0) { |
811 |
|
sprintf(str, GetString(STR_DR_CACHE_MMAP_ERR), strerror(errno)); |
812 |
|
ErrorAlert(str); |
813 |
|
goto quit; |
814 |
|
} |
815 |
|
dr_cache_area_mapped = true; |
816 |
+ |
#if !EMULATED_PPC |
817 |
+ |
if (vm_protect((char *)DR_CACHE_BASE, DR_CACHE_SIZE, VM_PAGE_READ | VM_PAGE_WRITE | VM_PAGE_EXECUTE) < 0) { |
818 |
+ |
sprintf(str, GetString(STR_DR_CACHE_MMAP_ERR), strerror(errno)); |
819 |
+ |
ErrorAlert(str); |
820 |
+ |
goto quit; |
821 |
+ |
} |
822 |
+ |
#endif |
823 |
|
DRCacheAddr = DR_CACHE_BASE; |
824 |
|
D(bug("DR Cache at %p\n", DRCacheAddr)); |
825 |
|
|
831 |
|
} |
832 |
|
|
833 |
|
// Create area for Mac ROM |
834 |
< |
if (vm_acquire_fixed((char *)ROM_BASE, ROM_AREA_SIZE) < 0) { |
834 |
> |
ROMBaseHost = (uint8 *)(ROM_BASE + NATMEM_OFFSET); |
835 |
> |
if (vm_acquire_fixed(ROMBaseHost, ROM_AREA_SIZE) < 0) { |
836 |
|
sprintf(str, GetString(STR_ROM_MMAP_ERR), strerror(errno)); |
837 |
|
ErrorAlert(str); |
838 |
|
goto quit; |
839 |
|
} |
840 |
|
#if !EMULATED_PPC |
841 |
< |
if (vm_protect((char *)ROM_BASE, ROM_AREA_SIZE, VM_PAGE_READ | VM_PAGE_WRITE | VM_PAGE_EXECUTE) < 0) { |
841 |
> |
if (vm_protect(ROMBaseHost, ROM_AREA_SIZE, VM_PAGE_READ | VM_PAGE_WRITE | VM_PAGE_EXECUTE) < 0) { |
842 |
|
sprintf(str, GetString(STR_ROM_MMAP_ERR), strerror(errno)); |
843 |
|
ErrorAlert(str); |
844 |
|
goto quit; |
845 |
|
} |
846 |
|
#endif |
847 |
|
rom_area_mapped = true; |
848 |
< |
D(bug("ROM area at %08x\n", ROM_BASE)); |
848 |
> |
D(bug("ROM area at %p (%08x)\n", ROMBaseHost, ROM_BASE)); |
849 |
|
|
850 |
|
// Create area for Mac RAM |
851 |
|
RAMSize = PrefsFindInt32("ramsize"); |
854 |
|
RAMSize = 8*1024*1024; |
855 |
|
} |
856 |
|
|
857 |
< |
if (vm_acquire_fixed((char *)RAM_BASE, RAMSize) < 0) { |
857 |
> |
RAMBaseHost = (uint8 *)(RAM_BASE + NATMEM_OFFSET); |
858 |
> |
if (vm_acquire_fixed(RAMBaseHost, RAMSize) < 0) { |
859 |
|
sprintf(str, GetString(STR_RAM_MMAP_ERR), strerror(errno)); |
860 |
|
ErrorAlert(str); |
861 |
|
goto quit; |
862 |
|
} |
863 |
|
#if !EMULATED_PPC |
864 |
< |
if (vm_protect((char *)RAM_BASE, RAMSize, VM_PAGE_READ | VM_PAGE_WRITE | VM_PAGE_EXECUTE) < 0) { |
864 |
> |
if (vm_protect(RAMBaseHost, RAMSize, VM_PAGE_READ | VM_PAGE_WRITE | VM_PAGE_EXECUTE) < 0) { |
865 |
|
sprintf(str, GetString(STR_RAM_MMAP_ERR), strerror(errno)); |
866 |
|
ErrorAlert(str); |
867 |
|
goto quit; |
869 |
|
#endif |
870 |
|
RAMBase = RAM_BASE; |
871 |
|
ram_area_mapped = true; |
872 |
< |
D(bug("RAM area at %08x\n", RAMBase)); |
872 |
> |
D(bug("RAM area at %p (%08x)\n", RAMBaseHost, RAMBase)); |
873 |
|
|
874 |
|
if (RAMBase > ROM_BASE) { |
875 |
|
ErrorAlert(GetString(STR_RAM_HIGHER_THAN_ROM_ERR)); |
947 |
|
XPRAM[0x137b] = i16 & 0xff; |
948 |
|
|
949 |
|
// Create BootGlobs at top of Mac memory |
950 |
< |
memset((void *)(RAMBase + RAMSize - 4096), 0, 4096); |
950 |
> |
memset(RAMBaseHost + RAMSize - 4096, 0, 4096); |
951 |
|
BootGlobsAddr = RAMBase + RAMSize - 0x1c; |
952 |
< |
boot_globs = (uint32 *)BootGlobsAddr; |
953 |
< |
boot_globs[-5] = htonl(RAMBase + RAMSize); // MemTop |
954 |
< |
boot_globs[0] = htonl(RAMBase); // First RAM bank |
955 |
< |
boot_globs[1] = htonl(RAMSize); |
747 |
< |
boot_globs[2] = htonl((uint32)-1); // End of bank table |
952 |
> |
WriteMacInt32(BootGlobsAddr - 5 * 4, RAMBase + RAMSize); // MemTop |
953 |
> |
WriteMacInt32(BootGlobsAddr + 0 * 4, RAMBase); // First RAM bank |
954 |
> |
WriteMacInt32(BootGlobsAddr + 1 * 4, RAMSize); |
955 |
> |
WriteMacInt32(BootGlobsAddr + 2 * 4, (uint32)-1); // End of bank table |
956 |
|
|
957 |
|
// Init thunks |
958 |
|
if (!ThunksInit()) |
997 |
|
|
998 |
|
// Clear caches (as we loaded and patched code) and write protect ROM |
999 |
|
#if !EMULATED_PPC |
1000 |
< |
MakeExecutable(0, (void *)ROM_BASE, ROM_AREA_SIZE); |
1000 |
> |
MakeExecutable(0, ROM_BASE, ROM_AREA_SIZE); |
1001 |
|
#endif |
1002 |
< |
vm_protect((char *)ROM_BASE, ROM_AREA_SIZE, VM_PAGE_READ | VM_PAGE_EXECUTE); |
1002 |
> |
vm_protect(ROMBaseHost, ROM_AREA_SIZE, VM_PAGE_READ | VM_PAGE_EXECUTE); |
1003 |
|
|
1004 |
|
// Initialize Kernel Data |
1005 |
|
memset(kernel_data, 0, sizeof(KernelData)); |
1006 |
|
if (ROMType == ROMTYPE_NEWWORLD) { |
1007 |
< |
uintptr of_dev_tree = SheepMem::Reserve(4 * sizeof(uint32)); |
1008 |
< |
memset((void *)of_dev_tree, 0, 4 * sizeof(uint32)); |
1009 |
< |
uintptr vector_lookup_tbl = SheepMem::Reserve(128); |
1010 |
< |
uintptr vector_mask_tbl = SheepMem::Reserve(64); |
1007 |
> |
uint32 of_dev_tree = SheepMem::Reserve(4 * sizeof(uint32)); |
1008 |
> |
Mac_memset(of_dev_tree, 0, 4 * sizeof(uint32)); |
1009 |
> |
uint32 vector_lookup_tbl = SheepMem::Reserve(128); |
1010 |
> |
uint32 vector_mask_tbl = SheepMem::Reserve(64); |
1011 |
|
memset((uint8 *)kernel_data + 0xb80, 0x3d, 0x80); |
1012 |
< |
memset((void *)vector_lookup_tbl, 0, 128); |
1013 |
< |
memset((void *)vector_mask_tbl, 0, 64); |
1012 |
> |
Mac_memset(vector_lookup_tbl, 0, 128); |
1013 |
> |
Mac_memset(vector_mask_tbl, 0, 64); |
1014 |
|
kernel_data->v[0xb80 >> 2] = htonl(ROM_BASE); |
1015 |
|
kernel_data->v[0xb84 >> 2] = htonl(of_dev_tree); // OF device tree base |
1016 |
|
kernel_data->v[0xb90 >> 2] = htonl(vector_lookup_tbl); |
1029 |
|
kernel_data->v[0xf60 >> 2] = htonl(PVR); |
1030 |
|
kernel_data->v[0xf64 >> 2] = htonl(CPUClockSpeed); // clock-frequency |
1031 |
|
kernel_data->v[0xf68 >> 2] = htonl(BusClockSpeed); // bus-frequency |
1032 |
< |
kernel_data->v[0xf6c >> 2] = htonl(BusClockSpeed / 4); // timebase-frequency |
1032 |
> |
kernel_data->v[0xf6c >> 2] = htonl(TimebaseSpeed); // timebase-frequency |
1033 |
|
} else { |
1034 |
|
kernel_data->v[0xc80 >> 2] = htonl(RAMSize); |
1035 |
|
kernel_data->v[0xc84 >> 2] = htonl(RAMSize); |
1043 |
|
kernel_data->v[0xf80 >> 2] = htonl(PVR); |
1044 |
|
kernel_data->v[0xf84 >> 2] = htonl(CPUClockSpeed); // clock-frequency |
1045 |
|
kernel_data->v[0xf88 >> 2] = htonl(BusClockSpeed); // bus-frequency |
1046 |
< |
kernel_data->v[0xf8c >> 2] = htonl(BusClockSpeed / 4); // timebase-frequency |
1046 |
> |
kernel_data->v[0xf8c >> 2] = htonl(TimebaseSpeed); // timebase-frequency |
1047 |
|
} |
1048 |
|
|
1049 |
|
// Initialize extra low memory |
1050 |
|
D(bug("Initializing Low Memory...\n")); |
1051 |
< |
memset(NULL, 0, 0x3000); |
1051 |
> |
Mac_memset(0, 0, 0x3000); |
1052 |
|
WriteMacInt32(XLM_SIGNATURE, FOURCC('B','a','a','h')); // Signature to detect SheepShaver |
1053 |
|
WriteMacInt32(XLM_KERNEL_DATA, KernelDataAddr); // For trap replacement routines |
1054 |
|
WriteMacInt32(XLM_PVR, PVR); // Theoretical PVR |
1068 |
|
D(bug("Low Memory initialized\n")); |
1069 |
|
|
1070 |
|
// Start 60Hz thread |
1071 |
+ |
tick_thread_cancel = false; |
1072 |
|
tick_thread_active = (pthread_create(&tick_thread, NULL, tick_func, NULL) == 0); |
1073 |
|
D(bug("Tick thread installed (%ld)\n", tick_thread)); |
1074 |
|
|
1075 |
|
// Start NVRAM watchdog thread |
1076 |
|
memcpy(last_xpram, XPRAM, XPRAM_SIZE); |
1077 |
+ |
nvram_thread_cancel = false; |
1078 |
|
nvram_thread_active = (pthread_create(&nvram_thread, NULL, nvram_func, NULL) == 0); |
1079 |
|
D(bug("NVRAM thread installed (%ld)\n", nvram_thread)); |
1080 |
|
|
1081 |
|
#if !EMULATED_PPC |
872 |
– |
// Create and install stacks for signal handlers |
873 |
– |
for (int i = 0; i < SIG_STACK_COUNT; i++) { |
874 |
– |
void *sig_stack = malloc(SIG_STACK_SIZE); |
875 |
– |
D(bug("Signal stack %d at %p\n", i, sig_stack)); |
876 |
– |
if (sig_stack == NULL) { |
877 |
– |
ErrorAlert(GetString(STR_NOT_ENOUGH_MEMORY_ERR)); |
878 |
– |
goto quit; |
879 |
– |
} |
880 |
– |
sig_stacks[i].ss_sp = sig_stack; |
881 |
– |
sig_stacks[i].ss_flags = 0; |
882 |
– |
sig_stacks[i].ss_size = SIG_STACK_SIZE; |
883 |
– |
} |
884 |
– |
sig_stack_id = 0; |
885 |
– |
if (sigaltstack(&sig_stacks[0], NULL) < 0) { |
886 |
– |
sprintf(str, GetString(STR_SIGALTSTACK_ERR), strerror(errno)); |
887 |
– |
ErrorAlert(str); |
888 |
– |
goto quit; |
889 |
– |
} |
890 |
– |
#endif |
891 |
– |
|
892 |
– |
#if !EMULATED_PPC |
893 |
– |
// Install SIGSEGV and SIGBUS handlers |
894 |
– |
sigemptyset(&sigsegv_action.sa_mask); // Block interrupts during SEGV handling |
895 |
– |
sigaddset(&sigsegv_action.sa_mask, SIGUSR2); |
896 |
– |
sigsegv_action.sa_sigaction = sigsegv_handler; |
897 |
– |
sigsegv_action.sa_flags = SA_ONSTACK | SA_SIGINFO; |
898 |
– |
#ifdef HAVE_SIGNAL_SA_RESTORER |
899 |
– |
sigsegv_action.sa_restorer = NULL; |
900 |
– |
#endif |
901 |
– |
if (sigaction(SIGSEGV, &sigsegv_action, NULL) < 0) { |
902 |
– |
sprintf(str, GetString(STR_SIGSEGV_INSTALL_ERR), strerror(errno)); |
903 |
– |
ErrorAlert(str); |
904 |
– |
goto quit; |
905 |
– |
} |
906 |
– |
if (sigaction(SIGBUS, &sigsegv_action, NULL) < 0) { |
907 |
– |
sprintf(str, GetString(STR_SIGSEGV_INSTALL_ERR), strerror(errno)); |
908 |
– |
ErrorAlert(str); |
909 |
– |
goto quit; |
910 |
– |
} |
911 |
– |
|
1082 |
|
// Install SIGILL handler |
1083 |
|
sigemptyset(&sigill_action.sa_mask); // Block interrupts during ILL handling |
1084 |
|
sigaddset(&sigill_action.sa_mask, SIGUSR2); |
1133 |
|
|
1134 |
|
// Stop 60Hz thread |
1135 |
|
if (tick_thread_active) { |
1136 |
+ |
tick_thread_cancel = true; |
1137 |
|
pthread_cancel(tick_thread); |
1138 |
|
pthread_join(tick_thread, NULL); |
1139 |
|
} |
1140 |
|
|
1141 |
|
// Stop NVRAM watchdog thread |
1142 |
|
if (nvram_thread_active) { |
1143 |
+ |
nvram_thread_cancel = true; |
1144 |
|
pthread_cancel(nvram_thread); |
1145 |
|
pthread_join(nvram_thread, NULL); |
1146 |
|
} |
1208 |
|
|
1209 |
|
// Delete RAM area |
1210 |
|
if (ram_area_mapped) |
1211 |
< |
vm_release((char *)RAM_BASE, RAMSize); |
1211 |
> |
vm_release(RAMBaseHost, RAMSize); |
1212 |
|
|
1213 |
|
// Delete ROM area |
1214 |
|
if (rom_area_mapped) |
1215 |
< |
vm_release((char *)ROM_BASE, ROM_AREA_SIZE); |
1215 |
> |
vm_release(ROMBaseHost, ROM_AREA_SIZE); |
1216 |
|
|
1217 |
|
// Delete DR cache areas |
1218 |
|
if (dr_emulator_area_mapped) |
1219 |
< |
vm_release((void *)DR_EMULATOR_BASE, DR_EMULATOR_SIZE); |
1219 |
> |
vm_release((void *)(DR_EMULATOR_BASE + NATMEM_OFFSET), DR_EMULATOR_SIZE); |
1220 |
|
if (dr_cache_area_mapped) |
1221 |
< |
vm_release((void *)DR_CACHE_BASE, DR_CACHE_SIZE); |
1221 |
> |
vm_release((void *)(DR_CACHE_BASE + NATMEM_OFFSET), DR_CACHE_SIZE); |
1222 |
|
|
1223 |
|
// Delete Kernel Data area |
1224 |
|
if (kernel_area >= 0) { |
1225 |
< |
shmdt((void *)KERNEL_DATA_BASE); |
1226 |
< |
shmdt((void *)KERNEL_DATA2_BASE); |
1225 |
> |
shmdt((void *)(KERNEL_DATA_BASE + NATMEM_OFFSET)); |
1226 |
> |
shmdt((void *)(KERNEL_DATA2_BASE + NATMEM_OFFSET)); |
1227 |
|
shmctl(kernel_area, IPC_RMID, NULL); |
1228 |
|
} |
1229 |
|
|
1230 |
|
// Delete Low Memory area |
1231 |
|
if (lm_area_mapped) |
1232 |
< |
munmap((char *)0x0000, 0x3000); |
1232 |
> |
vm_release((void *)NATMEM_OFFSET, 0x3000); |
1233 |
|
|
1234 |
|
// Close /dev/zero |
1235 |
|
if (zero_fd > 0) |
1247 |
|
#endif |
1248 |
|
|
1249 |
|
// Close X11 server connection |
1250 |
+ |
#ifndef USE_SDL_VIDEO |
1251 |
|
if (x_display) |
1252 |
|
XCloseDisplay(x_display); |
1253 |
+ |
#endif |
1254 |
|
|
1255 |
|
exit(0); |
1256 |
|
} |
1385 |
|
* Make code executable |
1386 |
|
*/ |
1387 |
|
|
1388 |
< |
void MakeExecutable(int dummy, void *start, uint32 length) |
1388 |
> |
void MakeExecutable(int dummy, uint32 start, uint32 length) |
1389 |
|
{ |
1390 |
< |
if (((uintptr)start >= ROM_BASE) && ((uintptr)start < (ROM_BASE + ROM_SIZE))) |
1390 |
> |
if ((start >= ROM_BASE) && (start < (ROM_BASE + ROM_SIZE))) |
1391 |
|
return; |
1392 |
|
#if EMULATED_PPC |
1393 |
< |
FlushCodeCache((uintptr)start, (uintptr)start + length); |
1393 |
> |
FlushCodeCache(start, start + length); |
1394 |
|
#else |
1395 |
< |
flush_icache_range(start, (void *)((uintptr)start + length)); |
1395 |
> |
flush_icache_range(start, (void *)(start + length)); |
1396 |
|
#endif |
1397 |
|
} |
1398 |
|
|
1412 |
|
* NVRAM watchdog thread (saves NVRAM every minute) |
1413 |
|
*/ |
1414 |
|
|
1415 |
< |
static void *nvram_func(void *arg) |
1415 |
> |
static void nvram_watchdog(void) |
1416 |
|
{ |
1417 |
< |
struct timespec req = {60, 0}; // 1 minute |
1417 |
> |
if (memcmp(last_xpram, XPRAM, XPRAM_SIZE)) { |
1418 |
> |
memcpy(last_xpram, XPRAM, XPRAM_SIZE); |
1419 |
> |
SaveXPRAM(); |
1420 |
> |
} |
1421 |
> |
} |
1422 |
|
|
1423 |
< |
for (;;) { |
1424 |
< |
pthread_testcancel(); |
1425 |
< |
nanosleep(&req, NULL); |
1426 |
< |
pthread_testcancel(); |
1427 |
< |
if (memcmp(last_xpram, XPRAM, XPRAM_SIZE)) { |
1428 |
< |
memcpy(last_xpram, XPRAM, XPRAM_SIZE); |
1251 |
< |
SaveXPRAM(); |
1252 |
< |
} |
1423 |
> |
static void *nvram_func(void *arg) |
1424 |
> |
{ |
1425 |
> |
while (!nvram_thread_cancel) { |
1426 |
> |
for (int i=0; i<60 && !nvram_thread_cancel; i++) |
1427 |
> |
Delay_usec(999999); // Only wait 1 second so we quit promptly when nvram_thread_cancel becomes true |
1428 |
> |
nvram_watchdog(); |
1429 |
|
} |
1430 |
|
return NULL; |
1431 |
|
} |
1438 |
|
static void *tick_func(void *arg) |
1439 |
|
{ |
1440 |
|
int tick_counter = 0; |
1441 |
< |
struct timespec req = {0, 16625000}; |
1441 |
> |
uint64 start = GetTicks_usec(); |
1442 |
> |
int64 ticks = 0; |
1443 |
> |
uint64 next = GetTicks_usec(); |
1444 |
|
|
1445 |
< |
for (;;) { |
1445 |
> |
while (!tick_thread_cancel) { |
1446 |
|
|
1447 |
|
// Wait |
1448 |
< |
nanosleep(&req, NULL); |
1448 |
> |
next += 16625; |
1449 |
> |
int64 delay = next - GetTicks_usec(); |
1450 |
> |
if (delay > 0) |
1451 |
> |
Delay_usec(delay); |
1452 |
> |
else if (delay < -16625) |
1453 |
> |
next = GetTicks_usec(); |
1454 |
> |
ticks++; |
1455 |
|
|
1456 |
|
#if !EMULATED_PPC |
1457 |
|
// Did we crash? |
1509 |
|
TriggerInterrupt(); |
1510 |
|
} |
1511 |
|
} |
1512 |
+ |
|
1513 |
+ |
uint64 end = GetTicks_usec(); |
1514 |
+ |
D(bug("%Ld ticks in %Ld usec = %f ticks/sec\n", ticks, end - start, ticks * 1000000.0 / (end - start))); |
1515 |
|
return NULL; |
1516 |
|
} |
1517 |
|
|
1664 |
|
|
1665 |
|
void DisableInterrupt(void) |
1666 |
|
{ |
1667 |
+ |
#if EMULATED_PPC |
1668 |
+ |
WriteMacInt32(XLM_IRQ_NEST, int32(ReadMacInt32(XLM_IRQ_NEST)) + 1); |
1669 |
+ |
#else |
1670 |
|
atomic_add((int *)XLM_IRQ_NEST, 1); |
1671 |
+ |
#endif |
1672 |
|
} |
1673 |
|
|
1674 |
|
|
1678 |
|
|
1679 |
|
void EnableInterrupt(void) |
1680 |
|
{ |
1681 |
+ |
#if EMULATED_PPC |
1682 |
+ |
WriteMacInt32(XLM_IRQ_NEST, int32(ReadMacInt32(XLM_IRQ_NEST)) - 1); |
1683 |
+ |
#else |
1684 |
|
atomic_add((int *)XLM_IRQ_NEST, -1); |
1685 |
+ |
#endif |
1686 |
|
} |
1687 |
|
|
1688 |
|
|
1695 |
|
{ |
1696 |
|
machine_regs *r = MACHINE_REGISTERS(scp); |
1697 |
|
|
1698 |
+ |
#ifdef USE_SDL_VIDEO |
1699 |
+ |
// We must fill in the events queue in the same thread that did call SDL_SetVideoMode() |
1700 |
+ |
SDL_PumpEvents(); |
1701 |
+ |
#endif |
1702 |
+ |
|
1703 |
|
// Do nothing if interrupts are disabled |
1704 |
|
if (*(int32 *)XLM_IRQ_NEST > 0) |
1705 |
|
return; |
2211 |
|
page_size = getpagesize(); |
2212 |
|
|
2213 |
|
// Allocate SheepShaver globals |
2214 |
< |
if (vm_acquire_fixed((char *)base, size) < 0) |
2214 |
> |
if (vm_acquire_fixed((char *)(base + NATMEM_OFFSET), size) < 0) |
2215 |
|
return false; |
2216 |
|
|
2217 |
|
// Allocate page with all bits set to 0 |
2218 |
|
zero_page = base + size; |
2219 |
< |
if (vm_acquire_fixed((char *)zero_page, page_size) < 0) |
2219 |
> |
uint8 *zero_page_host = (uint8 *)zero_page + NATMEM_OFFSET; |
2220 |
> |
if (vm_acquire_fixed(zero_page_host, page_size) < 0) |
2221 |
|
return false; |
2222 |
< |
memset((char *)zero_page, 0, page_size); |
2223 |
< |
if (vm_protect((char *)zero_page, page_size, VM_PAGE_READ) < 0) |
2222 |
> |
memset(zero_page_host, 0, page_size); |
2223 |
> |
if (vm_protect(zero_page_host, page_size, VM_PAGE_READ) < 0) |
2224 |
|
return false; |
2225 |
|
|
2226 |
|
#if EMULATED_PPC |
2227 |
|
// Allocate alternate stack for PowerPC interrupt routine |
2228 |
|
sig_stack = zero_page + page_size; |
2229 |
< |
if (vm_acquire_fixed((char *)sig_stack, SIG_STACK_SIZE) < 0) |
2229 |
> |
if (vm_acquire_fixed((char *)(sig_stack + NATMEM_OFFSET), SIG_STACK_SIZE) < 0) |
2230 |
|
return false; |
2231 |
|
#endif |
2232 |
|
|
2238 |
|
{ |
2239 |
|
if (top) { |
2240 |
|
// Delete SheepShaver globals |
2241 |
< |
vm_release((void *)base, size); |
2241 |
> |
vm_release((void *)(base + NATMEM_OFFSET), size); |
2242 |
|
|
2243 |
|
// Delete zero page |
2244 |
< |
vm_release((void *)zero_page, page_size); |
2244 |
> |
vm_release((void *)(zero_page + NATMEM_OFFSET), page_size); |
2245 |
|
|
2246 |
|
#if EMULATED_PPC |
2247 |
|
// Delete alternate stack for PowerPC interrupt routine |
2248 |
< |
vm_release((void *)sig_stack, SIG_STACK_SIZE); |
2248 |
> |
vm_release((void *)(sig_stack + NATMEM_OFFSET), SIG_STACK_SIZE); |
2249 |
|
#endif |
2250 |
|
} |
2251 |
|
} |
2300 |
|
|
2301 |
|
void ErrorAlert(const char *text) |
2302 |
|
{ |
2303 |
< |
#ifdef ENABLE_GTK |
2303 |
> |
#if defined(ENABLE_GTK) && !defined(USE_SDL_VIDEO) |
2304 |
|
if (PrefsFindBool("nogui") || x_display == NULL) { |
2305 |
|
printf(GetString(STR_SHELL_ERROR_PREFIX), text); |
2306 |
|
return; |
2319 |
|
|
2320 |
|
void WarningAlert(const char *text) |
2321 |
|
{ |
2322 |
< |
#ifdef ENABLE_GTK |
2322 |
> |
#if defined(ENABLE_GTK) && !defined(USE_SDL_VIDEO) |
2323 |
|
if (PrefsFindBool("nogui") || x_display == NULL) { |
2324 |
|
printf(GetString(STR_SHELL_WARNING_PREFIX), text); |
2325 |
|
return; |