Skip to content

Commit

Permalink
Sparc: avoid AREG0 wrappers for memory access helpers
Browse files Browse the repository at this point in the history
Adjust generation of load and store templates so that the functions
take a parameter for CPUState instead of relying on global env.

Remove wrappers. Move remaining memory helpers to ldst_helper.c.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
  • Loading branch information
blueswirl committed Mar 18, 2012
1 parent fe8d8f0 commit 0184e26
Show file tree
Hide file tree
Showing 6 changed files with 93 additions and 268 deletions.
12 changes: 9 additions & 3 deletions Makefile.target
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,10 @@ libobj-y = exec.o translate-all.o cpu-exec.o translate.o
libobj-y += tcg/tcg.o tcg/optimize.o
libobj-$(CONFIG_TCG_INTERPRETER) += tci.o
libobj-y += fpu/softfloat.o
libobj-y += op_helper.o helper.o
ifneq ($(TARGET_BASE_ARCH), sparc)
libobj-y += op_helper.o
endif
libobj-y += helper.o
ifeq ($(TARGET_BASE_ARCH), i386)
libobj-y += cpuid.o
endif
Expand All @@ -101,9 +104,12 @@ tci-dis.o: QEMU_CFLAGS += -I$(SRC_PATH)/tcg -I$(SRC_PATH)/tcg/tci

$(libobj-y): $(GENERATED_HEADERS)

# HELPER_CFLAGS is used for all the code compiled with static register
# HELPER_CFLAGS is used for all the legacy code compiled with static register
# variables
op_helper.o user-exec.o: QEMU_CFLAGS += $(HELPER_CFLAGS)
ifneq ($(TARGET_BASE_ARCH), sparc)
op_helper.o: QEMU_CFLAGS += $(HELPER_CFLAGS)
endif
user-exec.o: QEMU_CFLAGS += $(HELPER_CFLAGS)

# Note: this is a workaround. The real fix is to avoid compiling
# cpu_signal_handler() in user-exec.c.
Expand Down
7 changes: 7 additions & 0 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -3606,6 +3606,13 @@ case "$target_arch2" in
exit 1
;;
esac

case "$target_arch2" in
sparc*)
echo "CONFIG_TCG_PASS_AREG0=y" >> $config_target_mak
;;
esac

echo "TARGET_SHORT_ALIGNMENT=$target_short_alignment" >> $config_target_mak
echo "TARGET_INT_ALIGNMENT=$target_int_alignment" >> $config_target_mak
echo "TARGET_LONG_ALIGNMENT=$target_long_alignment" >> $config_target_mak
Expand Down
85 changes: 2 additions & 83 deletions target-sparc/cpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -587,89 +587,6 @@ void cpu_unassigned_access(CPUSPARCState *env1, target_phys_addr_t addr,
target_phys_addr_t cpu_get_phys_page_nofault(CPUSPARCState *env, target_ulong addr,
int mmu_idx);
#endif

#define WRAP_LD(rettype, fn) \
rettype cpu_ ## fn (CPUSPARCState *env1, target_ulong addr)

WRAP_LD(uint32_t, ldub_kernel);
WRAP_LD(uint32_t, lduw_kernel);
WRAP_LD(uint32_t, ldl_kernel);
WRAP_LD(uint64_t, ldq_kernel);

WRAP_LD(uint32_t, ldub_user);
WRAP_LD(uint32_t, lduw_user);
WRAP_LD(uint32_t, ldl_user);
WRAP_LD(uint64_t, ldq_user);

WRAP_LD(uint64_t, ldfq_kernel);
WRAP_LD(uint64_t, ldfq_user);

#ifdef TARGET_SPARC64
WRAP_LD(uint32_t, ldub_hypv);
WRAP_LD(uint32_t, lduw_hypv);
WRAP_LD(uint32_t, ldl_hypv);
WRAP_LD(uint64_t, ldq_hypv);

WRAP_LD(uint64_t, ldfq_hypv);

WRAP_LD(uint32_t, ldub_nucleus);
WRAP_LD(uint32_t, lduw_nucleus);
WRAP_LD(uint32_t, ldl_nucleus);
WRAP_LD(uint64_t, ldq_nucleus);

WRAP_LD(uint32_t, ldub_kernel_secondary);
WRAP_LD(uint32_t, lduw_kernel_secondary);
WRAP_LD(uint32_t, ldl_kernel_secondary);
WRAP_LD(uint64_t, ldq_kernel_secondary);

WRAP_LD(uint32_t, ldub_user_secondary);
WRAP_LD(uint32_t, lduw_user_secondary);
WRAP_LD(uint32_t, ldl_user_secondary);
WRAP_LD(uint64_t, ldq_user_secondary);
#endif
#undef WRAP_LD

#define WRAP_ST(datatype, fn) \
void cpu_ ## fn (CPUSPARCState *env1, target_ulong addr, datatype val)

WRAP_ST(uint32_t, stb_kernel);
WRAP_ST(uint32_t, stw_kernel);
WRAP_ST(uint32_t, stl_kernel);
WRAP_ST(uint64_t, stq_kernel);

WRAP_ST(uint32_t, stb_user);
WRAP_ST(uint32_t, stw_user);
WRAP_ST(uint32_t, stl_user);
WRAP_ST(uint64_t, stq_user);

WRAP_ST(uint64_t, stfq_kernel);
WRAP_ST(uint64_t, stfq_user);

#ifdef TARGET_SPARC64
WRAP_ST(uint32_t, stb_hypv);
WRAP_ST(uint32_t, stw_hypv);
WRAP_ST(uint32_t, stl_hypv);
WRAP_ST(uint64_t, stq_hypv);

WRAP_ST(uint64_t, stfq_hypv);

WRAP_ST(uint32_t, stb_nucleus);
WRAP_ST(uint32_t, stw_nucleus);
WRAP_ST(uint32_t, stl_nucleus);
WRAP_ST(uint64_t, stq_nucleus);

WRAP_ST(uint32_t, stb_kernel_secondary);
WRAP_ST(uint32_t, stw_kernel_secondary);
WRAP_ST(uint32_t, stl_kernel_secondary);
WRAP_ST(uint64_t, stq_kernel_secondary);

WRAP_ST(uint32_t, stb_user_secondary);
WRAP_ST(uint32_t, stw_user_secondary);
WRAP_ST(uint32_t, stl_user_secondary);
WRAP_ST(uint64_t, stq_user_secondary);
#endif

#undef WRAP_ST
#endif
int cpu_sparc_signal_handler(int host_signum, void *pinfo, void *puc);

Expand Down Expand Up @@ -782,6 +699,8 @@ uint64_t cpu_tick_get_count(CPUTimer *timer);
void cpu_tick_set_limit(CPUTimer *timer, uint64_t limit);
trap_state* cpu_tsptr(CPUSPARCState* env);
#endif
void do_unaligned_access(CPUSPARCState *env, target_ulong addr, int is_write,
int is_user, void *retaddr);

#define TB_FLAG_FPU_ENABLED (1 << 4)
#define TB_FLAG_AM_ENABLED (1 << 5)
Expand Down
73 changes: 69 additions & 4 deletions target-sparc/ldst_helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,24 @@
#define QT0 (env->qt0)
#define QT1 (env->qt1)

#if !defined(CONFIG_USER_ONLY)
#include "softmmu_exec.h"
#define MMUSUFFIX _mmu
#define ALIGNED_ONLY

#define SHIFT 0
#include "softmmu_template.h"

#define SHIFT 1
#include "softmmu_template.h"

#define SHIFT 2
#include "softmmu_template.h"

#define SHIFT 3
#include "softmmu_template.h"
#endif

#if defined(TARGET_SPARC64) && !defined(CONFIG_USER_ONLY)
/* Calculates TSB pointer value for fault page size 8k or 64k */
static uint64_t ultrasparc_tsb_pointer(uint64_t tsb_register,
Expand Down Expand Up @@ -523,17 +541,17 @@ uint64_t helper_ld_asi(CPUSPARCState *env, target_ulong addr, int asi, int size,
case 9: /* Supervisor code access */
switch (size) {
case 1:
ret = ldub_code(addr);
ret = cpu_ldub_code(env, addr);
break;
case 2:
ret = lduw_code(addr);
ret = cpu_lduw_code(env, addr);
break;
default:
case 4:
ret = ldl_code(addr);
ret = cpu_ldl_code(env, addr);
break;
case 8:
ret = ldq_code(addr);
ret = cpu_ldq_code(env, addr);
break;
}
break;
Expand Down Expand Up @@ -2355,3 +2373,50 @@ void cpu_unassigned_access(CPUSPARCState *env, target_phys_addr_t addr,
}
#endif
#endif

#if !defined(CONFIG_USER_ONLY)
/* XXX: make it generic ? */
static void cpu_restore_state2(CPUSPARCState *env, void *retaddr)
{
TranslationBlock *tb;
unsigned long pc;

if (retaddr) {
/* now we have a real cpu fault */
pc = (unsigned long)retaddr;
tb = tb_find_pc(pc);
if (tb) {
/* the PC is inside the translated code. It means that we have
a virtual CPU fault */
cpu_restore_state(tb, env, pc);
}
}
}

void do_unaligned_access(CPUSPARCState *env, target_ulong addr, int is_write,
int is_user, void *retaddr)
{
#ifdef DEBUG_UNALIGNED
printf("Unaligned access to 0x" TARGET_FMT_lx " from 0x" TARGET_FMT_lx
"\n", addr, env->pc);
#endif
cpu_restore_state2(env, retaddr);
helper_raise_exception(env, TT_UNALIGNED);
}

/* try to fill the TLB and return an exception if error. If retaddr is
NULL, it means that the function was called in C code (i.e. not
from generated code or from helper.c) */
/* XXX: fix it to restore all registers */
void tlb_fill(CPUSPARCState *env, target_ulong addr, int is_write, int mmu_idx,
void *retaddr)
{
int ret;

ret = cpu_sparc_handle_mmu_fault(env, addr, is_write, mmu_idx);
if (ret) {
cpu_restore_state2(env, retaddr);
cpu_loop_exit(env);
}
}
#endif
Loading

0 comments on commit 0184e26

Please sign in to comment.