target-ppc: Adding Functionality to rtas_ibm_get_system_parameter.
PATCH 1/1 target-ppc: Adding Functionality to rtas_ibm_get_system_parameter.
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.
--- hw/ppc/spapr_rtas.c | 34 ++++++++++++++++++++++++++++++++++ include/hw/ppc/spapr.h | 12 ++++++++++++ 2 files changed, 46 insertions(+)
hw/ppc/spapr_rtas.c +34 -0
@@ -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,36 @@ 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 =calloc (length,1 ); + +/* 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)); + +/* Copy the string into buffer using rtas_st_buffer to +* convert the addresses. */ + +rtas_st_buffer (buffer, length, (uint8_t *)local_buffer); + +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);
include/hw/ppc/spapr.h +12 -0
@@ -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); } +/* 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,
Signature · 1 line
1.8.3.1
Hi,
Am 14.03.2014 17:10, schrieb Tomo Berry:
Quoted 4 lines
This patch adds the functionality for
rtas_ibm_get_system_parameterto return a string containing the values forpartition_max_entitled_capacityandsystem_potential_processors.
Unintentionally indented?
Quoted 30 lines
Signed-off-by Tomo Berry <[email protected]>--- hw/ppc/spapr_rtas.c | 34 ++++++++++++++++++++++++++++++++++ include/hw/ppc/spapr.h | 12 ++++++++++++ 2 files changed, 46 insertions(+)hw/ppc/spapr_rtas.c +4
-0@@ -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 :
hw/ppc/spapr_rtas.c static void rtas_ibm_get_system_parameter(PowerPCCPU *cpu, · line 255
Quoted 8 lines
hw/ppc/spapr_rtas.c +5
-0@@ -244,6 +248,36 @@ 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 =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.
hw/ppc/spapr_rtas.c static void rtas_ibm_get_system_parameter(PowerPCCPU *cpu, · line 259
Quoted 4 lines
hw/ppc/spapr_rtas.c +4
-0+ +/* 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. */
*/ is preferred to make clear where the comment ends.
hw/ppc/spapr_rtas.c static void rtas_ibm_get_system_parameter(PowerPCCPU *cpu, · line 265
Quoted 6 lines
hw/ppc/spapr_rtas.c +6
-0+ + ((uint16_t *)local_buffer)[0 ] =cpu_to_be16 (snprintf (local_buffer +2 , + length -2 ,"MaxEntCap=%d,MaxPlatProcs=%d" , max_cpus, smp_cpus)); + +/* Copy the string into buffer using rtas_st_buffer to +* convert the addresses. */
Is this comment really needed? :)
hw/ppc/spapr_rtas.c static void rtas_ibm_get_system_parameter(PowerPCCPU *cpu, · line 269
Quoted 4 lines
hw/ppc/spapr_rtas.c +4
-0+ +rtas_st_buffer (buffer, length, (uint8_t *)local_buffer); + +free (local_buffer);
g_free() then.
Quoted 19 lines
hw/ppc/spapr_rtas.c +11
-0+ 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);include/hw/ppc/spapr.h +0
-0
include/hw/ppc/spapr.h static inline void rtas_st(target_ulong phys, int n, uint32_t val) · line 364
Quoted 9 lines
include/hw/ppc/spapr.h +6
-0@@ -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); } +/* 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.
include/hw/ppc/spapr.h static inline void rtas_st(target_ulong phys, int n, uint32_t val) · line 373
Quoted 9 lines
include/hw/ppc/spapr.h +6
-0+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,
Am I interpreting correctly that this is 2.1 material?
Regards,
Andreas
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg