5 * AMD CPU BIST Status Check Implementation.
7 * Implement CPU BIST Status checking
9 * @xrefitem bom "File Content Label" "Release Content"
12 * @e \$Revision: 56279 $ @e \$Date: 2011-07-11 13:11:28 -0600 (Mon, 11 Jul 2011) $
16 ******************************************************************************
18 * Copyright (C) 2012 Advanced Micro Devices, Inc.
19 * All rights reserved.
21 * Redistribution and use in source and binary forms, with or without
22 * modification, are permitted provided that the following conditions are met:
23 * * Redistributions of source code must retain the above copyright
24 * notice, this list of conditions and the following disclaimer.
25 * * Redistributions in binary form must reproduce the above copyright
26 * notice, this list of conditions and the following disclaimer in the
27 * documentation and/or other materials provided with the distribution.
28 * * Neither the name of Advanced Micro Devices, Inc. nor the names of
29 * its contributors may be used to endorse or promote products derived
30 * from this software without specific prior written permission.
32 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
33 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
34 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
35 * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
36 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
37 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
38 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
39 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
40 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
41 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
43 ******************************************************************************
46 /*----------------------------------------------------------------------------------------
47 * M O D U L E S U S E D
48 *----------------------------------------------------------------------------------------
53 #include "cpuRegisters.h"
54 #include "GeneralServices.h"
55 #include "cpuServices.h"
56 #include "cpuApicUtilities.h"
60 #define FILECODE PROC_CPU_CPUBIST_FILECODE
62 /*----------------------------------------------------------------------------------------
63 * P R O T O T Y P E S O F L O C A L F U N C T I O N S
64 *----------------------------------------------------------------------------------------
70 IN AMD_CONFIG_PARAMS *StdHeader
73 /*----------------------------------------------------------------------------------------
74 * E X P O R T E D F U N C T I O N S
75 *----------------------------------------------------------------------------------------
78 /*---------------------------------------------------------------------------------------*/
81 * This function checks the status of BIST and places the error status in the event log
82 * if there are any errors
84 * @param[in] StdHeader Header for library and services
86 * @retval AGESA_SUCCESS No BIST errors have been logged.
87 * @retval AGESA_ALERT BIST errors have been detected and added to the
92 IN AMD_CONFIG_PARAMS *StdHeader
99 UINT32 NumberOfSockets;
100 UINT32 NumberOfCores;
103 AGESA_STATUS IgnoredSts;
104 AGESA_STATUS AgesaStatus;
107 // Make sure that Standard Header is valid
108 ASSERT (StdHeader != NULL);
109 ASSERT (IsBsp (StdHeader, &IgnoredSts));
111 AgesaStatus = AGESA_SUCCESS;
113 // Get the BscSocket, BscCoreNum and NumberOfSockets in the system
114 IdentifyCore (StdHeader, &BscSocket, &Ignored, &BscCoreNum, &IgnoredSts);
115 NumberOfSockets = GetPlatformNumberOfSockets ();
117 // Setup TaskPtr struct to execute routine on APs
118 TaskPtr.FuncAddress.PfApTaskO = GetBistResults;
119 TaskPtr.DataTransfer.DataSizeInDwords = 0;
120 TaskPtr.ExeFlags = TASK_HAS_OUTPUT | WAIT_FOR_CORE;
122 for (Socket = 0; Socket < NumberOfSockets; Socket++) {
123 if (GetActiveCoresInGivenSocket (Socket, &NumberOfCores, StdHeader)) {
124 for (Core = 0; Core < NumberOfCores; Core++) {
125 if ((Socket != BscSocket) || (Core != BscCoreNum)) {
126 ReturnCode = ApUtilRunCodeOnSocketCore ((UINT8)Socket, (UINT8)Core, &TaskPtr, StdHeader);
128 ReturnCode = TaskPtr.FuncAddress.PfApTaskO (StdHeader);
131 // If BIST value is non-zero, add to BSP's event log
132 if (ReturnCode != 0) {
133 IDS_HDT_CONSOLE (CPU_TRACE, " BIST failure: socket %d core %d, status = 0x%x\n", Socket, Core, ReturnCode);
134 AgesaStatus = AGESA_ALERT;
135 PutEventLog (AGESA_ALERT,
136 CPU_EVENT_BIST_ERROR,
137 ReturnCode, Socket, Core, 0, StdHeader);
146 /*----------------------------------------------------------------------------------------
147 * L O C A L F U N C T I O N S
148 *----------------------------------------------------------------------------------------
151 /*---------------------------------------------------------------------------------------*/
154 * Reads the lower 32 bits of the BIST register
156 * @param[in] StdHeader Header for library and services
158 * @retval Value of the BIST register
163 IN AMD_CONFIG_PARAMS *StdHeader
168 // Read MSRC001_0060 BIST Results Register
169 LibAmdMsrRead (MSR_BIST, &BistResults, StdHeader);
171 return (UINT32) (BistResults & 0xFFFFFFFF);