From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47705) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X0Uho-0003Lq-9N for qemu-devel@nongnu.org; Fri, 27 Jun 2014 07:52:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X0Uhf-00085x-2G for qemu-devel@nongnu.org; Fri, 27 Jun 2014 07:52:36 -0400 From: Alexander Graf Date: Fri, 27 Jun 2014 13:52:12 +0200 Message-Id: <1403869944-31927-21-git-send-email-agraf@suse.de> In-Reply-To: <1403869944-31927-1-git-send-email-agraf@suse.de> References: <1403869944-31927-1-git-send-email-agraf@suse.de> Subject: [Qemu-devel] [PULL 20/32] spapr: Add rtas_st_buffer utility function List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-ppc@nongnu.org Cc: peter.maydell@linaro.org, qemu-devel@nongnu.org, Sam bobroff From: Sam bobroff 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 Signed-off-by: Alexander Graf --- include/hw/ppc/spapr.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h index f71d7de..25ca87f 100644 --- a/include/hw/ppc/spapr.h +++ b/include/hw/ppc/spapr.h @@ -412,6 +412,19 @@ 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) +{ + if (phys_len < 2) { + return; + } + stw_be_phys(&address_space_memory, + ppc64_phys_to_real(phys), buffer_len); + cpu_physical_memory_write(ppc64_phys_to_real(phys + 2), + buffer, MIN(buffer_len, phys_len - 2)); +} + typedef void (*spapr_rtas_fn)(PowerPCCPU *cpu, sPAPREnvironment *spapr, uint32_t token, uint32_t nargs, target_ulong args, -- 1.8.1.4