diff --git a/premake5.lua b/premake5.lua index 6040104..2b3772f 100644 --- a/premake5.lua +++ b/premake5.lua @@ -21,6 +21,13 @@ newoption { filter "options:enable-io-log" defines "ENABLE_IO_LOG" +newoption { + trigger = "enable-bios-hooks", + description = "Enable BIOS hooks/log", +} +filter "options:enable-bios-hooks" + defines "ENABLE_BIOS_HOOKS" + newoption { trigger = "asan", description = "Build with Address Sanitizer enabled" diff --git a/src/cpu/cpu.cpp b/src/cpu/cpu.cpp index e039729..50e5784 100644 --- a/src/cpu/cpu.cpp +++ b/src/cpu/cpu.cpp @@ -78,9 +78,10 @@ INLINE uint32_t CPU::fetchInstruction(uint32_t address) { bool CPU::executeInstructions(int count) { for (int i = 0; i < count; i++) { - // HACK: BIOS hooks +#ifdef ENABLE_BIOS_HOOKS uint32_t maskedPc = PC & 0x1fff'ffff; if (maskedPc == 0xa0 || maskedPc == 0xb0 || maskedPc == 0xc0) sys->handleBiosFunction(); +#endif saveStateForException(); checkForInterrupts(); diff --git a/src/system.h b/src/system.h index 35d1934..7ce94a3 100644 --- a/src/system.h +++ b/src/system.h @@ -33,6 +33,14 @@ * Enables IO access buffer log */ +/** + * #define ENABLE_BIOS_HOOKS + * Switch --enable-bios-hooks + * Default: false + * + * Enables BIOS syscall hooking/logging + */ + namespace bios { struct Function; }