#include #include #include "x86emu.h" #include "xf86include/xf86int10.h" #define __BUILDIO(bwl,bw,type) \ static inline void out##bwl##_local(unsigned long port, unsigned type value) { __asm__ __volatile__("out" #bwl " %" #bw "0, %w1" : : "a"(value), "Nd"(port)); \ }\ static inline unsigned type in##bwl##_local(unsigned long port) { \ unsigned type value; \ __asm__ __volatile__("in" #bwl " %w1, %" #bw "0" : "=a"(value) : "Nd"(port)); \ return value; \ }\ __BUILDIO(b,b,char) __BUILDIO(w,w,short) __BUILDIO(l,,int) static int address = 0; CARD8 x_inb_l(CARD16 port) { CARD8 val; val = inb_local(port); fprintf(stderr, "%04x:%04x R8 port: %04x data: %02x\n", M.x86.R_CS, M.x86.R_IP - 1, port, val); return val; } CARD16 x_inw_l(CARD16 port) { static int bottom = -1; CARD16 val; val = inw_local(port); fprintf(stderr, "%04x:%04x R16 port: %04x data: %04x\n", M.x86.R_CS, M.x86.R_IP - 1, port, val); if (address) { if (bottom >= 0) { if (port == 0x3d2) { fprintf(stderr, " Address 0x%08x read 0x%08x\n", address, val << 16 | bottom); address = 0; } bottom = -1; } if (port == 0x3d0) bottom = val; } return val; } CARD32 x_inl_l(CARD16 port) { CARD32 val; val = inl_local(port); fprintf(stderr, "%04x:%04x R32 port: %04x data: %08x\n", M.x86.R_CS, M.x86.R_IP - 1, port, (unsigned int)val); if (address && (port == 0x3d0 || port == 0xe80c)) { fprintf(stderr, " Address 0x%08x read 0x%08x\n", address, (unsigned int)val); address = 0; } return val; } void x_outb_l(CARD16 port, CARD8 val) { fprintf(stderr, "%04x:%04x W8 port: %04x data: %02x\n", M.x86.R_CS, M.x86.R_IP - 1, port, val); outb_local(port, val); } void x_outw_l(CARD16 port, CARD16 val) { static int top = -1; fprintf(stderr, "%04x:%04x W16 port: %04x data: %04x\n", M.x86.R_CS, M.x86.R_IP - 1, port, val); if (!address) { if (top >= 0) { if (port == 0x3d0) { address = top | val; fprintf(stderr, "Select address %08x\n", address); } top = -1; } if (port == 0x3d2) top = val << 16; } else { if (top >= 0) { // top is actually bottom here... if (port == 0x3d2) { fprintf(stderr, " Address 0x%08x write 0x%08x\n", address, val << 16 | top); address = 0; } top = -1; } if (port == 0x3d0) top = val; } outw_local(port, val); } void x_outl_l(CARD16 port, CARD32 val) { fprintf(stderr, "%04x:%04x W32 port: %04x data: %08x\n", M.x86.R_CS, M.x86.R_IP - 1, port, (unsigned int)val); if (port == 0x3d0 || port == 0xe808 || port == 0xe80c) { if (!address) { address = val; fprintf(stderr, "Select address %08x\n", address); } else { fprintf(stderr, " Address 0x%08x write 0x%08x\n", address, (int)val); address = 0; } } outl_local(port, val); } void log_nv_io() { X86EMU_pioFuncs pioFuncs = { (&x_inb_l), (&x_inw_l), (&x_inl_l), (&x_outb_l), (&x_outw_l), (&x_outl_l) }; X86EMU_setupPioFuncs(&pioFuncs); }