One last attempt at a fix to my own GPF handler.

This commit is contained in:
OBattler
2022-10-27 04:10:16 +02:00
parent 4dc74515e8
commit bff5026b8b
4 changed files with 7 additions and 6 deletions

View File

@@ -281,7 +281,7 @@ void codegen_block_start_recompile(codeblock_t *block)
block->status = cpu_cur_status; block->status = cpu_cur_status;
block_pos = BLOCK_GPF_OFFSET; block_pos = BLOCK_GPF_OFFSET;
#ifndef NEW_GPF #ifdef OLD_GPF
#if _WIN64 #if _WIN64
addbyte(0x48); /*XOR RCX, RCX*/ addbyte(0x48); /*XOR RCX, RCX*/
addbyte(0x31); addbyte(0x31);
@@ -306,8 +306,8 @@ void codegen_block_start_recompile(codeblock_t *block)
addbyte(0x31); /* xor eax,eax */ addbyte(0x31); /* xor eax,eax */
addbyte(0xc0); addbyte(0xc0);
addbyte(0x89); /*MOVB eax,(abrt_error)*/ addbyte(0x89); /*MOVB eax,(abrt_error)*/
addbyte(0x05); addbyte(0x85);
rip_rel = (uintptr_t) &(codeblock[block_current].data[block_pos]); rip_rel = ((uintptr_t)&cpu_state) + 128;
rip_rel = ((uintptr_t) &(abrt_error)) - rip_rel; rip_rel = ((uintptr_t) &(abrt_error)) - rip_rel;
addlong((uint32_t) rip_rel); addlong((uint32_t) rip_rel);
#endif #endif

View File

@@ -8,7 +8,7 @@
#define HASH(l) ((l) & 0x1ffff) #define HASH(l) ((l) & 0x1ffff)
#define BLOCK_EXIT_OFFSET 0x7e0 #define BLOCK_EXIT_OFFSET 0x7e0
#ifndef NEW_GPF #ifdef OLD_GPF
#define BLOCK_GPF_OFFSET (BLOCK_EXIT_OFFSET - 20) #define BLOCK_GPF_OFFSET (BLOCK_EXIT_OFFSET - 20)
#else #else
#define BLOCK_GPF_OFFSET (BLOCK_EXIT_OFFSET - 12) #define BLOCK_GPF_OFFSET (BLOCK_EXIT_OFFSET - 12)

View File

@@ -73,6 +73,9 @@ enum {
/* Make sure this is as low as possible. */ /* Make sure this is as low as possible. */
cpu_state_t cpu_state; cpu_state_t cpu_state;
/* Place this immediately after. */
uint32_t abrt_error;
#ifdef USE_DYNAREC #ifdef USE_DYNAREC
const OpFn *x86_dynarec_opcodes, *x86_dynarec_opcodes_0f, const OpFn *x86_dynarec_opcodes, *x86_dynarec_opcodes_0f,
*x86_dynarec_opcodes_d8_a16, *x86_dynarec_opcodes_d8_a32, *x86_dynarec_opcodes_d8_a16, *x86_dynarec_opcodes_d8_a32,

View File

@@ -41,8 +41,6 @@ uint8_t opcode2;
int cgate16, cgate32; int cgate16, cgate32;
int intgatesize; int intgatesize;
uint32_t abrt_error;
void taskswitch286(uint16_t seg, uint16_t *segdat, int is32); void taskswitch286(uint16_t seg, uint16_t *segdat, int is32);
void pmodeint(int num, int soft); void pmodeint(int num, int soft);