Skip to contentSkip to conversation

hw/arm/gumstix: Trivial cleanups

PATCH In review Philippe Mathieu-Daudé 2 participants 7 messages Feb 23, 2020 – Feb 25, 2020

lore
Share & tools
lore
#1 lore raw

PATCH 1/2 hw/arm/gumstix: Simplify since the machines are little-endian only

In reply to Philippe Mathieu-Daudé

From: Philippe Mathieu-Daudé <[email protected]>

As the Connex and Verdex machines only boot in little-endian, we can simplify the code.

---
 hw/arm/gumstix.c | 19 +++++--------------
 1 file changed, 5 insertions(+), 14 deletions(-)
hw/arm/gumstix.c +5 -14
index f26a0e8010..94904d717b 100644
@@ -51,7 +51,6 @@ static void connex_init(MachineState *machine)
 {
     PXA2xxState *cpu;
     DriveInfo *dinfo;
-    int be;
     MemoryRegion *address_space_mem = get_system_memory();
 
     uint32_t connex_rom = 0x01000000;
@@ -66,14 +65,9 @@ static void connex_init(MachineState *machine)
         exit(1);
     }
 
-#ifdef TARGET_WORDS_BIGENDIAN
-    be = 1;
-#else
-    be = 0;
-#endif
     if (!pflash_cfi01_register(0x00000000, "connext.rom", connex_rom,
                                dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
-                               sector_len, 2, 0, 0, 0, 0, be)) {
+                               sector_len, 2, 0, 0, 0, 0, 0)) {
         error_report("Error registering flash memory");
         exit(1);
     }
@@ -87,7 +81,6 @@ static void verdex_init(MachineState *machine)
 {
     PXA2xxState *cpu;
     DriveInfo *dinfo;
-    int be;
     MemoryRegion *address_space_mem = get_system_memory();
 
     uint32_t verdex_rom = 0x02000000;
@@ -102,14 +95,9 @@ static void verdex_init(MachineState *machine)
         exit(1);
     }
 
-#ifdef TARGET_WORDS_BIGENDIAN
-    be = 1;
-#else
-    be = 0;
-#endif
     if (!pflash_cfi01_register(0x00000000, "verdex.rom", verdex_rom,
                                dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
-                               sector_len, 2, 0, 0, 0, 0, be)) {
+                               sector_len, 2, 0, 0, 0, 0, 0)) {
         error_report("Error registering flash memory");
         exit(1);
     }
@@ -152,6 +140,9 @@ static const TypeInfo verdex_type = {
 
 static void gumstix_machine_init(void)
 {
+    if (target_words_bigendian()) {
+        return;
+    }
     type_register_static(&connex_type);
     type_register_static(&verdex_type);
 }
Signature · 1 line
2.21.1
#4 lore raw

PATCH 2/2 hw/arm/gumstix: Use the IEC binary prefix definitions

In reply to Philippe Mathieu-Daudé

From: Philippe Mathieu-Daudé <[email protected]>

IEC binary prefixes ease code review: the unit is explicit.

Add a comment describing the Connex uses a Numonyx RC28F128J3F75 flash, and the Verdex uses a Micron RC28F256P30TFA.

Correct the Verdex machine description (we model the 'Pro' board).

---
 hw/arm/gumstix.c | 23 +++++++++--------------
 1 file changed, 9 insertions(+), 14 deletions(-)
hw/arm/gumstix.c +9 -14
index 94904d717b..ca918fda0c 100644
@@ -35,6 +35,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/units.h"
 #include "qemu/error-report.h"
 #include "hw/arm/pxa.h"
 #include "net/net.h"
@@ -45,18 +46,14 @@
 #include "sysemu/qtest.h"
 #include "cpu.h"
 
-static const int sector_len = 128 * 1024;
+static const int sector_len = 128 * KiB;
 
 static void connex_init(MachineState *machine)
 {
     PXA2xxState *cpu;
     DriveInfo *dinfo;
-    MemoryRegion *address_space_mem = get_system_memory();
 
-    uint32_t connex_rom = 0x01000000;
-    uint32_t connex_ram = 0x04000000;
-
-    cpu = pxa255_init(address_space_mem, connex_ram);
+    cpu = pxa255_init(get_system_memory(), 64 * MiB);
 
     dinfo = drive_get(IF_PFLASH, 0, 0);
     if (!dinfo && !qtest_enabled()) {
@@ -65,7 +62,8 @@ static void connex_init(MachineState *machine)
         exit(1);
     }
 
-    if (!pflash_cfi01_register(0x00000000, "connext.rom", connex_rom,
+    /* Numonyx RC28F128J3F75 */
+    if (!pflash_cfi01_register(0x00000000, "connext.rom", 16 * MiB,
                                dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
                                sector_len, 2, 0, 0, 0, 0, 0)) {
         error_report("Error registering flash memory");
@@ -81,12 +79,8 @@ static void verdex_init(MachineState *machine)
 {
     PXA2xxState *cpu;
     DriveInfo *dinfo;
-    MemoryRegion *address_space_mem = get_system_memory();
 
-    uint32_t verdex_rom = 0x02000000;
-    uint32_t verdex_ram = 0x10000000;
-
-    cpu = pxa270_init(address_space_mem, verdex_ram, machine->cpu_type);
+    cpu = pxa270_init(get_system_memory(), 256 * MiB, machine->cpu_type);
 
     dinfo = drive_get(IF_PFLASH, 0, 0);
     if (!dinfo && !qtest_enabled()) {
@@ -95,7 +89,8 @@ static void verdex_init(MachineState *machine)
         exit(1);
     }
 
-    if (!pflash_cfi01_register(0x00000000, "verdex.rom", verdex_rom,
+    /* Micron RC28F256P30TFA */
+    if (!pflash_cfi01_register(0x00000000, "verdex.rom", 32 * MiB,
                                dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
                                sector_len, 2, 0, 0, 0, 0, 0)) {
         error_report("Error registering flash memory");
@@ -126,7 +121,7 @@ static void verdex_class_init(ObjectClass *oc, void *data)
 {
     MachineClass *mc = MACHINE_CLASS(oc);
 
-    mc->desc = "Gumstix Verdex (PXA270)";
+    mc->desc = "Gumstix Verdex Pro XL6P COMs (PXA270)";
     mc->init = verdex_init;
     mc->ignore_memory_transaction_failures = true;
     mc->default_cpu_type = ARM_CPU_TYPE_NAME("pxa270-c0");
Signature · 1 line
2.21.1
#0 lore raw

cover hw/arm/gumstix: Trivial cleanups

From: Philippe Mathieu-Daudé <[email protected]>

Two house keeping patches while looking at the Gumstix boards, to make the code slightly more readable/documented.

Philippe Mathieu-Daudé (2):
hw/arm/gumstix: Simplify since the machines are little-endian only hw/arm/gumstix: Use the IEC binary prefix definitions

 hw/arm/gumstix.c | 42 ++++++++++++++----------------------------
 1 file changed, 14 insertions(+), 28 deletions(-)
Signature · 1 line
2.21.1
Reviewed-by on v1 1/2
#2 lore raw

Re: [PATCH 1/2] hw/arm/gumstix: Simplify since the machines are little-endian only

In reply to Philippe Mathieu-Daudé
Quoted 11 lines · Philippe Mathieu-Daudé

From: Philippe Mathieu-Daudé <[email protected]>

As the Connex and Verdex machines only boot in little-endian, we can simplify the code.

---

static void gumstix_machine_init(void)
{

hw/arm/gumstix.c static const TypeInfo verdex_type = { · line 145

Quoted 3 lines
hw/arm/gumstix.c +3 -0
+    if (target_words_bigendian()) {
+        return;
+    }

I don't think we really need to do this, do we? We don't in any of the other arm boards that just assume little-endian. I think TARGET_WORDS_BIGENDIAN will only be true on Arm for the BE linux-user targets, never for softmmu.

Also, there's a warning comment in the header file for the declaration of target_words_bigendian() that says you probably don't want to use it...

If you drop this, then otherwise

thanks
-- PMM

#3 lore raw

Re: [PATCH 1/2] hw/arm/gumstix: Simplify since the machines are little-endian only

Quoted 16 lines · Peter Maydell
Quoted 11 lines · Philippe Mathieu-Daudé

From: Philippe Mathieu-Daudé <[email protected]>

As the Connex and Verdex machines only boot in little-endian, we can simplify the code.

---

  static void gumstix_machine_init(void)
  {

hw/arm/gumstix.c static const TypeInfo verdex_type = { · line 145

Quoted 3 lines
hw/arm/gumstix.c +3 -0
+    if (target_words_bigendian()) {
+        return;
+    }
Quoted 8 lines

I don't think we really need to do this, do we? We don't in any of the other arm boards that just assume little-endian. I think TARGET_WORDS_BIGENDIAN will only be true on Arm for the BE linux-user targets, never for softmmu.

Also, there's a warning comment in the header file for the declaration of target_words_bigendian() that says you probably don't want to use it...

Yes you (and the comment) are right, we should not use this call in target-specific code.

Quoted 3 lines

If you drop this, then otherwise

Thanks!

Quoted 4 lines

thanks
-- PMM

#5 lore raw

Re: [PATCH 2/2] hw/arm/gumstix: Use the IEC binary prefix definitions

In reply to Philippe Mathieu-Daudé
Quoted 11 lines · Philippe Mathieu-Daudé

From: Philippe Mathieu-Daudé <[email protected]>

IEC binary prefixes ease code review: the unit is explicit.

Add a comment describing the Connex uses a Numonyx RC28F128J3F75 flash, and the Verdex uses a Micron RC28F256P30TFA.

Correct the Verdex machine description (we model the 'Pro' board).

This patch is doing somewhat more than the commit Subject line suggests. I don't think it's particularly strongly in need of splitting into more patches, but could you make the subject line a bit closer to what the patch is doing?

Quoted 38 lines
---
 hw/arm/gumstix.c | 23 +++++++++--------------
 1 file changed, 9 insertions(+), 14 deletions(-)
hw/arm/gumstix.c +3 -6
index 94904d717b..ca918fda0c 100644
@@ -35,6 +35,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/units.h"
 #include "qemu/error-report.h"
 #include "hw/arm/pxa.h"
 #include "net/net.h"
@@ -45,18 +46,14 @@
 #include "sysemu/qtest.h"
 #include "cpu.h"
 
-static const int sector_len = 128 * 1024;
+static const int sector_len = 128 * KiB;
 
 static void connex_init(MachineState *machine)
 {
     PXA2xxState *cpu;
     DriveInfo *dinfo;
-    MemoryRegion *address_space_mem = get_system_memory();
 
-    uint32_t connex_rom = 0x01000000;
-    uint32_t connex_ram = 0x04000000;
-
-    cpu = pxa255_init(address_space_mem, connex_ram);
+    cpu = pxa255_init(get_system_memory(), 64 * MiB);
 
     dinfo = drive_get(IF_PFLASH, 0, 0);
     if (!dinfo && !qtest_enabled()) {

hw/arm/gumstix.c static void connex_init(MachineState *machine) · line 69

Quoted 9 lines
hw/arm/gumstix.c +2 -1
@@ -65,7 +62,8 @@ static void connex_init(MachineState *machine)
         exit(1);
     }
 
-    if (!pflash_cfi01_register(0x00000000, "connext.rom", connex_rom,
+    /* Numonyx RC28F128J3F75 */
+    if (!pflash_cfi01_register(0x00000000, "connext.rom", 16 * MiB,
                                dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
                                sector_len, 2, 0, 0, 0, 0, 0)) {
         error_report("Error registering flash memory");

Previously the variable names were helpfully acting as a bit of documentation of what the 64MB and 16MB things were. Perhaps we could instead have

#define CONNEX_ROM_SIZE (16 * MiB)
#define CONNEX_RAM_SIZE (64 * MiB)

and then use those?

Quoted 15 lines
hw/arm/gumstix.c +1 -5
@@ -81,12 +79,8 @@ static void verdex_init(MachineState *machine)
 {
     PXA2xxState *cpu;
     DriveInfo *dinfo;
-    MemoryRegion *address_space_mem = get_system_memory();
 
-    uint32_t verdex_rom = 0x02000000;
-    uint32_t verdex_ram = 0x10000000;
-
-    cpu = pxa270_init(address_space_mem, verdex_ram, machine->cpu_type);
+    cpu = pxa270_init(get_system_memory(), 256 * MiB, machine->cpu_type);
 
     dinfo = drive_get(IF_PFLASH, 0, 0);
     if (!dinfo && !qtest_enabled()) {

hw/arm/gumstix.c static void verdex_init(MachineState *machine) · line 96

Quoted 9 lines
hw/arm/gumstix.c +2 -1
@@ -95,7 +89,8 @@ static void verdex_init(MachineState *machine)
         exit(1);
     }
 
-    if (!pflash_cfi01_register(0x00000000, "verdex.rom", verdex_rom,
+    /* Micron RC28F256P30TFA */
+    if (!pflash_cfi01_register(0x00000000, "verdex.rom", 32 * MiB,
                                dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
                                sector_len, 2, 0, 0, 0, 0, 0)) {
         error_report("Error registering flash memory");

Similarly here.

hw/arm/gumstix.c static void verdex_class_init(ObjectClass *oc, void *data)

Quoted 10 lines
hw/arm/gumstix.c +1 -2
@@ -126,7 +121,7 @@ static void verdex_class_init(ObjectClass *oc, void *data)
 {
     MachineClass *mc = MACHINE_CLASS(oc);
 
-    mc->desc = "Gumstix Verdex (PXA270)";
+    mc->desc = "Gumstix Verdex Pro XL6P COMs (PXA270)";
     mc->init = verdex_init;
     mc->ignore_memory_transaction_failures = true;
     mc->default_cpu_type = ARM_CPU_TYPE_NAME("pxa270-c0");
--

thanks
-- PMM

#6 lore raw

Re: [PATCH 2/2] hw/arm/gumstix: Use the IEC binary prefix definitions

Quoted 70 lines · Peter Maydell
Quoted 11 lines · Philippe Mathieu-Daudé

From: Philippe Mathieu-Daudé <[email protected]>

IEC binary prefixes ease code review: the unit is explicit.

Add a comment describing the Connex uses a Numonyx RC28F128J3F75 flash, and the Verdex uses a Micron RC28F256P30TFA.

Correct the Verdex machine description (we model the 'Pro' board).

This patch is doing somewhat more than the commit Subject line suggests. I don't think it's particularly strongly in need of splitting into more patches, but could you make the subject line a bit closer to what the patch is doing?

Quoted 38 lines
---
  hw/arm/gumstix.c | 23 +++++++++--------------
  1 file changed, 9 insertions(+), 14 deletions(-)
hw/arm/gumstix.c +3 -6
index 94904d717b..ca918fda0c 100644
@@ -35,6 +35,7 @@
   */
 
  #include "qemu/osdep.h"
+#include "qemu/units.h"
  #include "qemu/error-report.h"
  #include "hw/arm/pxa.h"
  #include "net/net.h"
@@ -45,18 +46,14 @@
  #include "sysemu/qtest.h"
  #include "cpu.h"
 
-static const int sector_len = 128 * 1024;
+static const int sector_len = 128 * KiB;
 
  static void connex_init(MachineState *machine)
  {
      PXA2xxState *cpu;
      DriveInfo *dinfo;
-    MemoryRegion *address_space_mem = get_system_memory();
 
-    uint32_t connex_rom = 0x01000000;
-    uint32_t connex_ram = 0x04000000;
-
-    cpu = pxa255_init(address_space_mem, connex_ram);
+    cpu = pxa255_init(get_system_memory(), 64 * MiB);
 
      dinfo = drive_get(IF_PFLASH, 0, 0);
      if (!dinfo && !qtest_enabled()) {

hw/arm/gumstix.c static void connex_init(MachineState *machine) · line 69

Quoted 9 lines
hw/arm/gumstix.c +2 -1
@@ -65,7 +62,8 @@ static void connex_init(MachineState *machine)
          exit(1);
      }
 
-    if (!pflash_cfi01_register(0x00000000, "connext.rom", connex_rom,
+    /* Numonyx RC28F128J3F75 */
+    if (!pflash_cfi01_register(0x00000000, "connext.rom", 16 * MiB,
                                 dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
                                 sector_len, 2, 0, 0, 0, 0, 0)) {
          error_report("Error registering flash memory");

Previously the variable names were helpfully acting as a bit of documentation of what the 64MB and 16MB things were. Perhaps we could instead have

Quoted 4 lines

#define CONNEX_ROM_SIZE (16 * MiB)
#define CONNEX_RAM_SIZE (64 * MiB)

and then use those?

OK.

FYI long term plan for the pflash API is to use a white-list of tested flash models, and restrict models when boards have flash soldered.

Quoted 42 lines
Quoted 16 lines
hw/arm/gumstix.c +1 -5
@@ -81,12 +79,8 @@ static void verdex_init(MachineState *machine)
  {
      PXA2xxState *cpu;
      DriveInfo *dinfo;
-    MemoryRegion *address_space_mem = get_system_memory();
 
-    uint32_t verdex_rom = 0x02000000;
-    uint32_t verdex_ram = 0x10000000;
-
-    cpu = pxa270_init(address_space_mem, verdex_ram, machine->cpu_type);
+    cpu = pxa270_init(get_system_memory(), 256 * MiB, machine->cpu_type);
 
      dinfo = drive_get(IF_PFLASH, 0, 0);
      if (!dinfo && !qtest_enabled()) {

hw/arm/gumstix.c static void verdex_init(MachineState *machine) · line 96

Quoted 9 lines
hw/arm/gumstix.c +2 -1
@@ -95,7 +89,8 @@ static void verdex_init(MachineState *machine)
          exit(1);
      }
 
-    if (!pflash_cfi01_register(0x00000000, "verdex.rom", verdex_rom,
+    /* Micron RC28F256P30TFA */
+    if (!pflash_cfi01_register(0x00000000, "verdex.rom", 32 * MiB,
                                 dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
                                 sector_len, 2, 0, 0, 0, 0, 0)) {
          error_report("Error registering flash memory");

Similarly here.

hw/arm/gumstix.c static void verdex_class_init(ObjectClass *oc, void *data)

Quoted 10 lines
hw/arm/gumstix.c +1 -2
@@ -126,7 +121,7 @@ static void verdex_class_init(ObjectClass *oc, void *data)
  {
      MachineClass *mc = MACHINE_CLASS(oc);
 
-    mc->desc = "Gumstix Verdex (PXA270)";
+    mc->desc = "Gumstix Verdex Pro XL6P COMs (PXA270)";
      mc->init = verdex_init;
      mc->ignore_memory_transaction_failures = true;
      mc->default_cpu_type = ARM_CPU_TYPE_NAME("pxa270-c0");
--

thanks
-- PMM