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.5 by gbeauche, 2003-05-22T22:12:04Z vs.
Revision 1.6 by gbeauche, 2003-09-07T14:33:53Z

# Line 222 | Line 222 | static pthread_t emul_thread;                          // MacO
222   static bool ready_for_signals = false;          // Handler installed, signals can be sent
223   static int64 num_segv = 0;                                      // Number of handled SEGV signals
224  
225 #if !EMULATED_PPC
225   static struct sigaction sigusr2_action;         // Interrupt signal (of emulator thread)
226 + #if !EMULATED_PPC
227   static struct sigaction sigsegv_action;         // Data access exception signal (of emulator thread)
228   static struct sigaction sigill_action;          // Illegal instruction signal (of emulator thread)
229   static void *sig_stack = NULL;                          // Stack for signal handlers
# Line 238 | Line 238 | static void Quit(void);
238   static void *emul_func(void *arg);
239   static void *nvram_func(void *arg);
240   static void *tick_func(void *arg);
241 #if !EMULATED_PPC
241   static void sigusr2_handler(int sig, sigcontext_struct *sc);
242 + #if !EMULATED_PPC
243   static void sigsegv_handler(int sig, sigcontext_struct *sc);
244   static void sigill_handler(int sig, sigcontext_struct *sc);
245   #endif
# Line 457 | Line 457 | int main(int argc, char **argv)
457                  ErrorAlert(str);
458                  goto quit;
459          }
460 < #if !EMULATED_PPC
460 > #if !EMULATED_PPC || defined(__powerpc__)
461          if (vm_protect((char *)ROM_BASE, ROM_AREA_SIZE, VM_PAGE_READ | VM_PAGE_WRITE | VM_PAGE_EXECUTE) < 0) {
462                  sprintf(str, GetString(STR_ROM_MMAP_ERR), strerror(errno));
463                  ErrorAlert(str);
# Line 637 | Line 637 | int main(int argc, char **argv)
637          WriteMacInt32(XLM_PVR, PVR);                                                                    // Theoretical PVR
638          WriteMacInt32(XLM_BUS_CLOCK, BusClockSpeed);                                    // For DriverServicesLib patch
639          WriteMacInt16(XLM_EXEC_RETURN_OPCODE, M68K_EXEC_RETURN);                // For Execute68k() (RTS from the executed 68k code will jump here and end 68k mode)
640 < #if !EMULATED_PPC
640 > #if EMULATED_PPC
641 >        WriteMacInt32(XLM_ETHER_INIT, POWERPC_NATIVE_OP_FUNC(NATIVE_ETHER_INIT));
642 >        WriteMacInt32(XLM_ETHER_TERM, POWERPC_NATIVE_OP_FUNC(NATIVE_ETHER_TERM));
643 >        WriteMacInt32(XLM_ETHER_OPEN, POWERPC_NATIVE_OP_FUNC(NATIVE_ETHER_OPEN));
644 >        WriteMacInt32(XLM_ETHER_CLOSE, POWERPC_NATIVE_OP_FUNC(NATIVE_ETHER_CLOSE));
645 >        WriteMacInt32(XLM_ETHER_WPUT, POWERPC_NATIVE_OP_FUNC(NATIVE_ETHER_WPUT));
646 >        WriteMacInt32(XLM_ETHER_RSRV, POWERPC_NATIVE_OP_FUNC(NATIVE_ETHER_RSRV));
647 >        WriteMacInt32(XLM_VIDEO_DOIO, POWERPC_NATIVE_OP_FUNC(NATIVE_VIDEO_DO_DRIVER_IO));
648 > #else
649          WriteMacInt32(XLM_TOC, (uint32)TOC);                                                    // TOC pointer of emulator
650          WriteMacInt32(XLM_ETHER_INIT, (uint32)InitStreamModule);                // DLPI ethernet driver functions
651          WriteMacInt32(XLM_ETHER_TERM, (uint32)TerminateStreamModule);
# Line 707 | Line 715 | int main(int argc, char **argv)
715                  ErrorAlert(str);
716                  goto quit;
717          }
718 + #endif
719  
720          // Install interrupt signal handler
721          sigemptyset(&sigusr2_action.sa_mask);
722          sigusr2_action.sa_handler = (__sighandler_t)sigusr2_handler;
723 +        sigusr2_action.sa_flags = 0;
724 + #if !EMULATED_PPC
725          sigusr2_action.sa_flags = SA_ONSTACK | SA_RESTART;
726 + #endif
727          sigusr2_action.sa_restorer = NULL;
728          if (sigaction(SIGUSR2, &sigusr2_action, NULL) < 0) {
729                  sprintf(str, GetString(STR_SIGUSR2_INSTALL_ERR), strerror(errno));
730                  ErrorAlert(str);
731                  goto quit;
732          }
721 #endif
733  
734          // Get my thread ID and execute MacOS thread function
735          emul_thread = pthread_self();
# Line 995 | Line 1006 | void MakeExecutable(int dummy, void *sta
1006  
1007   void PatchAfterStartup(void)
1008   {
1009 + #if EMULATED_PPC
1010 +        ExecuteNative(NATIVE_VIDEO_INSTALL_ACCEL);
1011 + #else
1012          ExecutePPC(VideoInstallAccel);
1013 + #endif
1014          InstallExtFS();
1015   }
1016  
# Line 1135 | Line 1150 | void B2_delete_mutex(B2_mutex *mutex)
1150  
1151   void TriggerInterrupt(void)
1152   {
1138 #if EMULATED_PPC
1139        WriteMacInt32(0x16a, ReadMacInt32(0x16a) + 1);
1140 #else
1141 #if 0
1142        WriteMacInt32(0x16a, ReadMacInt32(0x16a) + 1);
1143 #else
1153          if (ready_for_signals)
1154                  pthread_kill(emul_thread, SIGUSR2);
1146 #endif
1147 #endif
1155   }
1156  
1157  
# Line 1171 | Line 1178 | void ClearInterruptFlag(uint32 flag)
1178  
1179   void DisableInterrupt(void)
1180   {
1181 <        atomic_add((int *)XLM_IRQ_NEST, 1);
1181 >        atomic_add((int *)XLM_IRQ_NEST, tswap32(1));
1182   }
1183  
1184  
# Line 1181 | Line 1188 | void DisableInterrupt(void)
1188  
1189   void EnableInterrupt(void)
1190   {
1191 <        atomic_add((int *)XLM_IRQ_NEST, -1);
1191 >        atomic_add((int *)XLM_IRQ_NEST, tswap32((uint32)-1));
1192   }
1193  
1194  
1188 #if !EMULATED_PPC
1195   /*
1196   *  USR2 handler
1197   */
1198  
1199   static void sigusr2_handler(int sig, sigcontext_struct *sc)
1200   {
1201 + #if EMULATED_PPC
1202 +        HandleInterrupt();
1203 + #else
1204          pt_regs *r = sc->regs;
1205  
1206          // Do nothing if interrupts are disabled
# Line 1273 | Line 1282 | static void sigusr2_handler(int sig, sig
1282   #endif
1283  
1284          }
1285 + #endif
1286   }
1287  
1288  
1289 + #if !EMULATED_PPC
1290   /*
1291   *  SIGSEGV handler
1292   */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines