ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/Unix/main_unix.cpp
(Generate patch)

Comparing BasiliskII/src/Unix/main_unix.cpp (file contents):
Revision 1.4 by cebix, 1999-10-26T16:28:37Z vs.
Revision 1.11 by cebix, 2000-04-10T18:53:02Z

# Line 1 | Line 1
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
# Line 48 | Line 48
48   #include <gtk/gtk.h>
49   #endif
50  
51 < #if ENABLE_DGA
51 > #if ENABLE_XF86_DGA
52   #include <X11/Xlib.h>
53   #include <X11/Xutil.h>
54   #include <X11/extensions/xf86dga.h>
# Line 58 | Line 58
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";
# Line 143 | Line 148 | int main(int argc, char **argv)
148                          x_display_name = argv[i];
149                  else if (strcmp(argv[i], "-break") == 0 && ++i < argc)
150                          ROMBreakpoint = strtol(argv[i], NULL, 0);
151 +                else if (strcmp(argv[i], "-rominfo") == 0)
152 +                        PrintROMInfo = true;
153          }
154  
155          // Open display
# Line 154 | Line 161 | int main(int argc, char **argv)
161                  QuitEmulator();
162          }
163  
164 < #if ENABLE_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
# Line 176 | Line 183 | int main(int argc, char **argv)
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          }
185        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");
# Line 238 | Line 268 | int main(int argc, char **argv)
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          }
# Line 351 | Line 381 | void FlushCodeCache(void *start, uint32
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();

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines