From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37604) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WzEVw-0001lo-GP for qemu-devel@nongnu.org; Mon, 23 Jun 2014 20:23:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WzEVl-00044Q-9h for qemu-devel@nongnu.org; Mon, 23 Jun 2014 20:23:08 -0400 Received: from e23smtp03.au.ibm.com ([202.81.31.145]:43618) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WzEVk-00043L-GH for qemu-devel@nongnu.org; Mon, 23 Jun 2014 20:22:57 -0400 Received: from /spool/local by e23smtp03.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 24 Jun 2014 10:22:49 +1000 Message-ID: <53A8C4D5.8010200@au1.ibm.com> Date: Tue, 24 Jun 2014 10:22:45 +1000 From: Sam Bobroff MIME-Version: 1.0 References: In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] [PATCH 1/4] spapr: Add rtas_st_buffer utility function List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: qemu-ppc@nongnu.org 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 --- 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