Skip to contentSkip to conversation

ARM-MIDR Make ARM-MIDR a property and use in Zynq

PATCH Superseded Alistair Francis 3 participants 5 messages Jan 12, 2014 – Jan 13, 2014 Arm/Zynq architecture

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

cover ARM-MIDR Make ARM-MIDR a property and use in Zynq

This series converts cpu->midr (the MIDR register) to a property. This allows it to be set after init which is useful for specific boards (such as Zynq). The change has been done in such a way that it doesn't break compatibility with boards that don't need a custom MIDR.

Alistair Francis (2):
ARM: Convert MIDR to a property
ZYNQ: Implement board MIDR control for Zynq

 hw/arm/xilinx_zynq.c |    7 +++++++
 target-arm/cpu.c     |   17 +++++++++++++++++
 2 files changed, 24 insertions(+), 0 deletions(-)
#1 lore raw

PATCH 1/2 ARM: Convert MIDR to a property

Convert the MIDR register to a property. This allows boards to later set a custom MIDR value. This has been done in such a way to maintain compatibility with all existing CPUs and boards

---
I added the properties to the cpu->midr variable in a similar method to how Peter Crosthwaite did in his 'Fix Support for ARM CBAR and reset-hivecs' series.

 target-arm/cpu.c |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)
target-arm/cpu.c +17 -0
index 408d207..bf625b0 100644
@@ -249,10 +249,14 @@ static Property arm_cpu_reset_cbar_property =
 static Property arm_cpu_reset_hivecs_property =
             DEFINE_PROP_BOOL("reset-hivecs", ARMCPU, reset_hivecs, false);
 
+static Property arm_cpu_midr_property =
+            DEFINE_PROP_UINT32("midr", ARMCPU, midr, 0);
+
 static void arm_cpu_post_init(Object *obj)
 {
     ARMCPU *cpu = ARM_CPU(obj);
     Error *err = NULL;
+    uint32_t temp = cpu->midr;
 
     if (arm_feature(&cpu->env, ARM_FEATURE_CBAR)) {
         qdev_property_add_static(DEVICE(obj), &arm_cpu_reset_cbar_property,
@@ -265,6 +269,19 @@ static void arm_cpu_post_init(Object *obj)
                                  &err);
         assert_no_error(err);
     }
+
+    /*
+     * Initialise the midr property and set it to the original CPU MIDR
+     * This is used to maintain compatibility with boards that don't set
+     * a custom MIDR
+     */
+    qdev_property_add_static(DEVICE(obj), &arm_cpu_midr_property, &err);
+    assert_no_error(err);
+    object_property_set_int(OBJECT(cpu), temp, "midr", &err);
+    if (err) {
+        error_report("%s", error_get_pretty(err));
+        exit(1);
+    }
 }
 
 static void arm_cpu_finalizefn(Object *obj)
Signature · 1 line
1.7.1
#2 lore raw

Re: [Qemu-devel] [PATCH arm-midr v1 1/2] ARM: Convert MIDR to a property

Am 13.01.2014 00:33, schrieb Alistair Francis:

Quoted 33 lines

Convert the MIDR register to a property. This allows boards to later set a custom MIDR value. This has been done in such a way to maintain compatibility with all existing CPUs and boards

---
I added the properties to the cpu->midr variable in a similar method to how Peter Crosthwaite did in his 'Fix Support for ARM CBAR and reset-hivecs' series.

 target-arm/cpu.c |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)
target-arm/cpu.c +4 -0
index 408d207..bf625b0 100644
@@ -249,10 +249,14 @@ static Property arm_cpu_reset_cbar_property =
 static Property arm_cpu_reset_hivecs_property =
             DEFINE_PROP_BOOL("reset-hivecs", ARMCPU, reset_hivecs, false);
 
+static Property arm_cpu_midr_property =
+            DEFINE_PROP_UINT32("midr", ARMCPU, midr, 0);
+
 static void arm_cpu_post_init(Object *obj)
 {
     ARMCPU *cpu = ARM_CPU(obj);
     Error *err = NULL;
+    uint32_t temp = cpu->midr;
 
     if (arm_feature(&cpu->env, ARM_FEATURE_CBAR)) {
         qdev_property_add_static(DEVICE(obj), &arm_cpu_reset_cbar_property,

target-arm/cpu.c static void arm_cpu_post_init(Object *obj) · line 278

Quoted 10 lines
target-arm/cpu.c +7 -0
@@ -265,6 +269,19 @@ static void arm_cpu_post_init(Object *obj)
                                  &err);
         assert_no_error(err);
     }
+
+    /*
+     * Initialise the midr property and set it to the original CPU MIDR
+     * This is used to maintain compatibility with boards that don't set
+     * a custom MIDR
+     */
+    qdev_property_add_static(DEVICE(obj), &arm_cpu_midr_property, &err);

This looks wrong to me. Use dc->props to add properties that are always present. Any qdev_* functions shouldn't spread further than necessary.

target-arm/cpu.c static void arm_cpu_post_init(Object *obj) · line 279

Quoted 1 line
target-arm/cpu.c +1 -0
+    assert_no_error(err);

Further, this seems to conflict with Peter C.'s work of introducing error_abort.

Andreas

Quoted 9 lines
target-arm/cpu.c +5 -0
+    object_property_set_int(OBJECT(cpu), temp, "midr", &err);
+    if (err) {
+        error_report("%s", error_get_pretty(err));
+        exit(1);
+    }
 }
 
 static void arm_cpu_finalizefn(Object *obj)
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#3 lore raw

Re: [Qemu-devel] [PATCH arm-midr v1 1/2] ARM: Convert MIDR to a property

Quoted 31 lines · Andreas Färber

Am 13.01.2014 00:33, schrieb Alistair Francis:

Quoted 30 lines

Convert the MIDR register to a property. This allows boards to later set a custom MIDR value. This has been done in such a way to maintain compatibility with all existing CPUs and boards

---
I added the properties to the cpu->midr variable in a similar method to how Peter Crosthwaite did in his 'Fix Support for ARM CBAR and reset-hivecs' series.

 target-arm/cpu.c |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)
target-arm/cpu.c +4 -0
index 408d207..bf625b0 100644
@@ -249,10 +249,14 @@ static Property arm_cpu_reset_cbar_property =
 static Property arm_cpu_reset_hivecs_property =
             DEFINE_PROP_BOOL("reset-hivecs", ARMCPU, reset_hivecs, false);
 
+static Property arm_cpu_midr_property =
+            DEFINE_PROP_UINT32("midr", ARMCPU, midr, 0);
+
 static void arm_cpu_post_init(Object *obj)
 {
     ARMCPU *cpu = ARM_CPU(obj);
     Error *err = NULL;
+    uint32_t temp = cpu->midr;
 
Quoted 17 lines

target-arm/cpu.c static void arm_cpu_post_init(Object *obj) · line 278

Quoted 13 lines
target-arm/cpu.c +7 -0
     if (arm_feature(&cpu->env, ARM_FEATURE_CBAR)) {
         qdev_property_add_static(DEVICE(obj), &arm_cpu_reset_cbar_property,
@@ -265,6 +269,19 @@ static void arm_cpu_post_init(Object *obj)
                                  &err);
         assert_no_error(err);
     }
+
+    /*
+     * Initialise the midr property and set it to the original CPU MIDR
+     * This is used to maintain compatibility with boards that don't set
+     * a custom MIDR
+     */
+    qdev_property_add_static(DEVICE(obj), &arm_cpu_midr_property, &err);

This looks wrong to me. Use dc->props to add properties that are always present. Any qdev_* functions shouldn't spread further than necessary.

If it is always present - PMM do you have any thoughts on this? does MIDR universally exist in the ARM universe?

Quoted 5 lines

target-arm/cpu.c static void arm_cpu_post_init(Object *obj) · line 279

Quoted 1 line
target-arm/cpu.c +1 -0
+    assert_no_error(err);

Further, this seems to conflict with Peter C.'s work of introducing error_abort.

While we are on that topic, that pull (QMP queue) is progressing slowly. Seems to be skipped over by Anthony in latest round of pulls for some reason?

Regards,
Peter

Quoted 17 lines

Andreas

target-arm/cpu.c static void arm_cpu_post_init(Object *obj) · line 287

Quoted 9 lines
target-arm/cpu.c +5 -0
+    object_property_set_int(OBJECT(cpu), temp, "midr", &err);
+    if (err) {
+        error_report("%s", error_get_pretty(err));
+        exit(1);
+    }
 }
 
 static void arm_cpu_finalizefn(Object *obj)

--
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg

#4 lore raw

PATCH 2/2 ZYNQ: Implement board MIDR control for Zynq

In reply to Alistair Francis

This patch uses the fact that the midr variable is now a property This patch sets the midr variable to the boards custom midr

---

 hw/arm/xilinx_zynq.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)
hw/arm/xilinx_zynq.c +7 -0
index 17251c7..e35fd07 100644
@@ -37,6 +37,7 @@
 #define IRQ_OFFSET 32 /* pic interrupts start from index 32 */
 
 #define MPCORE_PERIPHBASE 0xF8F00000
+#define ZYNQ_BOARD_MIDR 0x413FC090
 
 static const int dma_irqs[8] = {
     46, 47, 48, 49, 72, 73, 74, 75
@@ -129,6 +130,12 @@ static void zynq_init(QEMUMachineInitArgs *args)
         error_report("%s", error_get_pretty(err));
         exit(1);
     }
+
+    object_property_set_int(OBJECT(cpu), ZYNQ_BOARD_MIDR, "midr", &err);
+    if (err) {
+        error_report("%s", error_get_pretty(err));
+        exit(1);
+    }
     object_property_set_bool(OBJECT(cpu), true, "realized", &err);
     if (err) {
         error_report("%s", error_get_pretty(err));
Signature · 1 line
1.7.1