<p>Raul Rangel has uploaded this change for <strong>review</strong>.</p><p><a href="https://review.coreboot.org/26220">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">grunt: Add agesa performance metrics into cbmem<br><br>AGESA provides hooks for extracting performance metrics. It uses the IDS<br>callout to retrieve a pointer and it then writes TP_Perf_STRUCT.<br><br>The TP_Perf_STRUCT was missing from pi/00670F00. So I copied the file<br>from src/vendorcode/amd/pi/00630F01/Include/IdsPerf.h and removed<br>everything that we don't need. I did have to change<br>MAX_PERFORMANCE_UNIT_NUM so it matches the size used by pi/00670F00.<br><br>Once the struct has been populated I call timestamp_add for each entry<br>to add the timestamps to cbmem.<br><br>This does not pull out the S3 performance metrics because the IDS bios<br>callout happens in romstage as part of AmdInitResume. DRAM is up at this<br>point so I'm sure we could play some tricks if we wanted.<br><br>An AGESA binary with IDSOPT_PERF_ANALYSIS enabled must be used to<br>extract the timestamps.<br><br>MAX_TIMESTAMPS must also be increased.<br><br>BUG=b:64549506<br>TEST=boot on grunt and run cbmem -t<br>   0:1st timestamp                                     22,008<br> 900:calling AmdInitReset                              90,894 (68,886)<br>4396:BeginProcAmdInitReset                             92,274 (1,380)<br>4398:BeginInitReset                                    93,489 (1,215)<br>4399:EndInitReset                                      100,549 (7,060)<br>4397:EndProcAmdInitReset                               100,751 (202)<br> 901:back from AmdInitReset                            101,680 (929)<br>4352:BeginProcAmdInitEarly                             101,797 (117)<br>4354:BeginAmdTopoInitialize                            101,890 (93)<br>4355:EndAmdTopoInitialize                              102,259 (369)<br>4356:BeginGnbInitAtEarlier                             102,260 (1)<br> 902:calling AmdInitEarly                              102,689 (429)<br>4438:BeginGnbLoadScsData                               107,895 (5,206)<br>4439:EndGnbLoadScsData                                 108,833 (938)<br>4357:EndGnbInitAtEarlier                               108,906 (73)<br>4358:BeginAmdCpuEarly                                  108,907 (1)<br>4359:EndAmdCpuEarly                                    119,701 (10,794)<br>4360:BeginGnbInitAtEarly                               119,881 (180)<br>4440:BeginGnbPcieTraining                              125,608 (5,727)<br>4441:EndGnbPcieTraining                                142,405 (16,797)<br>4361:EndGnbInitAtEarly                                 142,488 (83)<br>4353:EndProcAmdInitEarly                               142,509 (21)<br> 903:back from AmdInitEarly                            143,537 (1,028)<br>   5:start of verified boot                            160,263 (16,726)<br>...<br><br>Change-Id: If8399dd5d69d53ad41834b40d7f06d6b6e0093ad<br>Signed-off-by: Raul E Rangel <rrangel@chromium.org><br>---<br>M src/commonlib/include/commonlib/timestamp_serialized.h<br>M src/soc/amd/common/block/include/amdblocks/agesawrapper.h<br>M src/soc/amd/common/block/pi/agesawrapper.c<br>M src/soc/amd/common/block/pi/def_callouts.c<br>A src/vendorcode/amd/pi/00670F00/Proc/IDS/IdsLib.h<br>M src/vendorcode/amd/pi/00670F00/agesa_headers.h<br>6 files changed, 254 insertions(+), 1 deletion(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://review.coreboot.org:29418/coreboot refs/changes/20/26220/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/src/commonlib/include/commonlib/timestamp_serialized.h b/src/commonlib/include/commonlib/timestamp_serialized.h</span><br><span>index 304e43f..5310a40 100644</span><br><span>--- a/src/commonlib/include/commonlib/timestamp_serialized.h</span><br><span>+++ b/src/commonlib/include/commonlib/timestamp_serialized.h</span><br><span>@@ -144,6 +144,12 @@</span><br><span> </span><br><span>     TS_START_KERNEL = 1101,</span><br><span>      TS_KERNEL_DECOMPRESSION = 1102,</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+     /*</span><br><span style="color: hsl(120, 100%, 40%);">+     * 0x1100 - 0x11FF reserved for AGESA internal IDs.</span><br><span style="color: hsl(120, 100%, 40%);">+    * The values are 0x1000 + the value of the enum defined in IdsPerf.h</span><br><span style="color: hsl(120, 100%, 40%);">+  */</span><br><span style="color: hsl(120, 100%, 40%);">+   TS_AGESA_INTERNAL_START             = 0x1100,</span><br><span> };</span><br><span> </span><br><span> static const struct timestamp_id_to_name {</span><br><span>@@ -258,6 +264,107 @@</span><br><span>        { TS_FSP_BEFORE_END_OF_FIRMWARE, "calling FspNotify(EndOfFirmware)" },</span><br><span>     { TS_FSP_AFTER_END_OF_FIRMWARE,</span><br><span>              "returning from FspNotify(EndOfFirmware)" },</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+      /*</span><br><span style="color: hsl(120, 100%, 40%);">+     * TODO(rrangel): Is there an ifdef I can add around this so it only</span><br><span style="color: hsl(120, 100%, 40%);">+   * gets included in the cbmem util and possibly ramstage?</span><br><span style="color: hsl(120, 100%, 40%);">+      */</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ /* AMD AGESA internal timestamps. See IdsPerf.h */</span><br><span style="color: hsl(120, 100%, 40%);">+    { 0x1100, "BeginProcAmdInitEarly" },</span><br><span style="color: hsl(120, 100%, 40%);">+        { 0x1101, "EndProcAmdInitEarly" },</span><br><span style="color: hsl(120, 100%, 40%);">+  { 0x1102, "BeginAmdTopoInitialize" },</span><br><span style="color: hsl(120, 100%, 40%);">+       { 0x1103, "EndAmdTopoInitialize" },</span><br><span style="color: hsl(120, 100%, 40%);">+ { 0x1104, "BeginGnbInitAtEarlier" },</span><br><span style="color: hsl(120, 100%, 40%);">+        { 0x1105, "EndGnbInitAtEarlier" },</span><br><span style="color: hsl(120, 100%, 40%);">+  { 0x1106, "BeginAmdCpuEarly" },</span><br><span style="color: hsl(120, 100%, 40%);">+     { 0x1107, "EndAmdCpuEarly" },</span><br><span style="color: hsl(120, 100%, 40%);">+       { 0x1108, "BeginGnbInitAtEarly" },</span><br><span style="color: hsl(120, 100%, 40%);">+  { 0x1109, "EndGnbInitAtEarly" },</span><br><span style="color: hsl(120, 100%, 40%);">+    { 0x110A, "BeginProcAmdInitEnv" },</span><br><span style="color: hsl(120, 100%, 40%);">+  { 0x110B, "EndProcAmdInitEnv" },</span><br><span style="color: hsl(120, 100%, 40%);">+    { 0x110C, "BeginInitEnv" },</span><br><span style="color: hsl(120, 100%, 40%);">+ { 0x110D, "EndInitEnv" },</span><br><span style="color: hsl(120, 100%, 40%);">+   { 0x110E, "BeginGnbInitAtEnv" },</span><br><span style="color: hsl(120, 100%, 40%);">+    { 0x110F, "EndGnbInitAtEnv" },</span><br><span style="color: hsl(120, 100%, 40%);">+      { 0x1110, "BeginProcAmdInitLate" },</span><br><span style="color: hsl(120, 100%, 40%);">+ { 0x1111, "EndProcAmdInitLate" },</span><br><span style="color: hsl(120, 100%, 40%);">+   { 0x1112, "BeginCreatSystemTable" },</span><br><span style="color: hsl(120, 100%, 40%);">+        { 0x1113, "EndCreatSystemTable" },</span><br><span style="color: hsl(120, 100%, 40%);">+  { 0x1114, "BeginDispatchCpuFeaturesLate" },</span><br><span style="color: hsl(120, 100%, 40%);">+ { 0x1115, "EndDispatchCpuFeaturesLate" },</span><br><span style="color: hsl(120, 100%, 40%);">+   { 0x1116, "BeginAmdCpuLate" },</span><br><span style="color: hsl(120, 100%, 40%);">+      { 0x1117, "EndAmdCpuLate" },</span><br><span style="color: hsl(120, 100%, 40%);">+        { 0x1118, "BeginGnbInitAtLate" },</span><br><span style="color: hsl(120, 100%, 40%);">+   { 0x1119, "EndGnbInitAtLate" },</span><br><span style="color: hsl(120, 100%, 40%);">+     { 0x111A, "BeginProcAmdInitMid" },</span><br><span style="color: hsl(120, 100%, 40%);">+  { 0x111B, "EndProcAmdInitMid" },</span><br><span style="color: hsl(120, 100%, 40%);">+    { 0x111E, "BeginInitMid" },</span><br><span style="color: hsl(120, 100%, 40%);">+ { 0x111F, "EndInitMid" },</span><br><span style="color: hsl(120, 100%, 40%);">+   { 0x1120, "BeginGnbInitAtMid" },</span><br><span style="color: hsl(120, 100%, 40%);">+    { 0x1121, "EndGnbInitAtMid" },</span><br><span style="color: hsl(120, 100%, 40%);">+      { 0x1122, "BeginProcAmdInitPost" },</span><br><span style="color: hsl(120, 100%, 40%);">+ { 0x1123, "EndProcAmdInitPost" },</span><br><span style="color: hsl(120, 100%, 40%);">+   { 0x1124, "BeginGnbInitAtPost" },</span><br><span style="color: hsl(120, 100%, 40%);">+   { 0x1125, "EndGnbInitAtPost" },</span><br><span style="color: hsl(120, 100%, 40%);">+     { 0x1126, "BeginAmdMemAuto" },</span><br><span style="color: hsl(120, 100%, 40%);">+      { 0x1127, "EndAmdMemAuto" },</span><br><span style="color: hsl(120, 100%, 40%);">+        { 0x1128, "BeginAmdCpuPost" },</span><br><span style="color: hsl(120, 100%, 40%);">+      { 0x1129, "EndAmdCpuPost" },</span><br><span style="color: hsl(120, 100%, 40%);">+        { 0x112A, "BeginGnbInitAtPostAfterDram" },</span><br><span style="color: hsl(120, 100%, 40%);">+  { 0x112B, "EndGnbInitAtPostAfterDram" },</span><br><span style="color: hsl(120, 100%, 40%);">+    { 0x112C, "BeginProcAmdInitReset" },</span><br><span style="color: hsl(120, 100%, 40%);">+        { 0x112D, "EndProcAmdInitReset" },</span><br><span style="color: hsl(120, 100%, 40%);">+  { 0x112E, "BeginInitReset" },</span><br><span style="color: hsl(120, 100%, 40%);">+       { 0x112F, "EndInitReset" },</span><br><span style="color: hsl(120, 100%, 40%);">+ { 0x1130, "BeginHtInitReset" },</span><br><span style="color: hsl(120, 100%, 40%);">+     { 0x1131, "EndHtInitReset" },</span><br><span style="color: hsl(120, 100%, 40%);">+       { 0x1132, "BeginProcAmdInitResume" },</span><br><span style="color: hsl(120, 100%, 40%);">+       { 0x1133, "EndProcAmdInitResume" },</span><br><span style="color: hsl(120, 100%, 40%);">+ { 0x1134, "BeginAmdMemS3Resume" },</span><br><span style="color: hsl(120, 100%, 40%);">+  { 0x1135, "EndAmdMemS3Resume" },</span><br><span style="color: hsl(120, 100%, 40%);">+    { 0x1136, "BeginDispatchCpuFeaturesS3Resume" },</span><br><span style="color: hsl(120, 100%, 40%);">+     { 0x1137, "EndDispatchCpuFeaturesS3Resume" },</span><br><span style="color: hsl(120, 100%, 40%);">+       { 0x1138, "BeginSetCoresTscFreqSel" },</span><br><span style="color: hsl(120, 100%, 40%);">+      { 0x1139, "EndSetCoresTscFreqSel" },</span><br><span style="color: hsl(120, 100%, 40%);">+        { 0x113A, "BeginMemFMctMemClr_Init" },</span><br><span style="color: hsl(120, 100%, 40%);">+      { 0x113B, "EndnMemFMctMemClr_Init" },</span><br><span style="color: hsl(120, 100%, 40%);">+       { 0x113C, "BeginMemBeforeMemDataInit" },</span><br><span style="color: hsl(120, 100%, 40%);">+    { 0x113D, "EndMemBeforeMemDataInit" },</span><br><span style="color: hsl(120, 100%, 40%);">+      { 0x113E, "BeginProcAmdMemAuto" },</span><br><span style="color: hsl(120, 100%, 40%);">+  { 0x113F, "EndProcAmdMemAuto" },</span><br><span style="color: hsl(120, 100%, 40%);">+    { 0x1140, "BeginMemMFlowC32" },</span><br><span style="color: hsl(120, 100%, 40%);">+     { 0x1141, "EndMemMFlowC32" },</span><br><span style="color: hsl(120, 100%, 40%);">+       { 0x1142, "BeginMemInitializeMCT" },</span><br><span style="color: hsl(120, 100%, 40%);">+        { 0x1143, "EndMemInitializeMCT" },</span><br><span style="color: hsl(120, 100%, 40%);">+  { 0x1144, "BeginMemSystemMemoryMapping" },</span><br><span style="color: hsl(120, 100%, 40%);">+  { 0x1145, "EndMemSystemMemoryMapping" },</span><br><span style="color: hsl(120, 100%, 40%);">+    { 0x1146, "BeginMemDramTraining" },</span><br><span style="color: hsl(120, 100%, 40%);">+ { 0x1147, "EndMemDramTraining" },</span><br><span style="color: hsl(120, 100%, 40%);">+   { 0x1148, "BeginMemOtherTiming" },</span><br><span style="color: hsl(120, 100%, 40%);">+  { 0x1149, "EndMemOtherTiming" },</span><br><span style="color: hsl(120, 100%, 40%);">+    { 0x114A, "BeginMemUMAMemTyping" },</span><br><span style="color: hsl(120, 100%, 40%);">+ { 0x114B, "EndMemUMAMemTyping" },</span><br><span style="color: hsl(120, 100%, 40%);">+   { 0x114C, "BeginMemMemClr" },</span><br><span style="color: hsl(120, 100%, 40%);">+       { 0x114D, "EndMemMemClr" },</span><br><span style="color: hsl(120, 100%, 40%);">+ { 0x114E, "BeginMemMFlowTN" },</span><br><span style="color: hsl(120, 100%, 40%);">+      { 0x114F, "EndMemMFlowTN" },</span><br><span style="color: hsl(120, 100%, 40%);">+        { 0x1150, "BeginAgesaHookBeforeDramInit" },</span><br><span style="color: hsl(120, 100%, 40%);">+ { 0x1151, "EndAgesaHookBeforeDramInit" },</span><br><span style="color: hsl(120, 100%, 40%);">+   { 0x1152, "BeginProcMemDramTraining" },</span><br><span style="color: hsl(120, 100%, 40%);">+     { 0x1153, "EndProcMemDramTraining" },</span><br><span style="color: hsl(120, 100%, 40%);">+       { 0x1154, "BeginGnbInitAtRtb" },</span><br><span style="color: hsl(120, 100%, 40%);">+    { 0x1155, "EndGnbInitAtRtb" },</span><br><span style="color: hsl(120, 100%, 40%);">+      { 0x1156, "BeginGnbLoadScsData" },</span><br><span style="color: hsl(120, 100%, 40%);">+  { 0x1157, "EndGnbLoadScsData" },</span><br><span style="color: hsl(120, 100%, 40%);">+    { 0x1158, "BeginGnbPcieTraining" },</span><br><span style="color: hsl(120, 100%, 40%);">+ { 0x1159, "EndGnbPcieTraining" },</span><br><span style="color: hsl(120, 100%, 40%);">+   { 0x115A, "BeginDispatchCpuFeaturesInitRtb" },</span><br><span style="color: hsl(120, 100%, 40%);">+      { 0x115B, "EndDispatchCpuFeaturesInitRtb" },</span><br><span style="color: hsl(120, 100%, 40%);">+        { 0x115C, "BeginAmdCpuEarly" },</span><br><span style="color: hsl(120, 100%, 40%);">+     { 0x115D, "EndAmdCpuEarly" },</span><br><span style="color: hsl(120, 100%, 40%);">+       { 0x115E, "BeginAmdGnbMidLate" },</span><br><span style="color: hsl(120, 100%, 40%);">+   { 0x115F, "EndAmdGnbMidLate" },</span><br><span> };</span><br><span> </span><br><span> #endif</span><br><span>diff --git a/src/soc/amd/common/block/include/amdblocks/agesawrapper.h b/src/soc/amd/common/block/include/amdblocks/agesawrapper.h</span><br><span>index 986d6f8..0ce9dfb 100644</span><br><span>--- a/src/soc/amd/common/block/include/amdblocks/agesawrapper.h</span><br><span>+++ b/src/soc/amd/common/block/include/amdblocks/agesawrapper.h</span><br><span>@@ -51,6 +51,8 @@</span><br><span> AGESA_STATUS agesawrapper_fchs3earlyrestore(void);</span><br><span> AGESA_STATUS agesawrapper_fchs3laterestore(void);</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+void *agesawrapper_allocateperfbuffer(void);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> VOID OemCustomizeInitEarly(IN OUT AMD_EARLY_PARAMS *InitEarly);</span><br><span> VOID amd_initcpuio(void);</span><br><span> const void *agesawrapper_locate_module(const CHAR8 name[8]);</span><br><span>diff --git a/src/soc/amd/common/block/pi/agesawrapper.c b/src/soc/amd/common/block/pi/agesawrapper.c</span><br><span>index 436bf8f..8f4368b 100644</span><br><span>--- a/src/soc/amd/common/block/pi/agesawrapper.c</span><br><span>+++ b/src/soc/amd/common/block/pi/agesawrapper.c</span><br><span>@@ -22,6 +22,7 @@</span><br><span> #include <delay.h></span><br><span> #include <rules.h></span><br><span> #include <rmodule.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include <stdlib.h></span><br><span> #include <stage_cache.h></span><br><span> #include <string.h></span><br><span> #include <timestamp.h></span><br><span>@@ -315,6 +316,65 @@</span><br><span>    return status;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+#if (ENV_RAMSTAGE)</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#define PERF_CANARY_VALUE 231</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+static TP_Perf_STRUCT *PerfData;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+void *agesawrapper_allocateperfbuffer(void)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+    if (PerfData) {</span><br><span style="color: hsl(120, 100%, 40%);">+               printk(BIOS_ERR,</span><br><span style="color: hsl(120, 100%, 40%);">+                     "agesawrapper: perf pointer already allocated\n");</span><br><span style="color: hsl(120, 100%, 40%);">+   }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+   // Allocate an additional byte to use as a canary to detect a buffer</span><br><span style="color: hsl(120, 100%, 40%);">+  // overflow.</span><br><span style="color: hsl(120, 100%, 40%);">+  PerfData = malloc(sizeof(*PerfData) + 1);</span><br><span style="color: hsl(120, 100%, 40%);">+     ((uint8_t *)PerfData)[sizeof(*PerfData)] = PERF_CANARY_VALUE;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+       return PerfData;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/* Converts the AGESA perf data to cbmem timestamps. */</span><br><span style="color: hsl(120, 100%, 40%);">+static void commit_agesa_perf_data(void)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+   if (PerfData == NULL) {</span><br><span style="color: hsl(120, 100%, 40%);">+               printk(BIOS_INFO, "agesawrapper: perf data not initialized\n");</span><br><span style="color: hsl(120, 100%, 40%);">+             return;</span><br><span style="color: hsl(120, 100%, 40%);">+       }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+   if (PerfData->Version != IDS_PERF_VERSION) {</span><br><span style="color: hsl(120, 100%, 40%);">+               printk(BIOS_ERR,</span><br><span style="color: hsl(120, 100%, 40%);">+                     "agesawrapper: perf data malformed, expected version "</span><br><span style="color: hsl(120, 100%, 40%);">+                      "%lx, but got %x\n",</span><br><span style="color: hsl(120, 100%, 40%);">+                IDS_PERF_VERSION, PerfData->Version);</span><br><span style="color: hsl(120, 100%, 40%);">+               return;</span><br><span style="color: hsl(120, 100%, 40%);">+       }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+   if (((uint8_t *)PerfData)[sizeof(*PerfData)] != PERF_CANARY_VALUE)</span><br><span style="color: hsl(120, 100%, 40%);">+            die("agesawrapper: perf data caused buffer overflow\n");</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+  printk(BIOS_INFO,</span><br><span style="color: hsl(120, 100%, 40%);">+            "AGESA Performance Data: sig: %x, ver: %x, idx: %d, mhz: %d\n",</span><br><span style="color: hsl(120, 100%, 40%);">+             PerfData->Signature, PerfData->Version, PerfData->Index,</span><br><span style="color: hsl(120, 100%, 40%);">+             PerfData->TscInMhz);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+      for (int i = 0; i < PerfData->Index; ++i) {</span><br><span style="color: hsl(120, 100%, 40%);">+             TestPoint_TSC *tsc = &PerfData->TP[i];</span><br><span style="color: hsl(120, 100%, 40%);">+         if (tsc->Description == 0)</span><br><span style="color: hsl(120, 100%, 40%);">+                 continue;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+           printk(BIOS_SPEW, "%llx:%x: %lld\n", tsc->Description,</span><br><span style="color: hsl(120, 100%, 40%);">+                  tsc->LineInFile, tsc->StartTsc);</span><br><span style="color: hsl(120, 100%, 40%);">+         enum timestamp_id id = TS_AGESA_INTERNAL_START -</span><br><span style="color: hsl(120, 100%, 40%);">+                                     TP_BEGINPROCAMDINITEARLY +</span><br><span style="color: hsl(120, 100%, 40%);">+                                    tsc->Description;</span><br><span style="color: hsl(120, 100%, 40%);">+           timestamp_add(id, tsc->StartTsc / PerfData->TscInMhz);</span><br><span style="color: hsl(120, 100%, 40%);">+  }</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> AGESA_STATUS agesawrapper_amdinitlate(void)</span><br><span> {</span><br><span>   AGESA_STATUS Status;</span><br><span>@@ -341,6 +401,8 @@</span><br><span>           ASSERT(Status == AGESA_SUCCESS);</span><br><span>     }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+ commit_agesa_perf_data();</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span>  DmiTable = LateParams->DmiTable;</span><br><span>  AcpiPstate = LateParams->AcpiPState;</span><br><span> </span><br><span>@@ -361,6 +423,17 @@</span><br><span>   return Status;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+#else</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+void *agesawrapper_allocateperfbuffer(void)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+      // This will happen in S3 romstage because it happens in AmdInitResume.</span><br><span style="color: hsl(120, 100%, 40%);">+       printk(BIOS_NOTICE, "agesawrapper: perf pointer is not available\n");</span><br><span style="color: hsl(120, 100%, 40%);">+       return NULL;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#endif</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> AGESA_STATUS agesawrapper_amdlaterunaptask(UINT32 Func, UINTN Data,</span><br><span>                           VOID *ConfigPtr)</span><br><span> {</span><br><span>diff --git a/src/soc/amd/common/block/pi/def_callouts.c b/src/soc/amd/common/block/pi/def_callouts.c</span><br><span>index fc3a88b..d0c1361 100644</span><br><span>--- a/src/soc/amd/common/block/pi/def_callouts.c</span><br><span>+++ b/src/soc/amd/common/block/pi/def_callouts.c</span><br><span>@@ -103,9 +103,14 @@</span><br><span> </span><br><span> AGESA_STATUS agesa_EmptyIdsInitData(UINT32 Func, UINTN Data, VOID *ConfigPtr)</span><br><span> {</span><br><span style="color: hsl(0, 100%, 40%);">-     IDS_NV_ITEM *IdsPtr = ((IDS_CALLOUT_STRUCT *) ConfigPtr)->IdsNvPtr;</span><br><span style="color: hsl(120, 100%, 40%);">+        IDS_CALLOUT_STRUCT *IdsCalloutData = (IDS_CALLOUT_STRUCT *) ConfigPtr;</span><br><span style="color: hsl(120, 100%, 40%);">+        IDS_NV_ITEM *IdsPtr = IdsCalloutData->IdsNvPtr;</span><br><span>   if (Data == IDS_CALLOUT_INIT)</span><br><span>                IdsPtr[0].IdsNvValue = IdsPtr[0].IdsNvId = 0xffff;</span><br><span style="color: hsl(120, 100%, 40%);">+    else if (Data == IDS_CALLOUT_GET_PERF_BUFFER)</span><br><span style="color: hsl(120, 100%, 40%);">+         IdsCalloutData->Reserved =</span><br><span style="color: hsl(120, 100%, 40%);">+                 (UINTN)agesawrapper_allocateperfbuffer();</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span>  return AGESA_SUCCESS;</span><br><span> }</span><br><span> </span><br><span>diff --git a/src/vendorcode/amd/pi/00670F00/Proc/IDS/IdsLib.h b/src/vendorcode/amd/pi/00670F00/Proc/IDS/IdsLib.h</span><br><span>new file mode 100644</span><br><span>index 0000000..2a65e18</span><br><span>--- /dev/null</span><br><span>+++ b/src/vendorcode/amd/pi/00670F00/Proc/IDS/IdsLib.h</span><br><span>@@ -0,0 +1,65 @@</span><br><span style="color: hsl(120, 100%, 40%);">+/* $NoKeywords:$ */</span><br><span style="color: hsl(120, 100%, 40%);">+/**</span><br><span style="color: hsl(120, 100%, 40%);">+ * @file</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * AMD IDS Routines</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * Contains AMD AGESA Integrated Debug Macros</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * @xrefitem bom "File Content Label" "Release Content"</span><br><span style="color: hsl(120, 100%, 40%);">+ * @e project:      AGESA</span><br><span style="color: hsl(120, 100%, 40%);">+ * @e sub-project:  IDS</span><br><span style="color: hsl(120, 100%, 40%);">+ * @e \$Revision: 281181 $   @e \$Date: 2013-12-18 02:18:55 -0600 (Wed, 18 Dec 2013) $</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+/*****************************************************************************</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * Copyright (c) 2008 - 2013, Advanced Micro Devices, Inc.</span><br><span style="color: hsl(120, 100%, 40%);">+ * All rights reserved.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * Redistribution and use in source and binary forms, with or without</span><br><span style="color: hsl(120, 100%, 40%);">+ * modification, are permitted provided that the following conditions are met:</span><br><span style="color: hsl(120, 100%, 40%);">+ *     * Redistributions of source code must retain the above copyright</span><br><span style="color: hsl(120, 100%, 40%);">+ *       notice, this list of conditions and the following disclaimer.</span><br><span style="color: hsl(120, 100%, 40%);">+ *     * Redistributions in binary form must reproduce the above copyright</span><br><span style="color: hsl(120, 100%, 40%);">+ *       notice, this list of conditions and the following disclaimer in the</span><br><span style="color: hsl(120, 100%, 40%);">+ *       documentation and/or other materials provided with the distribution.</span><br><span style="color: hsl(120, 100%, 40%);">+ *     * Neither the name of Advanced Micro Devices, Inc. nor the names of</span><br><span style="color: hsl(120, 100%, 40%);">+ *       its contributors may be used to endorse or promote products derived</span><br><span style="color: hsl(120, 100%, 40%);">+ *       from this software without specific prior written permission.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND</span><br><span style="color: hsl(120, 100%, 40%);">+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED</span><br><span style="color: hsl(120, 100%, 40%);">+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE</span><br><span style="color: hsl(120, 100%, 40%);">+ * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY</span><br><span style="color: hsl(120, 100%, 40%);">+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES</span><br><span style="color: hsl(120, 100%, 40%);">+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;</span><br><span style="color: hsl(120, 100%, 40%);">+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND</span><br><span style="color: hsl(120, 100%, 40%);">+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT</span><br><span style="color: hsl(120, 100%, 40%);">+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS</span><br><span style="color: hsl(120, 100%, 40%);">+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ ***************************************************************************/</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#ifndef _IDS_LIB_H_</span><br><span style="color: hsl(120, 100%, 40%);">+#define _IDS_LIB_H_</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/// Data Structure of Parameters for TestPoint_TSC.</span><br><span style="color: hsl(120, 100%, 40%);">+typedef struct {</span><br><span style="color: hsl(120, 100%, 40%);">+  UINT32 LineInFile;                    ///< Line of current time counter</span><br><span style="color: hsl(120, 100%, 40%);">+  UINT64 Description;                  ///<Description ID</span><br><span style="color: hsl(120, 100%, 40%);">+  UINT64 StartTsc;                  ///< The StartTimer of TestPoint_TSC</span><br><span style="color: hsl(120, 100%, 40%);">+} TestPoint_TSC;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#define RESERVED_TP_NUMER 0x20</span><br><span style="color: hsl(120, 100%, 40%);">+#define MAX_PERFORMANCE_UNIT_NUM (IDS_TP_END - TP_BEGINPROCAMDINITEARLY + 1 + RESERVED_TP_NUMER)</span><br><span style="color: hsl(120, 100%, 40%);">+/// Data Structure of Parameters for TP_Perf_STRUCT.</span><br><span style="color: hsl(120, 100%, 40%);">+typedef struct {</span><br><span style="color: hsl(120, 100%, 40%);">+  UINT32 Signature;                ///< "PERF"</span><br><span style="color: hsl(120, 100%, 40%);">+  UINT32 Version;       ///< version</span><br><span style="color: hsl(120, 100%, 40%);">+  UINT32 Index;                    ///< The Index of TP_Perf_STRUCT</span><br><span style="color: hsl(120, 100%, 40%);">+  UINT32 TscInMhz;            ///< Tsc counter in 1 mhz</span><br><span style="color: hsl(120, 100%, 40%);">+  TestPoint_TSC TP[MAX_PERFORMANCE_UNIT_NUM];       ///< The TP of TP_Perf_STRUCT</span><br><span style="color: hsl(120, 100%, 40%);">+} TP_Perf_STRUCT;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#endif //_IDS_LIB_H_</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span>diff --git a/src/vendorcode/amd/pi/00670F00/agesa_headers.h b/src/vendorcode/amd/pi/00670F00/agesa_headers.h</span><br><span>index a8deae5..fb17927 100644</span><br><span>--- a/src/vendorcode/amd/pi/00670F00/agesa_headers.h</span><br><span>+++ b/src/vendorcode/amd/pi/00670F00/agesa_headers.h</span><br><span>@@ -25,6 +25,7 @@</span><br><span> #include "Include/Ids.h"</span><br><span> #include "Include/PlatformMemoryConfiguration.h"</span><br><span> #include "Proc/Fch/FchPlatform.h"</span><br><span style="color: hsl(120, 100%, 40%);">+#include "Proc/IDS/IdsLib.h"</span><br><span> #include "Proc/Psp/PspBaseLib/PspBaseLib.h"</span><br><span> #pragma pack(pop)</span><br><span> #undef AGESA_HEADERS_ARE_WRAPPED</span><br><span></span><br></pre><p>To view, visit <a href="https://review.coreboot.org/26220">change 26220</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://review.coreboot.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://review.coreboot.org/26220"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: coreboot </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: If8399dd5d69d53ad41834b40d7f06d6b6e0093ad </div>
<div style="display:none"> Gerrit-Change-Number: 26220 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Raul Rangel <rrangel@chromium.org> </div>