mirror of https://github.com/xqemu/xqemu.git
Implement the PowerPC alternate time-base, following the 2.04 specification.
Share most code with the time-base management routines. Remove time-base write routines from user-mode emulation environments. git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3277 c046a42c-6fe2-441c-8c8c-71466251a162
This commit is contained in:
parent
4887d78b01
commit
a062e36c58
|
@ -124,24 +124,14 @@ uint32_t cpu_ppc_load_tbu (CPUState *env)
|
||||||
return cpu_ppc_get_tb(env) >> 32;
|
return cpu_ppc_get_tb(env) >> 32;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cpu_ppc_store_tb (CPUState *env, uint64_t value)
|
uint32_t cpu_ppc_load_atbl (CPUState *env)
|
||||||
{
|
{
|
||||||
/* TO FIX */
|
return cpu_ppc_get_tb(env) & 0xFFFFFFFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cpu_ppc_store_tbu (CPUState *env, uint32_t value)
|
uint32_t cpu_ppc_load_atbu (CPUState *env)
|
||||||
{
|
{
|
||||||
cpu_ppc_store_tb(env, ((uint64_t)value << 32) | cpu_ppc_load_tbl(env));
|
return cpu_ppc_get_tb(env) >> 32;
|
||||||
}
|
|
||||||
|
|
||||||
void cpu_ppc_store_tbl (CPUState *env, uint32_t value)
|
|
||||||
{
|
|
||||||
cpu_ppc_store_tb(env, ((uint64_t)cpu_ppc_load_tbl(env) << 32) | value);
|
|
||||||
}
|
|
||||||
|
|
||||||
void cpu_ppc601_store_rtcu (CPUState *env, uint32_t value)
|
|
||||||
{
|
|
||||||
cpu_ppc_store_tbu( env, value );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t cpu_ppc601_load_rtcu (CPUState *env)
|
uint32_t cpu_ppc601_load_rtcu (CPUState *env)
|
||||||
|
|
105
hw/ppc.c
105
hw/ppc.c
|
@ -408,6 +408,7 @@ void ppc405_irq_init (CPUState *env)
|
||||||
struct ppc_tb_t {
|
struct ppc_tb_t {
|
||||||
/* Time base management */
|
/* Time base management */
|
||||||
int64_t tb_offset; /* Compensation */
|
int64_t tb_offset; /* Compensation */
|
||||||
|
int64_t atb_offset; /* Compensation */
|
||||||
uint32_t tb_freq; /* TB frequency */
|
uint32_t tb_freq; /* TB frequency */
|
||||||
/* Decrementer management */
|
/* Decrementer management */
|
||||||
uint64_t decr_next; /* Tick for next decr interrupt */
|
uint64_t decr_next; /* Tick for next decr interrupt */
|
||||||
|
@ -422,7 +423,7 @@ struct ppc_tb_t {
|
||||||
void *opaque;
|
void *opaque;
|
||||||
};
|
};
|
||||||
|
|
||||||
static inline uint64_t cpu_ppc_get_tb (ppc_tb_t *tb_env)
|
static inline uint64_t cpu_ppc_get_tb (ppc_tb_t *tb_env, int64_t tb_offset)
|
||||||
{
|
{
|
||||||
/* TB time in tb periods */
|
/* TB time in tb periods */
|
||||||
return muldiv64(qemu_get_clock(vm_clock) + tb_env->tb_offset,
|
return muldiv64(qemu_get_clock(vm_clock) + tb_env->tb_offset,
|
||||||
|
@ -434,19 +435,10 @@ uint32_t cpu_ppc_load_tbl (CPUState *env)
|
||||||
ppc_tb_t *tb_env = env->tb_env;
|
ppc_tb_t *tb_env = env->tb_env;
|
||||||
uint64_t tb;
|
uint64_t tb;
|
||||||
|
|
||||||
tb = cpu_ppc_get_tb(tb_env);
|
tb = cpu_ppc_get_tb(tb_env, tb_env->tb_offset);
|
||||||
#ifdef PPC_DEBUG_TB
|
#if defined(PPC_DEBUG_TB)
|
||||||
{
|
if (loglevel != 0) {
|
||||||
static int last_time;
|
fprintf(logfile, "%s: tb=0x%016lx\n", __func__, tb);
|
||||||
int now;
|
|
||||||
now = time(NULL);
|
|
||||||
if (last_time != now) {
|
|
||||||
last_time = now;
|
|
||||||
if (loglevel != 0) {
|
|
||||||
fprintf(logfile, "%s: tb=0x%016lx %d %08lx\n",
|
|
||||||
__func__, tb, now, tb_env->tb_offset);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -458,7 +450,7 @@ uint32_t cpu_ppc_load_tbu (CPUState *env)
|
||||||
ppc_tb_t *tb_env = env->tb_env;
|
ppc_tb_t *tb_env = env->tb_env;
|
||||||
uint64_t tb;
|
uint64_t tb;
|
||||||
|
|
||||||
tb = cpu_ppc_get_tb(tb_env);
|
tb = cpu_ppc_get_tb(tb_env, tb_env->tb_offset);
|
||||||
#if defined(PPC_DEBUG_TB)
|
#if defined(PPC_DEBUG_TB)
|
||||||
if (loglevel != 0) {
|
if (loglevel != 0) {
|
||||||
fprintf(logfile, "%s: tb=0x%016lx\n", __func__, tb);
|
fprintf(logfile, "%s: tb=0x%016lx\n", __func__, tb);
|
||||||
|
@ -468,32 +460,89 @@ uint32_t cpu_ppc_load_tbu (CPUState *env)
|
||||||
return tb >> 32;
|
return tb >> 32;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cpu_ppc_store_tb (ppc_tb_t *tb_env, uint64_t value)
|
static inline void cpu_ppc_store_tb (ppc_tb_t *tb_env, int64_t *tb_offsetp,
|
||||||
|
uint64_t value)
|
||||||
{
|
{
|
||||||
tb_env->tb_offset = muldiv64(value, ticks_per_sec, tb_env->tb_freq)
|
*tb_offsetp = muldiv64(value, ticks_per_sec, tb_env->tb_freq)
|
||||||
- qemu_get_clock(vm_clock);
|
- qemu_get_clock(vm_clock);
|
||||||
#ifdef PPC_DEBUG_TB
|
#ifdef PPC_DEBUG_TB
|
||||||
if (loglevel != 0) {
|
if (loglevel != 0) {
|
||||||
fprintf(logfile, "%s: tb=0x%016lx offset=%08lx\n", __func__, value,
|
fprintf(logfile, "%s: tb=0x%016lx offset=%08lx\n", __func__, value,
|
||||||
tb_env->tb_offset);
|
*tb_offsetp);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void cpu_ppc_store_tbu (CPUState *env, uint32_t value)
|
|
||||||
{
|
|
||||||
ppc_tb_t *tb_env = env->tb_env;
|
|
||||||
|
|
||||||
cpu_ppc_store_tb(tb_env,
|
|
||||||
((uint64_t)value << 32) | cpu_ppc_load_tbl(env));
|
|
||||||
}
|
|
||||||
|
|
||||||
void cpu_ppc_store_tbl (CPUState *env, uint32_t value)
|
void cpu_ppc_store_tbl (CPUState *env, uint32_t value)
|
||||||
{
|
{
|
||||||
ppc_tb_t *tb_env = env->tb_env;
|
ppc_tb_t *tb_env = env->tb_env;
|
||||||
|
uint64_t tb;
|
||||||
|
|
||||||
cpu_ppc_store_tb(tb_env,
|
tb = cpu_ppc_get_tb(tb_env, tb_env->tb_offset);
|
||||||
((uint64_t)cpu_ppc_load_tbu(env) << 32) | value);
|
tb &= 0xFFFFFFFF00000000ULL;
|
||||||
|
cpu_ppc_store_tb(tb_env, &tb_env->tb_offset, tb | (uint64_t)value);
|
||||||
|
}
|
||||||
|
|
||||||
|
void cpu_ppc_store_tbu (CPUState *env, uint32_t value)
|
||||||
|
{
|
||||||
|
ppc_tb_t *tb_env = env->tb_env;
|
||||||
|
uint64_t tb;
|
||||||
|
|
||||||
|
tb = cpu_ppc_get_tb(tb_env, tb_env->tb_offset);
|
||||||
|
tb &= 0x00000000FFFFFFFFULL;
|
||||||
|
cpu_ppc_store_tb(tb_env, &tb_env->tb_offset,
|
||||||
|
((uint64_t)value << 32) | tb);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t cpu_ppc_load_atbl (CPUState *env)
|
||||||
|
{
|
||||||
|
ppc_tb_t *tb_env = env->tb_env;
|
||||||
|
uint64_t tb;
|
||||||
|
|
||||||
|
tb = cpu_ppc_get_tb(tb_env, tb_env->atb_offset);
|
||||||
|
#if defined(PPC_DEBUG_TB)
|
||||||
|
if (loglevel != 0) {
|
||||||
|
fprintf(logfile, "%s: tb=0x%016lx\n", __func__, tb);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return tb & 0xFFFFFFFF;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t cpu_ppc_load_atbu (CPUState *env)
|
||||||
|
{
|
||||||
|
ppc_tb_t *tb_env = env->tb_env;
|
||||||
|
uint64_t tb;
|
||||||
|
|
||||||
|
tb = cpu_ppc_get_tb(tb_env, tb_env->atb_offset);
|
||||||
|
#if defined(PPC_DEBUG_TB)
|
||||||
|
if (loglevel != 0) {
|
||||||
|
fprintf(logfile, "%s: tb=0x%016lx\n", __func__, tb);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return tb >> 32;
|
||||||
|
}
|
||||||
|
|
||||||
|
void cpu_ppc_store_atbl (CPUState *env, uint32_t value)
|
||||||
|
{
|
||||||
|
ppc_tb_t *tb_env = env->tb_env;
|
||||||
|
uint64_t tb;
|
||||||
|
|
||||||
|
tb = cpu_ppc_get_tb(tb_env, tb_env->atb_offset);
|
||||||
|
tb &= 0xFFFFFFFF00000000ULL;
|
||||||
|
cpu_ppc_store_tb(tb_env, &tb_env->atb_offset, tb | (uint64_t)value);
|
||||||
|
}
|
||||||
|
|
||||||
|
void cpu_ppc_store_atbu (CPUState *env, uint32_t value)
|
||||||
|
{
|
||||||
|
ppc_tb_t *tb_env = env->tb_env;
|
||||||
|
uint64_t tb;
|
||||||
|
|
||||||
|
tb = cpu_ppc_get_tb(tb_env, tb_env->atb_offset);
|
||||||
|
tb &= 0x00000000FFFFFFFFULL;
|
||||||
|
cpu_ppc_store_tb(tb_env, &tb_env->atb_offset,
|
||||||
|
((uint64_t)value << 32) | tb);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline uint32_t _cpu_ppc_load_decr (CPUState *env, uint64_t *next)
|
static inline uint32_t _cpu_ppc_load_decr (CPUState *env, uint64_t *next)
|
||||||
|
|
|
@ -664,7 +664,6 @@ void cpu_loop (CPUSPARCState *env)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef TARGET_PPC
|
#ifdef TARGET_PPC
|
||||||
|
|
||||||
static inline uint64_t cpu_ppc_get_tb (CPUState *env)
|
static inline uint64_t cpu_ppc_get_tb (CPUState *env)
|
||||||
{
|
{
|
||||||
/* TO FIX */
|
/* TO FIX */
|
||||||
|
@ -681,32 +680,19 @@ uint32_t cpu_ppc_load_tbu (CPUState *env)
|
||||||
return cpu_ppc_get_tb(env) >> 32;
|
return cpu_ppc_get_tb(env) >> 32;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cpu_ppc_store_tb (CPUState *env, uint64_t value)
|
uint32_t cpu_ppc_load_atbl (CPUState *env)
|
||||||
{
|
{
|
||||||
/* TO FIX */
|
return cpu_ppc_get_tb(env) & 0xFFFFFFFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cpu_ppc_store_tbu (CPUState *env, uint32_t value)
|
uint32_t cpu_ppc_load_atbu (CPUState *env)
|
||||||
{
|
{
|
||||||
cpu_ppc_store_tb(env, ((uint64_t)value << 32) | cpu_ppc_load_tbl(env));
|
return cpu_ppc_get_tb(env) >> 32;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cpu_ppc_store_tbl (CPUState *env, uint32_t value)
|
|
||||||
{
|
|
||||||
cpu_ppc_store_tb(env, ((uint64_t)cpu_ppc_load_tbl(env) << 32) | value);
|
|
||||||
}
|
|
||||||
|
|
||||||
void cpu_ppc601_store_rtcu (CPUState *env, uint32_t value)
|
|
||||||
__attribute__ (( alias ("cpu_ppc_store_tbu") ));
|
|
||||||
|
|
||||||
uint32_t cpu_ppc601_load_rtcu (CPUState *env)
|
uint32_t cpu_ppc601_load_rtcu (CPUState *env)
|
||||||
__attribute__ (( alias ("cpu_ppc_load_tbu") ));
|
__attribute__ (( alias ("cpu_ppc_load_tbu") ));
|
||||||
|
|
||||||
void cpu_ppc601_store_rtcl (CPUState *env, uint32_t value)
|
|
||||||
{
|
|
||||||
cpu_ppc_store_tbl(env, value & 0x3FFFFF80);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t cpu_ppc601_load_rtcl (CPUState *env)
|
uint32_t cpu_ppc601_load_rtcl (CPUState *env)
|
||||||
{
|
{
|
||||||
return cpu_ppc_load_tbl(env) & 0x3FFFFF80;
|
return cpu_ppc_load_tbl(env) & 0x3FFFFF80;
|
||||||
|
|
|
@ -625,6 +625,10 @@ uint32_t cpu_ppc_load_tbl (CPUPPCState *env);
|
||||||
uint32_t cpu_ppc_load_tbu (CPUPPCState *env);
|
uint32_t cpu_ppc_load_tbu (CPUPPCState *env);
|
||||||
void cpu_ppc_store_tbu (CPUPPCState *env, uint32_t value);
|
void cpu_ppc_store_tbu (CPUPPCState *env, uint32_t value);
|
||||||
void cpu_ppc_store_tbl (CPUPPCState *env, uint32_t value);
|
void cpu_ppc_store_tbl (CPUPPCState *env, uint32_t value);
|
||||||
|
uint32_t cpu_ppc_load_atbl (CPUPPCState *env);
|
||||||
|
uint32_t cpu_ppc_load_atbu (CPUPPCState *env);
|
||||||
|
void cpu_ppc_store_atbl (CPUPPCState *env, uint32_t value);
|
||||||
|
void cpu_ppc_store_atbu (CPUPPCState *env, uint32_t value);
|
||||||
uint32_t cpu_ppc_load_decr (CPUPPCState *env);
|
uint32_t cpu_ppc_load_decr (CPUPPCState *env);
|
||||||
void cpu_ppc_store_decr (CPUPPCState *env, uint32_t value);
|
void cpu_ppc_store_decr (CPUPPCState *env, uint32_t value);
|
||||||
#if defined(TARGET_PPC64H)
|
#if defined(TARGET_PPC64H)
|
||||||
|
@ -798,8 +802,8 @@ int ppc_dcr_write (ppc_dcr_t *dcr_env, int dcrn, target_ulong val);
|
||||||
#define SPR_BOOKE_SPEFSCR (0x200)
|
#define SPR_BOOKE_SPEFSCR (0x200)
|
||||||
#define SPR_E500_BBEAR (0x201)
|
#define SPR_E500_BBEAR (0x201)
|
||||||
#define SPR_E500_BBTAR (0x202)
|
#define SPR_E500_BBTAR (0x202)
|
||||||
#define SPR_BOOKE_ATBL (0x20E)
|
#define SPR_ATBL (0x20E)
|
||||||
#define SPR_BOOKE_ATBU (0x20F)
|
#define SPR_ATBU (0x20F)
|
||||||
#define SPR_IBAT0U (0x210)
|
#define SPR_IBAT0U (0x210)
|
||||||
#define SPR_BOOKE_IVOR32 (0x210)
|
#define SPR_BOOKE_IVOR32 (0x210)
|
||||||
#define SPR_IBAT0L (0x211)
|
#define SPR_IBAT0L (0x211)
|
||||||
|
|
|
@ -423,6 +423,18 @@ void OPPROTO op_load_tbu (void)
|
||||||
RETURN();
|
RETURN();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OPPROTO op_load_atbl (void)
|
||||||
|
{
|
||||||
|
T0 = cpu_ppc_load_atbl(env);
|
||||||
|
RETURN();
|
||||||
|
}
|
||||||
|
|
||||||
|
void OPPROTO op_load_atbu (void)
|
||||||
|
{
|
||||||
|
T0 = cpu_ppc_load_atbu(env);
|
||||||
|
RETURN();
|
||||||
|
}
|
||||||
|
|
||||||
#if !defined(CONFIG_USER_ONLY)
|
#if !defined(CONFIG_USER_ONLY)
|
||||||
void OPPROTO op_store_tbl (void)
|
void OPPROTO op_store_tbl (void)
|
||||||
{
|
{
|
||||||
|
@ -436,6 +448,18 @@ void OPPROTO op_store_tbu (void)
|
||||||
RETURN();
|
RETURN();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OPPROTO op_store_atbl (void)
|
||||||
|
{
|
||||||
|
cpu_ppc_store_atbl(env, T0);
|
||||||
|
RETURN();
|
||||||
|
}
|
||||||
|
|
||||||
|
void OPPROTO op_store_atbu (void)
|
||||||
|
{
|
||||||
|
cpu_ppc_store_atbu(env, T0);
|
||||||
|
RETURN();
|
||||||
|
}
|
||||||
|
|
||||||
void OPPROTO op_load_decr (void)
|
void OPPROTO op_load_decr (void)
|
||||||
{
|
{
|
||||||
T0 = cpu_ppc_load_decr(env);
|
T0 = cpu_ppc_load_decr(env);
|
||||||
|
|
|
@ -162,6 +162,18 @@ static void spr_read_tbu (void *opaque, int sprn)
|
||||||
gen_op_load_tbu();
|
gen_op_load_tbu();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
__attribute__ (( unused ))
|
||||||
|
static void spr_read_atbl (void *opaque, int sprn)
|
||||||
|
{
|
||||||
|
gen_op_load_atbl();
|
||||||
|
}
|
||||||
|
|
||||||
|
__attribute__ (( unused ))
|
||||||
|
static void spr_read_atbu (void *opaque, int sprn)
|
||||||
|
{
|
||||||
|
gen_op_load_atbu();
|
||||||
|
}
|
||||||
|
|
||||||
#if !defined(CONFIG_USER_ONLY)
|
#if !defined(CONFIG_USER_ONLY)
|
||||||
static void spr_write_tbl (void *opaque, int sprn)
|
static void spr_write_tbl (void *opaque, int sprn)
|
||||||
{
|
{
|
||||||
|
@ -172,6 +184,18 @@ static void spr_write_tbu (void *opaque, int sprn)
|
||||||
{
|
{
|
||||||
gen_op_store_tbu();
|
gen_op_store_tbu();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
__attribute__ (( unused ))
|
||||||
|
static void spr_write_atbl (void *opaque, int sprn)
|
||||||
|
{
|
||||||
|
gen_op_store_atbl();
|
||||||
|
}
|
||||||
|
|
||||||
|
__attribute__ (( unused ))
|
||||||
|
static void spr_write_atbu (void *opaque, int sprn)
|
||||||
|
{
|
||||||
|
gen_op_store_atbu();
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined(CONFIG_USER_ONLY)
|
#if !defined(CONFIG_USER_ONLY)
|
||||||
|
|
Loading…
Reference in New Issue