diff --git a/src/codegen/codegen_x86-64.c b/src/codegen/codegen_x86-64.c index 0559cc06d..7a9c00519 100644 --- a/src/codegen/codegen_x86-64.c +++ b/src/codegen/codegen_x86-64.c @@ -267,6 +267,7 @@ void codegen_block_init(uint32_t phys_addr) void codegen_block_start_recompile(codeblock_t *block) { page_t *page = &pages[block->phys >> 12]; + uintptr_t rip_rel; if (!page->block[(block->phys >> 10) & 3]) mem_flush_write_page(block->phys, cs+cpu_state.pc); @@ -298,15 +299,17 @@ void codegen_block_start_recompile(codeblock_t *block) while (block_pos < BLOCK_EXIT_OFFSET) addbyte(0x90); /*NOP*/ #else - addbyte(0xc6); /* mov byte ptr[&(cpu_state.abrt)],ABRT_GPF */ - addbyte(0x05); - addlong((uint32_t) (uintptr_t) &(cpu_state.abrt)); + addbyte(0xC6); /*MOVB ABRT_GPF,(abrt)*/ + addbyte(0x45); + addbyte((uint8_t)cpu_state_offset(abrt)); addbyte(ABRT_GPF); addbyte(0x31); /* xor eax,eax */ addbyte(0xc0); - addbyte(0x67); /* mov [&(abrt_error)],eax */ - addbyte(0xa3); - addlong((uint32_t) (uintptr_t) &(abrt_error)); + addbyte(0x89); /*MOVB eax,(abrt_error)*/ + addbyte(0x85); + rip_rel = ((uintptr_t)&cpu_state) + 128; + rip_rel = ((uintptr_t) &(abrt_error)) - rip_rel; + addlong((uint32_t) rip_rel); #endif block_pos = BLOCK_EXIT_OFFSET; /*Exit code*/ addbyte(0x48); /*ADDL $40,%rsp*/ diff --git a/src/codegen/codegen_x86-64.h b/src/codegen/codegen_x86-64.h index 529be99ae..1ef81ff89 100644 --- a/src/codegen/codegen_x86-64.h +++ b/src/codegen/codegen_x86-64.h @@ -11,7 +11,7 @@ #ifdef OLD_GPF #define BLOCK_GPF_OFFSET (BLOCK_EXIT_OFFSET - 20) #else -#define BLOCK_GPF_OFFSET (BLOCK_EXIT_OFFSET - 15) +#define BLOCK_GPF_OFFSET (BLOCK_EXIT_OFFSET - 12) #endif #define BLOCK_MAX 1620 diff --git a/src/cpu/cpu.c b/src/cpu/cpu.c index a2c06bc1f..0c0dd00d0 100644 --- a/src/cpu/cpu.c +++ b/src/cpu/cpu.c @@ -73,6 +73,9 @@ enum { /* Make sure this is as low as possible. */ cpu_state_t cpu_state; +/* Place this immediately after. */ +uint32_t abrt_error; + #ifdef USE_DYNAREC const OpFn *x86_dynarec_opcodes, *x86_dynarec_opcodes_0f, *x86_dynarec_opcodes_d8_a16, *x86_dynarec_opcodes_d8_a32, diff --git a/src/cpu/x86seg.c b/src/cpu/x86seg.c index 2fda437e7..6737133ed 100644 --- a/src/cpu/x86seg.c +++ b/src/cpu/x86seg.c @@ -41,8 +41,6 @@ uint8_t opcode2; int cgate16, cgate32; int intgatesize; -uint32_t abrt_error; - void taskswitch286(uint16_t seg, uint16_t *segdat, int is32); void pmodeint(int num, int soft); diff --git a/src/sio/sio_f82c710.c b/src/sio/sio_f82c710.c index 36f6b00a3..eccf799f4 100644 --- a/src/sio/sio_f82c710.c +++ b/src/sio/sio_f82c710.c @@ -60,6 +60,24 @@ typedef struct upc_t { serial_t *uart[2]; } upc_t; +#ifdef ENABLE_F82C710_LOG +int f82c710_do_log = ENABLE_F82C710_LOG; + +static void +f82c710_log(const char *fmt, ...) +{ + va_list ap; + + if (f82c710_do_log) { + va_start(ap, fmt); + pclog_ex(fmt, ap); + va_end(ap); + } +} +#else +# define f82c710_log(fmt, ...) +#endif + static void f82c710_update_ports(upc_t *dev, int set) { @@ -171,28 +189,28 @@ f82c606_update_ports(upc_t *dev, int set) if (dev->regs[0] & 1) { gameport_remap(dev->gameport, ((uint16_t) dev->regs[7]) << 2); - pclog("Game port at %04X\n", ((uint16_t) dev->regs[7]) << 2); + f82c710_log("Game port at %04X\n", ((uint16_t) dev->regs[7]) << 2); } if (dev->regs[0] & 2) { serial_setup(dev->uart[0], ((uint16_t) dev->regs[4]) << 2, uart1_int); - pclog("UART 1 at %04X, IRQ %i\n", ((uint16_t) dev->regs[4]) << 2, uart1_int); + f82c710_log("UART 1 at %04X, IRQ %i\n", ((uint16_t) dev->regs[4]) << 2, uart1_int); } if (dev->regs[0] & 4) { serial_setup(dev->uart[1], ((uint16_t) dev->regs[5]) << 2, uart2_int); - pclog("UART 2 at %04X, IRQ %i\n", ((uint16_t) dev->regs[5]) << 2, uart2_int); + f82c710_log("UART 2 at %04X, IRQ %i\n", ((uint16_t) dev->regs[5]) << 2, uart2_int); } if (dev->regs[0] & 8) { lpt1_init(((uint16_t) dev->regs[6]) << 2); lpt1_irq(lpt1_int); - pclog("LPT1 at %04X, IRQ %i\n", ((uint16_t) dev->regs[6]) << 2, lpt1_int); + f82c710_log("LPT1 at %04X, IRQ %i\n", ((uint16_t) dev->regs[6]) << 2, lpt1_int); } nvr_at_handler(1, ((uint16_t) dev->regs[3]) << 2, dev->nvr); nvr_irq_set(nvr_int, dev->nvr); - pclog("RTC at %04X, IRQ %i\n", ((uint16_t) dev->regs[3]) << 2, nvr_int); + f82c710_log("RTC at %04X, IRQ %i\n", ((uint16_t) dev->regs[3]) << 2, nvr_int); } static uint8_t diff --git a/src/win/Makefile.mingw b/src/win/Makefile.mingw index 1773198a6..8e0156943 100644 --- a/src/win/Makefile.mingw +++ b/src/win/Makefile.mingw @@ -298,7 +298,7 @@ else endif endif ifeq ($(DEBUG), y) - DFLAGS += -ggdb -DDEBUG -DUSE_ACYCS + DFLAGS += -ggdb -DDEBUG AOPTIM := ifndef COPTIM COPTIM := -Og