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.21 by cebix, 2000-09-25T17:54:01Z vs.
Revision 1.22 by cebix, 2000-10-09T17:05:16Z

# Line 133 | Line 133 | static struct sigaction sigirq_sa;     // Vi
133   static struct sigaction sigill_sa;      // Illegal instruction
134   static void *sig_stack = NULL;          // Stack for signal handlers
135   uint16 EmulatedSR;                                      // Emulated bits of SR (supervisor bit and interrupt mask)
136 uint8 *ScratchMem = NULL;                       // Scratch memory for Mac ROM writes
136   #endif
137  
138   #if USE_SCRATCHMEM_SUBTERFUGE
139 < uint8 *ScratchMem = 0;                          // Scratch memory for Mac ROM writes
139 > uint8 *ScratchMem = NULL;                       // Scratch memory for Mac ROM writes
140   #endif
141  
142   static struct sigaction timer_sa;       // sigaction used for timer
# Line 157 | Line 156 | static bool lm_area_mapped = false;    // F
156   static bool memory_mapped_from_zero = false; // Flag: Could allocate RAM area from 0
157   #endif
158  
159 + #if REAL_ADDRESSING || DIRECT_ADDRESSING
160 + static uint32 mapped_ram_rom_size;              // Total size of mmap()ed RAM/ROM area
161 + #endif
162 +
163   #ifdef USE_MAPPED_MEMORY
164   extern char *address_space, *good_address_map;
165   #endif
# Line 269 | Line 272 | int main(int argc, char **argv)
272          const uint32 page_size = getpagesize();
273          const uint32 page_mask = page_size - 1;
274          const uint32 aligned_ram_size = (RAMSize + page_mask) & ~page_mask;
275 <        const uint32 ram_rom_size = aligned_ram_size + 0x100000;
275 >        mapped_ram_rom_size = aligned_ram_size + 0x100000;
276   #endif
277  
278   #if REAL_ADDRESSING
279          // Try to allocate the complete address space from zero
280          // gb-- the Solaris manpage about mmap(2) states that using MAP_FIXED
281          // implies undefined behaviour for further use of sbrk(), malloc(), etc.
282 < #if defined(OS_solaris)
282 >        // cebix-- on NetBSD/m68k, this causes a segfault
283 > #if defined(OS_solaris) || defined(OS_netbsd)
284          // Anyway, it doesn't work...
285          if (0) {
286   #else
287 <        if (mmap((caddr_t)0x0000, ram_rom_size, PROT_READ | PROT_WRITE, MAP_FIXED | MAP_PRIVATE, zero_fd, 0) != MAP_FAILED) {
287 >        if (mmap((caddr_t)0x0000, mapped_ram_rom_size, PROT_READ | PROT_WRITE, MAP_FIXED | MAP_PRIVATE, zero_fd, 0) != MAP_FAILED) {
288   #endif
289                  D(bug("Could allocate RAM and ROM from 0x0000\n"));
290                  memory_mapped_from_zero = true;
# Line 298 | Line 302 | int main(int argc, char **argv)
302          }
303   #endif
304  
305 < #if !EMULATED_68K || USE_SCRATCHMEM_SUBTERFUGE
305 > #if USE_SCRATCHMEM_SUBTERFUGE
306          // Allocate scratch memory
307          ScratchMem = (uint8 *)malloc(SCRATCH_MEM_SIZE);
308          if (ScratchMem == NULL) {
# Line 339 | Line 343 | int main(int argc, char **argv)
343          else
344   #endif
345          {
346 <                RAMBaseHost = (uint8 *)mmap(0, ram_rom_size, PROT_READ | PROT_WRITE, MAP_PRIVATE, zero_fd, 0);
346 >                RAMBaseHost = (uint8 *)mmap(0, mapped_ram_rom_size, PROT_READ | PROT_WRITE, MAP_PRIVATE, zero_fd, 0);
347                  if (RAMBaseHost == (uint8 *)MAP_FAILED) {
348                          ErrorAlert(GetString(STR_NO_MEM_ERR));
349                          QuitEmulator();
# Line 354 | Line 358 | int main(int argc, char **argv)
358                  QuitEmulator();
359          }
360   #endif
361 +
362   #if DIRECT_ADDRESSING
363          // Initialize MEMBaseDiff now so that Host2MacAddr in the Video module
364          // will return correct results
# Line 617 | Line 622 | void QuitEmulator(void)
622          // Deinitialize everything
623          ExitAll();
624  
625 +        // Free ROM/RAM areas
626   #if REAL_ADDRESSING || DIRECT_ADDRESSING
627 <        // Unmap ROM area
628 <        if (ROMBaseHost != (uint8 *)MAP_FAILED) {
629 <                munmap((caddr_t)ROMBaseHost, 0x100000);
630 <                ROMBaseHost = 0;
631 <        }
626 <        
627 <        //Unmap RAM area
628 <        if (RAMBaseHost != (uint8 *)MAP_FAILED) {
629 <                const uint32 page_size = getpagesize();
630 <                const uint32 page_mask = page_size - 1;
631 <                munmap((caddr_t)RAMBaseHost, ((RAMSize + page_mask) & ~page_mask));
627 >        if (memory_mapped_from_zero)
628 >                munmap((caddr_t)0x0000, mapped_ram_rom_size);
629 >        else if (RAMBaseHost != (uint8 *)MAP_FAILED) {
630 >                munmap((caddr_t)RAMBaseHost, mapped_ram_rom_size);
631 >                RAMBaseHost = NULL;
632          }
633   #else
634        // Delete ROM area
634          if (ROMBaseHost) {
635                  free(ROMBaseHost);
636                  ROMBaseHost = NULL;
637          }
639
640        // Delete RAM area
638          if (RAMBaseHost) {
639                  free(RAMBaseHost);
640                  RAMBaseHost = NULL;
641          }
642   #endif
643  
644 < #if !EMULATED_68K || USE_SCRATMEM_SUBTERFUGE
644 > #if USE_SCRATCHMEM_SUBTERFUGE
645          // Delete scratch memory area
646          if (ScratchMem) {
647                  free((void *)(ScratchMem - SCRATCH_MEM_SIZE/2));
# Line 748 | Line 745 | void TriggerInterrupt(void)
745          raise(SIG_IRQ);
746   #endif
747   }
748 +
749 + void TriggerNMI(void)
750 + {
751 +        // not yet supported
752 + }
753   #endif
754  
755  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines