From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57145) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WQRi0-0001JC-4S for qemu-devel@nongnu.org; Wed, 19 Mar 2014 21:23:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WQRhs-0004rG-QF for qemu-devel@nongnu.org; Wed, 19 Mar 2014 21:23:48 -0400 Received: from cantor2.suse.de ([195.135.220.15]:60566 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WQRhs-0004rA-7A for qemu-devel@nongnu.org; Wed, 19 Mar 2014 21:23:40 -0400 Message-ID: <532A431A.5030508@suse.de> Date: Thu, 20 Mar 2014 02:23:38 +0100 From: =?ISO-8859-15?Q?Andreas_F=E4rber?= MIME-Version: 1.0 References: <1394813401-8953-1-git-send-email-tbberry@us.ibm.com> In-Reply-To: <1394813401-8953-1-git-send-email-tbberry@us.ibm.com> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH 1/1] target-ppc: Adding Functionality to rtas_ibm_get_system_parameter. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Tomo Berry , qemu-devel@nongnu.org Cc: Mike Day , Alexey Kardashevskiy , Greg Kurz Hi, Am 14.03.2014 17:10, schrieb Tomo Berry: > This patch adds the functionality for=20 > rtas_ibm_get_system_parameter to return a string containing=20 > the values for partition_max_entitled_capacity and=20 > system_potential_processors. Unintentionally indented? >=20 > Signed-off-by: Tomo Berry > --- > hw/ppc/spapr_rtas.c | 34 ++++++++++++++++++++++++++++++++++ > include/hw/ppc/spapr.h | 12 ++++++++++++ > 2 files changed, 46 insertions(+) >=20 > diff --git a/hw/ppc/spapr_rtas.c b/hw/ppc/spapr_rtas.c > index 1cb276d..931ba06 100644 > --- a/hw/ppc/spapr_rtas.c > +++ b/hw/ppc/spapr_rtas.c > @@ -225,6 +225,9 @@ static void rtas_stop_self(PowerPCCPU *cpu, sPAPREn= vironment *spapr, > } > =20 > #define DIAGNOSTICS_RUN_MODE 42 > +#define SPLPAR_CHARACTERISTICS_TOKEN 20 > +#define CMO_CHARACTERISTICS_TOKEN 44 > +#define CEDE_LATENCY_TOKEN 45 > =20 > static void rtas_ibm_get_system_parameter(PowerPCCPU *cpu, > sPAPREnvironment *spapr, > @@ -236,6 +239,7 @@ static void rtas_ibm_get_system_parameter(PowerPCCP= U *cpu, > target_ulong buffer =3D rtas_ld(args, 1); > target_ulong length =3D rtas_ld(args, 2); > target_ulong ret =3D RTAS_OUT_NOT_SUPPORTED; > + char *local_buffer; > =20 > switch (parameter) { > case DIAGNOSTICS_RUN_MODE: > @@ -244,6 +248,36 @@ static void rtas_ibm_get_system_parameter(PowerPCC= PU *cpu, > ret =3D RTAS_OUT_SUCCESS; > } > break; > + case SPLPAR_CHARACTERISTICS_TOKEN: > + > + /* Create a string of length bytes locally to copy to buffer = */ > + > + local_buffer =3D calloc(length, 1); Please use GLib allocation functions exclusively, e.g. g_malloc(length), in particular with regards to handling out-of-memory situations. calloc() might return NULL, g_{malloc,new}() will abort. > + > + /* These are the current system parameters supported. The fi= rst > + * 16 bits of the buffer must contain the length of the strin= g. > + * These 16 bits are not included in the length of the string= . */ */ is preferred to make clear where the comment ends. > + > + ((uint16_t *)local_buffer)[0] =3D cpu_to_be16(snprintf(local_b= uffer + 2, > + length - 2, "MaxEntCap=3D%d,MaxPlatProcs=3D%d", max_cpus,= smp_cpus)); > + > + /* Copy the string into buffer using rtas_st_buffer to > + * convert the addresses. */ Is this comment really needed? :) > + > + rtas_st_buffer(buffer, length, (uint8_t *)local_buffer); > + > + free(local_buffer); g_free() then. > + ret =3D RTAS_OUT_SUCCESS; > + break; > + case CMO_CHARACTERISTICS_TOKEN: > + ret =3D RTAS_OUT_NOT_SUPPORTED; > + break; > + case CEDE_LATENCY_TOKEN: > + ret =3D RTAS_OUT_NOT_SUPPORTED; > + break; > + default: > + ret =3D RTAS_OUT_NOT_SUPPORTED; > + break; > } > =20 > rtas_st(rets, 0, ret); > diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h > index b2f11e9..ee6ed2d 100644 > --- a/include/hw/ppc/spapr.h > +++ b/include/hw/ppc/spapr.h > @@ -356,6 +356,18 @@ static inline void rtas_st(target_ulong phys, int = n, uint32_t val) > stl_be_phys(ppc64_phys_to_real(phys + 4*n), val); > } > =20 > +/* 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) { { on new line please. > + uint32_t i; > + for (i =3D 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, Am I interpreting correctly that this is 2.1 material? Regards, Andreas --=20 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 N=FCrnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imend=F6rffer; HRB 16746 AG N=FCrnbe= rg