* [Qemu-devel] [PATCH 0/2] powerpc: Improve BookE emulation (v2)
@ 2010-09-20 17:30 Edgar E. Iglesias
2010-09-20 17:30 ` [Qemu-devel] [PATCH 1/2] powerpc: Improve emulation of the BookE MMU Edgar E. Iglesias
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Edgar E. Iglesias @ 2010-09-20 17:30 UTC (permalink / raw)
To: qemu-devel; +Cc: Edgar E. Iglesias, agraf
Improve BookE emulation in preparation for virtex 5 support.
Once this is OK, the Xilinx specific parts will follow.
Cheers,
Edgar
v2:
* Fix MMU emulation details and other comments from A. Graf.
Edgar E. Iglesias (2):
powerpc: Improve emulation of the BookE MMU
powerpc: Make the decr interrupt type overridable
hw/ppc.c | 16 +++++++++++++---
hw/ppc.h | 4 +++-
hw/ppc4xx_devs.c | 2 +-
target-ppc/cpu.h | 3 +++
target-ppc/helper.c | 38 ++++++++++++++++++++++++++++++--------
5 files changed, 50 insertions(+), 13 deletions(-)
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Qemu-devel] [PATCH 1/2] powerpc: Improve emulation of the BookE MMU
2010-09-20 17:30 [Qemu-devel] [PATCH 0/2] powerpc: Improve BookE emulation (v2) Edgar E. Iglesias
@ 2010-09-20 17:30 ` Edgar E. Iglesias
2010-09-20 17:30 ` [Qemu-devel] [PATCH 2/2] powerpc: Make the decr interrupt type overridable Edgar E. Iglesias
2010-09-24 20:22 ` [Qemu-devel] Re: [PATCH 0/2] powerpc: Improve BookE emulation (v2) Edgar E. Iglesias
2 siblings, 0 replies; 4+ messages in thread
From: Edgar E. Iglesias @ 2010-09-20 17:30 UTC (permalink / raw)
To: qemu-devel; +Cc: Edgar E. Iglesias, agraf
Improve the emulation of the BookE MMU to be able to boot linux
on virtex5 boards.
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
---
target-ppc/cpu.h | 3 +++
target-ppc/helper.c | 38 ++++++++++++++++++++++++++++++--------
2 files changed, 33 insertions(+), 8 deletions(-)
diff --git a/target-ppc/cpu.h b/target-ppc/cpu.h
index 9c8d774..dc1f4b8 100644
--- a/target-ppc/cpu.h
+++ b/target-ppc/cpu.h
@@ -453,6 +453,9 @@ struct ppc_slb_t {
#endif
#endif
+/* Exception state register bits definition */
+#define ESR_ST 23 /* Exception was caused by a store type access. */
+
enum {
POWERPC_FLAG_NONE = 0x00000000,
/* Flag for MSR bit 25 signification (VRE/SPE) */
diff --git a/target-ppc/helper.c b/target-ppc/helper.c
index f865d7a..3bc8a34 100644
--- a/target-ppc/helper.c
+++ b/target-ppc/helper.c
@@ -1325,8 +1325,15 @@ int get_physical_address (CPUState *env, mmu_ctx_t *ctx, target_ulong eaddr,
#endif
if ((access_type == ACCESS_CODE && msr_ir == 0) ||
(access_type != ACCESS_CODE && msr_dr == 0)) {
- /* No address translation */
- ret = check_physical(env, ctx, eaddr, rw);
+ if (env->mmu_model == POWERPC_MMU_BOOKE) {
+ /* The BookE MMU always performs address translation. The
+ IS and DS bits only affect the address space. */
+ ret = mmubooke_get_physical_address(env, ctx, eaddr,
+ rw, access_type);
+ } else {
+ /* No address translation. */
+ ret = check_physical(env, ctx, eaddr, rw);
+ }
} else {
ret = -1;
switch (env->mmu_model) {
@@ -1444,8 +1451,9 @@ int cpu_ppc_handle_mmu_fault (CPUState *env, target_ulong address, int rw,
env->error_code = 0x40000000;
break;
case POWERPC_MMU_BOOKE:
- /* XXX: TODO */
- cpu_abort(env, "BookE MMU model is not implemented\n");
+ env->exception_index = POWERPC_EXCP_ITLB;
+ env->error_code = 0;
+ env->spr[SPR_BOOKE_DEAR] = address;
return -1;
case POWERPC_MMU_BOOKE_FSL:
/* XXX: TODO */
@@ -1471,6 +1479,9 @@ int cpu_ppc_handle_mmu_fault (CPUState *env, target_ulong address, int rw,
break;
case -3:
/* No execute protection violation */
+ if (env->mmu_model == POWERPC_MMU_BOOKE) {
+ env->spr[SPR_BOOKE_ESR] = 0x00000000;
+ }
env->exception_index = POWERPC_EXCP_ISI;
env->error_code = 0x10000000;
break;
@@ -1556,8 +1567,10 @@ int cpu_ppc_handle_mmu_fault (CPUState *env, target_ulong address, int rw,
cpu_abort(env, "MPC8xx MMU model is not implemented\n");
break;
case POWERPC_MMU_BOOKE:
- /* XXX: TODO */
- cpu_abort(env, "BookE MMU model is not implemented\n");
+ env->exception_index = POWERPC_EXCP_DTLB;
+ env->error_code = 0;
+ env->spr[SPR_BOOKE_DEAR] = address;
+ env->spr[SPR_BOOKE_ESR] = rw ? 1 << ESR_ST : 0;
return -1;
case POWERPC_MMU_BOOKE_FSL:
/* XXX: TODO */
@@ -1582,6 +1595,9 @@ int cpu_ppc_handle_mmu_fault (CPUState *env, target_ulong address, int rw,
if (rw) {
env->spr[SPR_40x_ESR] |= 0x00800000;
}
+ } else if (env->mmu_model == POWERPC_MMU_BOOKE) {
+ env->spr[SPR_BOOKE_DEAR] = address;
+ env->spr[SPR_BOOKE_ESR] = rw ? 1 << ESR_ST : 0;
} else {
env->spr[SPR_DAR] = address;
if (rw == 1) {
@@ -1848,8 +1864,7 @@ void ppc_tlb_invalidate_all (CPUPPCState *env)
cpu_abort(env, "MPC8xx MMU model is not implemented\n");
break;
case POWERPC_MMU_BOOKE:
- /* XXX: TODO */
- cpu_abort(env, "BookE MMU model is not implemented\n");
+ tlb_flush(env, 1);
break;
case POWERPC_MMU_BOOKE_FSL:
/* XXX: TODO */
@@ -2607,6 +2622,13 @@ static inline void powerpc_excp(CPUState *env, int excp_model, int excp)
/* Reset exception state */
env->exception_index = POWERPC_EXCP_NONE;
env->error_code = 0;
+
+ if (env->mmu_model == POWERPC_MMU_BOOKE) {
+ /* XXX: The BookE changes address space when switching modes,
+ we should probably implement that as different MMU indexes,
+ but for the moment we do it the slow way and flush all. */
+ tlb_flush(env, 1);
+ }
}
void do_interrupt (CPUState *env)
--
1.7.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [Qemu-devel] [PATCH 2/2] powerpc: Make the decr interrupt type overridable
2010-09-20 17:30 [Qemu-devel] [PATCH 0/2] powerpc: Improve BookE emulation (v2) Edgar E. Iglesias
2010-09-20 17:30 ` [Qemu-devel] [PATCH 1/2] powerpc: Improve emulation of the BookE MMU Edgar E. Iglesias
@ 2010-09-20 17:30 ` Edgar E. Iglesias
2010-09-24 20:22 ` [Qemu-devel] Re: [PATCH 0/2] powerpc: Improve BookE emulation (v2) Edgar E. Iglesias
2 siblings, 0 replies; 4+ messages in thread
From: Edgar E. Iglesias @ 2010-09-20 17:30 UTC (permalink / raw)
To: qemu-devel; +Cc: Edgar E. Iglesias, agraf
Make it possible for boards to override the kind of interrupt
to be signaled when the decr timer hits. The 405's signal PIT
interrupts while the 440's signal DECR.
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
---
hw/ppc.c | 16 +++++++++++++---
hw/ppc.h | 4 +++-
hw/ppc4xx_devs.c | 2 +-
3 files changed, 17 insertions(+), 5 deletions(-)
diff --git a/hw/ppc.c b/hw/ppc.c
index 55e3808..968aec1 100644
--- a/hw/ppc.c
+++ b/hw/ppc.c
@@ -769,6 +769,9 @@ struct ppcemb_timer_t {
struct QEMUTimer *fit_timer;
uint64_t wdt_next; /* Tick for next WDT interrupt */
struct QEMUTimer *wdt_timer;
+
+ /* 405 have the PIT, 440 have a DECR. */
+ unsigned int decr_excp;
};
/* Fixed interval timer */
@@ -851,7 +854,7 @@ static void cpu_4xx_pit_cb (void *opaque)
ppcemb_timer = tb_env->opaque;
env->spr[SPR_40x_TSR] |= 1 << 27;
if ((env->spr[SPR_40x_TCR] >> 26) & 0x1)
- ppc_set_irq(env, PPC_INTERRUPT_PIT, 1);
+ ppc_set_irq(env, ppcemb_timer->decr_excp, 1);
start_stop_pit(env, tb_env, 1);
LOG_TB("%s: ar %d ir %d TCR " TARGET_FMT_lx " TSR " TARGET_FMT_lx " "
"%016" PRIx64 "\n", __func__,
@@ -948,10 +951,15 @@ target_ulong load_40x_pit (CPUState *env)
void store_booke_tsr (CPUState *env, target_ulong val)
{
+ ppc_tb_t *tb_env = env->tb_env;
+ ppcemb_timer_t *ppcemb_timer;
+
+ ppcemb_timer = tb_env->opaque;
+
LOG_TB("%s: val " TARGET_FMT_lx "\n", __func__, val);
env->spr[SPR_40x_TSR] &= ~(val & 0xFC000000);
if (val & 0x80000000)
- ppc_set_irq(env, PPC_INTERRUPT_PIT, 0);
+ ppc_set_irq(env, ppcemb_timer->decr_excp, 0);
}
void store_booke_tcr (CPUState *env, target_ulong val)
@@ -977,7 +985,8 @@ static void ppc_emb_set_tb_clk (void *opaque, uint32_t freq)
/* XXX: we should also update all timers */
}
-clk_setup_cb ppc_emb_timers_init (CPUState *env, uint32_t freq)
+clk_setup_cb ppc_emb_timers_init (CPUState *env, uint32_t freq,
+ unsigned int decr_excp)
{
ppc_tb_t *tb_env;
ppcemb_timer_t *ppcemb_timer;
@@ -996,6 +1005,7 @@ clk_setup_cb ppc_emb_timers_init (CPUState *env, uint32_t freq)
qemu_new_timer(vm_clock, &cpu_4xx_fit_cb, env);
ppcemb_timer->wdt_timer =
qemu_new_timer(vm_clock, &cpu_4xx_wdt_cb, env);
+ ppcemb_timer->decr_excp = decr_excp;
}
return &ppc_emb_set_tb_clk;
diff --git a/hw/ppc.h b/hw/ppc.h
index 1251932..34f54cf 100644
--- a/hw/ppc.h
+++ b/hw/ppc.h
@@ -19,7 +19,9 @@ int ppc_dcr_init (CPUState *env, int (*dcr_read_error)(int dcrn),
int (*dcr_write_error)(int dcrn));
int ppc_dcr_register (CPUState *env, int dcrn, void *opaque,
dcr_read_cb drc_read, dcr_write_cb dcr_write);
-clk_setup_cb ppc_emb_timers_init (CPUState *env, uint32_t freq);
+clk_setup_cb ppc_emb_timers_init (CPUState *env, uint32_t freq,
+ unsigned int decr_excp);
+
/* Embedded PowerPC reset */
void ppc40x_core_reset (CPUState *env);
void ppc40x_chip_reset (CPUState *env);
diff --git a/hw/ppc4xx_devs.c b/hw/ppc4xx_devs.c
index 7f698b8..5f581fe 100644
--- a/hw/ppc4xx_devs.c
+++ b/hw/ppc4xx_devs.c
@@ -56,7 +56,7 @@ CPUState *ppc4xx_init (const char *cpu_model,
cpu_clk->cb = NULL; /* We don't care about CPU clock frequency changes */
cpu_clk->opaque = env;
/* Set time-base frequency to sysclk */
- tb_clk->cb = ppc_emb_timers_init(env, sysclk);
+ tb_clk->cb = ppc_emb_timers_init(env, sysclk, PPC_INTERRUPT_PIT);
tb_clk->opaque = env;
ppc_dcr_init(env, NULL, NULL);
/* Register qemu callbacks */
--
1.7.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [Qemu-devel] Re: [PATCH 0/2] powerpc: Improve BookE emulation (v2)
2010-09-20 17:30 [Qemu-devel] [PATCH 0/2] powerpc: Improve BookE emulation (v2) Edgar E. Iglesias
2010-09-20 17:30 ` [Qemu-devel] [PATCH 1/2] powerpc: Improve emulation of the BookE MMU Edgar E. Iglesias
2010-09-20 17:30 ` [Qemu-devel] [PATCH 2/2] powerpc: Make the decr interrupt type overridable Edgar E. Iglesias
@ 2010-09-24 20:22 ` Edgar E. Iglesias
2 siblings, 0 replies; 4+ messages in thread
From: Edgar E. Iglesias @ 2010-09-24 20:22 UTC (permalink / raw)
To: qemu-devel; +Cc: agraf
On Mon, Sep 20, 2010 at 07:30:38PM +0200, Edgar E. Iglesias wrote:
> Improve BookE emulation in preparation for virtex 5 support.
> Once this is OK, the Xilinx specific parts will follow.
>
> Cheers,
> Edgar
Pushed.
> v2:
> * Fix MMU emulation details and other comments from A. Graf.
>
> Edgar E. Iglesias (2):
> powerpc: Improve emulation of the BookE MMU
> powerpc: Make the decr interrupt type overridable
>
> hw/ppc.c | 16 +++++++++++++---
> hw/ppc.h | 4 +++-
> hw/ppc4xx_devs.c | 2 +-
> target-ppc/cpu.h | 3 +++
> target-ppc/helper.c | 38 ++++++++++++++++++++++++++++++--------
> 5 files changed, 50 insertions(+), 13 deletions(-)
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2010-09-24 20:22 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-09-20 17:30 [Qemu-devel] [PATCH 0/2] powerpc: Improve BookE emulation (v2) Edgar E. Iglesias
2010-09-20 17:30 ` [Qemu-devel] [PATCH 1/2] powerpc: Improve emulation of the BookE MMU Edgar E. Iglesias
2010-09-20 17:30 ` [Qemu-devel] [PATCH 2/2] powerpc: Make the decr interrupt type overridable Edgar E. Iglesias
2010-09-24 20:22 ` [Qemu-devel] Re: [PATCH 0/2] powerpc: Improve BookE emulation (v2) Edgar E. Iglesias
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).