All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
To: qemu-devel@nongnu.org
Cc: "Peter Maydell" <peter.maydell@linaro.org>,
	"Thomas Huth" <thuth@redhat.com>,
	"Aleksandar Rikalo" <arikalo@wavecomp.com>,
	"Philippe Mathieu-Daudé" <f4bug@amsat.org>,
	"Hervé Poussineau" <hpoussin@reactos.org>,
	"Artyom Tarasenko" <atar4qemu@gmail.com>,
	"Aleksandar Markovic" <amarkovic@wavecomp.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Aurelien Jarno" <aurelien@aurel32.net>
Subject: [Qemu-devel] [PATCH 08/10] hw/mips/gt64xxx_pci: Add a 'cpu_big_endian' qdev property
Date: Tue, 25 Jun 2019 00:28:42 +0200	[thread overview]
Message-ID: <20190624222844.26584-9-f4bug@amsat.org> (raw)
In-Reply-To: <20190624222844.26584-1-f4bug@amsat.org>

This device does not have to be TARGET-dependent.
Add a 'cpu_big_endian' property which sets the byte-swapping
options if required.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
I might change my mind and name it 'little_endian' to be closer
to the datasheet.
---
 include/hw/mips/mips.h |  2 +-
 hw/mips/gt64xxx_pci.c  | 29 +++++++++++++----------------
 hw/mips/mips_malta.c   |  2 +-
 3 files changed, 15 insertions(+), 18 deletions(-)

diff --git a/include/hw/mips/mips.h b/include/hw/mips/mips.h
index 2f6774d540..6ec41d33f1 100644
--- a/include/hw/mips/mips.h
+++ b/include/hw/mips/mips.h
@@ -9,7 +9,7 @@
 #include "hw/irq.h"
 
 /* gt64xxx.c */
-PCIBus *gt64120_register(qemu_irq *pic);
+PCIBus *gt64120_create(qemu_irq *pic, bool target_is_bigendian);
 
 /* bonito.c */
 PCIBus *bonito_init(qemu_irq *pic);
diff --git a/hw/mips/gt64xxx_pci.c b/hw/mips/gt64xxx_pci.c
index 2fa313f498..5209038ee5 100644
--- a/hw/mips/gt64xxx_pci.c
+++ b/hw/mips/gt64xxx_pci.c
@@ -240,6 +240,7 @@ typedef struct GT64120State {
     PCI_MAPPING_ENTRY(ISD);
     MemoryRegion pci0_mem;
     AddressSpace pci0_mem_as;
+    bool cpu_big_endian;
 } GT64120State;
 
 /* Adjust range to avoid touching space which isn't mappable via PCI */
@@ -1028,15 +1029,12 @@ static void gt64120_pci_set_irq(void *opaque, int irq_num, int level)
 static void gt64120_reset(DeviceState *dev)
 {
     GT64120State *s = GT64120_PCI_HOST_BRIDGE(dev);
+    const uint32_t pci_cmd = s->cpu_big_endian ? 0x00000000 : 0x00010001;
 
     /* FIXME: Malta specific hw assumptions ahead */
 
     /* CPU Configuration */
-#ifdef TARGET_WORDS_BIGENDIAN
-    s->regs[GT_CPU]           = 0x00000000;
-#else
-    s->regs[GT_CPU]           = 0x00001000;
-#endif
+    s->regs[GT_CPU]           = !s->cpu_big_endian << 12;
     s->regs[GT_MULTI]         = 0x00000003;
 
     /* CPU Address decode */
@@ -1143,11 +1141,7 @@ static void gt64120_reset(DeviceState *dev)
     s->regs[GT_TC_CONTROL]    = 0x00000000;
 
     /* PCI Internal */
-#ifdef TARGET_WORDS_BIGENDIAN
-    s->regs[GT_PCI0_CMD]      = 0x00000000;
-#else
-    s->regs[GT_PCI0_CMD]      = 0x00010001;
-#endif
+    s->regs[GT_PCI0_CMD]      = pci_cmd;
     s->regs[GT_PCI0_TOR]      = 0x0000070f;
     s->regs[GT_PCI0_BS_SCS10] = 0x00fff000;
     s->regs[GT_PCI0_BS_SCS32] = 0x00fff000;
@@ -1164,11 +1158,7 @@ static void gt64120_reset(DeviceState *dev)
     s->regs[GT_PCI0_SSCS10_BAR] = 0x00000000;
     s->regs[GT_PCI0_SSCS32_BAR] = 0x01000000;
     s->regs[GT_PCI0_SCS3BT_BAR] = 0x1f000000;
-#ifdef TARGET_WORDS_BIGENDIAN
-    s->regs[GT_PCI1_CMD]      = 0x00000000;
-#else
-    s->regs[GT_PCI1_CMD]      = 0x00010001;
-#endif
+    s->regs[GT_PCI1_CMD]      = pci_cmd;
     s->regs[GT_PCI1_TOR]      = 0x0000070f;
     s->regs[GT_PCI1_BS_SCS10] = 0x00fff000;
     s->regs[GT_PCI1_BS_SCS32] = 0x00fff000;
@@ -1193,13 +1183,14 @@ static void gt64120_reset(DeviceState *dev)
     gt64120_pci_mapping(s);
 }
 
-PCIBus *gt64120_register(qemu_irq *pic)
+PCIBus *gt64120_create(qemu_irq *pic, bool target_is_bigendian)
 {
     GT64120State *d;
     PCIHostState *phb;
     DeviceState *dev;
 
     dev = qdev_create(NULL, TYPE_GT64120_PCI_HOST_BRIDGE);
+    qdev_prop_set_bit(dev, "cpu_big_endian", target_is_bigendian);
     d = GT64120_PCI_HOST_BRIDGE(dev);
     phb = PCI_HOST_BRIDGE(dev);
     memory_region_init(&d->pci0_mem, OBJECT(dev), "pci0-mem", 4 * GiB);
@@ -1262,6 +1253,11 @@ static const TypeInfo gt64120_pci_info = {
     },
 };
 
+static Property gt64120_properties[] = {
+    DEFINE_PROP_BOOL("cpu_big_endian", GT64120State, cpu_big_endian, true),
+    DEFINE_PROP_END_OF_LIST(),
+};
+
 static void gt64120_class_init(ObjectClass *klass, void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(klass);
@@ -1269,6 +1265,7 @@ static void gt64120_class_init(ObjectClass *klass, void *data)
     set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
     dc->reset = gt64120_reset;
     dc->vmsd = &vmstate_gt64120;
+    dc->props = gt64120_properties;
 }
 
 static const TypeInfo gt64120_info = {
diff --git a/hw/mips/mips_malta.c b/hw/mips/mips_malta.c
index 51db5212be..97f8ffbf1b 100644
--- a/hw/mips/mips_malta.c
+++ b/hw/mips/mips_malta.c
@@ -1375,7 +1375,7 @@ void mips_malta_init(MachineState *machine)
     isa_irq = qemu_irq_proxy(&s->i8259, 16);
 
     /* Northbridge */
-    pci_bus = gt64120_register(isa_irq);
+    pci_bus = gt64120_create(isa_irq, be);
 
     /* Southbridge */
     ide_drive_get(hd, ARRAY_SIZE(hd));
-- 
2.19.1



  parent reply	other threads:[~2019-06-24 22:35 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-24 22:28 [Qemu-devel] [PATCH 00/10] hw/pci-host: Clean the GT64120 north bridge Philippe Mathieu-Daudé
2019-06-24 22:28 ` [Qemu-devel] [PATCH 01/10] hw/mips/gt64xxx_pci: Fix multiline comment syntax Philippe Mathieu-Daudé
2019-06-25  0:20   ` Aleksandar Markovic
2019-06-24 22:28 ` [Qemu-devel] [PATCH 02/10] hw/mips/gt64xxx_pci: Fix 'tabs' coding style issues Philippe Mathieu-Daudé
2019-06-25  0:21   ` Aleksandar Markovic
2019-06-24 22:28 ` [Qemu-devel] [PATCH 03/10] hw/mips/gt64xxx_pci: Fix 'braces' " Philippe Mathieu-Daudé
2019-06-25  0:22   ` Aleksandar Markovic
2019-06-24 22:28 ` [Qemu-devel] [PATCH 04/10] hw/mips/gt64xxx_pci: Fix 'spaces' " Philippe Mathieu-Daudé
2019-06-25  0:23   ` Aleksandar Markovic
2019-06-24 22:28 ` [Qemu-devel] [PATCH 05/10] hw/mips/gt64xxx_pci: Use qemu_log_mask() instead of debug printf() Philippe Mathieu-Daudé
2019-06-25  0:37   ` Aleksandar Markovic
2019-06-25  7:14     ` Philippe Mathieu-Daudé
2019-06-25 18:16   ` Aleksandar Markovic
2019-06-24 22:28 ` [Qemu-devel] [PATCH 06/10] hw/mips/gt64xxx_pci: Convert debug printf()s to trace events Philippe Mathieu-Daudé
2019-06-25  0:40   ` Aleksandar Markovic
2019-06-25 10:00     ` Philippe Mathieu-Daudé
2019-06-25 18:17   ` Aleksandar Markovic
2019-06-24 22:28 ` [Qemu-devel] [PATCH 07/10] hw/mips/gt64xxx_pci: Align the pci0-mem size Philippe Mathieu-Daudé
2019-06-25  0:43   ` Aleksandar Markovic
2019-06-25  7:41     ` Philippe Mathieu-Daudé
2019-06-24 22:28 ` Philippe Mathieu-Daudé [this message]
2019-06-24 22:28 ` [Qemu-devel] [PATCH 09/10] hw/mips/gt64xxx_pci: Move it to hw/pci-host/ Philippe Mathieu-Daudé
2019-06-24 22:28 ` [Qemu-devel] [RFC PATCH 10/10] hw/pci-host/gt64120: Clean the decoded address space Philippe Mathieu-Daudé
2019-07-01 18:06   ` Philippe Mathieu-Daudé
2019-07-01 18:06     ` [Qemu-devel] " Philippe Mathieu-Daudé
2019-07-17 20:58     ` Paul Burton
2019-07-17 20:58       ` [Qemu-devel] " Paul Burton
2019-07-01 17:16 ` [Qemu-devel] [PATCH 00/10] hw/pci-host: Clean the GT64120 north bridge Aleksandar Markovic
2019-07-01 17:45   ` Philippe Mathieu-Daudé
2019-07-01 18:39     ` Aleksandar Markovic
2019-07-02  8:50       ` Philippe Mathieu-Daudé

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190624222844.26584-9-f4bug@amsat.org \
    --to=f4bug@amsat.org \
    --cc=amarkovic@wavecomp.com \
    --cc=arikalo@wavecomp.com \
    --cc=atar4qemu@gmail.com \
    --cc=aurelien@aurel32.net \
    --cc=hpoussin@reactos.org \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=thuth@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.