Skip to content

Commit

Permalink
memdbg: refactored memory accessors
Browse files Browse the repository at this point in the history
Signed-off-by: Vitaly Chipounov <vitaly@cyberhaven.io>
  • Loading branch information
vitaly-cyberhaven authored and vitalych committed Oct 11, 2018
1 parent 01fbce0 commit 3a65113
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 3 deletions.
29 changes: 29 additions & 0 deletions include/cpu/memdbg.h
Original file line number Diff line number Diff line change
@@ -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 <http://www.gnu.org/licenses/>.

#ifndef __LIBCPU_MEMDBG_H__

#define __LIBCPU_MEMDBG_H__

#include <cpu/config.h>
#include <cpu/i386/cpu.h>
#include <inttypes.h>

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
2 changes: 0 additions & 2 deletions src/cpu-all.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
4 changes: 3 additions & 1 deletion src/exec-memdbg.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
/// License along with this library; if not, see <http://www.gnu.org/licenses/>.

#include <cpu/config.h>
#include <cpu/memdbg.h>
#include <cpu/memory.h>
#include <inttypes.h>
#include "osdep.h"
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions src/target-i386/helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

#include "cpu.h"

#include <cpu/memdbg.h>

///
/// \brief cpu_compute_hflags gathers info scattered across different
/// cpu registers into the hflags register.
Expand Down

0 comments on commit 3a65113

Please sign in to comment.