diff --git a/include/cpu/memdbg.h b/include/cpu/memdbg.h
new file mode 100644
index 0000000..21d1e62
--- /dev/null
+++ b/include/cpu/memdbg.h
@@ -0,0 +1,29 @@
+/// Copyright (C) 2018 Cyberhaven
+/// Copyrights of all contributions belong to their respective owners.
+///
+/// This library is free software; you can redistribute it and/or
+/// modify it under the terms of the GNU Library General Public
+/// License as published by the Free Software Foundation; either
+/// version 2 of the License, or (at your option) any later version.
+///
+/// This library is distributed in the hope that it will be useful,
+/// but WITHOUT ANY WARRANTY; without even the implied warranty of
+/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+/// Library General Public License for more details.
+///
+/// You should have received a copy of the GNU Library General Public
+/// License along with this library; if not, see .
+
+#ifndef __LIBCPU_MEMDBG_H__
+
+#define __LIBCPU_MEMDBG_H__
+
+#include
+#include
+#include
+
+void cpu_host_memory_rw(uintptr_t source, uintptr_t dest, int length, int is_write);
+int cpu_memory_rw_debug(void *opaque_env, target_ulong addr, uint8_t *buf, int len, int is_write);
+void cpu_physical_memory_rw(target_phys_addr_t addr, uint8_t *buf, int len, int is_write);
+
+#endif
diff --git a/src/cpu-all.h b/src/cpu-all.h
index 4037cfa..0e8948a 100644
--- a/src/cpu-all.h
+++ b/src/cpu-all.h
@@ -381,6 +381,4 @@ void cpu_tlb_update_dirty(CPUArchState *env);
void dump_exec_info(FILE *f, fprintf_function cpu_fprintf);
-int cpu_memory_rw_debug(CPUArchState *env, target_ulong addr, uint8_t *buf, int len, int is_write);
-
#endif /* CPU_ALL_H */
diff --git a/src/exec-memdbg.c b/src/exec-memdbg.c
index 91713e5..4a47380 100644
--- a/src/exec-memdbg.c
+++ b/src/exec-memdbg.c
@@ -17,6 +17,7 @@
/// License along with this library; if not, see .
#include
+#include
#include
#include
#include "osdep.h"
@@ -154,10 +155,11 @@ void cpu_physical_memory_rw(target_phys_addr_t addr, uint8_t *buf, int len, int
}
/* virtual memory access for debug (includes writing to ROM) */
-int cpu_memory_rw_debug(CPUArchState *env, target_ulong addr, uint8_t *buf, int len, int is_write) {
+int cpu_memory_rw_debug(void *opaque_env, target_ulong addr, uint8_t *buf, int len, int is_write) {
int l;
target_phys_addr_t phys_addr;
target_ulong page;
+ CPUArchState *env = (CPUArchState *) opaque_env;
while (len > 0) {
page = addr & TARGET_PAGE_MASK;
diff --git a/src/target-i386/helper.c b/src/target-i386/helper.c
index 84c6ee1..f732f77 100644
--- a/src/target-i386/helper.c
+++ b/src/target-i386/helper.c
@@ -20,6 +20,8 @@
#include "cpu.h"
+#include
+
///
/// \brief cpu_compute_hflags gathers info scattered across different
/// cpu registers into the hflags register.