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

Comparing SheepShaver/src/Unix/main_unix.cpp (file contents):
Revision 1.16 by gbeauche, 2003-12-04T22:33:24Z vs.
Revision 1.19 by gbeauche, 2003-12-05T12:41:19Z

# Line 213 | Line 213 | static bool emul_thread_fatal = false;
213   static sigregs sigsegv_regs;                            // Register dump when crashed
214   #endif
215  
216 + uintptr SheepMem::zero_page = 0;                        // Address of ro page filled in with zeros
217   uintptr SheepMem::base = 0x60000000;            // Address of SheepShaver data
218   uintptr SheepMem::top = 0;                                      // Top of SheepShaver data (stack like storage)
219  
# Line 672 | Line 673 | int main(int argc, char **argv)
673          WriteMacInt32(XLM_PVR, PVR);                                                                    // Theoretical PVR
674          WriteMacInt32(XLM_BUS_CLOCK, BusClockSpeed);                                    // For DriverServicesLib patch
675          WriteMacInt16(XLM_EXEC_RETURN_OPCODE, M68K_EXEC_RETURN);                // For Execute68k() (RTS from the executed 68k code will jump here and end 68k mode)
676 < #if EMULATED_PPC
677 <        WriteMacInt32(XLM_ETHER_INIT, NativeFunction(NATIVE_ETHER_INIT));
676 >        WriteMacInt32(XLM_ZERO_PAGE, SheepMem::ZeroPage());                             // Pointer to read-only page with all bits set to 0
677 > #if !EMULATED_PPC
678 >        WriteMacInt32(XLM_TOC, (uint32)TOC);                                                            // TOC pointer of emulator
679 > #endif
680 >        WriteMacInt32(XLM_ETHER_INIT, NativeFunction(NATIVE_ETHER_INIT));       // DLPI ethernet driver functions
681          WriteMacInt32(XLM_ETHER_TERM, NativeFunction(NATIVE_ETHER_TERM));
682          WriteMacInt32(XLM_ETHER_OPEN, NativeFunction(NATIVE_ETHER_OPEN));
683          WriteMacInt32(XLM_ETHER_CLOSE, NativeFunction(NATIVE_ETHER_CLOSE));
684          WriteMacInt32(XLM_ETHER_WPUT, NativeFunction(NATIVE_ETHER_WPUT));
685          WriteMacInt32(XLM_ETHER_RSRV, NativeFunction(NATIVE_ETHER_RSRV));
686          WriteMacInt32(XLM_VIDEO_DOIO, NativeFunction(NATIVE_VIDEO_DO_DRIVER_IO));
683 #else
684        WriteMacInt32(XLM_TOC, (uint32)TOC);                                                    // TOC pointer of emulator
685        WriteMacInt32(XLM_ETHER_INIT, (uint32)InitStreamModule);                // DLPI ethernet driver functions
686        WriteMacInt32(XLM_ETHER_TERM, (uint32)TerminateStreamModule);
687        WriteMacInt32(XLM_ETHER_OPEN, (uint32)ether_open);
688        WriteMacInt32(XLM_ETHER_CLOSE, (uint32)ether_close);
689        WriteMacInt32(XLM_ETHER_WPUT, (uint32)ether_wput);
690        WriteMacInt32(XLM_ETHER_RSRV, (uint32)ether_rsrv);
691        WriteMacInt32(XLM_VIDEO_DOIO, (uint32)VideoDoDriverIO);
692 #endif
687          D(bug("Low Memory initialized\n"));
688  
689          // Start 60Hz thread
# Line 958 | Line 952 | void Execute68kTrap(uint16 trap, M68kReg
952          uint16 proc[2] = {trap, M68K_RTS};
953          Execute68k((uint32)proc, r);
954   }
961
962
963 /*
964 *  Execute PPC code from EMUL_OP routine (real mode switch)
965 */
966
967 void ExecutePPC(void (*func)())
968 {
969        uint32 tvect[2] = {(uint32)func, 0};    // Fake TVECT
970        SheepRoutineDescriptor desc(0, (uint32)tvect);
971        M68kRegisters r;
972        Execute68k(desc.addr(), &r);
973 }
955   #endif
956  
957  
# Line 1049 | Line 1030 | void MakeExecutable(int dummy, void *sta
1030  
1031   void PatchAfterStartup(void)
1032   {
1052 #if EMULATED_PPC
1033          ExecuteNative(NATIVE_VIDEO_INSTALL_ACCEL);
1054 #else
1055        ExecutePPC(VideoInstallAccel);
1056 #endif
1034          InstallExtFS();
1035   }
1036  
# Line 1394 | Line 1371 | static void sigusr2_handler(int sig, sig
1371                                          if (InterruptFlags & INTFLAG_VIA) {
1372                                                  ClearInterruptFlag(INTFLAG_VIA);
1373                                                  ADBInterrupt();
1374 <                                                ExecutePPC(VideoVBL);
1374 >                                                ExecuteNative(NATIVE_VIDEO_VBL);
1375                                          }
1376                                  }
1377   #endif
# Line 1798 | Line 1775 | bool SheepMem::Init(void)
1775   {
1776          if (vm_acquire_fixed((char *)base, size) < 0)
1777                  return false;
1778 +
1779 +        zero_page = base + size;
1780 +
1781 +        int page_size = getpagesize();
1782 +        if (vm_acquire_fixed((char *)zero_page, page_size) < 0)
1783 +                return false;
1784 +        memset((char *)zero_page, 0, page_size);
1785 +        if (vm_protect((char *)zero_page, page_size, VM_PAGE_READ) < 0)
1786 +                return false;
1787 +
1788          top = base + size;
1789          return true;
1790   }
1791  
1792   void SheepMem::Exit(void)
1793   {
1794 <        if (top)
1795 <                vm_release((void *)base, size);
1794 >        if (top) {
1795 >                // The zero page is next to SheepShaver globals
1796 >                vm_release((void *)base, size + getpagesize());
1797 >        }
1798   }
1799  
1800  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines