1 |
|
/* |
2 |
|
* main_unix.cpp - Startup code for Unix |
3 |
|
* |
4 |
< |
* Basilisk II (C) 1997-1999 Christian Bauer |
4 |
> |
* Basilisk II (C) 1997-2000 Christian Bauer |
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 |
58 |
|
#include "mon.h" |
59 |
|
#endif |
60 |
|
|
61 |
+ |
#ifdef USE_MAPPED_MEMORY |
62 |
+ |
#include <sys/mman.h> |
63 |
+ |
extern char *address_space, *good_address_map; |
64 |
+ |
#endif |
65 |
+ |
|
66 |
|
|
67 |
|
// Constants |
68 |
|
const char ROM_FILE_NAME[] = "ROM"; |
161 |
|
QuitEmulator(); |
162 |
|
} |
163 |
|
|
164 |
< |
#if ENABLE_XF86_DGA |
164 |
> |
#if ENABLE_XF86_DGA && !ENABLE_MON |
165 |
|
// Fork out, so we can return from fullscreen mode when things get ugly |
166 |
|
XF86DGAForkApp(DefaultScreen(x_display)); |
167 |
|
#endif |
183 |
|
if (!PrefsEditor()) |
184 |
|
QuitEmulator(); |
185 |
|
|
186 |
< |
// Create area for Mac RAM |
186 |
> |
// Read RAM size |
187 |
|
RAMSize = PrefsFindInt32("ramsize") & 0xfff00000; // Round down to 1MB boundary |
188 |
|
if (RAMSize < 1024*1024) { |
189 |
|
WarningAlert(GetString(STR_SMALL_RAM_WARN)); |
190 |
|
RAMSize = 1024*1024; |
191 |
|
} |
187 |
– |
RAMBaseHost = new uint8[RAMSize]; |
192 |
|
|
193 |
< |
// Create area for Mac ROM |
193 |
> |
// Create areas for Mac RAM and ROM |
194 |
> |
#ifdef USE_MAPPED_MEMORY |
195 |
> |
int fd = open("/dev/zero", O_RDWR); |
196 |
> |
good_address_map = (char *)mmap(NULL, 1<<24, PROT_READ, MAP_PRIVATE, fd, 0); |
197 |
> |
address_space = (char *)mmap(NULL, 1<<24, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0); |
198 |
> |
if ((int)address_space < 0 || (int)good_address_map < 0) { |
199 |
> |
ErrorAlert(GetString(STR_NOT_ENOUGH_MEMORY_ERR)); |
200 |
> |
QuitEmulator(); |
201 |
> |
} |
202 |
> |
RAMBaseHost = (uint8 *)mmap(address_space, RAMSize, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_FIXED, fd, 0); |
203 |
> |
ROMBaseHost = (uint8 *)mmap(address_space + 0x00400000, 0x80000, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_FIXED, fd, 0); |
204 |
> |
close(fd); |
205 |
> |
char *nam = tmpnam(NULL); |
206 |
> |
int good_address_fd = open(nam, O_CREAT | O_RDWR, 0600); |
207 |
> |
char buffer[4096]; |
208 |
> |
memset(buffer, 1, sizeof(buffer)); |
209 |
> |
write(good_address_fd, buffer, sizeof(buffer)); |
210 |
> |
unlink(nam); |
211 |
> |
for (int i=0; i<RAMSize; i+=4096) |
212 |
> |
mmap(good_address_map + i, 4096, PROT_READ, MAP_FIXED | MAP_PRIVATE, good_address_fd, 0); |
213 |
> |
for (int i=0; i<0x80000; i+=4096) |
214 |
> |
mmap(good_address_map + i + 0x00400000, 4096, PROT_READ, MAP_FIXED | MAP_PRIVATE, good_address_fd, 0); |
215 |
> |
#else |
216 |
> |
RAMBaseHost = new uint8[RAMSize]; |
217 |
|
ROMBaseHost = new uint8[0x100000]; |
218 |
+ |
#endif |
219 |
|
|
220 |
|
// Get rom file path from preferences |
221 |
|
const char *rom_path = PrefsFindString("rom"); |
268 |
|
req.it_value.tv_nsec = 16625000; |
269 |
|
req.it_interval.tv_sec = 0; |
270 |
|
req.it_interval.tv_nsec = 16625000; |
271 |
< |
if (timer_settime(timer, TIMER_RELTIME, &req, NULL) < 0) { |
271 |
> |
if (timer_settime(timer, 0, &req, NULL) < 0) { |
272 |
|
printf("FATAL: cannot start timer\n"); |
273 |
|
QuitEmulator(); |
274 |
|
} |
381 |
|
*/ |
382 |
|
|
383 |
|
#if ENABLE_MON |
384 |
+ |
extern void m68k_dumpstate(uaecptr *nextpc); |
385 |
|
static void sigint_handler(...) |
386 |
|
{ |
387 |
+ |
uaecptr nextpc; |
388 |
+ |
m68k_dumpstate(&nextpc); |
389 |
|
char *arg[2] = {"rmon", NULL}; |
390 |
|
mon(1, arg); |
391 |
|
QuitEmulator(); |