From 8ab82522c5e3d633e51dc1f86429c814751ccda2 Mon Sep 17 00:00:00 2001 From: Jonathan Campbell Date: Tue, 24 May 2022 11:33:35 -0700 Subject: [PATCH] Add include header that redefines common CPU memory I/O functions to make them invalid. This is intended for source files that emulate behavior on hardware outside the CPU and should never issue CPU memory I/O from that source file --- include/cpu_io_is_forbidden.h | 42 ++++++++++++++++++++++++++++++ src/hardware/vga_pc98_gdc_draw.cpp | 3 +++ 2 files changed, 45 insertions(+) create mode 100644 include/cpu_io_is_forbidden.h diff --git a/include/cpu_io_is_forbidden.h b/include/cpu_io_is_forbidden.h new file mode 100644 index 000000000..63d871b16 --- /dev/null +++ b/include/cpu_io_is_forbidden.h @@ -0,0 +1,42 @@ + +#undef mem_readb +#define mem_readb(x) THIS_IS_ILLEGAL_HERE + +#undef mem_writeb +#define mem_writeb(x,b) THIS_IS_ILLEGAL_HERE + +#undef mem_readw +#define mem_readw(x) THIS_IS_ILLEGAL_HERE + +#undef mem_writew +#define mem_writew(x,b) THIS_IS_ILLEGAL_HERE + +#undef mem_readd +#define mem_readd(x) THIS_IS_ILLEGAL_HERE + +#undef mem_writed +#define mem_writed(x,b) THIS_IS_ILLEGAL_HERE + +#undef real_readb +#define real_readb(x) THIS_IS_ILLEGAL_HERE + +#undef real_writeb +#define real_writeb(x,b) THIS_IS_ILLEGAL_HERE + +#undef real_readw +#define real_readw(x) THIS_IS_ILLEGAL_HERE + +#undef real_writew +#define real_writew(x,b) THIS_IS_ILLEGAL_HERE + +#undef real_readd +#define real_readd(x) THIS_IS_ILLEGAL_HERE + +#undef real_writed +#define real_writed(x,b) THIS_IS_ILLEGAL_HERE + +/* NTS: phys_readb/phys_writeb are fine, because they + * go directly to system memory. However unless + * you're emulating a PCI device with bus mastering + * enabled, you should not be using those either. */ + diff --git a/src/hardware/vga_pc98_gdc_draw.cpp b/src/hardware/vga_pc98_gdc_draw.cpp index 54ab7d1a6..fc27c3d2f 100644 --- a/src/hardware/vga_pc98_gdc_draw.cpp +++ b/src/hardware/vga_pc98_gdc_draw.cpp @@ -9,6 +9,9 @@ #include "pc98_gdc_const.h" #include +/* do not issue CPU-side I/O here -- this code emulates functions that the GDC itself carries out, not on the CPU */ +#include "cpu_io_is_forbidden.h" + uint8_t pc98_gdc_vread(const uint32_t addr); void pc98_gdc_vwrite(const uint32_t addr,const uint8_t b);