qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Alexander Graf <agraf@suse.de>
To: qemu-ppc@nongnu.org
Cc: Alexey Kardashevskiy <aik@ozlabs.ru>,
	peter.maydell@linaro.org, qemu-devel@nongnu.org
Subject: [Qemu-devel] [PULL 13/52] spapr: Move DT memory node rendering to a helper
Date: Thu,  4 Sep 2014 19:20:01 +0200	[thread overview]
Message-ID: <1409851240-48126-14-git-send-email-agraf@suse.de> (raw)
In-Reply-To: <1409851240-48126-1-git-send-email-agraf@suse.de>

From: Alexey Kardashevskiy <aik@ozlabs.ru>

This moves recurring bits of code related to memory@xxx nodes
creation to a helper.

This makes use of the new helper for node@0.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: Alexander Graf <agraf@suse.de>
---
 hw/ppc/spapr.c | 48 ++++++++++++++++++++++++++++--------------------
 1 file changed, 28 insertions(+), 20 deletions(-)

diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 522ee27..28c8578 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -634,6 +634,31 @@ int spapr_h_cas_compose_response(target_ulong addr, target_ulong size)
     return 0;
 }
 
+static void spapr_populate_memory_node(void *fdt, int nodeid, hwaddr start,
+                                       hwaddr size)
+{
+    uint32_t associativity[] = {
+        cpu_to_be32(0x4), /* length */
+        cpu_to_be32(0x0), cpu_to_be32(0x0),
+        cpu_to_be32(nodeid), cpu_to_be32(nodeid)
+    };
+    char mem_name[32];
+    uint64_t mem_reg_property[2];
+    int off;
+
+    mem_reg_property[0] = cpu_to_be64(start);
+    mem_reg_property[1] = cpu_to_be64(size);
+
+    sprintf(mem_name, "memory@" TARGET_FMT_lx, start);
+    off = fdt_add_subnode(fdt, 0, mem_name);
+    _FDT(off);
+    _FDT((fdt_setprop_string(fdt, off, "device_type", "memory")));
+    _FDT((fdt_setprop(fdt, off, "reg", mem_reg_property,
+                      sizeof(mem_reg_property))));
+    _FDT((fdt_setprop(fdt, off, "ibm,associativity", associativity,
+                      sizeof(associativity))));
+}
+
 static int spapr_populate_memory(sPAPREnvironment *spapr, void *fdt)
 {
     uint32_t associativity[] = {cpu_to_be32(0x4), cpu_to_be32(0x0),
@@ -652,29 +677,12 @@ static int spapr_populate_memory(sPAPREnvironment *spapr, void *fdt)
     }
 
     /* RMA */
-    mem_reg_property[0] = 0;
-    mem_reg_property[1] = cpu_to_be64(spapr->rma_size);
-    off = fdt_add_subnode(fdt, 0, "memory@0");
-    _FDT(off);
-    _FDT((fdt_setprop_string(fdt, off, "device_type", "memory")));
-    _FDT((fdt_setprop(fdt, off, "reg", mem_reg_property,
-                      sizeof(mem_reg_property))));
-    _FDT((fdt_setprop(fdt, off, "ibm,associativity", associativity,
-                      sizeof(associativity))));
+    spapr_populate_memory_node(fdt, 0, 0, spapr->rma_size);
 
     /* RAM: Node 0 */
     if (node0_size > spapr->rma_size) {
-        mem_reg_property[0] = cpu_to_be64(spapr->rma_size);
-        mem_reg_property[1] = cpu_to_be64(node0_size - spapr->rma_size);
-
-        sprintf(mem_name, "memory@" TARGET_FMT_lx, spapr->rma_size);
-        off = fdt_add_subnode(fdt, 0, mem_name);
-        _FDT(off);
-        _FDT((fdt_setprop_string(fdt, off, "device_type", "memory")));
-        _FDT((fdt_setprop(fdt, off, "reg", mem_reg_property,
-                          sizeof(mem_reg_property))));
-        _FDT((fdt_setprop(fdt, off, "ibm,associativity", associativity,
-                          sizeof(associativity))));
+        spapr_populate_memory_node(fdt, 0, spapr->rma_size,
+                                   node0_size - spapr->rma_size);
     }
 
     /* RAM: Node 1 and beyond */
-- 
1.8.1.4

  parent reply	other threads:[~2014-09-04 17:21 UTC|newest]

Thread overview: 60+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-04 17:19 [Qemu-devel] [PULL 00/52] ppc patch queue 2014-09-04 Alexander Graf
2014-09-04 17:19 ` [Qemu-devel] [PULL 01/52] PPC: KVM: Fix g3beige and mac99 when HV is loaded Alexander Graf
2014-09-04 17:19 ` [Qemu-devel] [PULL 02/52] ppc: spapr-rtas - implement os-term rtas call Alexander Graf
2014-09-04 17:19 ` [Qemu-devel] [PULL 03/52] linux-user: Fix Stack Pointer Bug in PPC setup_rt_frame Alexander Graf
2014-09-04 17:19 ` [Qemu-devel] [PULL 04/52] linux-user: Split PPC Trampoline Encoding from Register Save Alexander Graf
2014-09-04 17:19 ` [Qemu-devel] [PULL 05/52] linux-user: Enable Signal Handlers on PPC64 Alexander Graf
2014-09-04 17:19 ` [Qemu-devel] [PULL 06/52] linux-user: Properly Dereference PPC64 ELFv1 Signal Handler Pointer Alexander Graf
2014-09-04 17:19 ` [Qemu-devel] [PULL 07/52] linux-user: Implement do_setcontext for PPC64 Alexander Graf
2014-09-04 17:19 ` [Qemu-devel] [PULL 08/52] linux-user: Handle PPC64 ELFv2 Function Pointers Alexander Graf
2014-09-04 17:19 ` [Qemu-devel] [PULL 09/52] hw/ppc/spapr_hcall.c: Fix typo in function names Alexander Graf
2014-09-04 17:19 ` [Qemu-devel] [PULL 10/52] spapr: add uuid/host details to device tree Alexander Graf
2014-09-04 17:19 ` [Qemu-devel] [PULL 11/52] PPC: mac99: Move NVRAM to page boundary when necessary Alexander Graf
2014-09-04 17:20 ` [Qemu-devel] [PULL 12/52] spapr: fix possible memory leak Alexander Graf
2014-09-04 17:20 ` Alexander Graf [this message]
2014-09-04 17:20 ` [Qemu-devel] [PULL 14/52] spapr: Use DT memory node rendering helper for other nodes Alexander Graf
2014-09-04 17:20 ` [Qemu-devel] [PULL 15/52] spapr: Refactor spapr_populate_memory() to allow memoryless nodes Alexander Graf
2014-09-04 17:20 ` [Qemu-devel] [PULL 16/52] spapr: Split memory nodes to power-of-two blocks Alexander Graf
2014-09-04 17:20 ` [Qemu-devel] [PULL 17/52] spapr: Add a helper for node0_size calculation Alexander Graf
2014-09-04 17:20 ` [Qemu-devel] [PULL 18/52] spapr: Fix ibm, associativity for memory nodes Alexander Graf
2014-09-04 17:20 ` [Qemu-devel] [PULL 19/52] loader: Add load_image_size() to replace load_image() Alexander Graf
2014-09-04 17:20 ` [Qemu-devel] [PULL 20/52] spapr: Locate RTAS and device-tree based on real RMA Alexander Graf
2014-09-04 17:20 ` [Qemu-devel] [PULL 21/52] ppc: debug stub: Get trap instruction opcode from KVM Alexander Graf
2014-09-04 17:20 ` [Qemu-devel] [PULL 22/52] ppc: synchronize excp_vectors for injecting exception Alexander Graf
2014-09-04 17:20 ` [Qemu-devel] [PULL 23/52] ppc: Add software breakpoint support Alexander Graf
2014-09-04 17:20 ` [Qemu-devel] [PULL 24/52] ppc: Add hw breakpoint watchpoint support Alexander Graf
2014-09-04 17:20 ` [Qemu-devel] [PULL 25/52] ppc/spapr: Fix MAX_CPUS to 255 Alexander Graf
2014-09-04 17:20 ` [Qemu-devel] [PULL 26/52] target-ppc: Bug Fix: rlwinm Alexander Graf
2014-09-04 17:20 ` [Qemu-devel] [PULL 27/52] target-ppc: Bug Fix: rlwnm Alexander Graf
2014-09-04 17:20 ` [Qemu-devel] [PULL 28/52] target-ppc: Bug Fix: rlwimi Alexander Graf
2014-09-04 17:20 ` [Qemu-devel] [PULL 29/52] target-ppc: Bug Fix: mullwo Alexander Graf
2014-09-04 17:20 ` [Qemu-devel] [PULL 30/52] target-ppc: Bug Fix: mullw Alexander Graf
2014-09-04 17:20 ` [Qemu-devel] [PULL 31/52] target-ppc: Bug Fix: mulldo OV Detection Alexander Graf
2014-09-04 17:20 ` [Qemu-devel] [PULL 32/52] target-ppc: Bug Fix: srawi Alexander Graf
2014-09-04 17:20 ` [Qemu-devel] [PULL 33/52] target-ppc: Bug Fix: srad Alexander Graf
2014-09-04 17:20 ` [Qemu-devel] [PULL 34/52] KVM: Add helper to run KVM_CHECK_EXTENSION on vm fd Alexander Graf
2014-09-04 17:20 ` [Qemu-devel] [PULL 35/52] PPC: KVM: Use vm check_extension for pv hcall Alexander Graf
2014-09-04 17:20 ` [Qemu-devel] [PULL 36/52] PPC: mac99: Fix core99 timer frequency Alexander Graf
2014-09-04 17:20 ` [Qemu-devel] [PULL 37/52] PPC: mac_nvram: Remove unused functions Alexander Graf
2014-09-04 17:20 ` [Qemu-devel] [PULL 38/52] PPC: mac_nvram: Allow 2 and 4 byte accesses Alexander Graf
2014-09-04 17:20 ` [Qemu-devel] [PULL 39/52] PPC: mac_nvram: Split NVRAM into OF and OSX parts Alexander Graf
2014-09-04 17:20 ` [Qemu-devel] [PULL 40/52] PPC: Mac: Move tbfreq into local variable Alexander Graf
2014-09-04 17:20 ` [Qemu-devel] [PULL 41/52] PPC: Cuda: Use cuda timer to expose tbfreq to guest Alexander Graf
2014-09-04 17:20 ` [Qemu-devel] [PULL 42/52] spapr_pci: Fix config space corruption Alexander Graf
2014-09-04 17:20 ` [Qemu-devel] [PULL 43/52] spapr-vlan: Don't touch last entry in buffer list Alexander Graf
2014-09-04 17:20 ` [Qemu-devel] [PULL 44/52] target-ppc: Special Case of rlwimi Should Use Deposit Alexander Graf
2014-09-04 17:20 ` [Qemu-devel] [PULL 45/52] target-ppc: Optimize rlwinm MB=0 ME=31 Alexander Graf
2014-09-04 17:20 ` [Qemu-devel] [PULL 46/52] target-ppc: Optimize rlwnm " Alexander Graf
2014-09-04 17:20 ` [Qemu-devel] [PULL 47/52] target-ppc: Clean Up mullw Alexander Graf
2014-09-04 17:20 ` [Qemu-devel] [PULL 48/52] target-ppc: Clean up mullwo Alexander Graf
2014-09-04 17:20 ` [Qemu-devel] [PULL 49/52] target-ppc: Implement mulldo with TCG Alexander Graf
2014-09-04 17:20 ` [Qemu-devel] [PULL 50/52] spapr_pci: map the MSI window in each PHB Alexander Graf
2014-09-04 17:20 ` [Qemu-devel] [PULL 51/52] PPC: Fix default config ordering and add eTSEC for ppc64 Alexander Graf
2014-09-04 17:20 ` [Qemu-devel] [PULL 52/52] hypervisor property clashes with hypervisor node Alexander Graf
2014-09-04 18:38 ` [Qemu-devel] [PULL 00/52] ppc patch queue 2014-09-04 Peter Maydell
2014-09-04 19:13   ` Alexander Graf
2014-09-04 19:53     ` [Qemu-devel] [Qemu-ppc] " Tom Musta
2014-09-04 22:17       ` Alexander Graf
2014-09-05 10:36         ` Peter Maydell
2014-09-08 10:52           ` Alexander Graf
2014-09-08 12:14             ` Peter Maydell

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=1409851240-48126-14-git-send-email-agraf@suse.de \
    --to=agraf@suse.de \
    --cc=aik@ozlabs.ru \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    /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 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).