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

Comparing BasiliskII/src/uae_cpu/newcpu.cpp (file contents):
Revision 1.13 by gbeauche, 2002-09-01T15:17:13Z vs.
Revision 1.16 by gbeauche, 2002-09-17T16:05:39Z

# Line 22 | Line 22 | extern int intlev(void);       // From baisili
22   #include "memory.h"
23   #include "readcpu.h"
24   #include "newcpu.h"
25 + #include "compiler/compemu.h"
26 + #include "fpu/fpu.h"
27  
28 < #if defined(ENABLE_EXCLUSIVE_SPCFLAGS) && !defined(HAVE_HARDWARE_LOCKS) && defined(HAVE_PTHREADS)
29 < #include <pthread.h>
28 < pthread_mutex_t spcflags_lock = PTHREAD_MUTEX_INITIALIZER;
28 > #if defined(ENABLE_EXCLUSIVE_SPCFLAGS) && !defined(HAVE_HARDWARE_LOCKS)
29 > B2_mutex *spcflags_lock = NULL;
30   #endif
31  
32   #if ENABLE_MON
# Line 51 | Line 52 | int movem_index1[256];
52   int movem_index2[256];
53   int movem_next[256];
54  
54 int fpp_movem_index1[256];
55 int fpp_movem_index2[256];
56 int fpp_movem_next[256];
57
55   cpuop_func *cpufunctbl[65536];
56  
60 #define FLIGHT_RECORDER 0
61
57   #if FLIGHT_RECORDER
58   struct rec_step {
59          uae_u32 d[8];
# Line 76 | Line 71 | static const char *log_filename(void)
71          return name ? name : "log.68k";
72   }
73  
74 < static void record_step(uaecptr pc)
74 > void m68k_record_step(uaecptr pc)
75   {
76          for (int i = 0; i < 8; i++) {
77                  log[log_ptr].d[i] = m68k_dreg(regs, i);
# Line 236 | Line 231 | void init_m68k (void)
231          movem_index2[i] = 7-j;
232          movem_next[i] = i & (~(1 << j));
233      }
239    for (i = 0 ; i < 256 ; i++) {
240        int j;
241        for (j = 7 ; j >= 0 ; j--) {
242                if (i & (1 << j)) break;
243        }
244        fpp_movem_index1[i] = 7-j;
245        fpp_movem_index2[i] = j;
246        fpp_movem_next[i] = i & (~(1 << j));
247    }
234   #if COUNT_INSTRS
235      {
236          FILE *f = fopen (icountfilename (), "r");
# Line 265 | Line 251 | void init_m68k (void)
251      do_merges ();
252  
253      build_cpufunctbl ();
254 <    
255 <    fpu_init ();
256 <    fpu_set_integral_fpu (CPUType == 4);
254 >        
255 > #if defined(ENABLE_EXCLUSIVE_SPCFLAGS) && !defined(HAVE_HARDWARE_LOCKS)
256 >        spcflags_lock = B2_create_mutex();
257 > #endif
258 >    fpu_init(CPUType == 4);
259   }
260  
261   void exit_m68k (void)
262   {
263          fpu_exit ();
264 + #if defined(ENABLE_EXCLUSIVE_SPCFLAGS) && !defined(HAVE_HARDWARE_LOCKS)
265 +        B2_delete_mutex(spcflags_lock);
266 + #endif
267   }
268  
269   struct regstruct regs, lastint_regs;
# Line 810 | Line 801 | int m68k_move2c (int regno, uae_u32 *reg
801          switch (regno) {
802           case 0: regs.sfc = *regp & 7; break;
803           case 1: regs.dfc = *regp & 7; break;
804 <         case 2: cacr = *regp & (CPUType < 4 ? 0x3 : 0x80008000); break;
804 >         case 2:
805 >                cacr = *regp & (CPUType < 4 ? 0x3 : 0x80008000);
806 > #if USE_JIT
807 >                if (CPUType < 4) {
808 >                        set_cache_state(cacr&1);
809 >                        if (*regp & 0x08)
810 >                                flush_icache(1);
811 >                }
812 >                else {
813 >                        set_cache_state((cacr&0x8000) || 0);
814 >                        // FIXME: The User Manual claims bit 3 of CACR is undefined
815 >                        if (*regp & 0x08)
816 >                                flush_icache(2);
817 >                }
818 > #endif
819 >         break;
820           case 3: tc = *regp & 0xc000; break;
821           case 4: itt0 = *regp & 0xffffe364; break;
822           case 5: itt1 = *regp & 0xffffe364; break;
# Line 1199 | Line 1205 | cpuop_rettype REGPARAM2 op_illg (uae_u32
1205      }
1206  
1207      write_log ("Illegal instruction: %04x at %08lx\n", opcode, pc);
1208 + #if USE_JIT && JIT_DEBUG
1209 +    compiler_dumpstate();
1210 + #endif
1211  
1212      Exception (4,0);
1213          cpuop_return(CFLOW_TRAP);
# Line 1256 | Line 1265 | static void do_trace (void)
1265  
1266   int m68k_do_specialties (void)
1267   {
1268 + #if USE_JIT
1269 +    // Block was compiled
1270 +    SPCFLAGS_CLEAR( SPCFLAG_JIT_END_COMPILE );
1271 +
1272 +    // Retain the request to get out of compiled code until
1273 +    // we reached the toplevel execution, i.e. the one that
1274 +    // can compile then run compiled code. This also means
1275 +    // we processed all (nested) EmulOps
1276 +    if ((m68k_execute_depth == 0) && SPCFLAGS_TEST( SPCFLAG_JIT_EXEC_RETURN ))
1277 +        SPCFLAGS_CLEAR( SPCFLAG_JIT_EXEC_RETURN );
1278 + #endif
1279 +        
1280      if (SPCFLAGS_TEST( SPCFLAG_DOTRACE )) {
1281          Exception (9,last_trace_ad);
1282      }
# Line 1297 | Line 1318 | void m68k_do_execute (void)
1318          for (;;) {
1319                  uae_u32 opcode = GET_OPCODE;
1320   #if FLIGHT_RECORDER
1321 <                record_step(m68k_getpc());
1321 >                m68k_record_step(m68k_getpc());
1322   #endif
1323   #ifdef X86_ASSEMBLY
1324                  __asm__ __volatile__("\tpushl %%ebp\n\tcall *%%ebx\n\tpopl %%ebp" /* FIXME */
# Line 1313 | Line 1334 | void m68k_do_execute (void)
1334          }
1335   }
1336  
1337 + #if USE_JIT
1338 + void m68k_compile_execute (void)
1339 + {
1340 +    for (;;) {
1341 +        if (quit_program > 0) {
1342 +            if (quit_program == 1)
1343 +                break;
1344 +            quit_program = 0;
1345 +            m68k_reset ();
1346 +        }
1347 +        m68k_do_compile_execute();
1348 +    }
1349 +    if (debugging) {
1350 +        uaecptr nextpc;
1351 +        m68k_dumpstate(&nextpc);
1352 +        exit(1);
1353 +    }
1354 + }
1355 + #endif
1356 +
1357   void m68k_execute (void)
1358   {
1359 + #if USE_JIT
1360 +    ++m68k_execute_depth;
1361 + #endif
1362 +        
1363      for (;;) {
1364          if (quit_program > 0) {
1365              if (quit_program == 1)
# Line 1329 | Line 1374 | void m68k_execute (void)
1374                  m68k_dumpstate(&nextpc);
1375                  exit(1);
1376          }
1377 +        
1378 + #if USE_JIT
1379 +    --m68k_execute_depth;
1380 + #endif
1381   }
1382  
1383   static void m68k_verify (uaecptr addr, uaecptr *nextpc)
# Line 1437 | Line 1486 | void m68k_dumpstate (uaecptr *nextpc)
1486      printf ("T=%d%d S=%d M=%d X=%d N=%d Z=%d V=%d C=%d IMASK=%d\n",
1487              regs.t1, regs.t0, regs.s, regs.m,
1488              GET_XFLG, GET_NFLG, GET_ZFLG, GET_VFLG, GET_CFLG, regs.intmask);
1489 <    for (i = 0; i < 8; i++){
1490 <        printf ("FP%d: %g ", i, regs.fp[i]);
1491 <        if ((i & 3) == 3) printf ("\n");
1492 <    }
1444 <    printf ("N=%d Z=%d I=%d NAN=%d\n",
1445 <                (regs.fpsr & 0x8000000) != 0,
1446 <                (regs.fpsr & 0x4000000) != 0,
1447 <                (regs.fpsr & 0x2000000) != 0,
1448 <                (regs.fpsr & 0x1000000) != 0);
1449 <
1489 >        
1490 >        fpu_dump_registers();
1491 >        fpu_dump_flags();
1492 >        
1493      m68k_disasm(m68k_getpc (), nextpc, 1);
1494      if (nextpc)
1495          printf ("next PC: %08lx\n", *nextpc);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines