From patchwork Thu Mar 20 21:17:33 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomohiro B Berry X-Patchwork-Id: 332389 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 032792C00A1 for ; Fri, 21 Mar 2014 08:18:03 +1100 (EST) Received: from localhost ([::1]:49467 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WQkLg-0001gA-MZ for incoming@patchwork.ozlabs.org; Thu, 20 Mar 2014 17:18:00 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60090) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WQkLL-0001fu-Kd for qemu-devel@nongnu.org; Thu, 20 Mar 2014 17:17:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WQkLF-0000qZ-LQ for qemu-devel@nongnu.org; Thu, 20 Mar 2014 17:17:39 -0400 Received: from [32.97.110.56] (port=58889 helo=venice.austin.ibm.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WQkLF-0000qS-BJ for qemu-devel@nongnu.org; Thu, 20 Mar 2014 17:17:33 -0400 Received: from venice.austin.ibm.com (localhost [127.0.0.1]) by venice.austin.ibm.com (8.14.7/8.14.7) with ESMTP id s2KLHaBJ041982; Thu, 20 Mar 2014 17:17:37 -0400 Received: (from tbberry@localhost) by venice.austin.ibm.com (8.14.7/8.14.7/Submit) id s2KLHaAO041980; Thu, 20 Mar 2014 17:17:36 -0400 From: Tomo Berry To: qemu-devel@nongnu.org Date: Thu, 20 Mar 2014 17:17:33 -0400 Message-Id: <1395350253-41886-1-git-send-email-tbberry@us.ibm.com> X-Mailer: git-send-email 1.8.3.1 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 32.97.110.56 Cc: Tomo Berry Subject: [Qemu-devel] [PATCH 1/1 V2] target-ppc: Adding Functionality to rtas_ibm_get_system_parameter. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org This patch adds the functionality for rtas_ibm_get_system_parameter to return a string containing the values for partition_max_entitled_capacity and system_potential_processors. Signed-off-by: Tomo Berry --- V1->V2: changed memory allocation to glib calls I'm not sure if this is meant for 2.1 or not hw/ppc/spapr_rtas.c | 32 ++++++++++++++++++++++++++++++++ include/hw/ppc/spapr.h | 13 +++++++++++++ 2 files changed, 45 insertions(+) diff --git a/hw/ppc/spapr_rtas.c b/hw/ppc/spapr_rtas.c index 1cb276d..734ebc0 100644 --- a/hw/ppc/spapr_rtas.c +++ b/hw/ppc/spapr_rtas.c @@ -225,6 +225,9 @@ static void rtas_stop_self(PowerPCCPU *cpu, sPAPREnvironment *spapr, } #define DIAGNOSTICS_RUN_MODE 42 +#define SPLPAR_CHARACTERISTICS_TOKEN 20 +#define CMO_CHARACTERISTICS_TOKEN 44 +#define CEDE_LATENCY_TOKEN 45 static void rtas_ibm_get_system_parameter(PowerPCCPU *cpu, sPAPREnvironment *spapr, @@ -236,6 +239,7 @@ static void rtas_ibm_get_system_parameter(PowerPCCPU *cpu, target_ulong buffer = rtas_ld(args, 1); target_ulong length = rtas_ld(args, 2); target_ulong ret = RTAS_OUT_NOT_SUPPORTED; + char *local_buffer; switch (parameter) { case DIAGNOSTICS_RUN_MODE: @@ -244,6 +248,34 @@ static void rtas_ibm_get_system_parameter(PowerPCCPU *cpu, ret = RTAS_OUT_SUCCESS; } break; + case SPLPAR_CHARACTERISTICS_TOKEN: + + /* Create a string of length bytes locally to copy to buffer */ + + local_buffer = g_malloc0(length); + + /* These are the current system parameters supported. The first + * 16 bits of the buffer must contain the length of the string. + * These 16 bits are not included in the length of the string. + */ + + ((uint16_t *)local_buffer)[0] = cpu_to_be16(snprintf(local_buffer + 2, + length - 2, "MaxEntCap=%d,MaxPlatProcs=%d", max_cpus, smp_cpus)); + + rtas_st_buffer(buffer, length, (uint8_t *)local_buffer); + + g_free(local_buffer); + ret = RTAS_OUT_SUCCESS; + break; + case CMO_CHARACTERISTICS_TOKEN: + ret = RTAS_OUT_NOT_SUPPORTED; + break; + case CEDE_LATENCY_TOKEN: + ret = RTAS_OUT_NOT_SUPPORTED; + break; + default: + ret = RTAS_OUT_NOT_SUPPORTED; + break; } rtas_st(rets, 0, ret); diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h index b2f11e9..bf5b528 100644 --- a/include/hw/ppc/spapr.h +++ b/include/hw/ppc/spapr.h @@ -356,6 +356,19 @@ static inline void rtas_st(target_ulong phys, int n, uint32_t val) stl_be_phys(ppc64_phys_to_real(phys + 4*n), val); } +/* This function will store a buffer 1 byte at a time into the + * address at phys up to a maximum of phys_len bytes.*/ + +static inline void rtas_st_buffer(target_ulong phys, + target_ulong phys_len, + uint8_t *buffer) +{ + uint32_t i; + for (i = 0; i < phys_len; i++) { + stb_phys(ppc64_phys_to_real(phys + i), buffer[i]); + } +} + typedef void (*spapr_rtas_fn)(PowerPCCPU *cpu, sPAPREnvironment *spapr, uint32_t token, uint32_t nargs, target_ulong args,