softpear-cvs Mailing List for SoftPear PC/Mac interoperability
Status: Pre-Alpha
Brought to you by:
mist
You can subscribe to this list here.
2004 |
Jan
|
Feb
|
Mar
|
Apr
(10) |
May
(108) |
Jun
(50) |
Jul
(8) |
Aug
(27) |
Sep
(3) |
Oct
(1) |
Nov
(10) |
Dec
(71) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2005 |
Jan
(74) |
Feb
|
Mar
(21) |
Apr
(2) |
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Neateye <nit...@ao...> - 2005-05-26 17:49:26
|
Call out Gouranga be happy!!! Gouranga Gouranga Gouranga .... That which brings the highest happiness!! |
From: <mas...@us...> - 2005-04-16 11:11:05
|
Update of /cvsroot/softpear/softpear In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32303 Modified Files: AUTHORS configure.ac Log Message: added some more configure checks which were proposed by autocheck filled AUTHORS with content :) Index: AUTHORS =================================================================== RCS file: /cvsroot/softpear/softpear/AUTHORS,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- AUTHORS 11 Jan 2005 23:15:44 -0000 1.1 +++ AUTHORS 16 Apr 2005 11:10:57 -0000 1.2 @@ -0,0 +1,26 @@ + ______ ___ ______ + / _____) / __) _ (_____ \ +( (____ ___ _| |__ _| |_ _____) )____ _____ ____ + \____ \ / _ (_ __|_ _) ____/ ___ (____ |/ ___) + _____) ) |_| || | | |_| | | ____/ ___ | | +(______/ \___/ |_| \__)_| |_____)_____|_| + + + brought to you by + + +Project Admin: + Michael Steil + +Core development: + Michael Steil + Axel Auweter + +Developers: + Bernhard Bauer + Michael Engel + Roland Riegel + James Whitwell + +Special thanks: + Sebastian Biallas and the whole PearPC Team Index: configure.ac =================================================================== RCS file: /cvsroot/softpear/softpear/configure.ac,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- configure.ac 14 Apr 2005 14:50:02 -0000 1.8 +++ configure.ac 16 Apr 2005 11:10:57 -0000 1.9 @@ -93,7 +93,7 @@ dnl Checks for header files. AC_HEADER_DIRENT AC_HEADER_STDC -AC_CHECK_HEADERS([fcntl.h stddef.h stdlib.h string.h strings.h sys/ioctl.h unistd.h utime.h runetype.h]) +AC_CHECK_HEADERS([fcntl.h stddef.h stdlib.h string.h strings.h sys/ioctl.h unistd.h utime.h runetype.h locale.h termios.h]) dnl Checks for typedefs, structures, and compiler characteristics. AC_HEADER_STDBOOL @@ -174,7 +174,9 @@ AC_FUNC_SETVBUF_REVERSED AC_FUNC_STAT AC_FUNC_UTIME_NULL -AC_CHECK_FUNCS([bzero memmove memset munmap strchr strrchr utime]) +AC_FUNC_GETPGRP +AC_FUNC_VPRINTF +AC_CHECK_FUNCS([bzero memmove memset munmap strchr strrchr utime dup2 endpwent getcwd gethostname mkdir rmdir sethostname setlocale strerror strtol]) AC_OUTPUT |
From: <mas...@us...> - 2005-04-14 14:50:17
|
Update of /cvsroot/softpear/softpear In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25783 Modified Files: configure.ac Log Message: changes to configure script: now builds i386(32bit) executable on AMD64 machines Index: configure.ac =================================================================== RCS file: /cvsroot/softpear/softpear/configure.ac,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- configure.ac 16 Mar 2005 17:30:55 -0000 1.7 +++ configure.ac 14 Apr 2005 14:50:02 -0000 1.8 @@ -61,7 +61,9 @@ ;; *86_64*) AC_DEFINE(ARCH_X86_64, 1, [Define to compile for x86 64 bit]) - ;; + CPPFLAGS="$CPPFLAGS -m32" + SP_LDFLAGS="$SP_LDFLAGS -m32" + ;; *powerpc*) AC_DEFINE(ARCH_PPC, 1, [Define to compile for PowerPC]) ;; |
From: <mas...@us...> - 2005-03-17 09:32:24
|
Update of /cvsroot/softpear/softpear/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7141/test Modified Files: Makefile.am Added Files: qsort.c Log Message: Little changes to the threading concept: CPU can now be started by either calling "ppc_cpu_run_threaded" or "ppc_cpu_run_unthreaded". In the first case, the memory allocated by "ppc_cpu_init" is free'ed automatically, in the latter case, it is not so that the caller has access to the register contents after the CPU has finished. Added qsort.c example. --- NEW FILE: qsort.c --- #include <stdio.h> #include <stdlib.h> int compare(const void *vp1, const void *vp2) { int *p1, *p2; p1 = (int*)vp1; p2 = (int*)vp2; return (*p1 > *p2)?1:(*p1 == *p2)?0:-1; } int main(void) { int arr[10]; int i; for(i=0; i<10; i++) arr[i] = random() % 100; for(i=0;i<10;i++) printf("%d\t", arr[i]); printf("\n"); qsort((void*)&arr, 10, sizeof(int), compare); for(i=0;i<10;i++) printf("%d\t", arr[i]); printf("\n"); return 0; } Index: Makefile.am =================================================================== RCS file: /cvsroot/softpear/softpear/test/Makefile.am,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- Makefile.am 14 Mar 2005 01:19:42 -0000 1.2 +++ Makefile.am 17 Mar 2005 09:32:13 -0000 1.3 @@ -1,4 +1,4 @@ -bin_PROGRAMS = pthreads stderr mainargs endless_hello add4_local binomialN fac fib_it float funcptr funcptr2 globals pointer pow_naiv pow_quick_rec prime-unsigned prime short switch switch2 test-c test-many-params unaligned unaligned2 +bin_PROGRAMS = qsort pthreads stderr mainargs endless_hello add4_local binomialN fac fib_it float funcptr funcptr2 globals pointer pow_naiv pow_quick_rec prime-unsigned prime short switch switch2 test-c test-many-params unaligned unaligned2 |
From: <mas...@us...> - 2005-03-17 09:32:23
|
Update of /cvsroot/softpear/softpear/src/loader In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7141/src/loader Modified Files: nativelib.cc Log Message: Little changes to the threading concept: CPU can now be started by either calling "ppc_cpu_run_threaded" or "ppc_cpu_run_unthreaded". In the first case, the memory allocated by "ppc_cpu_init" is free'ed automatically, in the latter case, it is not so that the caller has access to the register contents after the CPU has finished. Added qsort.c example. Index: nativelib.cc =================================================================== RCS file: /cvsroot/softpear/softpear/src/loader/nativelib.cc,v retrieving revision 1.61 retrieving revision 1.62 diff -u -d -r1.61 -r1.62 --- nativelib.cc 15 Mar 2005 17:03:03 -0000 1.61 +++ nativelib.cc 17 Mar 2005 09:32:12 -0000 1.62 @@ -637,7 +637,7 @@ gCPU->lr = 0xdeadbeef; gCPU->pc = sorter_pc; // printf("+run() %x\n", gCPU->pc); - ppc_cpu_run((void*)gCPU); + ppc_cpu_run_unthreaded(gCPU); // printf("-run()\n"); gCPU->pc = saved_pc; @@ -1130,10 +1130,10 @@ newCPU->pc = gCPU->gpr[5]; /* The new CPU should start interpretation at the passed start_routine */ newCPU->gpr[3] = gCPU->gpr[6]; /* Argument for the start_routine should be in r3 of the new CPU */ - int result = pthread_create((pthread_t*)gCPU->gpr[3], (pthread_attr_t*)gCPU->gpr[4], ppc_cpu_run, (void*)newCPU); + int result = ppc_cpu_run_threaded(newCPU, (pthread_attr_t*)gCPU->gpr[4]); /* All CPUs have their thread ID stored in their gCPU structure */ - newCPU->thread = *((pthread_t*)gCPU->gpr[3]); + *((pthread_t*)gCPU->gpr[3]) = newCPU->thread; /* Since the first argument to pthread_create is a double pointer, change endianess, here */ *((sp_uint32_t*)gCPU->gpr[3]) = Host_to_BE32(*((sp_uint32_t*)gCPU->gpr[3])); @@ -1155,6 +1155,20 @@ gCPU->gpr[3] = usleep(gCPU->gpr[3]); } +/* +int rand(void); +*/ +void my_rand(PPC_CPU_State *gCPU) { + gCPU->gpr[3] = rand(); +} + +/* +long random(void); +*/ +void my_random(PPC_CPU_State *gCPU) { + gCPU->gpr[3] = random(); +} + /* This is a list with pointers to functions provided by the local environment */ /* Please do not forget to justify the #define NATIVELIBCOUNT in nativelib.h */ NativeLibEntry NativeLibs[] = { @@ -1295,6 +1309,8 @@ {"_pthread_create", (NativeLibFuncPtr) my_pthread_create }, {"_pthread_join", (NativeLibFuncPtr) my_pthread_join }, {"_usleep", (NativeLibFuncPtr) my_usleep }, + {"_rand", (NativeLibFuncPtr) my_rand }, + {"_random", (NativeLibFuncPtr) my_random }, }; const unsigned int kNativeLibCount = sizeof (NativeLibs) / sizeof (NativeLibEntry); |
From: <mas...@us...> - 2005-03-17 09:32:22
|
Update of /cvsroot/softpear/softpear/src/cpu/cpu_generic In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7141/src/cpu/cpu_generic Modified Files: ppc_cpu.cc Log Message: Little changes to the threading concept: CPU can now be started by either calling "ppc_cpu_run_threaded" or "ppc_cpu_run_unthreaded". In the first case, the memory allocated by "ppc_cpu_init" is free'ed automatically, in the latter case, it is not so that the caller has access to the register contents after the CPU has finished. Added qsort.c example. Index: ppc_cpu.cc =================================================================== RCS file: /cvsroot/softpear/softpear/src/cpu/cpu_generic/ppc_cpu.cc,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- ppc_cpu.cc 16 Mar 2005 18:03:47 -0000 1.13 +++ ppc_cpu.cc 17 Mar 2005 09:32:12 -0000 1.14 @@ -104,10 +104,9 @@ { } -void *ppc_cpu_run(void *p) +void ppc_cpu_run(PPC_CPU_State *gCPU) { - PPC_CPU_State *gCPU = (PPC_CPU_State*)p; #ifdef PEARPC gDebugger = new Debugger(); @@ -159,10 +158,8 @@ // printf("Executing...\n"); //MIST ppc_exec_opc(gCPU); #ifndef PEARPC - if (gCPU->npc == 0xdeadbeec) { - ppc_cpu_deinit(gCPU); - return NULL; - } + if (gCPU->npc == 0xdeadbeec) + return; #endif ops++; gCPU->ptb++; @@ -250,13 +247,24 @@ #endif } - ppc_cpu_deinit(gCPU); + return; +} + +void *ppc_cpu_thread_starter(void *p) +{ + ppc_cpu_run((PPC_CPU_State*)p); + ppc_cpu_deinit((PPC_CPU_State*)p); return NULL; } -void ppc_cpu_run_threaded(PPC_CPU_State *gCPU) +int ppc_cpu_run_threaded(PPC_CPU_State *gCPU, const pthread_attr_t *attr) { - pthread_create(&gCPU->thread, NULL, ppc_cpu_run, (void*)gCPU); + return pthread_create(&gCPU->thread, attr, ppc_cpu_thread_starter, (void*)gCPU); +} + +void ppc_cpu_run_unthreaded(PPC_CPU_State *gCPU) +{ + ppc_cpu_run(gCPU); } void ppc_cpu_stop(PPC_CPU_State *gCPU) |
From: <mas...@us...> - 2005-03-17 09:32:22
|
Update of /cvsroot/softpear/softpear/src/cpu In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7141/src/cpu Modified Files: cpu.h Log Message: Little changes to the threading concept: CPU can now be started by either calling "ppc_cpu_run_threaded" or "ppc_cpu_run_unthreaded". In the first case, the memory allocated by "ppc_cpu_init" is free'ed automatically, in the latter case, it is not so that the caller has access to the register contents after the CPU has finished. Added qsort.c example. Index: cpu.h =================================================================== RCS file: /cvsroot/softpear/softpear/src/cpu/cpu.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- cpu.h 15 Mar 2005 17:03:02 -0000 1.3 +++ cpu.h 17 Mar 2005 09:32:12 -0000 1.4 @@ -44,8 +44,10 @@ * May only be called from within a CPU thread. */ -void *ppc_cpu_run(void*); -void ppc_cpu_run_threaded(PPC_CPU_State*); +void ppc_cpu_run(PPC_CPU_State*); +void *ppc_cpu_thread_starter(void*); +int ppc_cpu_run_threaded(PPC_CPU_State*, const pthread_attr_t*); +void ppc_cpu_run_unthreaded(PPC_CPU_State*); /* The following functions are propably useless with SoftPears threaded CPU model |
From: <mas...@us...> - 2005-03-17 09:32:21
|
Update of /cvsroot/softpear/softpear/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7141/src Modified Files: main.cc Log Message: Little changes to the threading concept: CPU can now be started by either calling "ppc_cpu_run_threaded" or "ppc_cpu_run_unthreaded". In the first case, the memory allocated by "ppc_cpu_init" is free'ed automatically, in the latter case, it is not so that the caller has access to the register contents after the CPU has finished. Added qsort.c example. Index: main.cc =================================================================== RCS file: /cvsroot/softpear/softpear/src/main.cc,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- main.cc 14 Mar 2005 22:55:10 -0000 1.16 +++ main.cc 17 Mar 2005 09:32:11 -0000 1.17 @@ -63,10 +63,8 @@ debug_printf("Stack: 0x%lx-0x%lx\n", cpu_main->stack, cpu_main->gpr[1]); /* Start interpretation */ - ppc_cpu_run_threaded(cpu_main); + ppc_cpu_run_unthreaded(cpu_main); - pthread_join(cpu_main->thread, NULL); - /* Set exit status to exit status of emulated application */ return cpu_main->gpr[3]; } |
From: <mas...@us...> - 2005-03-16 18:03:59
|
Update of /cvsroot/softpear/softpear/src/cpu/cpu_generic In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17244/src/cpu/cpu_generic Modified Files: ppc_cpu.cc Log Message: re-enabled register dump in debug mode (but this will need some changes in the future since threaded register dumps are very confusing) Index: ppc_cpu.cc =================================================================== RCS file: /cvsroot/softpear/softpear/src/cpu/cpu_generic/ppc_cpu.cc,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- ppc_cpu.cc 15 Mar 2005 17:03:03 -0000 1.12 +++ ppc_cpu.cc 16 Mar 2005 18:03:47 -0000 1.13 @@ -123,13 +123,12 @@ #ifdef DEBUG // BEGIN MIST -/* for (i=0; i<32; i++) { + for (i=0; i<32; i++) { printf("r%02i: %08x ", i, gCPU->gpr[i]); if (!((i+1) & 7)) printf("\n"); } printf("pc: %08x lr: %08x opc: %08x\n", gCPU->pc, gCPU->lr, gCPU->current_opc);//MIST printf("----------\n"); -*/ // END MIST #endif |
From: <rol...@us...> - 2005-03-16 17:31:25
|
Update of /cvsroot/softpear/softpear In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8807 Modified Files: configure.ac Log Message: check for libpthread the right way :) #define is HAVE_LIBPTHREAD, if this should ever be needed Index: configure.ac =================================================================== RCS file: /cvsroot/softpear/softpear/configure.ac,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- configure.ac 24 Jan 2005 16:51:57 -0000 1.6 +++ configure.ac 16 Mar 2005 17:30:55 -0000 1.7 @@ -86,6 +86,7 @@ AC_PROG_MAKE_SET dnl Checks for libraries. +AC_CHECK_LIB(pthread, pthread_create) dnl Checks for header files. AC_HEADER_DIRENT |
From: <rol...@us...> - 2005-03-16 17:31:19
|
Update of /cvsroot/softpear/softpear/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8807/src Modified Files: Makefile.am Log Message: check for libpthread the right way :) #define is HAVE_LIBPTHREAD, if this should ever be needed Index: Makefile.am =================================================================== RCS file: /cvsroot/softpear/softpear/src/Makefile.am,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- Makefile.am 14 Mar 2005 22:55:10 -0000 1.3 +++ Makefile.am 16 Mar 2005 17:30:56 -0000 1.4 @@ -15,9 +15,9 @@ loader/spmalloc.cc if DEBUG -softpear_LDFLAGS = $(SP_LDFLAGS) -lpthread +softpear_LDFLAGS = $(SP_LDFLAGS) else -softpear_LDFLAGS = $(SP_LDFLAGS) -s -lpthread +softpear_LDFLAGS = $(SP_LDFLAGS) -s endif |
From: <mas...@us...> - 2005-03-15 17:03:14
|
Update of /cvsroot/softpear/softpear/src/loader In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22357/src/loader Modified Files: nativelib.cc Log Message: fixed memory leak causing threads not to free their malloc'ed memory the thread object of the current thread is now always accessable via the local gCPU structure Index: nativelib.cc =================================================================== RCS file: /cvsroot/softpear/softpear/src/loader/nativelib.cc,v retrieving revision 1.60 retrieving revision 1.61 diff -u -d -r1.60 -r1.61 --- nativelib.cc 14 Mar 2005 22:55:11 -0000 1.60 +++ nativelib.cc 15 Mar 2005 17:03:03 -0000 1.61 @@ -1126,10 +1126,18 @@ printf("Could not create new CPU, aborting!\n"); exit(EXIT_FAILURE); } - newCPU->pc = gCPU->gpr[5]; - newCPU->gpr[3] = gCPU->gpr[6]; + + newCPU->pc = gCPU->gpr[5]; /* The new CPU should start interpretation at the passed start_routine */ + newCPU->gpr[3] = gCPU->gpr[6]; /* Argument for the start_routine should be in r3 of the new CPU */ + int result = pthread_create((pthread_t*)gCPU->gpr[3], (pthread_attr_t*)gCPU->gpr[4], ppc_cpu_run, (void*)newCPU); + + /* All CPUs have their thread ID stored in their gCPU structure */ + newCPU->thread = *((pthread_t*)gCPU->gpr[3]); + + /* Since the first argument to pthread_create is a double pointer, change endianess, here */ *((sp_uint32_t*)gCPU->gpr[3]) = Host_to_BE32(*((sp_uint32_t*)gCPU->gpr[3])); + gCPU->gpr[3] = result; } |
From: <mas...@us...> - 2005-03-15 17:03:13
|
Update of /cvsroot/softpear/softpear/src/cpu/cpu_generic In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22357/src/cpu/cpu_generic Modified Files: ppc_cpu.cc Log Message: fixed memory leak causing threads not to free their malloc'ed memory the thread object of the current thread is now always accessable via the local gCPU structure Index: ppc_cpu.cc =================================================================== RCS file: /cvsroot/softpear/softpear/src/cpu/cpu_generic/ppc_cpu.cc,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- ppc_cpu.cc 14 Mar 2005 22:55:11 -0000 1.11 +++ ppc_cpu.cc 15 Mar 2005 17:03:03 -0000 1.12 @@ -160,7 +160,10 @@ // printf("Executing...\n"); //MIST ppc_exec_opc(gCPU); #ifndef PEARPC - if (gCPU->npc == 0xdeadbeec) return NULL; + if (gCPU->npc == 0xdeadbeec) { + ppc_cpu_deinit(gCPU); + return NULL; + } #endif ops++; gCPU->ptb++; @@ -248,6 +251,7 @@ #endif } + ppc_cpu_deinit(gCPU); return NULL; } |
From: <mas...@us...> - 2005-03-15 17:03:12
|
Update of /cvsroot/softpear/softpear/src/cpu In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22357/src/cpu Modified Files: cpu.h Log Message: fixed memory leak causing threads not to free their malloc'ed memory the thread object of the current thread is now always accessable via the local gCPU structure Index: cpu.h =================================================================== RCS file: /cvsroot/softpear/softpear/src/cpu/cpu.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- cpu.h 14 Mar 2005 22:55:10 -0000 1.2 +++ cpu.h 15 Mar 2005 17:03:02 -0000 1.3 @@ -29,7 +29,7 @@ uint64 ppc_get_timebase_frequency(int cpu); PPC_CPU_State *ppc_cpu_init(); -void ppc_cpu_deinit(); +void ppc_cpu_deinit(PPC_CPU_State*); void ppc_cpu_init_config(); void ppc_cpu_stop(); |
From: <mas...@us...> - 2005-03-14 22:55:22
|
Update of /cvsroot/softpear/softpear/src/cpu/cpu_generic In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7977/src/cpu/cpu_generic Modified Files: ppc_alu.cc ppc_alu.h ppc_cpu.cc ppc_cpu.h ppc_dec.cc ppc_dec.h ppc_exc.cc ppc_exc.h ppc_fpu.cc ppc_fpu.h ppc_mmu.cc ppc_mmu.h ppc_opc.cc ppc_opc.h Log Message: Implemented preliminary pthread-support. The idea is to have an interpreter thread running on the host for every guest thread. To achieve this, the global gCPU structure is now local per thread. Because I didn't think enough, it is still called gCPU everywhere, although it is no longer a global structure. Only pthread_create and pthread_join are implemented. I'm sure they need some additional code to work correctly, but the major work should be done, now. Index: ppc_alu.cc =================================================================== RCS file: /cvsroot/softpear/softpear/src/cpu/cpu_generic/ppc_alu.cc,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- ppc_alu.cc 16 Nov 2004 22:50:15 -0000 1.1.1.1 +++ ppc_alu.cc 14 Mar 2005 22:55:11 -0000 1.2 @@ -46,28 +46,28 @@ * addx Add * .422 */ -void ppc_opc_addx() +void ppc_opc_addx(PPC_CPU_State *gCPU) { int rD, rA, rB; - PPC_OPC_TEMPL_XO(gCPU.current_opc, rD, rA, rB); - gCPU.gpr[rD] = gCPU.gpr[rA] + gCPU.gpr[rB]; - if (gCPU.current_opc & PPC_OPC_Rc) { + PPC_OPC_TEMPL_XO(gCPU->current_opc, rD, rA, rB); [...1727 lines suppressed...] - PPC_OPC_TEMPL_D_UImm(gCPU.current_opc, rS, rA, imm); - gCPU.gpr[rA] = gCPU.gpr[rS] ^ imm; + PPC_OPC_TEMPL_D_UImm(gCPU->current_opc, rS, rA, imm); + gCPU->gpr[rA] = gCPU->gpr[rS] ^ imm; } /* * xoris XOR Immediate Shifted * .682 */ -void ppc_opc_xoris() +void ppc_opc_xoris(PPC_CPU_State *gCPU) { int rS, rA; uint32 imm; - PPC_OPC_TEMPL_D_Shift16(gCPU.current_opc, rS, rA, imm); - gCPU.gpr[rA] = gCPU.gpr[rS] ^ imm; + PPC_OPC_TEMPL_D_Shift16(gCPU->current_opc, rS, rA, imm); + gCPU->gpr[rA] = gCPU->gpr[rS] ^ imm; } Index: ppc_alu.h =================================================================== RCS file: /cvsroot/softpear/softpear/src/cpu/cpu_generic/ppc_alu.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- ppc_alu.h 16 Nov 2004 22:50:15 -0000 1.1.1.1 +++ ppc_alu.h 14 Mar 2005 22:55:11 -0000 1.2 @@ -21,79 +21,81 @@ #ifndef __PPC_ALU_H__ #define __PPC_ALU_H__ -void ppc_opc_addx(); -void ppc_opc_addcx(); -void ppc_opc_addex(); -void ppc_opc_addi(); -void ppc_opc_addic(); -void ppc_opc_addic_(); -void ppc_opc_addis(); -void ppc_opc_addmex(); -void ppc_opc_addzex(); +#include "cpu/cpu.h" -void ppc_opc_andx(); -void ppc_opc_andcx(); -void ppc_opc_andi_(); -void ppc_opc_andis_(); +void ppc_opc_addx(PPC_CPU_State*); +void ppc_opc_addcx(PPC_CPU_State*); +void ppc_opc_addex(PPC_CPU_State*); +void ppc_opc_addi(PPC_CPU_State*); +void ppc_opc_addic(PPC_CPU_State*); +void ppc_opc_addic_(PPC_CPU_State*); +void ppc_opc_addis(PPC_CPU_State*); +void ppc_opc_addmex(PPC_CPU_State*); +void ppc_opc_addzex(PPC_CPU_State*); -void ppc_opc_cmp(); -void ppc_opc_cmpi(); -void ppc_opc_cmpl(); -void ppc_opc_cmpli(); +void ppc_opc_andx(PPC_CPU_State*); +void ppc_opc_andcx(PPC_CPU_State*); +void ppc_opc_andi_(PPC_CPU_State*); +void ppc_opc_andis_(PPC_CPU_State*); -void ppc_opc_cntlzwx(); +void ppc_opc_cmp(PPC_CPU_State*); +void ppc_opc_cmpi(PPC_CPU_State*); +void ppc_opc_cmpl(PPC_CPU_State*); +void ppc_opc_cmpli(PPC_CPU_State*); -void ppc_opc_crand(); -void ppc_opc_crandc(); -void ppc_opc_creqv(); -void ppc_opc_crnand(); -void ppc_opc_crnor(); -void ppc_opc_cror(); -void ppc_opc_crorc(); -void ppc_opc_crxor(); +void ppc_opc_cntlzwx(PPC_CPU_State*); -void ppc_opc_divwx(); -void ppc_opc_divwux(); +void ppc_opc_crand(PPC_CPU_State*); +void ppc_opc_crandc(PPC_CPU_State*); +void ppc_opc_creqv(PPC_CPU_State*); +void ppc_opc_crnand(PPC_CPU_State*); +void ppc_opc_crnor(PPC_CPU_State*); +void ppc_opc_cror(PPC_CPU_State*); +void ppc_opc_crorc(PPC_CPU_State*); +void ppc_opc_crxor(PPC_CPU_State*); -void ppc_opc_eqvx(); +void ppc_opc_divwx(PPC_CPU_State*); +void ppc_opc_divwux(PPC_CPU_State*); -void ppc_opc_extsbx(); -void ppc_opc_extshx(); +void ppc_opc_eqvx(PPC_CPU_State*); -void ppc_opc_mulhwx(); -void ppc_opc_mulhwux(); -void ppc_opc_mulli(); -void ppc_opc_mullwx(); +void ppc_opc_extsbx(PPC_CPU_State*); +void ppc_opc_extshx(PPC_CPU_State*); -void ppc_opc_nandx(); +void ppc_opc_mulhwx(PPC_CPU_State*); +void ppc_opc_mulhwux(PPC_CPU_State*); +void ppc_opc_mulli(PPC_CPU_State*); +void ppc_opc_mullwx(PPC_CPU_State*); -void ppc_opc_negx(); -void ppc_opc_norx(); +void ppc_opc_nandx(PPC_CPU_State*); -void ppc_opc_orx(); -void ppc_opc_orcx(); -void ppc_opc_ori(); -void ppc_opc_oris(); +void ppc_opc_negx(PPC_CPU_State*); +void ppc_opc_norx(PPC_CPU_State*); -void ppc_opc_rlwimix(); -void ppc_opc_rlwinmx(); -void ppc_opc_rlwnmx(); +void ppc_opc_orx(PPC_CPU_State*); +void ppc_opc_orcx(PPC_CPU_State*); +void ppc_opc_ori(PPC_CPU_State*); +void ppc_opc_oris(PPC_CPU_State*); -void ppc_opc_slwx(); -void ppc_opc_srawx(); -void ppc_opc_srawix(); -void ppc_opc_srwx(); +void ppc_opc_rlwimix(PPC_CPU_State*); +void ppc_opc_rlwinmx(PPC_CPU_State*); +void ppc_opc_rlwnmx(PPC_CPU_State*); -void ppc_opc_subfx(); -void ppc_opc_subfcx(); -void ppc_opc_subfex(); -void ppc_opc_subfic(); -void ppc_opc_subfmex(); -void ppc_opc_subfzex(); +void ppc_opc_slwx(PPC_CPU_State*); +void ppc_opc_srawx(PPC_CPU_State*); +void ppc_opc_srawix(PPC_CPU_State*); +void ppc_opc_srwx(PPC_CPU_State*); -void ppc_opc_xorx(); -void ppc_opc_xori(); -void ppc_opc_xoris(); +void ppc_opc_subfx(PPC_CPU_State*); +void ppc_opc_subfcx(PPC_CPU_State*); +void ppc_opc_subfex(PPC_CPU_State*); +void ppc_opc_subfic(PPC_CPU_State*); +void ppc_opc_subfmex(PPC_CPU_State*); +void ppc_opc_subfzex(PPC_CPU_State*); + +void ppc_opc_xorx(PPC_CPU_State*); +void ppc_opc_xori(PPC_CPU_State*); +void ppc_opc_xoris(PPC_CPU_State*); #endif Index: ppc_cpu.cc =================================================================== RCS file: /cvsroot/softpear/softpear/src/cpu/cpu_generic/ppc_cpu.cc,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- ppc_cpu.cc 14 Mar 2005 18:47:06 -0000 1.10 +++ ppc_cpu.cc 14 Mar 2005 22:55:11 -0000 1.11 @@ -29,6 +29,7 @@ #include "cpu/debug.h" #include "info.h" #include "io/pic/pic.h" +#include "loader/spmalloc.h" #ifdef PEARPC #include "debug/debugger.h" #endif @@ -40,9 +41,6 @@ #include "ppc_mmu.h" #include "ppc_tools.h" -//#include "io/graphic/gcard.h" - -PPC_CPU_State gCPU; #ifdef PEARPC Debugger *gDebugger; #endif @@ -55,17 +53,17 @@ uint32 gBreakpoint2 = 0xc017a4f4&0; bool activate = false; -static inline void ppc_debug_hook() +static inline void ppc_debug_hook(PPC_CPU_State *gCPU) { - if (gCPU.pc == gBreakpoint) { + if (gCPU->pc == gBreakpoint) { gSinglestep = true; // SINGLESTEP("breakpoint 1"); } - if (gCPU.pc == gBreakpoint2) { + if (gCPU->pc == gBreakpoint2) { SINGLESTEP("breakpoint 2"); } -// if (gCPU.pc == gBreakpoint3 && gCPU.gpr[5]==0x100004ec) { -/* if (gCPU.pc == gBreakpoint3) { +// if (gCPU->pc == gBreakpoint3 && gCPU->gpr[5]==0x100004ec) { +/* if (gCPU->pc == gBreakpoint3) { activate = true; SINGLESTEP("breakpoint 3"); }*/ @@ -78,27 +76,27 @@ sys_mutex exception_mutex; -void ppc_cpu_atomic_raise_ext_exception() +void ppc_cpu_atomic_raise_ext_exception(PPC_CPU_State *gCPU) { sys_lock_mutex(exception_mutex); - gCPU.ext_exception = true; - gCPU.exception_pending = true; + gCPU->ext_exception = true; + gCPU->exception_pending = true; sys_unlock_mutex(exception_mutex); } -void ppc_cpu_atomic_cancel_ext_exception() +void ppc_cpu_atomic_cancel_ext_exception(PPC_CPU_State *gCPU) { sys_lock_mutex(exception_mutex); - gCPU.ext_exception = false; - if (!gCPU.dec_exception) gCPU.exception_pending = false; + gCPU->ext_exception = false; + if (!gCPU->dec_exception) gCPU->exception_pending = false; sys_unlock_mutex(exception_mutex); } -void ppc_cpu_atomic_raise_dec_exception() +void ppc_cpu_atomic_raise_dec_exception(PPC_CPU_State *gCPU) { sys_lock_mutex(exception_mutex); - gCPU.dec_exception = true; - gCPU.exception_pending = true; + gCPU->dec_exception = true; + gCPU->exception_pending = true; sys_unlock_mutex(exception_mutex); } @@ -106,15 +104,18 @@ { } -void ppc_cpu_run() +void *ppc_cpu_run(void *p) { + + PPC_CPU_State *gCPU = (PPC_CPU_State*)p; + #ifdef PEARPC gDebugger = new Debugger(); gDebugger->mAlwaysShowRegs = true; #endif - PPC_CPU_TRACE("execution started at %08x\n", gCPU.pc); + PPC_CPU_TRACE("execution started at %08x\n", gCPU->pc); int ops=0; - gCPU.effective_code_page = 0xffffffff; + gCPU->effective_code_page = 0xffffffff; // ppc_fpu_test(); // return; while (true) { @@ -122,63 +123,64 @@ #ifdef DEBUG // BEGIN MIST - for (i=0; i<32; i++) { - printf("r%02i: %08x ", i, gCPU.gpr[i]); +/* for (i=0; i<32; i++) { + printf("r%02i: %08x ", i, gCPU->gpr[i]); if (!((i+1) & 7)) printf("\n"); } - printf("pc: %08x lr: %08x opc: %08x\n", gCPU.pc, gCPU.lr, gCPU.current_opc);//MIST + printf("pc: %08x lr: %08x opc: %08x\n", gCPU->pc, gCPU->lr, gCPU->current_opc);//MIST printf("----------\n"); +*/ // END MIST #endif - gCPU.npc = gCPU.pc+4; + gCPU->npc = gCPU->pc+4; #ifdef PEARPC - if ((gCPU.pc & ~0xfff) == gCPU.effective_code_page) { - gCPU.current_opc = ppc_word_to_BE(*((uint32*)(&gCPU.physical_code_page[gCPU.pc & 0xfff]))); + if ((gCPU->pc & ~0xfff) == gCPU->effective_code_page) { + gCPU->current_opc = ppc_word_to_BE(*((uint32*)(&gCPU->physical_code_page[gCPU->pc & 0xfff]))); ppc_debug_hook(); } else { int ret; - if ((ret = ppc_direct_effective_memory_handle_code(gCPU.pc & ~0xfff, gCPU.physical_code_page))) { + if ((ret = ppc_direct_effective_memory_handle_code(gCPU->pc & ~0xfff, gCPU->physical_code_page))) { if (ret == PPC_MMU_EXC) { - gCPU.pc = gCPU.npc; + gCPU->pc = gCPU->npc; continue; } else { PPC_CPU_ERR("?\n"); } } - gCPU.effective_code_page = gCPU.pc & ~0xfff; + gCPU->effective_code_page = gCPU->pc & ~0xfff; continue; } #else //printf("X\n");//MIST -// gCPU.current_opc = ppc_word_to_BE(*((uint32*)(gMemory+gCPU.pc))); - ppc_read_physical_word(gCPU.pc, gCPU.current_opc); -// printf("opcode: %08x\n", gCPU.current_opc); +// gCPU->current_opc = ppc_word_to_BE(*((uint32*)(gMemory+gCPU->pc))); + ppc_read_physical_word(gCPU->pc, gCPU->current_opc); +// printf("opcode: %08x\n", gCPU->current_opc); #endif // printf("Executing...\n"); //MIST - ppc_exec_opc(); + ppc_exec_opc(gCPU); #ifndef PEARPC - if (gCPU.npc == 0xdeadbeec) return; + if (gCPU->npc == 0xdeadbeec) return NULL; #endif ops++; - gCPU.ptb++; - if (gCPU.pdec == 0) { - gCPU.exception_pending = true; - gCPU.dec_exception = true; - gCPU.pdec=0xffffffff*TB_TO_PTB_FACTOR; + gCPU->ptb++; + if (gCPU->pdec == 0) { + gCPU->exception_pending = true; + gCPU->dec_exception = true; + gCPU->pdec=0xffffffff*TB_TO_PTB_FACTOR; } else { - gCPU.pdec--; + gCPU->pdec--; } if ((ops & 0x3ffff)==0) { /* if (pic_check_interrupt()) { - gCPU.exception_pending = true; - gCPU.ext_exception = true; + gCPU->exception_pending = true; + gCPU->ext_exception = true; }*/ if ((ops & 0x0fffff)==0) { // uint32 j=0; // ppc_read_effective_word(0xc046b2f8, j); #ifdef PEARPC - ht_printf("@%08x (%d ops) pdec: %08x lr: %08x\r", gCPU.pc, ops, gCPU.pdec, gCPU.lr); + ht_printf("@%08x (%d ops) pdec: %08x lr: %08x\r", gCPU->pc, ops, gCPU->pdec, gCPU->lr); #endif #if 0 extern uint32 PIC_enable_low; @@ -203,29 +205,29 @@ } } - gCPU.pc = gCPU.npc; + gCPU->pc = gCPU->npc; - if (gCPU.exception_pending) { - if (gCPU.stop_exception) { - gCPU.stop_exception = false; - if (!gCPU.dec_exception && !gCPU.ext_exception) gCPU.exception_pending = false; + if (gCPU->exception_pending) { + if (gCPU->stop_exception) { + gCPU->stop_exception = false; + if (!gCPU->dec_exception && !gCPU->ext_exception) gCPU->exception_pending = false; break; } - if (gCPU.msr & MSR_EE) { + if (gCPU->msr & MSR_EE) { sys_lock_mutex(exception_mutex); - if (gCPU.ext_exception) { - ppc_exception(PPC_EXC_EXT_INT); - gCPU.ext_exception = false; - gCPU.pc = gCPU.npc; - if (!gCPU.dec_exception) gCPU.exception_pending = false; + if (gCPU->ext_exception) { + ppc_exception(gCPU, PPC_EXC_EXT_INT); + gCPU->ext_exception = false; + gCPU->pc = gCPU->npc; + if (!gCPU->dec_exception) gCPU->exception_pending = false; sys_unlock_mutex(exception_mutex); continue; } - if (gCPU.dec_exception) { - ppc_exception(PPC_EXC_DEC); - gCPU.dec_exception = false; - gCPU.pc = gCPU.npc; - gCPU.exception_pending = false; + if (gCPU->dec_exception) { + ppc_exception(gCPU, PPC_EXC_DEC); + gCPU->dec_exception = false; + gCPU->pc = gCPU->npc; + gCPU->exception_pending = false; sys_unlock_mutex(exception_mutex); continue; } @@ -234,24 +236,31 @@ } } #ifdef PPC_CPU_ENABLE_SINGLESTEP - if (gCPU.msr & MSR_SE) { - if (gCPU.singlestep_ignore) { - gCPU.singlestep_ignore = false; + if (gCPU->msr & MSR_SE) { + if (gCPU->singlestep_ignore) { + gCPU->singlestep_ignore = false; } else { - ppc_exception(PPC_EXC_TRACE2); - gCPU.pc = gCPU.npc; + ppc_exception(gCPU, PPC_EXC_TRACE2); + gCPU->pc = gCPU->npc; continue; } } #endif } + + return NULL; } -void ppc_cpu_stop() +void ppc_cpu_run_threaded(PPC_CPU_State *gCPU) +{ + pthread_create(&gCPU->thread, NULL, ppc_cpu_run, (void*)gCPU); +} + +void ppc_cpu_stop(PPC_CPU_State *gCPU) { sys_lock_mutex(exception_mutex); - gCPU.stop_exception = true; - gCPU.exception_pending = true; + gCPU->stop_exception = true; + gCPU->exception_pending = true; sys_unlock_mutex(exception_mutex); } @@ -276,43 +285,47 @@ PPC_CPU_ERR("machine check exception\n"); } +/* The following functions are unnecessary with SoftPear's threaded CPU model uint32 ppc_cpu_get_gpr(int cpu, int i) { - return gCPU.gpr[i]; + return gCPU->gpr[i]; } void ppc_cpu_set_gpr(int cpu, int i, uint32 newvalue) { - gCPU.gpr[i] = newvalue; + gCPU->gpr[i] = newvalue; } void ppc_cpu_set_msr(int cpu, uint32 newvalue) { - gCPU.msr = newvalue; + gCPU->msr = newvalue; } void ppc_cpu_set_pc(int cpu, uint32 newvalue) { - gCPU.pc = newvalue; + gCPU->pc = newvalue; } uint32 ppc_cpu_get_pc(int cpu) { - return gCPU.pc; + return gCPU->pc; } uint32 ppc_cpu_get_pvr(int cpu) { - return gCPU.pvr; + return gCPU->pvr; } +*/ +/* void ppc_cpu_map_framebuffer(uint32 pa, uint32 ea) { // use BAT for framebuffer - gCPU.dbatu[0] = ea|(7<<2)|0x3; - gCPU.dbat_bl17[0] = ~(BATU_BL(gCPU.dbatu[0])<<17); - gCPU.dbatl[0] = pa; + gCPU->dbatu[0] = ea|(7<<2)|0x3; + gCPU->dbat_bl17[0] = ~(BATU_BL(gCPU->dbatu[0])<<17); + gCPU->dbatl[0] = pa; } +*/ void ppc_set_singlestep_v(bool v, const char *file, int line, const char *format, ...) { @@ -336,20 +349,42 @@ #include "configparser.h" #endif -bool ppc_cpu_init() +PPC_CPU_State *ppc_cpu_init() { - memset(&gCPU, 0, sizeof gCPU); + PPC_CPU_State *gCPU = (PPC_CPU_State*)spmalloc(sizeof(PPC_CPU_State)); + if(!gCPU) + return NULL; + + memset(gCPU, 0, sizeof gCPU); #ifdef PEARPC - gCPU.pvr = gConfig->getConfigInt(CPU_KEY_PVR); + gCPU->pvr = gConfig->getConfigInt(CPU_KEY_PVR); #endif - gCPU.msr = MSR_FP; + +#define STACK_SIZE 1024*1024 + gCPU->stack = (byte*) spmalloc(STACK_SIZE); + byte *stack_end = gCPU->stack + STACK_SIZE; + /* the stack pointer will be initialized to the top of stack + (some bytes will be kept free) + gMemory will be subtracted, because every read access will + add gMemory in order to convert guest to host addresses + */ + gCPU->gpr[1] = (int)(stack_end-32) - (int)gMemory; + + gCPU->lr = 0xdeadbeef; // will be recognized as return address by the interpreter + + gCPU->msr = MSR_FP; ppc_dec_init(); // initialize srs (mostly for prom) for (int i=0; i<16; i++) { - gCPU.sr[i] = 0x2aa*i; + gCPU->sr[i] = 0x2aa*i; } sys_create_mutex(&exception_mutex); - return true; + return gCPU; +} + +void ppc_cpu_deinit(PPC_CPU_State *gCPU) { + spfree(gCPU->stack); + spfree(gCPU); } void ppc_cpu_init_config() Index: ppc_cpu.h =================================================================== RCS file: /cvsroot/softpear/softpear/src/cpu/cpu_generic/ppc_cpu.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- ppc_cpu.h 16 Nov 2004 22:50:18 -0000 1.1.1.1 +++ ppc_cpu.h 14 Mar 2005 22:55:11 -0000 1.2 @@ -22,6 +22,7 @@ #define __PPC_CPU_H__ #include <stddef.h> +#include <pthread.h> #include "system/types.h" #define PPC_MHz(v) ((v)*1000*1000) @@ -95,10 +96,15 @@ byte *physical_code_page; uint64 pdec; // more precise version of dec uint64 ptb; // more precise version of tb - + + // stack reference for freeing stack associated with this CPU + byte *stack; + + // thread-reference + pthread_t thread; }; -extern PPC_CPU_State gCPU; +typedef struct PPC_CPU_State PPC_CPU_State; /* cr: .67 @@ -441,8 +447,8 @@ #define HID0_nopti 31 #define HID0_noptim 0x00000001 -void ppc_cpu_atomic_raise_ext_exception(); -void ppc_cpu_atomic_cancel_ext_exception(); +void ppc_cpu_atomic_raise_ext_exception(PPC_CPU_State*); +void ppc_cpu_atomic_cancel_ext_exception(PPC_CPU_State*); extern uint32 gBreakpoint; extern uint32 gBreakpoint2; Index: ppc_dec.cc =================================================================== RCS file: /cvsroot/softpear/softpear/src/cpu/cpu_generic/ppc_dec.cc,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- ppc_dec.cc 16 Dec 2004 21:08:01 -0000 1.3 +++ ppc_dec.cc 14 Mar 2005 22:55:11 -0000 1.4 @@ -35,19 +35,19 @@ #include "loader/nativelib.h" #include "stdlib.h" -static void ppc_opc_invalid() +static void ppc_opc_invalid(PPC_CPU_State *gCPU) { #ifdef PEARPC - if (gCPU.pc == gPromOSIEntry && gCPU.current_opc == PROM_MAGIC_OPCODE) { + if (gCPU->pc == gPromOSIEntry && gCPU->current_opc == PROM_MAGIC_OPCODE) { call_prom_osi(); return; } #endif - if (gCPU.current_opc == 0x00333301) { + if (gCPU->current_opc == 0x00333301) { // memset(r3, r4, r5) - uint32 dest = gCPU.gpr[3]; - uint32 c = gCPU.gpr[4]; - uint32 size = gCPU.gpr[5]; + uint32 dest = gCPU->gpr[3]; + uint32 c = gCPU->gpr[4]; + uint32 size = gCPU->gpr[5]; if (dest & 0xfff) { byte *dst; ppc_direct_effective_memory_handle(dest, dst); @@ -68,14 +68,14 @@ ppc_direct_effective_memory_handle(dest, dst); memset(dst, c, size); } - gCPU.pc = gCPU.npc; + gCPU->pc = gCPU->npc; return; } - if (gCPU.current_opc == 0x00333302) { + if (gCPU->current_opc == 0x00333302) { // memcpy - uint32 dest = gCPU.gpr[3]; - uint32 src = gCPU.gpr[4]; - uint32 size = gCPU.gpr[5]; + uint32 dest = gCPU->gpr[3]; + uint32 src = gCPU->gpr[4]; + uint32 size = gCPU->gpr[5]; byte *d, *s; ppc_direct_effective_memory_handle(dest, d); ppc_direct_effective_memory_handle(src, s); @@ -85,54 +85,54 @@ *d = *s; src++; dest++; d++; s++; } - gCPU.pc = gCPU.npc; + gCPU->pc = gCPU->npc; return; } - if ((gCPU.current_opc & 0xffff0000) == 0x08000000) { - nativelib_execute(gCPU.current_opc & 0xffff); + if ((gCPU->current_opc & 0xffff0000) == 0x08000000) { + nativelib_execute(gCPU->current_opc & 0xffff, gCPU); return; } - printf("\nunknown instruction: %08x\n", gCPU.current_opc); + printf("\nunknown instruction: %08x\n", gCPU->current_opc); exit(1); //SINGLESTEP("unknown instruction\n"); } // main opcode 19 -static void ppc_opc_group_1() +static void ppc_opc_group_1(PPC_CPU_State *gCPU) { - uint32 ext = PPC_OPC_EXT(gCPU.current_opc); + uint32 ext = PPC_OPC_EXT(gCPU->current_opc); if (ext & 1) { // crxxx if (ext <= 225) { switch (ext) { - case 33: ppc_opc_crnor(); return; - case 129: ppc_opc_crandc(); return; - case 193: ppc_opc_crxor(); return; - case 225: ppc_opc_crnand(); return; + case 33: ppc_opc_crnor(gCPU); return; + case 129: ppc_opc_crandc(gCPU); return; + case 193: ppc_opc_crxor(gCPU); return; + case 225: ppc_opc_crnand(gCPU); return; } } else { switch (ext) { - case 257: ppc_opc_crand(); return; - case 289: ppc_opc_creqv(); return; - case 417: ppc_opc_crorc(); return; - case 449: ppc_opc_cror(); return; + case 257: ppc_opc_crand(gCPU); return; + case 289: ppc_opc_creqv(gCPU); return; + case 417: ppc_opc_crorc(gCPU); return; + case 449: ppc_opc_cror(gCPU); return; } } } else if (ext & (1<<9)) { // bcctrx if (ext == 528) { - ppc_opc_bcctrx(); + ppc_opc_bcctrx(gCPU); return; } } else { switch (ext) { - case 16: ppc_opc_bclrx(); return; - case 0: ppc_opc_mcrf(); return; - case 50: ppc_opc_rfi(); return; - case 150: ppc_opc_isync(); return; + case 16: ppc_opc_bclrx(gCPU); return; + case 0: ppc_opc_mcrf(gCPU); return; + case 50: ppc_opc_rfi(gCPU); return; + case 150: ppc_opc_isync(gCPU); return; } } - ppc_opc_invalid(); + ppc_opc_invalid(gCPU); } ppc_opc_function ppc_opc_table_group2[1015]; @@ -240,81 +240,81 @@ } // main opcode 31 -static void ppc_opc_group_2() +static void ppc_opc_group_2(PPC_CPU_State *gCPU) { - uint32 ext = PPC_OPC_EXT(gCPU.current_opc); + uint32 ext = PPC_OPC_EXT(gCPU->current_opc); if (ext >= (sizeof ppc_opc_table_group2 / sizeof ppc_opc_table_group2[0])) { - ppc_opc_invalid(); + ppc_opc_invalid(gCPU); } - ppc_opc_table_group2[ext](); + ppc_opc_table_group2[ext](gCPU); } // main opcode 59 -static void ppc_opc_group_f1() +static void ppc_opc_group_f1(PPC_CPU_State *gCPU) { - if ((gCPU.msr & MSR_FP) == 0) { - ppc_exception(PPC_EXC_NO_FPU); + if ((gCPU->msr & MSR_FP) == 0) { + ppc_exception(gCPU, PPC_EXC_NO_FPU); return; } - uint32 ext = PPC_OPC_EXT(gCPU.current_opc); + uint32 ext = PPC_OPC_EXT(gCPU->current_opc); switch (ext & 0x1f) { - case 18: ppc_opc_fdivsx(); return; - case 20: ppc_opc_fsubsx(); return; - case 21: ppc_opc_faddsx(); return; - case 22: ppc_opc_fsqrtsx(); return; - case 24: ppc_opc_fresx(); return; - case 25: ppc_opc_fmulsx(); return; - case 28: ppc_opc_fmsubsx(); return; - case 29: ppc_opc_fmaddsx(); return; - case 30: ppc_opc_fnmsubsx(); return; - case 31: ppc_opc_fnmaddsx(); return; + case 18: ppc_opc_fdivsx(gCPU); return; + case 20: ppc_opc_fsubsx(gCPU); return; + case 21: ppc_opc_faddsx(gCPU); return; + case 22: ppc_opc_fsqrtsx(gCPU); return; + case 24: ppc_opc_fresx(gCPU); return; + case 25: ppc_opc_fmulsx(gCPU); return; + case 28: ppc_opc_fmsubsx(gCPU); return; + case 29: ppc_opc_fmaddsx(gCPU); return; + case 30: ppc_opc_fnmsubsx(gCPU); return; + case 31: ppc_opc_fnmaddsx(gCPU); return; } - ppc_opc_invalid(); + ppc_opc_invalid(gCPU); } // main opcode 63 -static void ppc_opc_group_f2() +static void ppc_opc_group_f2(PPC_CPU_State *gCPU) { - if ((gCPU.msr & MSR_FP) == 0) { - ppc_exception(PPC_EXC_NO_FPU); + if ((gCPU->msr & MSR_FP) == 0) { + ppc_exception(gCPU, PPC_EXC_NO_FPU); return; } - uint32 ext = PPC_OPC_EXT(gCPU.current_opc); + uint32 ext = PPC_OPC_EXT(gCPU->current_opc); if (ext & 16) { switch (ext & 0x1f) { - case 18: ppc_opc_fdivx(); return; - case 20: ppc_opc_fsubx(); return; - case 21: ppc_opc_faddx(); return; - case 22: ppc_opc_fsqrtx(); return; - case 23: ppc_opc_fselx(); return; - case 25: ppc_opc_fmulx(); return; - case 26: ppc_opc_frsqrtex(); return; - case 28: ppc_opc_fmsubx(); return; - case 29: ppc_opc_fmaddx(); return; - case 30: ppc_opc_fnmsubx(); return; - case 31: ppc_opc_fnmaddx(); return; + case 18: ppc_opc_fdivx(gCPU); return; + case 20: ppc_opc_fsubx(gCPU); return; + case 21: ppc_opc_faddx(gCPU); return; + case 22: ppc_opc_fsqrtx(gCPU); return; + case 23: ppc_opc_fselx(gCPU); return; + case 25: ppc_opc_fmulx(gCPU); return; + case 26: ppc_opc_frsqrtex(gCPU); return; + case 28: ppc_opc_fmsubx(gCPU); return; + case 29: ppc_opc_fmaddx(gCPU); return; + case 30: ppc_opc_fnmsubx(gCPU); return; + case 31: ppc_opc_fnmaddx(gCPU); return; } } else { switch (ext) { - case 0: ppc_opc_fcmpu(); return; - case 12: ppc_opc_frspx(); return; - case 14: ppc_opc_fctiwx(); return; - case 15: ppc_opc_fctiwzx(); return; + case 0: ppc_opc_fcmpu(gCPU); return; + case 12: ppc_opc_frspx(gCPU); return; + case 14: ppc_opc_fctiwx(gCPU); return; + case 15: ppc_opc_fctiwzx(gCPU); return; //-- - case 32: ppc_opc_fcmpo(); return; - case 38: ppc_opc_mtfsb1x(); return; - case 40: ppc_opc_fnegx(); return; - case 64: ppc_opc_mcrfs(); return; - case 70: ppc_opc_mtfsb0x(); return; - case 72: ppc_opc_fmrx(); return; - case 134: ppc_opc_mtfsfix(); return; - case 136: ppc_opc_fnabsx(); return; - case 264: ppc_opc_fabsx(); return; - case 583: ppc_opc_mffsx(); return; - case 711: ppc_opc_mtfsfx(); return; + case 32: ppc_opc_fcmpo(gCPU); return; + case 38: ppc_opc_mtfsb1x(gCPU); return; + case 40: ppc_opc_fnegx(gCPU); return; + case 64: ppc_opc_mcrfs(gCPU); return; + case 70: ppc_opc_mtfsb0x(gCPU); return; + case 72: ppc_opc_fmrx(gCPU); return; + case 134: ppc_opc_mtfsfix(gCPU); return; + case 136: ppc_opc_fnabsx(gCPU); return; + case 264: ppc_opc_fabsx(gCPU); return; + case 583: ppc_opc_mffsx(gCPU); return; + case 711: ppc_opc_mtfsfx(gCPU); return; } } - ppc_opc_invalid(); + ppc_opc_invalid(gCPU); } static ppc_opc_function ppc_opc_table_main[64] = { @@ -384,10 +384,10 @@ &ppc_opc_group_f2, // 63 }; -void FASTCALL ppc_exec_opc() +void FASTCALL ppc_exec_opc(PPC_CPU_State *gCPU) { - uint32 mainopc = PPC_OPC_MAIN(gCPU.current_opc); - ppc_opc_table_main[mainopc](); + uint32 mainopc = PPC_OPC_MAIN(gCPU->current_opc); + ppc_opc_table_main[mainopc](gCPU); } void ppc_dec_init() Index: ppc_dec.h =================================================================== RCS file: /cvsroot/softpear/softpear/src/cpu/cpu_generic/ppc_dec.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- ppc_dec.h 16 Nov 2004 22:50:18 -0000 1.1.1.1 +++ ppc_dec.h 14 Mar 2005 22:55:11 -0000 1.2 @@ -22,11 +22,12 @@ #define __PPC_DEC_H__ #include "system/types.h" +#include "cpu/cpu.h" -void FASTCALL ppc_exec_opc(); +void FASTCALL ppc_exec_opc(PPC_CPU_State*); void ppc_dec_init(); -typedef void (*ppc_opc_function)(); +typedef void (*ppc_opc_function)(PPC_CPU_State*); #define PPC_OPC_ASSERT(v) Index: ppc_exc.cc =================================================================== RCS file: /cvsroot/softpear/softpear/src/cpu/cpu_generic/ppc_exc.cc,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- ppc_exc.cc 16 Nov 2004 22:50:18 -0000 1.1.1.1 +++ ppc_exc.cc 14 Mar 2005 22:55:11 -0000 1.2 @@ -29,71 +29,71 @@ /* * .247 */ -bool FASTCALL ppc_exception(uint32 type, uint32 flags, uint32 a) +bool FASTCALL ppc_exception(PPC_CPU_State *gCPU, uint32 type, uint32 flags, uint32 a) { - if (type != PPC_EXC_DEC) PPC_EXC_TRACE("@%08x: type = %08x (%08x, %08x)\n", gCPU.pc, type, flags, a); + if (type != PPC_EXC_DEC) PPC_EXC_TRACE("@%08x: type = %08x (%08x, %08x)\n", gCPU->pc, type, flags, a); switch (type) { case PPC_EXC_DSI: { // .271 - gCPU.srr[0] = gCPU.pc; - gCPU.srr[1] = gCPU.msr & 0x87c0ffff; - gCPU.dar = a; - gCPU.dsisr = flags; + gCPU->srr[0] = gCPU->pc; + gCPU->srr[1] = gCPU->msr & 0x87c0ffff; + gCPU->dar = a; + gCPU->dsisr = flags; break; } case PPC_EXC_ISI: { // .274 - if (gCPU.pc == 0) { + if (gCPU->pc == 0) { PPC_EXC_WARN("pc == 0 in ISI\n"); SINGLESTEP(""); } - gCPU.srr[0] = gCPU.pc; - gCPU.srr[1] = (gCPU.msr & 0x87c0ffff) | flags; + gCPU->srr[0] = gCPU->pc; + gCPU->srr[1] = (gCPU->msr & 0x87c0ffff) | flags; break; } case PPC_EXC_DEC: { // .284 - gCPU.srr[0] = gCPU.pc; - gCPU.srr[1] = gCPU.msr & 0x87c0ffff; + gCPU->srr[0] = gCPU->pc; + gCPU->srr[1] = gCPU->msr & 0x87c0ffff; break; } case PPC_EXC_EXT_INT: { - gCPU.srr[0] = gCPU.pc; - gCPU.srr[1] = gCPU.msr & 0x87c0ffff; + gCPU->srr[0] = gCPU->pc; + gCPU->srr[1] = gCPU->msr & 0x87c0ffff; break; } case PPC_EXC_SC: { // .285 - gCPU.srr[0] = gCPU.npc; - gCPU.srr[1] = gCPU.msr & 0x87c0ffff; + gCPU->srr[0] = gCPU->npc; + gCPU->srr[1] = gCPU->msr & 0x87c0ffff; break; } case PPC_EXC_NO_FPU: { // .284 - gCPU.srr[0] = gCPU.pc; - gCPU.srr[1] = gCPU.msr & 0x87c0ffff; + gCPU->srr[0] = gCPU->pc; + gCPU->srr[1] = gCPU->msr & 0x87c0ffff; break; } case PPC_EXC_PROGRAM: { // .283 if (flags & PPC_EXC_PROGRAM_NEXT) { - gCPU.srr[0] = gCPU.npc; + gCPU->srr[0] = gCPU->npc; } else { - gCPU.srr[0] = gCPU.pc; + gCPU->srr[0] = gCPU->pc; } - gCPU.srr[1] = (gCPU.msr & 0x87c0ffff) | flags; + gCPU->srr[1] = (gCPU->msr & 0x87c0ffff) | flags; break; } case PPC_EXC_FLOAT_ASSIST: { // .288 - gCPU.srr[0] = gCPU.pc; - gCPU.srr[1] = gCPU.msr & 0x87c0ffff; + gCPU->srr[0] = gCPU->pc; + gCPU->srr[1] = gCPU->msr & 0x87c0ffff; break; } case PPC_EXC_MACHINE_CHECK: { // .270 - if (!(gCPU.msr & MSR_ME)) { + if (!(gCPU->msr & MSR_ME)) { PPC_EXC_ERR("machine check exception and MSR[ME]=0.\n"); } - gCPU.srr[0] = gCPU.pc; - gCPU.srr[1] = (gCPU.msr & 0x87c0ffff) | MSR_RI; + gCPU->srr[0] = gCPU->pc; + gCPU->srr[1] = (gCPU->msr & 0x87c0ffff) | MSR_RI; break; } case PPC_EXC_TRACE2: { // .286 - gCPU.srr[0] = gCPU.pc; - gCPU.srr[1] = gCPU.msr & 0x87c0ffff; + gCPU->srr[0] = gCPU->pc; + gCPU->srr[1] = gCPU->msr & 0x87c0ffff; break; } default: @@ -101,17 +101,17 @@ return false; } ppc_mmu_tlb_invalidate(); - gCPU.msr = 0; - gCPU.npc = type; + gCPU->msr = 0; + gCPU->npc = type; return true; } -void ppc_cpu_raise_ext_exception() +void ppc_cpu_raise_ext_exception(PPC_CPU_State *gCPU) { - ppc_cpu_atomic_raise_ext_exception(); + ppc_cpu_atomic_raise_ext_exception(gCPU); } -void ppc_cpu_cancel_ext_exception() +void ppc_cpu_cancel_ext_exception(PPC_CPU_State *gCPU) { - ppc_cpu_atomic_cancel_ext_exception(); + ppc_cpu_atomic_cancel_ext_exception(gCPU); } Index: ppc_exc.h =================================================================== RCS file: /cvsroot/softpear/softpear/src/cpu/cpu_generic/ppc_exc.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- ppc_exc.h 16 Nov 2004 22:50:18 -0000 1.1.1.1 +++ ppc_exc.h 14 Mar 2005 22:55:11 -0000 1.2 @@ -22,6 +22,7 @@ #define __PPC_EXC_H__ #include "system/types.h" +#include "cpu/cpu.h" /* * .250 @@ -65,9 +66,9 @@ */ #define PPC_EXC_PROGRAM_NEXT (1<<16) -bool FASTCALL ppc_exception(uint32 type=0, uint32 flags=0, uint32 a=0); -void ppc_cpu_raise_ext_exception(); -void ppc_cpu_cancel_ext_exception(); +bool FASTCALL ppc_exception(PPC_CPU_State*, uint32 type=0, uint32 flags=0, uint32 a=0); +void ppc_cpu_raise_ext_exception(PPC_CPU_State*); +void ppc_cpu_cancel_ext_exception(PPC_CPU_State*); #endif Index: ppc_fpu.cc =================================================================== RCS file: /cvsroot/softpear/softpear/src/cpu/cpu_generic/ppc_fpu.cc,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- ppc_fpu.cc 16 Nov 2004 22:50:33 -0000 1.1.1.1 +++ ppc_fpu.cc 14 Mar 2005 22:55:11 -0000 1.2 @@ -28,7 +28,7 @@ #define PPC_FPR_TYPE2(a,b) (((a)<<8)|(b)) -inline void ppc_fpu_add(ppc_double &res, ppc_double &a, ppc_double &b) +inline void ppc_fpu_add(ppc_double &res, ppc_double &a, ppc_double &b, PPC_CPU_State *gCPU) { switch (PPC_FPR_TYPE2(a.type, b.type)) { case PPC_FPR_TYPE2(ppc_fpr_norm, ppc_fpr_norm): { @@ -65,7 +65,7 @@ res.s = a.s; res.m = a.m - b.m; if (!res.m) { - if (FPSCR_RN(gCPU.fpscr) == FPSCR_RN_MINF) { + if (FPSCR_RN(gCPU->fpscr) == FPSCR_RN_MINF) { res.s |= b.s; } else { res.s &= b.s; @@ -180,7 +180,7 @@ } // res has 107 significant bits. a, b have 106 significant bits each. -inline void ppc_fpu_add_quadro(ppc_quadro &res, ppc_quadro &a, ppc_quadro &b) +inline void ppc_fpu_add_quadro(ppc_quadro &res, ppc_quadro &a, ppc_quadro &b, PPC_CPU_State *gCPU) { // treat as 107 bit mantissa if (a.type == ppc_fpr_norm) ppc_fpu_quadro_mshl(a, 1); @@ -242,7 +242,7 @@ } } if (!cmp) { - if (FPSCR_RN(gCPU.fpscr) == FPSCR_RN_MINF) { + if (FPSCR_RN(gCPU->fpscr) == FPSCR_RN_MINF) { res.s |= b.s; } else { res.s &= b.s; @@ -496,7 +496,7 @@ // button: the top line is not rendered correctly. This works with the jitc_x86 // FPU however... inline void ppc_fpu_mul_add(ppc_double &res, ppc_double &m1, ppc_double &m2, - ppc_double &s) + ppc_double &s, PPC_CPU_State *gCPU) { ppc_quadro p; /* ht_printf("m1 = %d * %016qx * 2^%d, %s\n", m1.s, m1.m, m1.e, @@ -522,7 +522,7 @@ ppc_fpu_get_fpr_type(q.type));*/ // now we must add p, q. ppc_quadro x; - ppc_fpu_add_quadro(x, p, q); + ppc_fpu_add_quadro(x, p, q, gCPU); // x = [107] /* ht_printf("x = %d * %016qx%016qx * 2^%d %s\n", x.s, x.m0, x.m1, x.e, ppc_fpu_get_fpr_type(x.type));*/ @@ -600,13 +600,13 @@ } } -inline void ppc_fpu_sqrt(ppc_double &D, const ppc_double &B) +inline void ppc_fpu_sqrt(ppc_double &D, const ppc_double &B, PPC_CPU_State *gCPU) { switch (B.type) { case ppc_fpr_norm: if (B.s) { D.type = ppc_fpr_NaN; - gCPU.fpscr |= FPSCR_VXSQRT; + gCPU->fpscr |= FPSCR_VXSQRT; break; } // D := 1/2(D_old + B/D_old) @@ -616,7 +616,7 @@ ppc_double D_old = D; ppc_double B_div_D_old; ppc_fpu_div(B_div_D_old, B, D_old); - ppc_fpu_add(D, D_old, B_div_D_old); + ppc_fpu_add(D, D_old, B_div_D_old, gCPU); D.e--; /* uint64 e; @@ -632,7 +632,7 @@ case ppc_fpr_Inf: if (B.s) { D.type = ppc_fpr_NaN; - gCPU.fpscr |= FPSCR_VXSQRT; + gCPU->fpscr |= FPSCR_VXSQRT; } else { D.type = ppc_fpr_Inf; D.s = 0; @@ -644,7 +644,7 @@ } } -void ppc_fpu_test() +void ppc_fpu_test(PPC_CPU_State *gCPU) { ppc_double A, B, C; double a, b, c; @@ -661,13 +661,13 @@ a = ppc_fpu_get_double(A); b = ppc_fpu_get_double(B); printf("%f + %f = \n", a, b); - ppc_fpu_add(C, A, B); + ppc_fpu_add(C, A, B, gCPU); uint64 d; uint32 s; - ppc_fpu_pack_double_as_single(C, d); + ppc_fpu_pack_double_as_single(C, d, gCPU); ht_printf("%064qb\n", d); ppc_fpu_unpack_double(C, d); - ppc_fpu_pack_single(C, s); + ppc_fpu_pack_single(C, s, gCPU); ht_printf("single: %032b\n", s); ppc_single Cs; ppc_fpu_unpack_single(Cs, s); @@ -734,13 +734,13 @@ * fabsx Floating Absolute Value * .484 */ -void ppc_opc_fabsx() +void ppc_opc_fabsx(PPC_CPU_State *gCPU) { int frD, frA, frB; - PPC_OPC_TEMPL_X(gCPU.current_opc, frD, frA, frB); + PPC_OPC_TEMPL_X(gCPU->current_opc, frD, frA, frB); PPC_OPC_ASSERT(frA==0); - gCPU.fpr[frD] = gCPU.fpr[frB] & ~FPU_SIGN_BIT; - if (gCPU.current_opc & PPC_OPC_Rc) { + gCPU->fpr[frD] = gCPU->fpr[frB] & ~FPU_SIGN_BIT; + if (gCPU->current_opc & PPC_OPC_Rc) { // update cr1 flags PPC_FPU_ERR("fabs.\n"); } @@ -749,20 +749,20 @@ * faddx Floating Add (Double-Precision) * .485 */ -void ppc_opc_faddx() +void ppc_opc_faddx(PPC_CPU_State *gCPU) { int frD, frA, frB, frC; - PPC_OPC_TEMPL_A(gCPU.current_opc, frD, frA, frB, frC); + PPC_OPC_TEMPL_A(gCPU->current_opc, frD, frA, frB, frC); PPC_OPC_ASSERT(frC==0); ppc_double A, B, D; - ppc_fpu_unpack_double(A, gCPU.fpr[frA]); - ppc_fpu_unpack_double(B, gCPU.fpr[frB]); + ppc_fpu_unpack_double(A, gCPU->fpr[frA]); + ppc_fpu_unpack_double(B, gCPU->fpr[frB]); if (A.s != B.s && A.type == ppc_fpr_Inf && B.type == ppc_fpr_Inf) { - gCPU.fpscr |= FPSCR_VXISI; + gCPU->fpscr |= FPSCR_VXISI; } - ppc_fpu_add(D, A, B); - gCPU.fpscr |= ppc_fpu_pack_double(D, gCPU.fpr[frD]); - if (gCPU.current_opc & PPC_OPC_Rc) { + ppc_fpu_add(D, A, B, gCPU); + gCPU->fpscr |= ppc_fpu_pack_double(D, gCPU->fpr[frD], gCPU); + if (gCPU->current_opc & PPC_OPC_Rc) { // update cr1 flags PPC_FPU_ERR("fadd.\n"); } @@ -771,20 +771,20 @@ * faddx Floating Add Single * .486 */ -void ppc_opc_faddsx() +void ppc_opc_faddsx(PPC_CPU_State *gCPU) { int frD, frA, frB, frC; - PPC_OPC_TEMPL_A(gCPU.current_opc, frD, frA, frB, frC); + PPC_OPC_TEMPL_A(gCPU->current_opc, frD, frA, frB, frC); PPC_OPC_ASSERT(frC==0); ppc_double A, B, D; - ppc_fpu_unpack_double(A, gCPU.fpr[frA]); - ppc_fpu_unpack_double(B, gCPU.fpr[frB]); + ppc_fpu_unpack_double(A, gCPU->fpr[frA]); + ppc_fpu_unpack_double(B, gCPU->fpr[frB]); if (A.s != B.s && A.type == ppc_fpr_Inf && B.type == ppc_fpr_Inf) { - gCPU.fpscr |= FPSCR_VXISI; + gCPU->fpscr |= FPSCR_VXISI; } - ppc_fpu_add(D, A, B); - gCPU.fpscr |= ppc_fpu_pack_double_as_single(D, gCPU.fpr[frD]); - if (gCPU.current_opc & PPC_OPC_Rc) { + ppc_fpu_add(D, A, B, gCPU); + gCPU->fpscr |= ppc_fpu_pack_double_as_single(D, gCPU->fpr[frD], gCPU); + if (gCPU->current_opc & PPC_OPC_Rc) { // update cr1 flags PPC_FPU_ERR("fadds.\n"); } @@ -803,66 +803,66 @@ 0xf0ffffff, 0x0fffffff, }; -void ppc_opc_fcmpo() +void ppc_opc_fcmpo(PPC_CPU_State *gCPU) { int crfD, frA, frB; - PPC_OPC_TEMPL_X(gCPU.current_opc, crfD, frA, frB); + PPC_OPC_TEMPL_X(gCPU->current_opc, crfD, frA, frB); crfD >>= 2; ppc_double A, B; - ppc_fpu_unpack_double(A, gCPU.fpr[frA]); - ppc_fpu_unpack_double(B, gCPU.fpr[frB]); + ppc_fpu_unpack_double(A, gCPU->fpr[frA]); + ppc_fpu_unpack_double(B, gCPU->fpr[frB]); uint32 cmp; if (A.type == ppc_fpr_NaN || B.type == ppc_fpr_NaN) { - gCPU.fpscr |= FPSCR_VXSNAN; - /*if (bla)*/ gCPU.fpscr |= FPSCR_VXVC; + gCPU->fpscr |= FPSCR_VXSNAN; + /*if (bla)*/ gCPU->fpscr |= FPSCR_VXVC; cmp = 1; } else { cmp = ppc_fpu_compare(A, B); } crfD = 7-crfD; - gCPU.fpscr &= ~0x1f000; - gCPU.fpscr |= (cmp << 12); - gCPU.cr &= ppc_fpu_cmp_and_mask[crfD]; - gCPU.cr |= (cmp << (crfD * 4)); + gCPU->fpscr &= ~0x1f000; + gCPU->fpscr |= (cmp << 12); + gCPU->cr &= ppc_fpu_cmp_and_mask[crfD]; + gCPU->cr |= (cmp << (crfD * 4)); } /* * fcmpu Floating Compare Unordered * .489 */ -void ppc_opc_fcmpu() +void ppc_opc_fcmpu(PPC_CPU_State *gCPU) { int crfD, frA, frB; - PPC_OPC_TEMPL_X(gCPU.current_opc, crfD, frA, frB); + PPC_OPC_TEMPL_X(gCPU->current_opc, crfD, frA, frB); crfD >>= 2; ppc_double A, B; - ppc_fpu_unpack_double(A, gCPU.fpr[frA]); - ppc_fpu_unpack_double(B, gCPU.fpr[frB]); + ppc_fpu_unpack_double(A, gCPU->fpr[frA]); + ppc_fpu_unpack_double(B, gCPU->fpr[frB]); uint32 cmp; if (A.type == ppc_fpr_NaN || B.type == ppc_fpr_NaN) { - gCPU.fpscr |= FPSCR_VXSNAN; + gCPU->fpscr |= FPSCR_VXSNAN; cmp = 1; } else { cmp = ppc_fpu_compare(A, B); } crfD = 7-crfD; - gCPU.fpscr &= ~0x1f000; - gCPU.fpscr |= (cmp << 12); - gCPU.cr &= ppc_fpu_cmp_and_mask[crfD]; - gCPU.cr |= (cmp << (crfD * 4)); + gCPU->fpscr &= ~0x1f000; + gCPU->fpscr |= (cmp << 12); + gCPU->cr &= ppc_fpu_cmp_and_mask[crfD]; + gCPU->cr |= (cmp << (crfD * 4)); } /* * fctiwx Floating Convert to Integer Word * .492 */ -void ppc_opc_fctiwx() +void ppc_opc_fctiwx(PPC_CPU_State *gCPU) { int frD, frA, frB; - PPC_OPC_TEMPL_X(gCPU.current_opc, frD, frA, frB); + PPC_OPC_TEMPL_X(gCPU->current_opc, frD, frA, frB); PPC_OPC_ASSERT(frA==0); ppc_double B; - ppc_fpu_unpack_double(B, gCPU.fpr[frB]); - gCPU.fpr[frD] = ppc_fpu_double_to_int(B); - if (gCPU.current_opc & PPC_OPC_Rc) { + ppc_fpu_unpack_double(B, gCPU->fpr[frB]); + gCPU->fpr[frD] = ppc_fpu_double_to_int(B, gCPU); + if (gCPU->current_opc & PPC_OPC_Rc) { // update cr1 flags PPC_FPU_ERR("fctiw.\n"); } @@ -871,19 +871,19 @@ * fctiwzx Floating Convert to Integer Word with Round toward Zero * .493 */ -void ppc_opc_fctiwzx() +void ppc_opc_fctiwzx(PPC_CPU_State *gCPU) { int frD, frA, frB; - PPC_OPC_TEMPL_X(gCPU.current_opc, frD, frA, frB); + PPC_OPC_TEMPL_X(gCPU->current_opc, frD, frA, frB); PPC_OPC_ASSERT(frA==0); - uint32 oldfpscr = gCPU.fpscr; - gCPU.fpscr &= ~3; - gCPU.fpscr |= 1; + uint32 oldfpscr = gCPU->fpscr; + gCPU->fpscr &= ~3; + gCPU->fpscr |= 1; ppc_double B; - ppc_fpu_unpack_double(B, gCPU.fpr[frB]); - gCPU.fpr[frD] = ppc_fpu_double_to_int(B); - gCPU.fpscr = oldfpscr; - if (gCPU.current_opc & PPC_OPC_Rc) { + ppc_fpu_unpack_double(B, gCPU->fpr[frB]); + gCPU->fpr[frD] = ppc_fpu_double_to_int(B, gCPU); + gCPU->fpscr = oldfpscr; + if (gCPU->current_opc & PPC_OPC_Rc) { // update cr1 flags PPC_FPU_ERR("fctiwz.\n"); } @@ -892,27 +892,27 @@ * fdivx Floating Divide (Double-Precision) * .494 */ -void ppc_opc_fdivx() +void ppc_opc_fdivx(PPC_CPU_State *gCPU) { int frD, frA, frB, frC; - PPC_OPC_TEMPL_A(gCPU.current_opc, frD, frA, frB, frC); + PPC_OPC_TEMPL_A(gCPU->current_opc, frD, frA, frB, frC); PPC_OPC_ASSERT(frC==0); ppc_double A, B, D; - ppc_fpu_unpack_double(A, gCPU.fpr[frA]); - ppc_fpu_unpack_double(B, gCPU.fpr[frB]); + ppc_fpu_unpack_double(A, gCPU->fpr[frA]); + ppc_fpu_unpack_double(B, gCPU->fpr[frB]); if (A.type == ppc_fpr_zero && B.type == ppc_fpr_zero) { - gCPU.fpscr |= FPSCR_VXZDZ; + gCPU->fpscr |= FPSCR_VXZDZ; } if (A.type == ppc_fpr_Inf && B.type == ppc_fpr_Inf) { - gCPU.fpscr |= FPSCR_VXIDI; + gCPU->fpscr |= FPSCR_VXIDI; } if (B.type == ppc_fpr_zero && A.type != ppc_fpr_zero) { // FIXME:: - gCPU.fpscr |= FPSCR_VXIDI; + gCPU->fpscr |= FPSCR_VXIDI; } ppc_fpu_div(D, A, B); - gCPU.fpscr |= ppc_fpu_pack_double(D, gCPU.fpr[frD]); - if (gCPU.current_opc & PPC_OPC_Rc) { + gCPU->fpscr |= ppc_fpu_pack_double(D, gCPU->fpr[frD], gCPU); + if (gCPU->current_opc & PPC_OPC_Rc) { // update cr1 flags PPC_FPU_ERR("fdiv.\n"); } @@ -921,27 +921,27 @@ * fdivsx Floating Divide Single * .495 */ -void ppc_opc_fdivsx() +void ppc_opc_fdivsx(PPC_CPU_State *gCPU) { int frD, frA, frB, frC; - PPC_OPC_TEMPL_A(gCPU.current_opc, frD, frA, frB, frC); + PPC_OPC_TEMPL_A(gCPU->current_opc, frD, frA, frB, frC); PPC_OPC_ASSERT(frC==0); ppc_double A, B, D; - ppc_fpu_unpack_double(A, gCPU.fpr[frA]); - ppc_fpu_unpack_double(B, gCPU.fpr[frB]); + ppc_fpu_unpack_double(A, gCPU->fpr[frA]); + ppc_fpu_unpack_double(B, gCPU->fpr[frB]); if (A.type == ppc_fpr_zero && B.type == ppc_fpr_zero) { - gCPU.fpscr |= FPSCR_VXZDZ; + gCPU->fpscr |= FPSCR_VXZDZ; } if (A.type == ppc_fpr_Inf && B.type == ppc_fpr_Inf) { - gCPU.fpscr |= FPSCR_VXIDI; + gCPU->fpscr |= FPSCR_VXIDI; } if (B.type == ppc_fpr_zero && A.type != ppc_fpr_zero) { // FIXME:: - gCPU.fpscr |= FPSCR_VXIDI; + gCPU->fpscr |= FPSCR_VXIDI; } ppc_fpu_div(D, A, B); - gCPU.fpscr |= ppc_fpu_pack_double_as_single(D, gCPU.fpr[frD]); - if (gCPU.current_opc & PPC_OPC_Rc) { + gCPU->fpscr |= ppc_fpu_pack_double_as_single(D, gCPU->fpr[frD], gCPU); + if (gCPU->current_opc & PPC_OPC_Rc) { // update cr1 flags PPC_FPU_ERR("fdivs.\n"); } @@ -950,17 +950,17 @@ * fmaddx Floating Multiply-Add (Double-Precision) * .496 */ -void ppc_opc_fmaddx() +void ppc_opc_fmaddx(PPC_CPU_State *gCPU) { int frD, frA, frB, frC; - PPC_OPC_TEMPL_A(gCPU.current_opc, frD, frA, frB, frC); + PPC_OPC_TEMPL_A(gCPU->current_opc, frD, frA, frB, frC); ppc_double A, B, C, D; - ppc_fpu_unpack_double(A, gCPU.fpr[frA]); - ppc_fpu_unpack_double(B, gCPU.fpr[frB]); - ppc_fpu_unpack_double(C, gCPU.fpr[frC]); - ppc_fpu_mul_add(D, A, C, B); - gCPU.fpscr |= ppc_fpu_pack_double(D, gCPU.fpr[frD]); - if (gCPU.current_opc & PPC_OPC_Rc) { + ppc_fpu_unpack_double(A, gCPU->fpr[frA]); + ppc_fpu_unpack_double(B, gCPU->fpr[frB]); + ppc_fpu_unpack_double(C, gCPU->fpr[frC]); + ppc_fpu_mul_add(D, A, C, B, gCPU); + gCPU->fpscr |= ppc_fpu_pack_double(D, gCPU->fpr[frD], gCPU); + if (gCPU->current_opc & PPC_OPC_Rc) { // update cr1 flags PPC_FPU_ERR("fmadd.\n"); } @@ -969,17 +969,17 @@ * fmaddx Floating Multiply-Add Single * .497 */ -void ppc_opc_fmaddsx() +void ppc_opc_fmaddsx(PPC_CPU_State *gCPU) { int frD, frA, frB, frC; - PPC_OPC_TEMPL_A(gCPU.current_opc, frD, frA, frB, frC); + PPC_OPC_TEMPL_A(gCPU->current_opc, frD, frA, frB, frC); ppc_double A, B, C, D; - ppc_fpu_unpack_double(A, gCPU.fpr[frA]); - ppc_fpu_unpack_double(B, gCPU.fpr[frB]); - ppc_fpu_unpack_double(C, gCPU.fpr[frC]); - ppc_fpu_mul_add(D, A, C, B); - gCPU.fpscr |= ppc_fpu_pack_double_as_single(D, gCPU.fpr[frD]); - if (gCPU.current_opc & PPC_OPC_Rc) { + ppc_fpu_unpack_double(A, gCPU->fpr[frA]); + ppc_fpu_unpack_double(B, gCPU->fpr[frB]); + ppc_fpu_unpack_double(C, gCPU->fpr[frC]); + ppc_fpu_mul_add(D, A, C, B, gCPU); + gCPU->fpscr |= ppc_fpu_pack_double_as_single(D, gCPU->fpr[frD], gCPU); + if (gCPU->current_opc & PPC_OPC_Rc) { // update cr1 flags PPC_FPU_ERR("fmadds.\n"); } @@ -988,13 +988,13 @@ * fmrx Floating Move Register * .498 */ -void ppc_opc_fmrx() +void ppc_opc_fmrx(PPC_CPU_State *gCPU) { int frD, rA, frB; - PPC_OPC_TEMPL_X(gCPU.current_opc, frD, rA, frB); + PPC_OPC_TEMPL_X(gCPU->current_opc, frD, rA, frB); PPC_OPC_ASSERT(rA==0); - gCPU.fpr[frD] = gCPU.fpr[frB]; - if (gCPU.current_opc & PPC_OPC_Rc) { + gCPU->fpr[frD] = gCPU->fpr[frB]; + if (gCPU->current_opc & PPC_OPC_Rc) { // update cr1 flags PPC_FPU_ERR("fmr.\n"); } @@ -1003,18 +1003,18 @@ * fmsubx Floating Multiply-Subtract (Double-Precision) * .499 */ -void ppc_opc_fmsubx() +void ppc_opc_fmsubx(PPC_CPU_State *gCPU) { int frD, frA, frB, frC; - PPC_OPC_TEMPL_A(gCPU.current_opc, frD, frA, frB, frC); + PPC_OPC_TEMPL_A(gCPU->current_opc, frD, frA, frB, frC); ppc_double A, B, C, D; - ppc_fpu_unpack_double(A, gCPU.fpr[frA]); - ppc_fpu_unpack_double(B, gCPU.fpr[frB]); - ppc_fpu_unpack_double(C, gCPU.fpr[frC]); + ppc_fpu_unpack_double(A, gCPU->fpr[frA]); + ppc_fpu_unpack_double(B, gCPU->fpr[frB]); + ppc_fpu_unpack_double(C, gCPU->fpr[frC]); B.s ^= 1; - ppc_fpu_mul_add(D, A, C, B); - gCPU.fpscr |= ppc_fpu_pack_double(D, gCPU.fpr[frD]); - if (gCPU.current_opc & PPC_OPC_Rc) { + ppc_fpu_mul_add(D, A, C, B, gCPU); + gCPU->fpscr |= ppc_fpu_pack_double(D, gCPU->fpr[frD], gCPU); + if (gCPU->current_opc & PPC_OPC_Rc) { // update cr1 flags PPC_FPU_ERR("fmsub.\n"); } @@ -1023,17 +1023,17 @@ * fmsubsx Floating Multiply-Subtract Single * .500 */ -void ppc_opc_fmsubsx() +void ppc_opc_fmsubsx(PPC_CPU_State *gCPU) { int frD, frA, frB, frC; - PPC_OPC_TEMPL_A(gCPU.current_opc, frD, frA, frB, frC); + PPC_OPC_TEMPL_A(gCPU->current_opc, frD, frA, frB, frC); ppc_double A, B, C, D; - ppc_fpu_unpack_double(A, gCPU.fpr[frA]); - ppc_fpu_unpack_double(B, gCPU.fpr[frB]); - ppc_fpu_unpack_double(C, gCPU.fpr[frC]); - ppc_fpu_mul_add(D, A, C, B); - gCPU.fpscr |= ppc_fpu_pack_double_as_single(D, gCPU.fpr[frD]); - if (gCPU.current_opc & PPC_OPC_Rc) { + ppc_fpu_unpack_double(A, gCPU->fpr[frA]); + ppc_fpu_unpack_double(B, gCPU->fpr[frB]); + ppc_fpu_unpack_double(C, gCPU->fpr[frC]); + ppc_fpu_mul_add(D, A, C, B, gCPU); + gCPU->fpscr |= ppc_fpu_pack_double_as_single(D, gCPU->fpr[frD], gCPU); + if (gCPU->current_opc & PPC_OPC_Rc) { // update cr1 flags PPC_FPU_ERR("fmsubs.\n"); } @@ -1042,22 +1042,22 @@ * fmulx Floating Multipy (Double-Precision) * .501 */ -void ppc_opc_fmulx() +void ppc_opc_fmulx(PPC_CPU_State *gCPU) { int frD, frA, frB, frC; - PPC_OPC_TEMPL_A(gCPU.current_opc, frD, frA, frB, frC); + PPC_OPC_TEMPL_A(gCPU->current_opc, frD, frA, frB, frC); PPC_OPC_ASSERT(frB==0); ppc_double A, C, D; - ppc_fpu_unpack_double(A, gCPU.fpr[frA]); - ppc_fpu_unpack_double(C, gCPU.fpr[frC]); + ppc_fpu_unpack_double(A, gCPU->fpr[frA]); + ppc_fpu_unpack_double(C, gCPU->fpr[frC]); if ((A.type == ppc_fpr_Inf && C.type == ppc_fpr_zero) || (A.type == ppc_fpr_zero && C.type == ppc_fpr_Inf)) { - gCPU.fpscr |= FPSCR_VXIMZ; + gCPU->fpscr |= FPSCR_VXIMZ; } ppc_fpu_mul(D, A, C); - gCPU.fpscr |= ppc_fpu_pack_double(D, gCPU.fpr[frD]); -// *((double*)&gCPU.fpr[frD]) = *((double*)(&gCPU.fpr[frA]))*(*((double*)(&gCPU.fpr[frC]))); - if (gCPU.current_opc & PPC_OPC_Rc) { + gCPU->fpscr |= ppc_fpu_pack_double(D, gCPU->fpr[frD], gCPU); +// *((double*)&gCPU->fpr[frD]) = *((double*)(&gCPU->fpr[frA]))*(*((double*)(&gCPU->fpr[frC]))); + if (gCPU->current_opc & PPC_OPC_Rc) { // update cr1 flags PPC_FPU_ERR("fmul.\n"); } @@ -1066,21 +1066,21 @@ * fmulsx Floating Multipy Single * .502 */ -void ppc_opc_fmulsx() +void ppc_opc_fmulsx(PPC_CPU_State *gCPU) { int frD, frA, frB, frC; - PPC_OPC_TEMPL_A(gCPU.current_opc, frD, frA, frB, frC); + PPC_OPC_TEMPL_A(gCPU->current_opc, frD, frA, frB, frC); PPC_OPC_ASSERT(frB==0); ppc_double A, C, D; - ppc_fpu_unpack_double(A, gCPU.fpr[frA]); - ppc_fpu_unpack_double(C, gCPU.fpr[frC]); + ppc_fpu_unpack_double(A, gCPU->fpr[frA]); + ppc_fpu_unpack_double(C, gCPU->fpr[frC]); if ((A.type == ppc_fpr_Inf && C.type == ppc_fpr_zero) || (A.type == ppc_fpr_zero && C.type == ppc_fpr_Inf)) { - gCPU.fpscr |= FPSCR_VXIMZ; + gCPU->fpscr |= FPSCR_VXIMZ; } ppc_fpu_mul(D, A, C); - gCPU.fpscr |= ppc_fpu_pack_double_as_single(D, gCPU.fpr[frD]); - if (gCPU.current_opc & PPC_OPC_Rc) { + gCPU->fpscr |= ppc_fpu_pack_double_as_single(D, gCPU->fpr[frD], gCPU); + if (gCPU->current_opc & PPC_OPC_Rc) { // update cr1 flags PPC_FPU_ERR("fmuls.\n"); } @@ -1089,13 +1089,13 @@ * fnabsx Floating Negative Absolute Value * .503 */ -void ppc_opc_fnabsx() +void ppc_opc_fnabsx(PPC_CPU_State *gCPU) { int frD, frA, frB; - PPC_OPC_TEMPL_X(gCPU.current_opc, frD, frA, frB); + PPC_OPC_TEMPL_X(gCPU->current_opc, frD, frA, frB); PPC_OPC_ASSERT(frA==0); - gCPU.fpr[frD] = gCPU.fpr[frB] | FPU_SIGN_BIT; - if (gCPU.current_opc & PPC_OPC_Rc) { + gCPU->fpr[frD] = gCPU->fpr[frB] | FPU_SIGN_BIT; + if (gCPU->current_opc & PPC_OPC_Rc) { // update cr1 flags PPC_FPU_ERR("fnabs.\n"); } @@ -1104,13 +1104,13 @@ * fnegx Floating Negate * .504 */ -void ppc_opc_fnegx() +void ppc_opc_fnegx(PPC_CPU_State *gCPU) { int frD, frA, frB; - PPC_OPC_TEMPL_X(gCPU.current_opc, frD, frA, frB); + PPC_OPC_TEMPL_X(gCPU->current_opc, frD, frA, frB); PPC_OPC_ASSERT(frA==0); - gCPU.fpr[frD] = gCPU.fpr[frB] ^ FPU_SIGN_BIT; - if (gCPU.current_opc & PPC_OPC_Rc) { + gCPU->fpr[frD] = gCPU->fpr[frB] ^ FPU_SIGN_BIT; + if (gCPU->current_opc & PPC_OPC_Rc) { // update cr1 flags PPC_FPU_ERR("fneg.\n"); } @@ -1119,18 +1119,18 @@ * fnmaddx Floating Negative Multiply-Add (Double-Precision) * .505 */ -void ppc_opc_fnmaddx() +void ppc_opc_fnmaddx(PPC_CPU_State *gCPU) { int frD, frA, frB, frC; - PPC_OPC_TEMPL_A(gCPU.current_opc, frD, frA, frB, frC); + PPC_OPC_TEMPL_A(gCPU->current_opc, frD, frA, frB, frC); ppc_double A, B, C, D/*, E*/; - ppc_fpu_unpack_double(A, gCPU.fpr[frA]); - ppc_fpu_unpack_double(B, gCPU.fpr[frB]); - ppc_fpu_unpack_double(C, gCPU.fpr[frC]); - ppc_fpu_mul_add(D, A, C, B); + ppc_fpu_unpack_double(A, gCPU->fpr[frA]); + ppc_fpu_unpack_double(B, gCPU->fpr[frB]); + ppc_fpu_unpack_double(C, gCPU->fpr[frC]); + ppc_fpu_mul_add(D, A, C, B, gCPU); D.s ^= 1; - gCPU.fpscr |= ppc_fpu_pack_double(D, gCPU.fpr[frD]); - if (gCPU.current_opc & PPC_OPC_Rc) { + gCPU->fpscr |= ppc_fpu_pack_double(D, gCPU->fpr[frD], gCPU); + if (gCPU->current_opc & PPC_OPC_Rc) { // update cr1 flags PPC_FPU_ERR("fnmadd.\n"); } @@ -1139,18 +1139,18 @@ * fnmaddsx Floating Negative Multiply-Add Single * .506 */ -void ppc_opc_fnmaddsx() +void ppc_opc_fnmaddsx(PPC_CPU_State *gCPU) { int frD, frA, frB, frC; - PPC_OPC_TEMPL_A(gCPU.current_opc, frD, frA, frB, frC); + PPC_OPC_TEMPL_A(gCPU->current_opc, frD, frA, frB, frC); ppc_double A, B, C, D; - ppc_fpu_unpack_double(A, gCPU.fpr[frA]); - ppc_fpu_unpack_double(B, gCPU.fpr[frB]); - ppc_fpu_unpack_double(C, gCPU.fpr[frC]); - ppc_fpu_mul_add(D, A, C, B); + ppc_fpu_unpack_double(A, gCPU->fpr[frA]); + ppc_fpu_unpack_double(B, gCPU->fpr[frB]); + ppc_fpu_unpack_double(C, gCPU->fpr[frC]); + ppc_fpu_mul_add(D, A, C, B, gCPU); D.s ^= 1; - gCPU.fpscr |= ppc_fpu_pack_double_as_single(D, gCPU.fpr[frD]); - if (gCPU.current_opc & PPC_OPC_Rc) { + gCPU->fpscr |= ppc_fpu_pack_double_as_single(D, gCPU->fpr[frD], gCPU); + if (gCPU->current_opc & PPC_OPC_Rc) { // update cr1 flags PPC_FPU_ERR("fnmadds.\n"); } @@ -1159,19 +1159,19 @@ * fnmsubx Floating Negative Multiply-Subtract (Double-Precision) * .507 */ -void ppc_opc_fnmsubx() +void ppc_opc_fnmsubx(PPC_CPU_State *gCPU) { int frD, frA, frB, frC; - PPC_OPC_TEMPL_A(gCPU.current_opc, frD, frA, frB, frC); + PPC_OPC_TEMPL_A(gCPU->current_opc, frD, frA, frB, frC); ppc_double A, B, C, D; - ppc_fpu_unpack_double(A, gCPU.fpr[frA]); - ppc_fpu_unpack_double(B, gCPU.fpr[frB]); - ppc_fpu_unpack_double(C, gCPU.fpr[frC]); + ppc_fpu_unpack_double(A, gCPU->fpr[frA]); + ppc_fpu_unpack_double(B, gCPU->fpr[frB]); + ppc_fpu_unpack_double(C, gCPU->fpr[frC]); B.s ^= 1; - ppc_fpu_mul_add(D, A, C, B); + ppc_fpu_mul_add(D, A, C, B, gCPU); D.s ^= 1; - gCPU.fpscr |= ppc_fpu_pack_double(D, gCPU.fpr[frD]); - if (gCPU.current_opc & PPC_OPC_Rc) { + gCPU->fpscr |= ppc_fpu_pack_double(D, gCPU->fpr[frD], gCPU); + if (gCPU->current_opc & PPC_OPC_Rc) { // update cr1 flags PPC_FPU_ERR("fnmsub.\n"); } @@ -1180,19 +1180,19 @@ * fnsubsx Floating Negative Multiply-Subtract Single * .508 */ -void ppc_opc_fnmsubsx() +void ppc_opc_fnmsubsx(PPC_CPU_State *gCPU) { int frD, frA, frB, frC; - PPC_OPC_TEMPL_A(gCPU.current_opc, frD, frA, frB, frC); + PPC_OPC_TEMPL_A(gCPU->current_opc, frD, frA, frB, frC); ppc_double A, B, C, D; - ppc_fpu_unpack_double(A, gCPU.fpr[frA]); - ppc_fpu_unpack_double(B, gCPU.fpr[frB]); - ppc_fpu_unpack_double(C, gCPU.fpr[frC]); + ppc_fpu_unpack_double(A, gCPU->fpr[frA]); + ppc_fpu_unpack_double(B, gCPU->fpr[frB]); + ppc_fpu_unpack_double(C, gCPU->fpr[frC]); B.s ^= 1; - ppc_fpu_mul_add(D, A, C, B); + ppc_fpu_mul_add(D, A, C, B, gCPU); D.s ^= 1; - gCPU.fpscr |= ppc_fpu_pack_double_as_single(D, gCPU.fpr[frD]); - if (gCPU.current_opc & PPC_OPC_Rc) { + gCPU->fpscr |= ppc_fpu_pack_double_as_single(D, gCPU->fpr[frD], gCPU); + if (gCPU->current_opc & PPC_OPC_Rc) { // update cr1 flags PPC_FPU_ERR("fnmsubs.\n"); } @@ -1201,12 +1201,12 @@ * fresx Floating Reciprocal Estimate Single * .509 */ -void ppc_opc_fresx() +void ppc_opc_fresx(PPC_CPU_State *gCPU) { int frD, frA, frB, frC; - PPC_OPC_TEMPL_A(gCPU.current_opc, frD, frA, frB, frC); + PPC_OPC_TEMPL_A(gCPU->current_opc, frD, frA, frB, frC); PPC_OPC_ASSERT(frA==0 && frC==0); - if (gCPU.current_opc & PPC_OPC_Rc) { + if (gCPU->current_opc & PPC_OPC_Rc) { // update cr1 flags PPC_FPU_ERR("fres.\n"); } @@ -1216,15 +1216,15 @@ * frspx Floating Round to Single * .511 */ -void ppc_opc_frspx() +void ppc_opc_frspx(PPC_CPU_State *gCPU) { int frD, frA, frB; - PPC_OPC_TEMPL_X(gCPU.current_opc, frD, frA, frB); + PPC_OPC_TEMPL_X(gCPU->current_opc, frD, frA, frB); PPC_OPC_ASSERT(frA==0); ppc_double B; - ppc_fpu_unpack_double(B, gCPU.fpr[frB]); - gCPU.fpscr |= ppc_fpu_pack_double_as_single(B, gCPU.fpr[frD]); - if (gCPU.current_opc & PPC_OPC_Rc) { + ppc_fpu_unpack_double(B, gCPU->fpr[frB]); + gCPU->fpscr |= ppc_fpu_pack_double_as_single(B, gCPU->fpr[frD], gCPU); + if (gCPU->current_opc & PPC_OPC_Rc) { // update cr1 flags PPC_FPU_ERR("frsp.\n"); } @@ -1233,21 +1233,21 @@ * frsqrtex Floating Reciprocal Square Root Estimate * .512 */ -void ppc_opc_frsqrtex() +void ppc_opc_frsqrtex(PPC_CPU_State *gCPU) { int frD, frA, frB, frC; - PPC_OPC_TEMPL_A(gCPU.current_opc, frD, frA, frB, frC); + PPC_OPC_TEMPL_A(gCPU->current_opc, frD, frA, frB, frC); PPC_OPC_ASSERT(frA==0 && frC==0); ppc_double B; ppc_double D; ppc_double E; ppc_double Q; - ppc_fpu_unpack_double(B, gCPU.fpr[frB]); - ppc_fpu_sqrt(Q, B); + ppc_fpu_unpack_double(B, gCPU->fpr[frB]); + ppc_fpu_sqrt(Q, B, gCPU); E.type = ppc_fpr_norm; E.s = 0; E.e = 0; E.m = 0x80000000000000ULL; ppc_fpu_div(D, E, Q); - gCPU.fpscr |= ppc_fpu_pack_double(D, gCPU.fpr[frD]); - if (gCPU.current_opc & PPC_OPC_Rc) { + gCPU->fpscr |= ppc_fpu_pack_double(D, gCPU->fpr[frD], gCPU); + if (gCPU->current_opc & PPC_OPC_Rc) { // update cr1 flags PPC_FPU_ERR("frsqrte.\n"); } @@ -1256,18 +1256,18 @@ * fselx Floating Select * .514 */ -void ppc_opc_fselx() +void ppc_opc_fselx(PPC_CPU_State *gCPU) { int frD, frA, frB, frC; - PPC_OPC_TEMPL_A(gCPU.current_opc, frD, frA, frB, frC); + PPC_OPC_TEMPL_A(gCPU->current_opc, frD, frA, frB, frC); ppc_double A; - ppc_fpu_unpack_double(A, gCPU.fpr[frA]); + ppc_fpu_unpack_double(A, gCPU->fpr[frA]); if (A.type == ppc_fpr_NaN || (A.type != ppc_fpr_zero && A.s)) { - gCPU.fpr[frD] = gCPU.fpr[frB]; + gCPU->fpr[frD] = gCPU->fpr[frB]; } else { - gCPU.fpr[frD] = gCPU.fpr[frC]; + gCPU->fpr[frD] = gCPU->fpr[frC]; } - if (gCPU.current_opc & PPC_OPC_Rc) { + if (gCPU->current_opc & PPC_OPC_Rc) { // update cr1 flags PPC_FPU_ERR("fsel.\n"); } @@ -1276,17 +1276,17 @@ * fsqrtx Floating Square Root (Double-Precision) * .515 */ -void ppc_opc_fsqrtx() +void ppc_opc_fsqrtx(PPC_CPU_State *gCPU) { int frD, frA, frB, frC; - PPC_OPC_TEMPL_A(gCPU.current_opc, frD, frA, frB, frC); + PPC_OPC_TEMPL_A(gCPU->current_opc, frD, frA, frB, frC); PPC_OPC_ASSERT(frA==0 && frC==0); ppc_double B; ppc_double D; - ppc_fpu_unpack_double(B, gCPU.fpr[frB]); - ppc_fpu_sqrt(D, B); - gCPU.fpscr |= ppc_fpu_pack_double(D, gCPU.fpr[frD]); - if (gCPU.current_opc & PPC_OPC_Rc) { + ppc_fpu_unpack_double(B, gCPU->fpr[frB]); + ppc_fpu_sqrt(D, B, gCPU); + gCPU->fpscr |= ppc_fpu_pack_double(D, gCPU->fpr[frD], gCPU); + if (gCPU->current_opc & PPC_OPC_Rc) { // update cr1 flags PPC_FPU_ERR("fsqrt.\n"); } @@ -1295,12 +1295,12 @@ * fsqrtsx Floating Square Root Single * .515 */ -void ppc_opc_fsqrtsx() +void ppc_opc_fsqrtsx(PPC_CPU_State *gCPU) { int frD, frA, frB, frC; - PPC_OPC_TEMPL_A(gCPU.current_opc, frD, frA, frB, frC); + PPC_OPC_TEMPL_A(gCPU->current_opc, frD, frA, frB, frC); PPC_OPC_ASSERT(frA==0 && frC==0); - if (gCPU.current_opc & PPC_OPC_Rc) { + if (gCPU->current_opc & PPC_OPC_Rc) { // update cr1 flags PPC_FPU_ERR("fsqrts.\n"); } @@ -1310,23 +1310,23 @@ * fsubx Floating Subtract (Double-Precision) * .517 */ -void ppc_opc_fsubx() +void ppc_opc_fsubx(PPC_CPU_State *gCPU) { int frD, frA, frB, frC; - PPC_OPC_TEMPL_A(gCPU.current_opc, frD, frA, frB, frC); + PPC_OPC_TEMPL_A(gCPU->current_opc, frD, frA, frB, frC); PPC_OPC_ASSERT(frC==0); ppc_double A, B, D; - ppc_fpu_unpack_double(A, gCPU.fpr[frA]); - ppc_fpu_unpack_double(B, gCPU.fpr[frB]); + ppc_fpu_unpack_double(A, gCPU->fpr[frA]); + ppc_fpu_unpack_double(B, gCPU->fpr[frB]); if (B.type != ppc_fpr_NaN) { B.s ^= 1; } if (A.s != B.s && A.type == ppc_fpr_Inf && B.type == ppc_fpr_Inf) { - gCPU.fpscr |= FPSCR_VXISI; + gCPU->fpscr |= FPSCR_VXISI; } - ppc_fpu_add(D, A, B); - gCPU.fpscr |= ppc_fpu_pack_double(D, gCPU.fpr[frD]); - if (gCPU.current_opc & PPC_OPC_Rc) { + ppc_fpu_add(D, A, B, gCPU); + gCPU->fpscr |= ppc_fpu_pack_double(D, gCPU->fpr[frD], gCPU); + if (gCPU->current_opc & PPC_OPC_Rc) { // update cr1 flags PPC_FPU_ERR("fsub.\n"); } @@ -1335,23 +1335,23 @@ * fsubsx Floating Subtract Single * .518 */ -void ppc_opc_fsubsx() +void ppc_opc_fsubsx(PPC_CPU_State *gCPU) { int frD, frA, frB, frC; - PPC_OPC_TEMPL_A(gCPU.current_opc, frD, frA, frB, frC); + PPC_OPC_TEMPL_A(gCPU->current_opc, frD, frA, frB, frC); PPC_OPC_ASSERT(frC==0); ppc_double A, B, D; - ppc_fpu_unpack_double(A, gCPU.fpr[frA]); - ppc_fpu_unpack_double(B, gCPU.fpr[frB]); + ppc_fpu_unpack_double(A, gCPU->fpr[frA]); + ppc_fpu_unpack_double(B, gCPU->fpr[frB]); if (B.type != ppc_fpr_NaN) { B.s ^= 1; } if (A.s != B.s && A.type == ppc_fpr_Inf && B.type == ppc_fpr_Inf) { - gCPU.fpscr |= FPSCR_VXISI; + gCPU->fpscr |= FPSCR_VXISI; } - ppc_fpu_add(D, A, B); - gCPU.fpscr |= ppc_fpu_pack_double_as_single(D, gCPU.fpr[frD]); - if (gCPU.current_opc & PPC_OPC_Rc) { + ppc_fpu_add(D, A, B, gCPU); + gCPU->fpscr |= ppc_fpu_pack_double_as_single(D, gCPU->fpr[frD], gCPU); + if (gCPU->current_opc & PPC_OPC_Rc) { // update cr1 flags PPC_FPU_ERR("fsubs.\n"); } Index: ppc_fpu.h =================================================================== RCS file: /cvsroot/softpear/softpear/src/cpu/cpu_generic/ppc_fpu.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- ppc_fpu.h 16 Nov 2004 22:50:33 -0000 1.1.1.1 +++ ppc_fpu.h 14 Mar 2005 22:55:11 -0000 1.2 @@ -21,6 +21,8 @@ #ifndef __PPC_FPU_H__ #define __PPC_FPU_H__ +#include "cpu/cpu.h" + #define FPU_SIGN_BIT (0x8000000000000000ULL) @@ -182,10 +184,10 @@ } } -inline uint32 ppc_fpu_round(ppc_double &d) +inline uint32 ppc_fpu_round(ppc_double &d, PPC_CPU_State *gCPU) { // .132 - switch (FPSCR_RN(gCPU.fpscr)) { + switch (FPSCR_RN(gCPU->fpscr)) { case FPSCR_RN_NEAR: if (d.m & 0x7) { if ((d.m & 0x7) != 4) { @@ -217,9 +219,9 @@ return 0; } -inline uint32 ppc_fpu_round_single(ppc_single &s) +inline uint32 ppc_fpu_round_singl... [truncated message content] |
From: <mas...@us...> - 2005-03-14 22:55:22
|
Update of /cvsroot/softpear/softpear/src/loader In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7977/src/loader Modified Files: nativelib.cc nativelib.h Log Message: Implemented preliminary pthread-support. The idea is to have an interpreter thread running on the host for every guest thread. To achieve this, the global gCPU structure is now local per thread. Because I didn't think enough, it is still called gCPU everywhere, although it is no longer a global structure. Only pthread_create and pthread_join are implemented. I'm sure they need some additional code to work correctly, but the major work should be done, now. Index: nativelib.cc =================================================================== RCS file: /cvsroot/softpear/softpear/src/loader/nativelib.cc,v retrieving revision 1.59 retrieving revision 1.60 diff -u -d -r1.59 -r1.60 --- nativelib.cc 14 Mar 2005 00:59:39 -0000 1.59 +++ nativelib.cc 14 Mar 2005 22:55:11 -0000 1.60 @@ -20,6 +20,7 @@ #include <sys/ioctl.h> #include <fcntl.h> #include <inttypes.h> +#include <pthread.h> #ifdef OS_DARWIN #include <vis.h> @@ -49,13 +50,13 @@ printf("\n"); } [...1259 lines suppressed...] const unsigned int kNativeLibCount = sizeof (NativeLibs) / sizeof (NativeLibEntry); -void nativelib_execute(int nativelib_index) { +void nativelib_execute(int nativelib_index, PPC_CPU_State *gCPU) { NativeLibFuncPtr p = NativeLibs[nativelib_index].addr; #ifdef DEBUG printf("\nlibc function %i (%s) at %08x\n", nativelib_index, NativeLibs[nativelib_index].name, p); @@ -1264,9 +1300,9 @@ printf("\nunknown libc function %i (%s) at %08x\n", nativelib_index, NativeLibs[nativelib_index].name, (unsigned int)p); exit(1); } else { - p(); + p(gCPU); } - gCPU.npc = gCPU.lr & 0xfffffffc; + gCPU->npc = gCPU->lr & 0xfffffffc; } /* Create an array which is needed for handling references to stdout, stdin, stderr */ Index: nativelib.h =================================================================== RCS file: /cvsroot/softpear/softpear/src/loader/nativelib.h,v retrieving revision 1.29 retrieving revision 1.30 diff -u -d -r1.29 -r1.30 --- nativelib.h 26 Jan 2005 01:47:15 -0000 1.29 +++ nativelib.h 14 Mar 2005 22:55:12 -0000 1.30 @@ -7,6 +7,8 @@ #include <config.h> +#include "cpu/cpu.h" + #ifndef NATIVE_LIB_H #define NATIVE_LIB_H @@ -131,6 +133,6 @@ extern int Darwin_opterr; extern int Darwin_optopt; -void nativelib_execute(int nativelib_index); +void nativelib_execute(int nativelib_index, PPC_CPU_State*); #endif |
From: <mas...@us...> - 2005-03-14 22:55:21
|
Update of /cvsroot/softpear/softpear/src/cpu In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7977/src/cpu Modified Files: cpu.h Log Message: Implemented preliminary pthread-support. The idea is to have an interpreter thread running on the host for every guest thread. To achieve this, the global gCPU structure is now local per thread. Because I didn't think enough, it is still called gCPU everywhere, although it is no longer a global structure. Only pthread_create and pthread_join are implemented. I'm sure they need some additional code to work correctly, but the major work should be done, now. Index: cpu.h =================================================================== RCS file: /cvsroot/softpear/softpear/src/cpu/cpu.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- cpu.h 16 Nov 2004 22:50:15 -0000 1.1.1.1 +++ cpu.h 14 Mar 2005 22:55:10 -0000 1.2 @@ -22,12 +22,14 @@ #define __CPU_H__ #include "system/types.h" +#include "cpu/cpu_generic/ppc_cpu.h" uint64 ppc_get_clock_frequency(int cpu); uint64 ppc_get_bus_frequency(int cpu); uint64 ppc_get_timebase_frequency(int cpu); -bool ppc_cpu_init(); +PPC_CPU_State *ppc_cpu_init(); +void ppc_cpu_deinit(); void ppc_cpu_init_config(); void ppc_cpu_stop(); @@ -35,14 +37,18 @@ void ppc_machine_check_exception(); -void ppc_cpu_raise_ext_exception(); -void ppc_cpu_cancel_ext_exception(); +void ppc_cpu_raise_ext_exception(PPC_CPU_State*); +void ppc_cpu_cancel_ext_exception(PPC_CPU_State*); /* * May only be called from within a CPU thread. */ -void ppc_cpu_run(); +void *ppc_cpu_run(void*); +void ppc_cpu_run_threaded(PPC_CPU_State*); + +/* The following functions are propably useless with SoftPears threaded CPU model + uint32 ppc_cpu_get_gpr(int cpu, int i); void ppc_cpu_set_gpr(int cpu, int i, uint32 newvalue); void ppc_cpu_set_msr(int cpu, uint32 newvalue); @@ -50,4 +56,6 @@ uint32 ppc_cpu_get_pc(int cpu); uint32 ppc_cpu_get_pvr(int cpu); +*/ + #endif |
From: <mas...@us...> - 2005-03-14 22:55:21
|
Update of /cvsroot/softpear/softpear/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7977/src Modified Files: Makefile.am main.cc Log Message: Implemented preliminary pthread-support. The idea is to have an interpreter thread running on the host for every guest thread. To achieve this, the global gCPU structure is now local per thread. Because I didn't think enough, it is still called gCPU everywhere, although it is no longer a global structure. Only pthread_create and pthread_join are implemented. I'm sure they need some additional code to work correctly, but the major work should be done, now. Index: Makefile.am =================================================================== RCS file: /cvsroot/softpear/softpear/src/Makefile.am,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- Makefile.am 14 Jan 2005 23:24:06 -0000 1.2 +++ Makefile.am 14 Mar 2005 22:55:10 -0000 1.3 @@ -15,9 +15,9 @@ loader/spmalloc.cc if DEBUG -softpear_LDFLAGS = $(SP_LDFLAGS) +softpear_LDFLAGS = $(SP_LDFLAGS) -lpthread else -softpear_LDFLAGS = $(SP_LDFLAGS) -s +softpear_LDFLAGS = $(SP_LDFLAGS) -s -lpthread endif Index: main.cc =================================================================== RCS file: /cvsroot/softpear/softpear/src/main.cc,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- main.cc 9 Jan 2005 20:20:25 -0000 1.15 +++ main.cc 14 Mar 2005 22:55:10 -0000 1.16 @@ -23,11 +23,12 @@ LdrResult_t *ldrResult = LdrLoadMachO(argv[1], NULL); if (!ldrResult) { - printf("Error loading file!\n\n"); - exit(EXIT_FAILURE); + printf("Error loading file!\n\n"); + exit(EXIT_FAILURE); } - if (!ppc_cpu_init()) { + PPC_CPU_State *cpu_main = ppc_cpu_init(); + if (!cpu_main) { printf("cpu_init failed! Out of memory?\n"); exit(1); } @@ -36,45 +37,36 @@ This is zero since spMemInit allocates all virtual memory from 0x0 to 0x800000 */ gMemory = 0; -#define STACK_SIZE 1024*1024 - byte *stack = (byte*) spmalloc(STACK_SIZE); - byte *stack_end = stack + STACK_SIZE; - /* the stack pointer will be initialized to the top of stack - (some bytes will be kept free) - gMemory will be subtracted, because every read access will - add gMemory in order to convert guest to host addresses - */ /* Push command line parameters on the stack */ - gCPU.gpr[1] = (int)(stack_end-32) - (int)gMemory; - - *((unsigned long*)gCPU.gpr[1]) = 0; + *((unsigned long*)cpu_main->gpr[1]) = 0; int i; for(i=argc-1;i>0;i--) { - gCPU.gpr[1] -= 4; - *((char**)gCPU.gpr[1]) = (char*) BE32_toHost((int)argv[i]); + cpu_main->gpr[1] -= 4; + *((char**)cpu_main->gpr[1]) = (char*) BE32_toHost((int)argv[i]); } - gCPU.gpr[1] -= 4; - *((unsigned long*)gCPU.gpr[1]) = BE32_toHost(argc-1); + cpu_main->gpr[1] -= 4; + *((unsigned long*)cpu_main->gpr[1]) = BE32_toHost(argc-1); /* initialization of registers ( you could call LdrLoadMachO(argv[1], "_main") to start interpretation from the main function, therefore we make sure - that the registers contain the the right values that main expect */ - gCPU.pc = ldrResult->entrypoint; - gCPU.lr = 0xdeadbeef; // will be recognized as return address by the interpreter + that the registers contain the the values that main expects */ + cpu_main->pc = ldrResult->entrypoint; - gCPU.gpr[3] = argc-1; - gCPU.gpr[4] = (unsigned int)(&argv[1]); - gCPU.gpr[5] = 0; + cpu_main->gpr[3] = argc-1; + cpu_main->gpr[4] = (unsigned int)(&argv[1]); + cpu_main->gpr[5] = 0; - debug_printf("Starting at: 0x%lx\n", gCPU.pc); - debug_printf("Stack: 0x%lx-0x%lx\n", stack, gCPU.gpr[1]); + debug_printf("Starting at: 0x%lx\n", cpu_main->pc); + debug_printf("Stack: 0x%lx-0x%lx\n", cpu_main->stack, cpu_main->gpr[1]); /* Start interpretation */ - ppc_cpu_run(); + ppc_cpu_run_threaded(cpu_main); + + pthread_join(cpu_main->thread, NULL); /* Set exit status to exit status of emulated application */ - return gCPU.gpr[3]; + return cpu_main->gpr[3]; } |
From: <mas...@us...> - 2005-03-14 18:47:18
|
Update of /cvsroot/softpear/softpear/src/cpu/cpu_generic In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5170/src/cpu/cpu_generic Modified Files: ppc_cpu.cc Log Message: cleanups Index: ppc_cpu.cc =================================================================== RCS file: /cvsroot/softpear/softpear/src/cpu/cpu_generic/ppc_cpu.cc,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- ppc_cpu.cc 14 Mar 2005 00:43:09 -0000 1.9 +++ ppc_cpu.cc 14 Mar 2005 18:47:06 -0000 1.10 @@ -332,7 +332,9 @@ #define CPU_KEY_PVR "cpu_pvr" +#ifdef PEARPC #include "configparser.h" +#endif bool ppc_cpu_init() { |
From: <mas...@us...> - 2005-03-14 18:47:17
|
Update of /cvsroot/softpear/softpear/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5170/src Removed Files: configparser.h Log Message: cleanups --- configparser.h DELETED --- |
From: <mas...@us...> - 2005-03-14 01:20:22
|
Update of /cvsroot/softpear/softpear/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27315/test Modified Files: Makefile.am Added Files: pthreads.c Log Message: added pthreads test application --- NEW FILE: pthreads.c --- #include <stdio.h> #include <pthread.h> void *thread1(void *nothing) { int i; for(i = 0; i<100; i++) { printf("."); usleep(50); } return NULL; } void *thread2(void *nothing) { int i; for(i = 0; i<50; i++) { printf("o"); usleep(100); } return NULL; } int main(void) { pthread_t t1, t2; pthread_create(&t1, NULL, thread1, NULL); pthread_create(&t2, NULL, thread2, NULL); pthread_join(t1, NULL); printf("\n"); return 0; } Index: Makefile.am =================================================================== RCS file: /cvsroot/softpear/softpear/test/Makefile.am,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- Makefile.am 11 Jan 2005 23:15:48 -0000 1.1 +++ Makefile.am 14 Mar 2005 01:19:42 -0000 1.2 @@ -1,4 +1,4 @@ -bin_PROGRAMS = stderr mainargs endless_hello add4_local binomialN fac fib_it float funcptr funcptr2 globals pointer pow_naiv pow_quick_rec prime-unsigned prime short switch switch2 test-c test-many-params unaligned unaligned2 +bin_PROGRAMS = pthreads stderr mainargs endless_hello add4_local binomialN fac fib_it float funcptr funcptr2 globals pointer pow_naiv pow_quick_rec prime-unsigned prime short switch switch2 test-c test-many-params unaligned unaligned2 |
From: <mas...@us...> - 2005-03-14 00:59:51
|
Update of /cvsroot/softpear/softpear/src/loader In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21762/src/loader Modified Files: nativelib.cc Log Message: #ifdef'ed some functions out to make it compile on linux again (they are all marked TODO and are waiting for a wrapper function which brings BSD's functionality to non-BSD systems) Index: nativelib.cc =================================================================== RCS file: /cvsroot/softpear/softpear/src/loader/nativelib.cc,v retrieving revision 1.58 retrieving revision 1.59 diff -u -d -r1.58 -r1.59 --- nativelib.cc 14 Mar 2005 00:43:09 -0000 1.58 +++ nativelib.cc 14 Mar 2005 00:59:39 -0000 1.59 @@ -161,7 +161,9 @@ pwd->pw_gid = (gid_t)Host_to_BE32((sp_uint32_t)pwd->pw_gid); /* TODO: pwd->pw_change */ +#ifndef OS_LINUX /* pw_class not a member of Linux's struct passwd */ pwd->pw_class = (char*)Host_to_BE32((sp_uint32_t)pwd->pw_class); +#endif pwd->pw_gecos = (char*)Host_to_BE32((sp_uint32_t)pwd->pw_gecos); pwd->pw_dir = (char*)Host_to_BE32((sp_uint32_t)pwd->pw_dir); pwd->pw_shell = (char*)Host_to_BE32((sp_uint32_t)pwd->pw_shell); @@ -883,22 +885,34 @@ char *dirname (const char *path); */ char *my_dirname() { - gCPU.gpr[3] = (unsigned int)dirname ((const char *)gCPU.gpr[3]); + gCPU.gpr[3] = (unsigned int)dirname ((char *)gCPU.gpr[3]); } /* mode_t getmode (const void *set, mode_t mode); */ void my_getmode() { +#ifdef OS_LINUX + + /* TODO */ + +#else /* Darwin or BSD */ gCPU.gpr[3] = (unsigned int)getmode ((const void *)gCPU.gpr[3], (mode_t)gCPU.gpr[4]); +#endif } /* void *setmode (const char *mode_str); */ void my_setmode() { +#ifdef OS_LINUX + + /* TODO */ + +#else /* Darwin or BSD */ gCPU.gpr[3] = (unsigned int)setmode ((const char *)gCPU.gpr[3]); +#endif } /* @@ -976,7 +990,13 @@ void strmode (mode_t mode, char *bp); */ void my_strmode() { +#ifdef OS_LINUX + + /* TODO */ + +#else /* Darwin or BSD */ strmode ((mode_t)gCPU.gpr[3], (char *)gCPU.gpr[4]); +#endif } /* |
From: <mas...@us...> - 2005-03-14 00:43:20
|
Update of /cvsroot/softpear/softpear/src/loader In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17038/src/loader Modified Files: nativelib.cc Log Message: added James' floating point patch some more nativelib calls (some are still no-op's) Index: nativelib.cc =================================================================== RCS file: /cvsroot/softpear/softpear/src/loader/nativelib.cc,v retrieving revision 1.57 retrieving revision 1.58 diff -u -d -r1.57 -r1.58 --- nativelib.cc 26 Jan 2005 10:25:47 -0000 1.57 +++ nativelib.cc 14 Mar 2005 00:43:09 -0000 1.58 @@ -19,6 +19,7 @@ #include <sys/stat.h> #include <sys/ioctl.h> #include <fcntl.h> +#include <inttypes.h> #ifdef OS_DARWIN #include <vis.h> @@ -153,6 +154,19 @@ return (FILE*)reg; } +void convert_passwd(struct passwd *pwd) { + pwd->pw_name = (char*)Host_to_BE32((sp_uint32_t)pwd->pw_name); + pwd->pw_passwd = (char*)Host_to_BE32((sp_uint32_t)pwd->pw_passwd); + pwd->pw_uid = (uid_t)Host_to_BE32((sp_uint32_t)pwd->pw_uid); + pwd->pw_gid = (gid_t)Host_to_BE32((sp_uint32_t)pwd->pw_gid); + /* TODO: + pwd->pw_change */ + pwd->pw_class = (char*)Host_to_BE32((sp_uint32_t)pwd->pw_class); + pwd->pw_gecos = (char*)Host_to_BE32((sp_uint32_t)pwd->pw_gecos); + pwd->pw_dir = (char*)Host_to_BE32((sp_uint32_t)pwd->pw_dir); + pwd->pw_shell = (char*)Host_to_BE32((sp_uint32_t)pwd->pw_shell); +} + /**********************************************************************************/ /* @@ -975,6 +989,111 @@ gCPU.gpr[10]); } +/* +int sigsetjmp (sigjmp_buf env, int savemask) +*/ +void my_sigsetjmp() { + /* TODO */ + gCPU.gpr[3] = 0; +} + +/* +int sigaction(int sig, const struct sigaction * restrict act, struct sigaction * restrict oact); +*/ +void my_sigaction() { + /* TODO */ + gCPU.gpr[3] = 0; +} + +/* +int sigprocmask (int how, const sigset_t *set, sigset_t *oset); +*/ +void my_sigprocmask() { + /* TODO */ + gCPU.gpr[3] = 0; +} + +/* +struct passwd * getpwuid(uid_t uid); +*/ +void my_getpwuid() { + struct passwd *pwd = getpwuid((uid_t)gCPU.gpr[3]); + convert_passwd(pwd); + gCPU.gpr[3] = (unsigned int)pwd; +} + +/* +void endpwent(void); +*/ +void my_endpwent() { + endpwent(); +} + +/* +pid_t getpid(void); +*/ +void my_getpid() { + gCPU.gpr[3] = getpid(); +} + +/* +pid_t getppid(void); +*/ +void my_getppid() { + gCPU.gpr[3] = getppid(); +} + +/* +intmax_t strtoimax(const char * restrict nptr, char **restrict endptr, int base); +*/ +void my_strtoimax() { + char **endptr = (char**)gCPU.gpr[4]; + set_gpr64(3,4,strtoimax((char*)gCPU.gpr[3], endptr, gCPU.gpr[5])); + *endptr = (char*) Host_to_BE32((sp_uint32_t) *endptr); +} + +/* +pid_t getpgrp(void); +*/ +void my_getpgrp() { + gCPU.gpr[3] = (unsigned int)getpgrp(); +} + +/* +pid_t tcgetpgrp(int fd); +*/ +void my_tcgetpgrp() { + gCPU.gpr[3] = tcgetpgrp(gCPU.gpr[3]); +} + +/* +int dup(int oldd); +*/ +void my_dup() { + gCPU.gpr[3] = dup(gCPU.gpr[3]); +} + +/* +int dup2(int oldd, int newd); +*/ +void my_dup2() { + gCPU.gpr[3] = dup2(gCPU.gpr[3], gCPU.gpr[4]); +} + +/* +int getdtablsize(void); +*/ +void my_getdtablesize() { + gCPU.gpr[3] = getdtablesize(); +} + +/* +int fcntl (int fd, int cmd, int arg); +*/ +void my_fcntl() { + gCPU.gpr[3] = fcntl(gCPU.gpr[3], gCPU.gpr[4], gCPU.gpr[5]); +} + /* This is a list with pointers to functions provided by the local environment */ /* Please do not forget to justify the #define NATIVELIBCOUNT in nativelib.h */ NativeLibEntry NativeLibs[] = { @@ -1098,6 +1217,20 @@ {"_geteuid", (NativeLibFuncPtr) my_geteuid }, {"_strmode", (NativeLibFuncPtr) my_strmode }, {"_warnx", (NativeLibFuncPtr) my_warnx }, + {"_sigsetjmp", (NativeLibFuncPtr) my_sigsetjmp }, + {"_sigaction", (NativeLibFuncPtr) my_sigaction }, + {"_sigprocmask", (NativeLibFuncPtr) my_sigprocmask }, + {"_getpwuid", (NativeLibFuncPtr) my_getpwuid }, + {"_endpwent", (NativeLibFuncPtr) my_endpwent }, + {"_getpid", (NativeLibFuncPtr) my_getpid }, + {"_getppid", (NativeLibFuncPtr) my_getppid }, + {"_strtoimax", (NativeLibFuncPtr) my_strtoimax }, + {"_getpgrp", (NativeLibFuncPtr) my_getpgrp }, + {"_tcgetpgrp", (NativeLibFuncPtr) my_tcgetpgrp }, + {"_dup", (NativeLibFuncPtr) my_dup }, + {"_dup2", (NativeLibFuncPtr) my_dup2 }, + {"_getdtablesize", (NativeLibFuncPtr) my_getdtablesize }, + {"_fcntl", (NativeLibFuncPtr) my_fcntl }, }; const unsigned int kNativeLibCount = sizeof (NativeLibs) / sizeof (NativeLibEntry); |
From: <mas...@us...> - 2005-03-14 00:43:19
|
Update of /cvsroot/softpear/softpear/src/cpu/cpu_generic In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17038/src/cpu/cpu_generic Modified Files: ppc_cpu.cc Log Message: added James' floating point patch some more nativelib calls (some are still no-op's) Index: ppc_cpu.cc =================================================================== RCS file: /cvsroot/softpear/softpear/src/cpu/cpu_generic/ppc_cpu.cc,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- ppc_cpu.cc 12 Jan 2005 12:46:32 -0000 1.8 +++ ppc_cpu.cc 14 Mar 2005 00:43:09 -0000 1.9 @@ -340,7 +340,7 @@ #ifdef PEARPC gCPU.pvr = gConfig->getConfigInt(CPU_KEY_PVR); #endif - + gCPU.msr = MSR_FP; ppc_dec_init(); // initialize srs (mostly for prom) for (int i=0; i<16; i++) { |
From: <wha...@us...> - 2005-01-26 10:26:12
|
Update of /cvsroot/softpear/softpear/src/loader In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25460 Modified Files: nativelib.cc Log Message: Some more libSystem functions to help run /bin/[ and /bin/chmod Index: nativelib.cc =================================================================== RCS file: /cvsroot/softpear/softpear/src/loader/nativelib.cc,v retrieving revision 1.56 retrieving revision 1.57 diff -u -d -r1.56 -r1.57 --- nativelib.cc 26 Jan 2005 01:47:13 -0000 1.56 +++ nativelib.cc 26 Jan 2005 10:25:47 -0000 1.57 @@ -927,6 +927,54 @@ unsetenv((const char *)gCPU.gpr[3]); } +/* +long strtol (const char * restrict nptr, char ** restrict endptr, int base); +*/ +void my_strtol() { + char **endptr = (char **)gCPU.gpr[4]; + *endptr = (char *)BE32_toHost ((unsigned int)*endptr); + gCPU.gpr[3] = strtol ((const char *)gCPU.gpr[3], endptr, (int)gCPU.gpr[5]); + *endptr = (char *)Host_to_BE32 ((unsigned int)*endptr); +} + +/* +int setegid (uid_t euid); +*/ +void my_setegid() { + gCPU.gpr[3] = setegid ((uid_t)gCPU.gpr[3]); +} + +/* +gid_t getegid (void); +*/ +void my_getegid() { + gCPU.gpr[3] = (unsigned int)getegid(); +} + +/* +uid_t geteuid (void); +*/ +void my_geteuid() { + gCPU.gpr[3] = (unsigned int)geteuid(); +} + +/* +void strmode (mode_t mode, char *bp); +*/ +void my_strmode() { + strmode ((mode_t)gCPU.gpr[3], (char *)gCPU.gpr[4]); +} + +/* +void warnx (const char *fmt, ...); +*/ +void my_warnx() { + /* TODO: variadic */ + warnx ((const char *)gCPU.gpr[3], gCPU.gpr[4], gCPU.gpr[5], + gCPU.gpr[6], gCPU.gpr[7], gCPU.gpr[8], gCPU.gpr[9], + gCPU.gpr[10]); +} + /* This is a list with pointers to functions provided by the local environment */ /* Please do not forget to justify the #define NATIVELIBCOUNT in nativelib.h */ NativeLibEntry NativeLibs[] = { @@ -1044,6 +1092,12 @@ {"_snprintf", (NativeLibFuncPtr) my_snprintf }, {"_getcwd", (NativeLibFuncPtr) my_getcwd }, {"_unsetenv", (NativeLibFuncPtr) my_unsetenv }, + {"_strtol", (NativeLibFuncPtr) my_strtol }, + {"_setegid", (NativeLibFuncPtr) my_setegid }, + {"_getegid", (NativeLibFuncPtr) my_getegid }, + {"_geteuid", (NativeLibFuncPtr) my_geteuid }, + {"_strmode", (NativeLibFuncPtr) my_strmode }, + {"_warnx", (NativeLibFuncPtr) my_warnx }, }; const unsigned int kNativeLibCount = sizeof (NativeLibs) / sizeof (NativeLibEntry); |