qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Sam Bobroff <sam.bobroff@au1.ibm.com>
To: qemu-devel@nongnu.org
Cc: qemu-ppc@nongnu.org
Subject: [Qemu-devel] [PATCH 1/4] spapr: Add rtas_st_buffer utility function
Date: Tue, 24 Jun 2014 10:22:45 +1000	[thread overview]
Message-ID: <53A8C4D5.8010200@au1.ibm.com> (raw)
In-Reply-To: <cover.1403569210.git.sam.bobroff@au1.ibm.com>

Add a function to write lengh + data into a buffer as required for the
emulation of the RTAS ibm,get-system-parameter call.

If the destination is smaller than the source, the write is truncated
and success is returned. This matches the behaviour of pHyp.

This will be used in following patches.

Signed-off-by: Sam Bobroff <sam.bobroff@au1.ibm.com>
---
 include/hw/ppc/spapr.h | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h
index 08c301f..39a7764 100644
--- a/include/hw/ppc/spapr.h
+++ b/include/hw/ppc/spapr.h
@@ -373,6 +373,23 @@ static inline void rtas_st(target_ulong phys, int n, uint32_t val)
     stl_be_phys(&address_space_memory, ppc64_phys_to_real(phys + 4*n), val);
 }
 
+
+static inline void rtas_st_buffer(target_ulong phys, target_ulong phys_len,
+                                  uint8_t *buffer, uint16_t buffer_len)
+{
+    uint16_t i;
+
+    if (phys_len < 2) {
+        return;
+    }
+    stw_be_phys(&address_space_memory,
+                ppc64_phys_to_real(phys), buffer_len);
+    for (i = 0; i < MIN(buffer_len, phys_len - 2); i++) {
+        stb_phys(&address_space_memory,
+                 ppc64_phys_to_real(phys + 2 + i), buffer[i]);
+    }
+}
+
 typedef void (*spapr_rtas_fn)(PowerPCCPU *cpu, sPAPREnvironment *spapr,
                               uint32_t token,
                               uint32_t nargs, target_ulong args,
-- 
1.9.0

       reply	other threads:[~2014-06-24  0:23 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <cover.1403569210.git.sam.bobroff@au1.ibm.com>
2014-06-24  0:22 ` Sam Bobroff [this message]
2014-06-24 11:51   ` [Qemu-devel] [Qemu-ppc] [PATCH 1/4] spapr: Add rtas_st_buffer utility function Alexander Graf
2014-06-24  0:22 ` [Qemu-devel] [PATCH 2/4] spapr: Add RTAS sysparm UUID Sam Bobroff
2014-06-24  0:22 ` [Qemu-devel] [PATCH 3/4] spapr: Fix RTAS sysparm DIAGNOSTICS_RUN_MODE Sam Bobroff
2014-06-24 11:58   ` [Qemu-devel] [Qemu-ppc] " Alexander Graf
2014-06-24 12:02     ` Alexander Graf
2014-06-24  0:22 ` [Qemu-devel] [PATCH 4/4] spapr: Add RTAS sysparm SPLPAR Characteristics Sam Bobroff
2014-06-24 12:03   ` [Qemu-devel] [Qemu-ppc] " Alexander Graf

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=53A8C4D5.8010200@au1.ibm.com \
    --to=sam.bobroff@au1.ibm.com \
    --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).