qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 00/10] MicroBlaze queue
@ 2013-10-24 21:08 edgar.iglesias
  2013-10-24 21:08 ` [Qemu-devel] [PATCH 01/10] microblaze: Clarify expected input of write_carry edgar.iglesias
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: edgar.iglesias @ 2013-10-24 21:08 UTC (permalink / raw)
  To: qemu-devel

From: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>

Hi,

These are various MicroBlaze patches sitting in my queue.
A few optimizations, sysemu initrd boot loading support and improvement to
the exclusive load/store for system emulation.

Cheers,
Edgar

Edgar E. Iglesias (10):
  microblaze: Clarify expected input of write_carry
  microblaze: Make write_carryi input a boolean
  microblaze: Simplify andn by using tcg_gen_andc
  microblaze: Improve srl
  microblaze: Improve src
  microblaze: Move the saving of the reservation addr into gen_load
  microblaze: Turn res_addr into a tcg global
  microblaze: At swx, check that the reserved word is unmodified
  hw/microblaze: Indentation cleanups
  hw/microblaze: Add support for loading initrd images

 hw/microblaze/boot.c                     |   50 +++++++++++++++++---
 hw/microblaze/boot.h                     |    4 +-
 hw/microblaze/petalogix_ml605_mmu.c      |    6 ++-
 hw/microblaze/petalogix_s3adsp1800_mmu.c |    4 +-
 target-microblaze/cpu.h                  |    1 +
 target-microblaze/translate.c            |   75 +++++++++++++++++-------------
 6 files changed, 98 insertions(+), 42 deletions(-)

-- 
1.7.10.4

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Qemu-devel] [PATCH 01/10] microblaze: Clarify expected input of write_carry
  2013-10-24 21:08 [Qemu-devel] [PATCH 00/10] MicroBlaze queue edgar.iglesias
@ 2013-10-24 21:08 ` edgar.iglesias
  2013-10-24 21:08 ` [Qemu-devel] [PATCH 02/10] microblaze: Make write_carryi input a boolean edgar.iglesias
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: edgar.iglesias @ 2013-10-24 21:08 UTC (permalink / raw)
  To: qemu-devel

From: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>

Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
---
 target-microblaze/translate.c |    4 ++++
 1 file changed, 4 insertions(+)

diff --git a/target-microblaze/translate.c b/target-microblaze/translate.c
index 1b937b3..76b2570 100644
--- a/target-microblaze/translate.c
+++ b/target-microblaze/translate.c
@@ -150,6 +150,10 @@ static void read_carry(DisasContext *dc, TCGv d)
     tcg_gen_shri_tl(d, cpu_SR[SR_MSR], 31);
 }
 
+/*
+ * write_carry sets the carry bits in MSR based on bit 0 of v.
+ * v[31:1] are ignored.
+ */
 static void write_carry(DisasContext *dc, TCGv v)
 {
     TCGv t0 = tcg_temp_new();
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [Qemu-devel] [PATCH 02/10] microblaze: Make write_carryi input a boolean
  2013-10-24 21:08 [Qemu-devel] [PATCH 00/10] MicroBlaze queue edgar.iglesias
  2013-10-24 21:08 ` [Qemu-devel] [PATCH 01/10] microblaze: Clarify expected input of write_carry edgar.iglesias
@ 2013-10-24 21:08 ` edgar.iglesias
  2013-10-24 21:08 ` [Qemu-devel] [PATCH 03/10] microblaze: Simplify andn by using tcg_gen_andc edgar.iglesias
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: edgar.iglesias @ 2013-10-24 21:08 UTC (permalink / raw)
  To: qemu-devel

From: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>

Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
---
 target-microblaze/translate.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/target-microblaze/translate.c b/target-microblaze/translate.c
index 76b2570..d183e17 100644
--- a/target-microblaze/translate.c
+++ b/target-microblaze/translate.c
@@ -166,10 +166,10 @@ static void write_carry(DisasContext *dc, TCGv v)
     tcg_temp_free(t0);
 }
 
-static void write_carryi(DisasContext *dc, int carry)
+static void write_carryi(DisasContext *dc, bool carry)
 {
     TCGv t0 = tcg_temp_new();
-    tcg_gen_movi_tl(t0, carry ? 1 : 0);
+    tcg_gen_movi_tl(t0, carry);
     write_carry(dc, t0);
     tcg_temp_free(t0);
 }
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [Qemu-devel] [PATCH 03/10] microblaze: Simplify andn by using tcg_gen_andc
  2013-10-24 21:08 [Qemu-devel] [PATCH 00/10] MicroBlaze queue edgar.iglesias
  2013-10-24 21:08 ` [Qemu-devel] [PATCH 01/10] microblaze: Clarify expected input of write_carry edgar.iglesias
  2013-10-24 21:08 ` [Qemu-devel] [PATCH 02/10] microblaze: Make write_carryi input a boolean edgar.iglesias
@ 2013-10-24 21:08 ` edgar.iglesias
  2013-10-24 21:08 ` [Qemu-devel] [PATCH 04/10] microblaze: Improve srl edgar.iglesias
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: edgar.iglesias @ 2013-10-24 21:08 UTC (permalink / raw)
  To: qemu-devel

From: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>

Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
---
 target-microblaze/translate.c |    5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/target-microblaze/translate.c b/target-microblaze/translate.c
index d183e17..916db15 100644
--- a/target-microblaze/translate.c
+++ b/target-microblaze/translate.c
@@ -390,10 +390,7 @@ static void dec_and(DisasContext *dc)
         return;
 
     if (not) {
-        TCGv t = tcg_temp_new();
-        tcg_gen_not_tl(t, *(dec_alu_op_b(dc)));
-        tcg_gen_and_tl(cpu_R[dc->rd], cpu_R[dc->ra], t);
-        tcg_temp_free(t);
+        tcg_gen_andc_tl(cpu_R[dc->rd], cpu_R[dc->ra], *(dec_alu_op_b(dc)));
     } else
         tcg_gen_and_tl(cpu_R[dc->rd], cpu_R[dc->ra], *(dec_alu_op_b(dc)));
 }
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [Qemu-devel] [PATCH 04/10] microblaze: Improve srl
  2013-10-24 21:08 [Qemu-devel] [PATCH 00/10] MicroBlaze queue edgar.iglesias
                   ` (2 preceding siblings ...)
  2013-10-24 21:08 ` [Qemu-devel] [PATCH 03/10] microblaze: Simplify andn by using tcg_gen_andc edgar.iglesias
@ 2013-10-24 21:08 ` edgar.iglesias
  2013-10-24 21:08 ` [Qemu-devel] [PATCH 05/10] microblaze: Improve src edgar.iglesias
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: edgar.iglesias @ 2013-10-24 21:08 UTC (permalink / raw)
  To: qemu-devel

From: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>

write_carry only looks at bit zero, no need to mask out the others.

Meassured a 12% speed improvement in linux-user srl loops.

Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
---
 target-microblaze/translate.c |    7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/target-microblaze/translate.c b/target-microblaze/translate.c
index 916db15..93aafac 100644
--- a/target-microblaze/translate.c
+++ b/target-microblaze/translate.c
@@ -780,13 +780,10 @@ static void dec_bit(DisasContext *dc)
         case 0x1:
         case 0x41:
             /* srl.  */
-            t0 = tcg_temp_new();
             LOG_DIS("srl r%d r%d\n", dc->rd, dc->ra);
 
-            /* Update carry.  */
-            tcg_gen_andi_tl(t0, cpu_R[dc->ra], 1);
-            write_carry(dc, t0);
-            tcg_temp_free(t0);
+            /* Update carry. Note that write carry only looks at the LSB.  */
+            write_carry(dc, cpu_R[dc->ra]);
             if (dc->rd) {
                 if (op == 0x41)
                     tcg_gen_shri_tl(cpu_R[dc->rd], cpu_R[dc->ra], 1);
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [Qemu-devel] [PATCH 05/10] microblaze: Improve src
  2013-10-24 21:08 [Qemu-devel] [PATCH 00/10] MicroBlaze queue edgar.iglesias
                   ` (3 preceding siblings ...)
  2013-10-24 21:08 ` [Qemu-devel] [PATCH 04/10] microblaze: Improve srl edgar.iglesias
@ 2013-10-24 21:08 ` edgar.iglesias
  2013-10-24 21:08 ` [Qemu-devel] [PATCH 06/10] microblaze: Move the saving of the reservation addr into gen_load edgar.iglesias
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: edgar.iglesias @ 2013-10-24 21:08 UTC (permalink / raw)
  To: qemu-devel

From: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>

Microblaze carry is mirrored in MSR[31], pick it directly from
there. Also, no need to mask cpu_R[dc->ra] when calling
write_carry.

15% improvement in linux-user src loops.

Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
---
 target-microblaze/translate.c |   15 ++++-----------
 1 file changed, 4 insertions(+), 11 deletions(-)

diff --git a/target-microblaze/translate.c b/target-microblaze/translate.c
index 93aafac..232015a 100644
--- a/target-microblaze/translate.c
+++ b/target-microblaze/translate.c
@@ -750,7 +750,7 @@ static void dec_barrel(DisasContext *dc)
 
 static void dec_bit(DisasContext *dc)
 {
-    TCGv t0, t1;
+    TCGv t0;
     unsigned int op;
     int mem_index = cpu_mmu_index(dc->env);
 
@@ -761,19 +761,12 @@ static void dec_bit(DisasContext *dc)
             t0 = tcg_temp_new();
 
             LOG_DIS("src r%d r%d\n", dc->rd, dc->ra);
-            tcg_gen_andi_tl(t0, cpu_R[dc->ra], 1);
+            tcg_gen_andi_tl(t0, cpu_SR[SR_MSR], MSR_CC);
+            write_carry(dc, cpu_R[dc->ra]);
             if (dc->rd) {
-                t1 = tcg_temp_new();
-                read_carry(dc, t1);
-                tcg_gen_shli_tl(t1, t1, 31);
-
                 tcg_gen_shri_tl(cpu_R[dc->rd], cpu_R[dc->ra], 1);
-                tcg_gen_or_tl(cpu_R[dc->rd], cpu_R[dc->rd], t1);
-                tcg_temp_free(t1);
+                tcg_gen_or_tl(cpu_R[dc->rd], cpu_R[dc->rd], t0);
             }
-
-            /* Update carry.  */
-            write_carry(dc, t0);
             tcg_temp_free(t0);
             break;
 
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [Qemu-devel] [PATCH 06/10] microblaze: Move the saving of the reservation addr into gen_load
  2013-10-24 21:08 [Qemu-devel] [PATCH 00/10] MicroBlaze queue edgar.iglesias
                   ` (4 preceding siblings ...)
  2013-10-24 21:08 ` [Qemu-devel] [PATCH 05/10] microblaze: Improve src edgar.iglesias
@ 2013-10-24 21:08 ` edgar.iglesias
  2013-10-24 21:08 ` [Qemu-devel] [PATCH 07/10] microblaze: Turn res_addr into a tcg global edgar.iglesias
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: edgar.iglesias @ 2013-10-24 21:08 UTC (permalink / raw)
  To: qemu-devel

From: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>

No functional change.

Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
---
 target-microblaze/translate.c |   13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/target-microblaze/translate.c b/target-microblaze/translate.c
index 232015a..021a504 100644
--- a/target-microblaze/translate.c
+++ b/target-microblaze/translate.c
@@ -863,7 +863,7 @@ static void dec_imm(DisasContext *dc)
 }
 
 static inline void gen_load(DisasContext *dc, TCGv dst, TCGv addr,
-                            unsigned int size)
+                            unsigned int size, bool exclusive)
 {
     int mem_index = cpu_mmu_index(dc->env);
 
@@ -875,6 +875,10 @@ static inline void gen_load(DisasContext *dc, TCGv dst, TCGv addr,
         tcg_gen_qemu_ld32u(dst, addr, mem_index);
     } else
         cpu_abort(dc->env, "Incorrect load size %d\n", size);
+
+    if (exclusive) {
+        tcg_gen_st_tl(addr, cpu_env, offsetof(CPUMBState, res_addr));
+    }
 }
 
 static inline TCGv *compute_ldst_addr(DisasContext *dc, TCGv *t)
@@ -1046,7 +1050,7 @@ static void dec_load(DisasContext *dc)
          * into v. If the load succeeds, we verify alignment of the
          * address and if that succeeds we write into the destination reg.
          */
-        gen_load(dc, v, *addr, size);
+        gen_load(dc, v, *addr, size, ex);
 
         tcg_gen_movi_tl(cpu_SR[SR_PC], dc->pc);
         gen_helper_memalign(cpu_env, *addr, tcg_const_tl(dc->rd),
@@ -1061,20 +1065,19 @@ static void dec_load(DisasContext *dc)
         tcg_temp_free(v);
     } else {
         if (dc->rd) {
-            gen_load(dc, cpu_R[dc->rd], *addr, size);
+            gen_load(dc, cpu_R[dc->rd], *addr, size, ex);
             if (rev) {
                 dec_byteswap(dc, cpu_R[dc->rd], cpu_R[dc->rd], size);
             }
         } else {
             /* We are loading into r0, no need to reverse.  */
-            gen_load(dc, env_imm, *addr, size);
+            gen_load(dc, env_imm, *addr, size, ex);
         }
     }
 
     if (ex) { /* lwx */
         /* no support for for AXI exclusive so always clear C */
         write_carryi(dc, 0);
-        tcg_gen_st_tl(*addr, cpu_env, offsetof(CPUMBState, res_addr));
     }
 
     if (addr == &t)
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [Qemu-devel] [PATCH 07/10] microblaze: Turn res_addr into a tcg global
  2013-10-24 21:08 [Qemu-devel] [PATCH 00/10] MicroBlaze queue edgar.iglesias
                   ` (5 preceding siblings ...)
  2013-10-24 21:08 ` [Qemu-devel] [PATCH 06/10] microblaze: Move the saving of the reservation addr into gen_load edgar.iglesias
@ 2013-10-24 21:08 ` edgar.iglesias
  2013-10-24 21:08 ` [Qemu-devel] [PATCH 08/10] microblaze: At swx, check that the reserved word is unmodified edgar.iglesias
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: edgar.iglesias @ 2013-10-24 21:08 UTC (permalink / raw)
  To: qemu-devel

From: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>

Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
---
 target-microblaze/translate.c |   13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/target-microblaze/translate.c b/target-microblaze/translate.c
index 021a504..57627fc 100644
--- a/target-microblaze/translate.c
+++ b/target-microblaze/translate.c
@@ -49,6 +49,7 @@ static TCGv env_imm;
 static TCGv env_btaken;
 static TCGv env_btarget;
 static TCGv env_iflags;
+static TCGv env_res_addr;
 
 #include "exec/gen-icount.h"
 
@@ -877,7 +878,7 @@ static inline void gen_load(DisasContext *dc, TCGv dst, TCGv addr,
         cpu_abort(dc->env, "Incorrect load size %d\n", size);
 
     if (exclusive) {
-        tcg_gen_st_tl(addr, cpu_env, offsetof(CPUMBState, res_addr));
+        tcg_gen_mov_tl(env_res_addr, addr);
     }
 }
 
@@ -1101,7 +1102,7 @@ static void gen_store(DisasContext *dc, TCGv addr, TCGv val,
 
 static void dec_store(DisasContext *dc)
 {
-    TCGv t, *addr, swx_addr, r_check;
+    TCGv t, *addr, swx_addr;
     int swx_skip = 0;
     unsigned int size, rev = 0, ex = 0;
 
@@ -1125,7 +1126,6 @@ static void dec_store(DisasContext *dc)
     sync_jmpstate(dc);
     addr = compute_ldst_addr(dc, &t);
 
-    r_check = tcg_temp_new();
     swx_addr = tcg_temp_local_new();
     if (ex) { /* swx */
 
@@ -1135,10 +1135,9 @@ static void dec_store(DisasContext *dc)
         /* swx does not throw unaligned access errors, so force alignment */
         tcg_gen_andi_tl(swx_addr, swx_addr, ~3);
 
-        tcg_gen_ld_tl(r_check, cpu_env, offsetof(CPUMBState, res_addr));
         write_carryi(dc, 1);
         swx_skip = gen_new_label();
-        tcg_gen_brcond_tl(TCG_COND_NE, r_check, swx_addr, swx_skip);
+        tcg_gen_brcond_tl(TCG_COND_NE, env_res_addr, swx_addr, swx_skip);
         write_carryi(dc, 0);
     }
 
@@ -1221,7 +1220,6 @@ static void dec_store(DisasContext *dc)
     if (ex) {
         gen_set_label(swx_skip);
     }
-    tcg_temp_free(r_check);
     tcg_temp_free(swx_addr);
 
     if (addr == &t)
@@ -2008,6 +2006,9 @@ void mb_tcg_init(void)
     env_btaken = tcg_global_mem_new(TCG_AREG0,
                      offsetof(CPUMBState, btaken),
                      "btaken");
+    env_res_addr = tcg_global_mem_new(TCG_AREG0,
+                     offsetof(CPUMBState, res_addr),
+                     "res_addr");
     for (i = 0; i < ARRAY_SIZE(cpu_R); i++) {
         cpu_R[i] = tcg_global_mem_new(TCG_AREG0,
                           offsetof(CPUMBState, regs[i]),
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [Qemu-devel] [PATCH 08/10] microblaze: At swx, check that the reserved word is unmodified
  2013-10-24 21:08 [Qemu-devel] [PATCH 00/10] MicroBlaze queue edgar.iglesias
                   ` (6 preceding siblings ...)
  2013-10-24 21:08 ` [Qemu-devel] [PATCH 07/10] microblaze: Turn res_addr into a tcg global edgar.iglesias
@ 2013-10-24 21:08 ` edgar.iglesias
  2013-10-24 21:08 ` [Qemu-devel] [PATCH 09/10] hw/microblaze: Indentation cleanups edgar.iglesias
  2013-10-24 21:08 ` [Qemu-devel] [PATCH 10/10] hw/microblaze: Add support for loading initrd images edgar.iglesias
  9 siblings, 0 replies; 11+ messages in thread
From: edgar.iglesias @ 2013-10-24 21:08 UTC (permalink / raw)
  To: qemu-devel

From: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>

This improves the reservation check for system emulation, making
it possible to catch stores that modify reserved word.

Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
---
 target-microblaze/cpu.h       |    1 +
 target-microblaze/translate.c |   16 ++++++++++++++++
 2 files changed, 17 insertions(+)

diff --git a/target-microblaze/cpu.h b/target-microblaze/cpu.h
index 7508cf5..e1415f0 100644
--- a/target-microblaze/cpu.h
+++ b/target-microblaze/cpu.h
@@ -246,6 +246,7 @@ struct CPUMBState {
     /* lwx/swx reserved address */
 #define RES_ADDR_NONE 0xffffffff /* Use 0xffffffff to indicate no reservation */
     uint32_t res_addr;
+    uint32_t res_val;
 
     /* Internal flags.  */
 #define IMM_FLAG	4
diff --git a/target-microblaze/translate.c b/target-microblaze/translate.c
index 57627fc..9edcb67 100644
--- a/target-microblaze/translate.c
+++ b/target-microblaze/translate.c
@@ -50,6 +50,7 @@ static TCGv env_btaken;
 static TCGv env_btarget;
 static TCGv env_iflags;
 static TCGv env_res_addr;
+static TCGv env_res_val;
 
 #include "exec/gen-icount.h"
 
@@ -879,6 +880,7 @@ static inline void gen_load(DisasContext *dc, TCGv dst, TCGv addr,
 
     if (exclusive) {
         tcg_gen_mov_tl(env_res_addr, addr);
+        tcg_gen_mov_tl(env_res_val, dst);
     }
 }
 
@@ -1128,6 +1130,7 @@ static void dec_store(DisasContext *dc)
 
     swx_addr = tcg_temp_local_new();
     if (ex) { /* swx */
+        TCGv tval;
 
         /* Force addr into the swx_addr. */
         tcg_gen_mov_tl(swx_addr, *addr);
@@ -1138,7 +1141,17 @@ static void dec_store(DisasContext *dc)
         write_carryi(dc, 1);
         swx_skip = gen_new_label();
         tcg_gen_brcond_tl(TCG_COND_NE, env_res_addr, swx_addr, swx_skip);
+
+        /* Compare the value loaded at lwx with current contents of
+           the reserved location.
+           FIXME: This only works for system emulation where we can expect
+           this compare and the following write to be atomic. For user
+           emulation we need to add atomicity between threads.  */
+        tval = tcg_temp_new();
+        gen_load(dc, tval, swx_addr, 4, false);
+        tcg_gen_brcond_tl(TCG_COND_NE, env_res_val, tval, swx_skip);
         write_carryi(dc, 0);
+        tcg_temp_free(tval);
     }
 
     if (rev && size != 4) {
@@ -2009,6 +2022,9 @@ void mb_tcg_init(void)
     env_res_addr = tcg_global_mem_new(TCG_AREG0,
                      offsetof(CPUMBState, res_addr),
                      "res_addr");
+    env_res_val = tcg_global_mem_new(TCG_AREG0,
+                     offsetof(CPUMBState, res_val),
+                     "res_val");
     for (i = 0; i < ARRAY_SIZE(cpu_R); i++) {
         cpu_R[i] = tcg_global_mem_new(TCG_AREG0,
                           offsetof(CPUMBState, regs[i]),
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [Qemu-devel] [PATCH 09/10] hw/microblaze: Indentation cleanups
  2013-10-24 21:08 [Qemu-devel] [PATCH 00/10] MicroBlaze queue edgar.iglesias
                   ` (7 preceding siblings ...)
  2013-10-24 21:08 ` [Qemu-devel] [PATCH 08/10] microblaze: At swx, check that the reserved word is unmodified edgar.iglesias
@ 2013-10-24 21:08 ` edgar.iglesias
  2013-10-24 21:08 ` [Qemu-devel] [PATCH 10/10] hw/microblaze: Add support for loading initrd images edgar.iglesias
  9 siblings, 0 replies; 11+ messages in thread
From: edgar.iglesias @ 2013-10-24 21:08 UTC (permalink / raw)
  To: qemu-devel

From: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>

Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
---
 hw/microblaze/boot.c                     |   11 ++++++-----
 hw/microblaze/petalogix_ml605_mmu.c      |    5 +++--
 hw/microblaze/petalogix_s3adsp1800_mmu.c |    2 +-
 3 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/hw/microblaze/boot.c b/hw/microblaze/boot.c
index 5b057f7..59be5b9 100644
--- a/hw/microblaze/boot.c
+++ b/hw/microblaze/boot.c
@@ -57,9 +57,9 @@ static void main_cpu_reset(void *opaque)
 }
 
 static int microblaze_load_dtb(hwaddr addr,
-                                      uint32_t ramsize,
-                                      const char *kernel_cmdline,
-                                      const char *dtb_filename)
+                               uint32_t ramsize,
+                               const char *kernel_cmdline,
+                               const char *dtb_filename)
 {
     int fdt_size;
     void *fdt = NULL;
@@ -157,8 +157,9 @@ void microblaze_load_kernel(MicroBlazeCPU *cpu, hwaddr ddr_base,
         }
         /* Provide a device-tree.  */
         boot_info.fdt = boot_info.cmdline + 4096;
-        microblaze_load_dtb(boot_info.fdt, ram_size, kernel_cmdline,
-                                                     dtb_filename);
+        microblaze_load_dtb(boot_info.fdt, ram_size,
+                            kernel_cmdline,
+                            dtb_filename);
     }
 
 }
diff --git a/hw/microblaze/petalogix_ml605_mmu.c b/hw/microblaze/petalogix_ml605_mmu.c
index e003c7c..1c44231 100644
--- a/hw/microblaze/petalogix_ml605_mmu.c
+++ b/hw/microblaze/petalogix_ml605_mmu.c
@@ -176,8 +176,9 @@ petalogix_ml605_init(QEMUMachineInitArgs *args)
         }
     }
 
-    microblaze_load_kernel(cpu, ddr_base, ram_size, BINARY_DEVICE_TREE_FILE,
-                                                            machine_cpu_reset);
+    microblaze_load_kernel(cpu, ddr_base, ram_size,
+                           BINARY_DEVICE_TREE_FILE,
+                           machine_cpu_reset);
 
 }
 
diff --git a/hw/microblaze/petalogix_s3adsp1800_mmu.c b/hw/microblaze/petalogix_s3adsp1800_mmu.c
index 00af2b5..39ce2c4 100644
--- a/hw/microblaze/petalogix_s3adsp1800_mmu.c
+++ b/hw/microblaze/petalogix_s3adsp1800_mmu.c
@@ -108,7 +108,7 @@ petalogix_s3adsp1800_init(QEMUMachineInitArgs *args)
     xilinx_ethlite_create(&nd_table[0], ETHLITE_BASEADDR, irq[1], 0, 0);
 
     microblaze_load_kernel(cpu, ddr_base, ram_size,
-                    BINARY_DEVICE_TREE_FILE, machine_cpu_reset);
+                           BINARY_DEVICE_TREE_FILE, machine_cpu_reset);
 }
 
 static QEMUMachine petalogix_s3adsp1800_machine = {
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [Qemu-devel] [PATCH 10/10] hw/microblaze: Add support for loading initrd images
  2013-10-24 21:08 [Qemu-devel] [PATCH 00/10] MicroBlaze queue edgar.iglesias
                   ` (8 preceding siblings ...)
  2013-10-24 21:08 ` [Qemu-devel] [PATCH 09/10] hw/microblaze: Indentation cleanups edgar.iglesias
@ 2013-10-24 21:08 ` edgar.iglesias
  9 siblings, 0 replies; 11+ messages in thread
From: edgar.iglesias @ 2013-10-24 21:08 UTC (permalink / raw)
  To: qemu-devel

From: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>

Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
---
 hw/microblaze/boot.c                     |   39 +++++++++++++++++++++++++++++-
 hw/microblaze/boot.h                     |    4 ++-
 hw/microblaze/petalogix_ml605_mmu.c      |    1 +
 hw/microblaze/petalogix_s3adsp1800_mmu.c |    4 ++-
 4 files changed, 45 insertions(+), 3 deletions(-)

diff --git a/hw/microblaze/boot.c b/hw/microblaze/boot.c
index 59be5b9..2a7ea5c 100644
--- a/hw/microblaze/boot.c
+++ b/hw/microblaze/boot.c
@@ -26,6 +26,7 @@
 
 #include "qemu/option.h"
 #include "qemu/config-file.h"
+#include "qemu/error-report.h"
 #include "qemu-common.h"
 #include "sysemu/device_tree.h"
 #include "sysemu/sysemu.h"
@@ -39,6 +40,8 @@ static struct
     void (*machine_cpu_reset)(MicroBlazeCPU *);
     uint32_t bootstrap_pc;
     uint32_t cmdline;
+    uint32_t initrd_start;
+    uint32_t initrd_end;
     uint32_t fdt;
 } boot_info;
 
@@ -49,6 +52,7 @@ static void main_cpu_reset(void *opaque)
 
     cpu_reset(CPU(cpu));
     env->regs[5] = boot_info.cmdline;
+    env->regs[6] = boot_info.initrd_start;
     env->regs[7] = boot_info.fdt;
     env->sregs[SR_PC] = boot_info.bootstrap_pc;
     if (boot_info.machine_cpu_reset) {
@@ -58,6 +62,8 @@ static void main_cpu_reset(void *opaque)
 
 static int microblaze_load_dtb(hwaddr addr,
                                uint32_t ramsize,
+                               uint32_t initrd_start,
+                               uint32_t initrd_end,
                                const char *kernel_cmdline,
                                const char *dtb_filename)
 {
@@ -80,6 +86,14 @@ static int microblaze_load_dtb(hwaddr addr,
         }
     }
 
+    if (initrd_start) {
+        qemu_devtree_setprop_cell(fdt, "/chosen", "linux,initrd-start",
+                                  initrd_start);
+
+        qemu_devtree_setprop_cell(fdt, "/chosen", "linux,initrd-end",
+                                  initrd_end);
+    }
+
     cpu_physical_memory_write(addr, fdt, fdt_size);
     return fdt_size;
 }
@@ -90,7 +104,9 @@ static uint64_t translate_kernel_address(void *opaque, uint64_t addr)
 }
 
 void microblaze_load_kernel(MicroBlazeCPU *cpu, hwaddr ddr_base,
-                            uint32_t ramsize, const char *dtb_filename,
+                            uint32_t ramsize,
+                            const char *initrd_filename,
+                            const char *dtb_filename,
                             void (*machine_cpu_reset)(MicroBlazeCPU *))
 {
     QemuOpts *machine_opts;
@@ -151,6 +167,25 @@ void microblaze_load_kernel(MicroBlazeCPU *cpu, hwaddr ddr_base,
             high = (ddr_base + kernel_size + 3) & ~3;
         }
 
+        if (initrd_filename) {
+            int initrd_size;
+            uint32_t initrd_offset;
+
+            high = ROUND_UP(high + kernel_size, 4);
+            boot_info.initrd_start = high;
+            initrd_offset = boot_info.initrd_start - ddr_base;
+            initrd_size = load_image_targphys(initrd_filename,
+                                              boot_info.initrd_start,
+                                              ram_size - initrd_offset);
+            if (initrd_size < 0) {
+                error_report("qemu: could not load initrd '%s'\n",
+                             initrd_filename);
+                exit(EXIT_FAILURE);
+            }
+            boot_info.initrd_end = boot_info.initrd_start + initrd_size;
+            high = ROUND_UP(high + initrd_size, 4);
+        }
+
         boot_info.cmdline = high + 4096;
         if (kernel_cmdline && strlen(kernel_cmdline)) {
             pstrcpy_targphys("cmdline", boot_info.cmdline, 256, kernel_cmdline);
@@ -158,6 +193,8 @@ void microblaze_load_kernel(MicroBlazeCPU *cpu, hwaddr ddr_base,
         /* Provide a device-tree.  */
         boot_info.fdt = boot_info.cmdline + 4096;
         microblaze_load_dtb(boot_info.fdt, ram_size,
+                            boot_info.initrd_start,
+                            boot_info.initrd_end,
                             kernel_cmdline,
                             dtb_filename);
     }
diff --git a/hw/microblaze/boot.h b/hw/microblaze/boot.h
index b14ef2b..0eb7f8e 100644
--- a/hw/microblaze/boot.h
+++ b/hw/microblaze/boot.h
@@ -4,7 +4,9 @@
 #include "hw/hw.h"
 
 void microblaze_load_kernel(MicroBlazeCPU *cpu, hwaddr ddr_base,
-                            uint32_t ramsize, const char *dtb_filename,
+                            uint32_t ramsize,
+                            const char *initrd_filename,
+                            const char *dtb_filename,
                             void (*machine_cpu_reset)(MicroBlazeCPU *));
 
 #endif /* __MICROBLAZE_BOOT __ */
diff --git a/hw/microblaze/petalogix_ml605_mmu.c b/hw/microblaze/petalogix_ml605_mmu.c
index 1c44231..10970e0 100644
--- a/hw/microblaze/petalogix_ml605_mmu.c
+++ b/hw/microblaze/petalogix_ml605_mmu.c
@@ -177,6 +177,7 @@ petalogix_ml605_init(QEMUMachineInitArgs *args)
     }
 
     microblaze_load_kernel(cpu, ddr_base, ram_size,
+                           args->initrd_filename,
                            BINARY_DEVICE_TREE_FILE,
                            machine_cpu_reset);
 
diff --git a/hw/microblaze/petalogix_s3adsp1800_mmu.c b/hw/microblaze/petalogix_s3adsp1800_mmu.c
index 39ce2c4..ec6489c 100644
--- a/hw/microblaze/petalogix_s3adsp1800_mmu.c
+++ b/hw/microblaze/petalogix_s3adsp1800_mmu.c
@@ -108,7 +108,9 @@ petalogix_s3adsp1800_init(QEMUMachineInitArgs *args)
     xilinx_ethlite_create(&nd_table[0], ETHLITE_BASEADDR, irq[1], 0, 0);
 
     microblaze_load_kernel(cpu, ddr_base, ram_size,
-                           BINARY_DEVICE_TREE_FILE, machine_cpu_reset);
+                           args->initrd_filename,
+                           BINARY_DEVICE_TREE_FILE,
+                           machine_cpu_reset);
 }
 
 static QEMUMachine petalogix_s3adsp1800_machine = {
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2013-10-24 21:13 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-24 21:08 [Qemu-devel] [PATCH 00/10] MicroBlaze queue edgar.iglesias
2013-10-24 21:08 ` [Qemu-devel] [PATCH 01/10] microblaze: Clarify expected input of write_carry edgar.iglesias
2013-10-24 21:08 ` [Qemu-devel] [PATCH 02/10] microblaze: Make write_carryi input a boolean edgar.iglesias
2013-10-24 21:08 ` [Qemu-devel] [PATCH 03/10] microblaze: Simplify andn by using tcg_gen_andc edgar.iglesias
2013-10-24 21:08 ` [Qemu-devel] [PATCH 04/10] microblaze: Improve srl edgar.iglesias
2013-10-24 21:08 ` [Qemu-devel] [PATCH 05/10] microblaze: Improve src edgar.iglesias
2013-10-24 21:08 ` [Qemu-devel] [PATCH 06/10] microblaze: Move the saving of the reservation addr into gen_load edgar.iglesias
2013-10-24 21:08 ` [Qemu-devel] [PATCH 07/10] microblaze: Turn res_addr into a tcg global edgar.iglesias
2013-10-24 21:08 ` [Qemu-devel] [PATCH 08/10] microblaze: At swx, check that the reserved word is unmodified edgar.iglesias
2013-10-24 21:08 ` [Qemu-devel] [PATCH 09/10] hw/microblaze: Indentation cleanups edgar.iglesias
2013-10-24 21:08 ` [Qemu-devel] [PATCH 10/10] hw/microblaze: Add support for loading initrd images edgar.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).