summaryrefslogtreecommitdiffstats
path: root/src/occ_405/wof
diff options
context:
space:
mode:
authorAndres Lugo-Reyes <aalugore@us.ibm.com>2016-12-19 16:07:30 -0600
committerWilliam A. Bryan <wilbryan@us.ibm.com>2017-02-01 11:06:24 -0500
commit009f439d2aa9df1944eb08b7f1fc30006abd8137 (patch)
tree719f526548b4c125984d45aeaa30051ae32c7afe /src/occ_405/wof
parent11bf85d22eed50613085dfea02c4df9e53e1a380 (diff)
downloadtalos-occ-009f439d2aa9df1944eb08b7f1fc30006abd8137.tar.gz
talos-occ-009f439d2aa9df1944eb08b7f1fc30006abd8137.zip
WOF: Function to calculate VDD/VDN step number
1. Calculate VDN/VDD step number 2. Extract the WOF header address from the PGPE header 3. Save important data from WOF header into global struct 4. Create global pointer struct to save important addresses to a pinned location in memory. Change-Id: I2249777134608d9f79bdc85692a3acbf7907c3f5 RTC:130216 Depends-on: Ic323321b8c66945732a6b7345ad85d6f41a62edd Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/34300 Tested-by: FSP CI Jenkins <fsp-CI-jenkins+hostboot@us.ibm.com> Reviewed-by: William A. Bryan <wilbryan@us.ibm.com>
Diffstat (limited to 'src/occ_405/wof')
-rw-r--r--src/occ_405/wof/wof.c106
-rw-r--r--src/occ_405/wof/wof.h40
2 files changed, 143 insertions, 3 deletions
diff --git a/src/occ_405/wof/wof.c b/src/occ_405/wof/wof.c
index 2adde1f..f222359 100644
--- a/src/occ_405/wof/wof.c
+++ b/src/occ_405/wof/wof.c
@@ -24,8 +24,114 @@
/* IBM_PROLOG_END_TAG */
#include <errl.h>
#include <trac.h>
+#include <sensor.h>
+#include <occhw_async.h>
#include "wof.h"
+//******************************************************************************
+// Globals
+//******************************************************************************
+uint32_t G_wof_active_quads_sram_addr;
+uint32_t G_wof_tables_main_mem_addr;
+uint32_t G_wof_tables_len;
+bool G_run_wof_main;
+wof_header_data_t G_wof_header __attribute__ ((section (".global_data")));
+
+
+/**
+ * wof_main
+ *
+ * Description: Main Wof algorithm
+ *
+ * Param: None
+ *
+ * Return: None
+ */
+void wof_main(void)
+{
+
+ // TODO Read out necessary Sensor data for WOF calculation
+ // uint16_t l_current_vdd = getSensorByGsid(CURVDD)->sample;
+ // uint16_t l_current_vdn = getSensorByGsid(CURVDN)->sample
+ // Functions to calculate Ceff_vdd and Ceff_vdn here.
+ uint16_t ceff_vdd = 0; // TODO: replace with future function call
+ uint16_t ceff_vdn = 0; // TODO: replace with future function call
+
+
+ // Calculate how many steps from the beginning for VDD and VDN
+ uint16_t vdn_step_from_start =
+ calculate_step_from_start( ceff_vdd,
+ G_wof_header.vdn_step,
+ G_wof_header.vdn_start,
+ G_wof_header.vdn_size );
+
+ uint16_t vdd_step_from_start =
+ calculate_step_from_start( ceff_vdn,
+ G_wof_header.vdd_step,
+ G_wof_header.vdd_start,
+ G_wof_header.vdd_size );
+
+ // TODO: REMOVE THESE TRACES
+ // NOTE to Reviewers: This trace is here just to put references to the above
+ // variables such that compilation is successful. Will be removed in final
+ // version
+ TRAC_INFO("Step from start VDN = %d, VDN = %d",
+ vdn_step_from_start,
+ vdd_step_from_start );
+
+
+
+}
+
+
+/**
+ * calculate_step
+ *
+ * Description: Calculates the step number for the current VDN/VDD
+ *
+ * Param[in]: i_ceff_vdx - The current Ceff_vdd or Ceff_vdn to calculate the step
+ * for.
+ * Param[in]: i_step_size - The size of each step.
+ * Param[in]: i_min_ceff - The minimum step number for this VDN/VDD
+ * Param[in]: i_max_step - The maximum step number for this VDN/VDD
+ *
+ * Return: The calculated step for current Ceff_vdd/Ceff_vdn
+ */
+uint16_t calculate_step_from_start(uint16_t i_ceff_vdx,
+ uint8_t i_step_size,
+ uint8_t i_min_ceff,
+ uint8_t i_max_step )
+{
+ uint16_t l_current_step;
+
+ // Ensure ceff is at least the min step
+ if( (i_ceff_vdx <= i_min_ceff) || (i_step_size == 0) )
+ {
+ l_current_step = 0;
+ }
+ else
+ {
+ // Add step size to current vdd/vdn to round up.
+ // -1 to prevent overshoot when i_ceff_vdx is equal to Ceff table value
+ l_current_step = i_ceff_vdx + i_step_size - 1;
+
+ // Subtract the starting ceff to skip the 0 table entry
+ l_current_step -= i_min_ceff;
+
+ // Divide by step size to determine how many from the 0 entry ceff is
+ l_current_step /= i_step_size;
+
+ // If the calculated step is greater than the max step, use max step
+ if( l_current_step >= i_max_step )
+ {
+ // Since function returns number of steps from start
+ // (first entry is 0 from start) subtract 1.
+ l_current_step = i_max_step-1;
+ }
+ }
+
+ return l_current_step;
+}
diff --git a/src/occ_405/wof/wof.h b/src/occ_405/wof/wof.h
index ba19383..6d3948d 100644
--- a/src/occ_405/wof/wof.h
+++ b/src/occ_405/wof/wof.h
@@ -27,14 +27,48 @@
-
-
//******************************************************************************
-// Globals
+// Define
//******************************************************************************
+#define MIN_BCE_REQ_SIZE 256
+
+
+typedef struct __attribute__ ((packed))
+{
+ uint64_t magic_number;
+ uint8_t size_of_vfrt;
+ uint8_t vfrt_data_size;
+ uint8_t active_quads_start;
+ uint8_t active_quads_size;
+ uint8_t vdn_start;
+ uint8_t vdn_step;
+ uint8_t vdn_size;
+ uint8_t vdd_start;
+ uint8_t vdd_step;
+ uint8_t vdd_size;
+} wof_header_data_t;
+
+
+
+typedef struct
+{
+ // There is no guarantee that we can fit everything into the min BceRequest
+ // size of 128 given that there may be a need to padding in the event the
+ // Main Memory address is not 128-byte aligned. The data here is 256 to
+ // ensure we have enough room for any and all padding that may be needed.
+ uint8_t data[MIN_BCE_REQ_SIZE];
+} temp_bce_request_buffer_t __attribute ((aligned(128)));
//******************************************************************************
// Function Prototypes
//******************************************************************************
+
+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 );
+
#endif
OpenPOWER on IntegriCloud