Commit graph

1883 commits

Author SHA1 Message Date
Sven Eckelmann
2688e4db9f Disable unused cryptographic functions in included minizip 2012-10-07 22:08:31 +02:00
Sven Eckelmann
81506b856f Merge port of Ari64's new experimental dynamic recompiler for i386
Signed-off-by: Sven Eckelmann <sven@narfation.org>
---
 doc/new_dynarec.txt                 |  413 ++
 projects/unix/Makefile              |   17 +
 src/main/savestates.c               |   25 +
 src/memory/dma.c                    |    4 +
 src/memory/memory.c                 |   21 +-
 src/r4300/interupt.c                |    9 +
 src/r4300/new_dynarec/assem_x86.c   | 4364 ++++++++++++++
 src/r4300/new_dynarec/assem_x86.h   |   20 +
 src/r4300/new_dynarec/linkage_x86.s |  929 +++
 src/r4300/new_dynarec/new_dynarec.c |10974 +++++++++++++++++++++++++++++++++++
 src/r4300/new_dynarec/new_dynarec.h |   38 +
 src/r4300/r4300.c                   |   23 +-
 12 files changed, 16834 insertions(+), 3 deletions(-)
 create mode 100644 doc/new_dynarec.txt
 create mode 100644 src/r4300/new_dynarec/assem_x86.c
 create mode 100644 src/r4300/new_dynarec/assem_x86.h
 create mode 100644 src/r4300/new_dynarec/linkage_x86.s
 create mode 100644 src/r4300/new_dynarec/new_dynarec.c
 create mode 100644 src/r4300/new_dynarec/new_dynarec.h
2012-09-30 11:17:08 +02:00
Emil Langrock
ba195256ed Synchronize cycle counting between cores
Signed-off-by: Sven Eckelmann <sven@narfation.org>
---
 src/r4300/interpreter_cop0.def |    4 +++-
 src/r4300/x86/gr4300.c         |    9 +++++----
 2 files changed, 8 insertions(+), 5 deletions(-)
2012-09-30 11:17:08 +02:00
Emil Langrock
f77324341f Don't try to access uninitialized blocks[x] in dma_pi_write
Signed-off-by: Sven Eckelmann <sven@narfation.org>
---
 src/memory/dma.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
2012-09-30 11:17:08 +02:00
Sven Eckelmann
839e192c68 Don't store mapped host registers on stack before dynarec call
The dynamic recompiler uses a simple register mapping for currently used
registers to reduce memory access for operations. The content of these
registers have to be saved back to the memory region containing the emulated
register bar before they will be remapped or may get damaged by an unsave
operation.

Emulated operations in the amd64 dynamic recompiler tried to avoid the complex
register free'ing operation before an call to a C function by storing the
content of mapped registers to the stack. This implementation is faulty because

 * the return address (top most stack position when the dynamic recompiler
   started a recompiled block) may get written during the execution of the C
   function. The problem is that the return address is moved to another
   position when the registers were stored in the stack and therefore the
   content of a saved register gets damaged by this write.
 * the called C function may want to access the content of an emulated
   register. This is done by reading the content of the emulated register bar
   in memory. This read will return an outdated value because the new value is
   only stored on the stack.

This problem can be avoided without more complicated checks by not saving the
content on the stack and instead unmapping the registers and saving their
content in the emulated register bar.
2012-09-23 13:31:03 +02:00
Sven Eckelmann
168ae23a47 Allow to build without OpenGL support for non-OpenGL devices 2012-09-16 21:51:23 +02:00
Richard Goedeken
0b6d4fa50c fix memset parameters from last commit 2012-09-12 22:47:30 -07:00
Sven Eckelmann
d2f23bae6b Don't free random memory on config option type change
It is possible that the config parser changes a type of an option from any
other type to string. A string is actually only a pointer to another memory
region storing the string. ConfigSetParameter will try to free the old value in
hope to avoid memory leaks. This is a problem when the pointer shares the same
memory region as the previously stored value. The free(..) will try to free a
different part and create a crash at a later point.
2012-09-11 19:38:32 +02:00
Richard Goedeken
57d08111ae increased FRONTEND_API_VERSION number for changes in commands, added documentation of api change 2012-09-09 21:54:01 -07:00
Richard Goedeken
388f321887 merged later changes from casualjames branch 2012-09-09 16:15:54 -07:00
casualjames casualjames
31aaa633ab Crash fix for BC which doesn't depend on the plugins CheckInterrupts. This is just here because it's a simple fix and for documentation purposes, because I'll soon implement CheckInterrupts at this branch. Also, for the expansion PAK settings, instead of doing it if Count<0x100000 (which has potential for being run multiple times when Count overflows), do it on the main code transfer. This has potential for breaking some things, so testing is required. 2012-08-29 22:46:49 +02:00
casualjames casualjames
f37674f32d Implement DP freeze bit (or rather, what can be done with HLE RSP and RDP). Properly fixes DK64, BC (intro speed bug, not the crash). FINALLYclear
I'm not sure if the implementation is correct, maybe the SP interrupt must be sent anyway and only the DP interrupt is delayed. Also there's still some polygon glitches and 'DIV_S by 0' errors, but at least it kinda works now, and documents what was wrong with it.
2012-08-29 03:47:32 +02:00
casualjames casualjames
3646c24d72 Remove tlb.c (this should have been sone when interpreter_tlb.def was added). Request the RSP to execute a lot of cycles (i.e. run until the end of the task), so the RSP plugin's DoRspCycles method can be changed to execute the requested amount of cycles in the future, which should make it easier to implement better RSP synchronization. 2012-08-27 17:51:22 +02:00
Richard Goedeken
ee21a0073c fix bugs with NO_ASM=1 and DEBUGGER=1 builds 2012-08-26 15:33:58 -07:00
Richard Goedeken
80804a5923 mask off the rsp register low 4 bits to ensure stack is 16-byte aligned in 64-bit rjump.c dyna_start() 2012-08-26 13:49:12 -07:00
Richard Goedeken
8f91e78144 fix several compiler errors and warnings. fix rjump.c code for 64-bit build 2012-08-26 13:12:29 -07:00
casualjames casualjames
252d09f30c Implement SI register DMA busy bit. Fixes some message spamming (multiple SI DMA interrupts in queue) on diddy kong racing. 2012-08-26 02:20:52 +02:00
casualjames casualjames
9c86c74b4a Unbreak soft reset, which I broke in the commit that introduced generic_jump_to. 2012-08-26 00:49:59 +02:00
casualjames casualjames
e10782a0ce Don't use debug_count on the expansion pack setup, since it's not saved nor restored on savestates and may cause problems. I don't think this will cause problems, since it usually takes a lot of cycles before another PI DMA is done, and also debug_count just had a value of 0x5002 in all cases I've seen. 2012-08-25 22:27:47 +02:00
casualjames casualjames
2d9bbfc146 Move the endian swap stuff to util.c, and fix the rest of the savestates.c warnings. 2012-08-25 22:16:01 +02:00
casualjames casualjames
6d729c5b81 Simplify dynarec and block system setup. Instead of starting executing code straight away after calling dyna_start but waiting until NOTCOMPILED at 0xa4000040 executes to adjust the stack, adjust the stack on dyna_start then call a auxiliary function which sets up the code at 0xa4000040 (which doesn't require special cases now). I don't have access to a 64 bit machine right now so the 64 bit code is untested. Also, remove the old cached interpreter files from the VC project. 2012-08-25 16:28:51 +02:00
casualjames casualjames
0911d91861 Misc cleanup 2012-08-24 17:30:11 +02:00
casualjames casualjames
52290dbd59 Pure interpreter: Instead of dynamically allocating a precomp_instr in PC, use a global variable. Now, we can use PC->addr instead of interp_addr, so PC->addr is the instruction pointer irregardless of the CPU mode, simplifying some code. 2012-08-24 00:18:45 +02:00
casualjames casualjames
a1712c724f Do cleanup simetrically and in the same place where initialization was done. 2012-08-23 23:47:41 +02:00
casualjames casualjames
a0bcd1abcd Integrate the idle jump optimization of recomp.c with the pure interpreter. 2012-08-23 18:49:18 +02:00
casualjames casualjames
4c5f3c8000 Remove the write to R0 checks from the instruction code, since all instructions are now decoded by recomp.c, which already does the checks. 2012-08-23 18:21:45 +02:00
casualjames casualjames
cc34b8339d Simplify the pure interpreter with the new instruction dispatch implementation. 2012-08-23 18:16:34 +02:00
casualjames casualjames
1f25cc2b2f Complete last commit. 2012-08-23 18:09:56 +02:00
casualjames casualjames
ae0d54eaf4 Organize the R4300 opcodes in a single cpu_instruction_table structure, as a preparation for the future instruction dispatch simplification. Currently, current_intruction_table is always set to the cached interpreter table. 2012-08-23 18:05:38 +02:00
casualjames casualjames
fdb67d06f5 - Add the write to R0 checks (which were only on the pure interpreter) to the interpreter code (so now the cached interpreter has it too). I've left it disabled by default on the cached interpreter, just as before.
- Add all the necessary COP1 unusable checks everywhere. There were some checks which were only on pure interpreter, and some which were only on cached interpreter.
- Add the DIV by zero checks to the interpreter codebase (was only in pure interpreter)
- Minor code fixes
2012-08-21 23:02:34 +02:00
casualjames casualjames
18e3326d23 Fix the cached interpreter which I broke last commit. 2012-08-21 19:30:34 +02:00
casualjames casualjames
0a80a2d229 Fixes for the JALR and COP1 jump instructions. 2012-08-21 19:24:59 +02:00
casualjames casualjames
4f0298a0aa Reimplement busy wait optimization on the pure interpreter (I forgot).
I did some small timing tests and I found no relevant difference between the old and the new pure interpreter implementation. So for now I'll center on fixing things.
2012-08-21 18:57:48 +02:00
casualjames casualjames
b05457b693 Initial attempt to join the pure interpreter and the cached interpreter main codebase.
This is just the bare minimum for it to work, since there's still some warnings/slowdowns/ugly code which has to be fixed.
2012-08-21 13:47:42 +02:00
casualjames casualjames
30c049b09b Fix a bug that caused a leading space to be inserted to the config file every time it was loaded then saved. 2012-08-17 23:43:01 +02:00
casualjames casualjames
22c00013a5 Join all of the 'access executable memory quickly' tricks in one function.
I'm not sure if NOTCOMPILED is correct, just because the old code was a bit weird and maybe there was a reason for it.
Also, this adds support for executing code from SP_IMEM (this happens on a PIF boot).
2012-08-17 21:43:53 +02:00
casualjames casualjames
be91c75c8e Set the PJ64 savestate TLB EntryDefined to 1 only if the entry has one of the valid bits set, 0 otherwise. In addition, I confirm that the TLB writing code should be correct since last commit which changed it. The previous code did leave some bits undefined. 2012-08-17 19:14:01 +02:00
casualjames casualjames
15dbffe8f5 Merge the status register handling code back to their original functions, now that we don't need to set the byte flags. 2012-08-17 04:59:02 +02:00
casualjames casualjames
28742feb75 Use AND+negation to unset bits 2012-08-17 04:35:22 +02:00
casualjames casualjames
40d68a384f Remove flashRAM load/save from buffer functions, which are unused following the savestates changes. The old setup was pointless anyway, since it hid the global variables, but provided a backdoor to read and write them anyway. 2012-08-17 03:11:39 +02:00
casualjames casualjames
4ba11f9e18 SEE THIS BEFORE PREVIOUS COMMIT. Remove the rest of the memory flags, and correct a bug which last commit uncovered.
Before last commit, SP_INT ORed sp_status_reg with 0x303 (signal1, signal2, halt, broke), but only set the byte flags for signal2, broke, halt (the line for signal1 was commented). This caused a desync between the status reg and the byteflags. Next time update_SP was called, the register was rebuilt using the flags, so signal1 was unset from the status reg.
This commit does not set the signal1 bit in the sp status reg (which is consistent with the taskdone() function on the HLE RSP and the most likely previous behaviour), but this may change behaviour (for the better).
2012-08-17 02:04:06 +02:00
casualjames casualjames
11a61dda3f Remove byte flags from SP_register. More to follow. 2012-08-17 00:19:41 +02:00
casualjames casualjames
7035d4b15d Finished the new savestate model.
By the way, last commit also changed the way Project64 TLB entries were written, not sure why. I believe they are written correctly now since I'm writting the same register values that are set in the TLBWI/TLBWR instruction. Anyway, I don't think TLB was working anyway since EntryDefined was never set (now it's always set, so it may still not work). This needs more testing agains PJ64.
The big file size increase should stop now, and maybe some cleanup will make up for it.
2012-08-16 22:27:48 +02:00
casualjames casualjames
3ca17b143c Bring the new savestates improvements to PJ64 savestate saving.
In addition, this fixes two other bugs to the PJ64 saving code: A out-of-bounds error when writting zeroes to the FCR1..31 field, and a uninitialized value error when writting the EntryDefined field of the TLB.
2012-08-16 03:47:09 +02:00
casualjames casualjames
75fa1948fc Initial attempt to make the savestate code endian-independent, compiler-independent and detach it from the emulator's internal representation.
So far only the code to read savestates has been modified. There's no error checking yet, but should be easy to add. A test to load a savestate from another endianness has been successful.
There has been a noticeable file size increment, but there's hardly any way to avoid it. I expect to be able to remove some code from other parts of the emulator once this task has been completed and structures can be modified freely.
2012-08-16 02:32:04 +02:00
casualjames casualjames
126d6e1d11 Experiment: Group all plugin functions in structures, to make it clear through the code where we're using plugins (they look like normal function calls to the untrained eye). 2012-08-15 04:27:42 +02:00
casualjames casualjames
3a538efff5 Tab fix. 2012-08-15 02:43:40 +02:00
casualjames casualjames
77c9ea932a Allow forward RefMD5 references. 2012-08-15 02:36:42 +02:00
casualjames casualjames
9db46fa4e7 Add lots of error checking to the ROM database code. 2012-08-15 02:25:25 +02:00
casualjames casualjames
8d74a599d6 Plugin.c: Readd l_GfxAttached=1 line which was somehow removed during the refactorings. 2012-08-10 17:54:52 +02:00