From 4f65685b9708aa567f407fd8e0a42c6a7ff85673 Mon Sep 17 00:00:00 2001 From: notaz Date: Sat, 1 Sep 2007 12:24:04 +0000 Subject: [PATCH] some io stats added git-svn-id: file:///home/notaz/opt/svn/PicoDrive@232 be3aeb3a-fb24-0410-a615-afba39da0efa --- Pico/Memory.c | 12 ++++++ platform/linux/Makefile | 4 +- platform/linux/gp2x.c | 4 ++ platform/linux/log_io.c | 81 ++++++++++++++++++++++++++++++++++++ platform/linux/log_io.h | 3 ++ platform/linux/port_config.h | 4 +- 6 files changed, 104 insertions(+), 4 deletions(-) create mode 100644 platform/linux/log_io.c create mode 100644 platform/linux/log_io.h diff --git a/Pico/Memory.c b/Pico/Memory.c index 01e92f4a..ec31ea25 100644 --- a/Pico/Memory.c +++ b/Pico/Memory.c @@ -38,6 +38,12 @@ int lrp_cyc=0, lrp_mus=0, lwp_cyc=0, lwp_mus=0; extern unsigned int ppop; #endif +#ifdef IO_STATS +void log_io(unsigned int addr, int bits, int rw); +#else +#define log_io(...) +#endif + #if defined(EMU_C68K) || defined(EMU_A68K) static __inline int PicoMemBase(u32 pc) { @@ -294,6 +300,7 @@ PICO_INTERNAL_ASM u32 CPU_CALL PicoRead8(u32 a) #endif if (a>=8; @@ -336,6 +343,7 @@ PICO_INTERNAL_ASM u32 CPU_CALL PicoRead16(u32 a) #endif if (a>16); pm[1]=(u16)d; return; } + log_io(a, 32, 1); a&=0xfffffe; OtherWrite16(a, (u16)(d>>16)); diff --git a/platform/linux/Makefile b/platform/linux/Makefile index 3380ae9a..880c27dc 100644 --- a/platform/linux/Makefile +++ b/platform/linux/Makefile @@ -4,7 +4,7 @@ dprint = 1 # profile = 1 -DEFINC = -I../.. -I. -D__GP2X__ -D_UNZIP_SUPPORT # -DBENCHMARK +DEFINC = -I../.. -I. -D__GP2X__ -D_UNZIP_SUPPORT -DIO_STATS # -DBENCHMARK GCC = gcc STRIP = strip AS = gcc @@ -25,7 +25,7 @@ LDFLAGS += `pkg-config --libs gthread-2.0` # frontend OBJS += ../gp2x/main.o ../gp2x/menu.o ../gp2x/emu.o ../gp2x/usbjoy.o blit.o \ - gp2x.o 940ctl_ym2612.o + gp2x.o 940ctl_ym2612.o log_io.o # common OBJS += ../common/menu.o ../common/fonts.o ../common/readpng.o diff --git a/platform/linux/gp2x.c b/platform/linux/gp2x.c index 0a1c73b2..f5da1670 100644 --- a/platform/linux/gp2x.c +++ b/platform/linux/gp2x.c @@ -18,6 +18,8 @@ #include "../gp2x/usbjoy.h" #include "../gp2x/version.h" +#include "log_io.h" + void *gp2x_screen; static int current_bpp = 8; static int current_pal[256]; @@ -65,6 +67,8 @@ static gint key_press_event (GtkWidget *widget, GdkEventKey *event) case 0x29: current_keys |= GP2X_PUSH; break; // f case 0x18: current_keys |= GP2X_VOL_DOWN;break; // q case 0x19: current_keys |= GP2X_VOL_UP;break; // w + case 0x2d: log_io_clear(); break; // k + case 0x2e: log_io_dump(); break; // l } return 0; diff --git a/platform/linux/log_io.c b/platform/linux/log_io.c new file mode 100644 index 00000000..9f3d4892 --- /dev/null +++ b/platform/linux/log_io.c @@ -0,0 +1,81 @@ +#include + +typedef struct +{ + unsigned int addr_min, addr_max; + int r8, r16, r32, w8, w16, w32; +} io_log_location; + +static io_log_location io_locations[] = +{ + { 0x400000, 0x9FFFFF, 0, }, // unused + { 0xa00000, 0xa03fff, 0, }, // z80 RAM + { 0xa04000, 0xa05fff, 0, }, // ym2612 + { 0xa06000, 0xa060ff, 0, }, // bank reg + { 0xa06100, 0xa07eff, 0, }, // unused + { 0xa07f00, 0xa07fff, 0, }, // vdp + { 0xa08000, 0xa0ffff, 0, }, // 0xa00000-0xa07fff mirror + { 0xa10000, 0xa1001f, 0, }, // i/o + { 0xa10020, 0xa10fff, 0, }, // expansion + { 0xa11000, 0xa110ff, 0, }, // expansion + { 0xa11100, 0xa11101, 0, }, // z80 busreq + { 0xa11102, 0xa111ff, 0, }, // expansion + { 0xa11200, 0xa11201, 0, }, // z80 reset + { 0xa11202, 0xbfffff, 0, }, // expansion + { 0xc00000, 0xc00003, 0, }, // vdp data port + { 0xc00004, 0xc00007, 0, }, // vdp control + { 0xc00009, 0xc0000f, 0, }, // hv counter + { 0xc00010, 0xc00017, 0, }, // PSG + { 0xc00018, 0xc0001f, 0, }, // unused + { 0xc00020, 0xdfffff, 0, } // vdp mirrors +}; + + +void log_io(unsigned int a, int bits, int is_write) +{ + int i; + a &= 0x00ffffff; + if (bits > 8) a&=~1; + + for (i = 0; i < sizeof(io_locations)/sizeof(io_locations[0]); i++) + { + if (a >= io_locations[i].addr_min && a <= io_locations[i].addr_max) + { + switch (bits|(is_write<<8)) { + case 0x008: io_locations[i].r8 ++; break; + case 0x010: io_locations[i].r16++; break; + case 0x020: io_locations[i].r32++; break; + case 0x108: io_locations[i].w8 ++; break; + case 0x110: io_locations[i].w16++; break; + case 0x120: io_locations[i].w32++; break; + default: printf("%06x %i %i\n", a, bits, is_write); break; + } + } + } +} + +void log_io_clear(void) +{ + int i; + for (i = 0; i < sizeof(io_locations)/sizeof(io_locations[0]); i++) + { + io_log_location *iol = &io_locations[i]; + iol->r8 = iol->r16 = iol->r32 = iol->w8 = iol->w16 = iol->w32 = 0; + } +} + +void log_io_dump(void) +{ + int i; + printf(" range : r8 r16 r32 w8 w16 w32\n"); + for (i = 0; i < sizeof(io_locations)/sizeof(io_locations[0]); i++) + { + io_log_location *iol = &io_locations[i]; + if (iol->r8 == 0 && iol->r16 == 0 && iol->r32 == 0 && iol->w8 == 0 && iol->w16 == 0 && iol->w32 == 0) + continue; + printf("%06x - %06x : %8i %8i %8i %8i %8i %8i\n", iol->addr_min, iol->addr_max, + iol->r8, iol->r16, iol->r32, iol->w8, iol->w16, iol->w32); + } + printf("\n"); +} + diff --git a/platform/linux/log_io.h b/platform/linux/log_io.h new file mode 100644 index 00000000..eda84cf7 --- /dev/null +++ b/platform/linux/log_io.h @@ -0,0 +1,3 @@ +void log_io_clear(void); +void log_io_dump(void); + diff --git a/platform/linux/port_config.h b/platform/linux/port_config.h index 765c0cd5..ce3d41f3 100644 --- a/platform/linux/port_config.h +++ b/platform/linux/port_config.h @@ -13,8 +13,8 @@ // pico.c #define CAN_HANDLE_240_LINES 1 -#define dprintf(f,...) printf("%05i:%03i: " f "\n",Pico.m.frame_count,Pico.m.scanline,##__VA_ARGS__) -//#define dprintf(x...) +//#define dprintf(f,...) printf("%05i:%03i: " f "\n",Pico.m.frame_count,Pico.m.scanline,##__VA_ARGS__) +#define dprintf(x...) #endif //PORT_CONFIG_H -- 2.39.5