From 4d6a99902a2a377a12dbef720fea81873fb920cc Mon Sep 17 00:00:00 2001 From: Andres Lugo-Reyes Date: Tue, 10 Jan 2017 07:35:12 -0600 Subject: [PATCH] WOF: Function to calculate the Active Quad step number Change-Id: I3acafe872623838fa2ad16e8c85288dddb275fb5 RTC: 130216 Depends-on: I2249777134608d9f79bdc85692a3acbf7907c3f5 Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/34657 Reviewed-by: William A. Bryan Tested-by: William A. Bryan --- src/occ_405/main.c | 38 +++++++++++++++++++++++++++++++++ src/occ_405/occ_service_codes.h | 4 ++++ src/occ_405/wof/wof.c | 19 ++++++++++++++++- src/occ_405/wof/wof.h | 13 +++++++---- 4 files changed, 69 insertions(+), 5 deletions(-) diff --git a/src/occ_405/main.c b/src/occ_405/main.c index e1ffd577..873e65dd 100755 --- a/src/occ_405/main.c +++ b/src/occ_405/main.c @@ -555,6 +555,44 @@ void read_wof_header(void) memcpy(&G_wof_header, &(l_temp_bce_buff.data[pad]), sizeof(wof_header_data_t)); + // Make sure the header is reporting a valid number of quads i.e. 1 or 6 + if( (G_wof_header.active_quads_size != ACTIVE_QUAD_SZ_MIN) && + (G_wof_header.active_quads_size != ACTIVE_QUAD_SZ_MAX) ) + { + CMDH_TRAC_ERR("read_wof_header: Invalid number of active quads!" + " Expected: 1 or 6, Actual %d", + G_wof_header.active_quads_size ); + + /* + * @errortype + * @moduleid READ_WOF_HEADER + * @reasoncode INVALID_ACTIVE_QUAD_COUNT + * @userdata1 Reported active quad count + * @devdesc Read an invalid number of active quads + */ + l_reasonCode = INVALID_ACTIVE_QUAD_COUNT; + l_extReasonCode = ERC_WOF_QUAD_COUNT_FAILURE; + errlHndl_t l_errl = createErrl(READ_WOF_HEADER, //modId + INVALID_ACTIVE_QUAD_COUNT, //reasoncode + ERC_WOF_QUAD_COUNT_FAILURE, //Extended reason code + ERRL_SEV_UNRECOVERABLE, //Severity + NULL, //Trace Buf + 0, //Trace Size + G_wof_header.active_quads_size, //userdata1 + 0); //userdata2 + + // Callout firmware + addCalloutToErrl(l_errl, + ERRL_CALLOUT_TYPE_COMPONENT_ID, + ERRL_COMPONENT_ID_FIRMWARE, + ERRL_CALLOUT_PRIORITY_HIGH); + + // Commit error log + commitErrl(&l_errl); + + // We were unable to get the active quad count. Do not run wof algo. + G_run_wof_main = false; + } }while( 0 ); diff --git a/src/occ_405/occ_service_codes.h b/src/occ_405/occ_service_codes.h index d1015820..0750cf19 100644 --- a/src/occ_405/occ_service_codes.h +++ b/src/occ_405/occ_service_codes.h @@ -59,6 +59,8 @@ enum occReasonCode SSX_GENERIC_FAILURE = 0x17, /// Failure to handshake with an external fw entity (HB, FSP, PHYP, etc) EXTERNAL_INTERFACE_FAILURE = 0x18, + /// Incorrect number of active quads reported + INVALID_ACTIVE_QUAD_COUNT = 0x19, /// VRM reached error threshold (VR_HOT asserted) VRM_ERROR_TEMP = 0x20, /// VR_FAN - AVS Bus over-temperature reported @@ -240,6 +242,8 @@ enum occExtReasonCode ERC_PGPE_SUSPEND_FAILURE = 0x00B6, ERC_PGPE_CLIP_FAILURE = 0x00B7, ERC_PGPE_PPMR_OPPB_SIZE_MISMATCH = 0x00B8, + + ERC_WOF_QUAD_COUNT_FAILURE = 0x00C0, }; // Error log Module Ids diff --git a/src/occ_405/wof/wof.c b/src/occ_405/wof/wof.c index f222359b..bad31b67 100644 --- a/src/occ_405/wof/wof.c +++ b/src/occ_405/wof/wof.c @@ -88,7 +88,7 @@ void wof_main(void) /** - * calculate_step + * calculate_step_from_start * * Description: Calculates the step number for the current VDN/VDD * @@ -135,3 +135,20 @@ uint16_t calculate_step_from_start(uint16_t i_ceff_vdx, return l_current_step; } + + +/** + * calc_quad_step_from_start + * + * Description: Calculates the step number for the current number + * of active quads + * + * Param[in]: i_num_active_quads - The current number of active quads. + * + * Return: The calculated step for current active quads + */ +uint8_t calc_quad_step_from_start( uint8_t i_num_active_quads ) +{ + return (G_wof_header.active_quads_size == ACTIVE_QUAD_SZ_MIN) ? 0 : + (i_num_active_quads - 1); +} diff --git a/src/occ_405/wof/wof.h b/src/occ_405/wof/wof.h index 6d3948d9..52a5ff0c 100644 --- a/src/occ_405/wof/wof.h +++ b/src/occ_405/wof/wof.h @@ -31,7 +31,8 @@ // Define //****************************************************************************** #define MIN_BCE_REQ_SIZE 256 - +#define ACTIVE_QUAD_SZ_MIN 1 +#define ACTIVE_QUAD_SZ_MAX 6 typedef struct __attribute__ ((packed)) { @@ -67,8 +68,12 @@ typedef struct void wof_main( void ); uint16_t calculate_step_from_start( uint16_t i_ceff_vdx, - uint8_t i_step_size, - uint8_t i_min_step, - uint8_t i_max_step ); + uint8_t i_step_size, + uint8_t i_min_step, + uint8_t i_max_step ); + +uint8_t calc_quad_step_from_start( uint8_t i_num_active_quads ); + + #endif