7 * Memory error handling
9 * @xrefitem bom "File Content Label" "Release Content"
11 * @e sub-project: (Mem/Main)
12 * @e \$Revision: 56279 $ @e \$Date: 2011-07-11 13:11:28 -0600 (Mon, 11 Jul 2011) $
15 /*****************************************************************************
17 * Copyright (C) 2012 Advanced Micro Devices, Inc.
18 * All rights reserved.
20 * Redistribution and use in source and binary forms, with or without
21 * modification, are permitted provided that the following conditions are met:
22 * * Redistributions of source code must retain the above copyright
23 * notice, this list of conditions and the following disclaimer.
24 * * Redistributions in binary form must reproduce the above copyright
25 * notice, this list of conditions and the following disclaimer in the
26 * documentation and/or other materials provided with the distribution.
27 * * Neither the name of Advanced Micro Devices, Inc. nor the names of
28 * its contributors may be used to endorse or promote products derived
29 * from this software without specific prior written permission.
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
32 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
33 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
34 * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
35 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
36 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
37 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
38 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
39 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
40 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
42 * ***************************************************************************
47 *----------------------------------------------------------------------------
50 *----------------------------------------------------------------------------
56 #include "OptionMemory.h"
60 #include "heapManager.h"
66 #define FILECODE PROC_MEM_MAIN_MERRHDL_FILECODE
68 extern MEM_FEAT_BLOCK_MAIN MemFeatMain;
69 /*----------------------------------------------------------------------------
70 * DEFINITIONS AND MACROS
72 *----------------------------------------------------------------------------
75 /*----------------------------------------------------------------------------
76 * TYPEDEFS AND STRUCTURES
78 *----------------------------------------------------------------------------
81 /*----------------------------------------------------------------------------
82 * PROTOTYPES OF LOCAL FUNCTIONS
84 *----------------------------------------------------------------------------
87 /*----------------------------------------------------------------------------
90 *----------------------------------------------------------------------------
93 /* -----------------------------------------------------------------------------*/
96 * This function handle errors occur in memory code.
99 * @param[in,out] *MCTPtr - pointer to DIE_STRUCT.
100 * @param[in,out] DCT - DCT that needs to be handled.
101 * @param[in,out] ChipSelMask - Chip select mask that needs to be handled
102 * @param[in,out] *StdHeader - pointer to AMD_CONFIG_PARAMS
104 * @return TRUE - No fatal error occurs.
105 * @return FALSE - Fatal error occurs.
109 IN DIE_STRUCT *MCTPtr,
111 IN UINT16 ChipSelMask,
112 IN AMD_CONFIG_PARAMS *StdHeader
115 BOOLEAN ErrorRecovery;
119 LOCATE_HEAP_PTR LocHeap;
121 MEM_MAIN_DATA_BLOCK mmData;
123 DCTPtr = MCTPtr->DctData;
124 ErrorRecovery = TRUE;
126 IDS_OPTION_HOOK (IDS_MEM_ERROR_RECOVERY, &ErrorRecovery, StdHeader);
129 if (DCT == EXCLUDE_ALL_DCT) {
130 // Exclude all DCTs on a node
131 for (CurrentDCT = 0; CurrentDCT < MCTPtr->DctCount; CurrentDCT++) {
132 DCTPtr[CurrentDCT].Timings.CsTestFail = DCTPtr[CurrentDCT].Timings.CsPresent;
134 } else if (ChipSelMask == EXCLUDE_ALL_CHIPSEL) {
135 // Exclude the specified DCT
136 DCTPtr[DCT].Timings.CsTestFail = DCTPtr[DCT].Timings.CsPresent;
138 // Exclude the chip select that has been marked out
139 DCTPtr[DCT].Timings.CsTestFail |= ChipSelMask & DCTPtr[DCT].Timings.CsPresent;
140 IDS_OPTION_HOOK (IDS_LOADCARD_ERROR_RECOVERY, &DCTPtr[DCT], StdHeader);
143 // Exclude the failed dimm to recovery from error
144 if (MCTPtr->NodeMemSize != 0) {
145 LocHeap.BufferHandle = AMD_MEM_AUTO_HANDLE;
146 if (HeapLocateBuffer (&LocHeap, StdHeader) == AGESA_SUCCESS) {
147 // NB block has already been constructed by main block.
148 // No need to construct it here.
149 NBPtr = (MEM_NB_BLOCK *)LocHeap.BufferPtr;
150 if (!NBPtr->SharedPtr->NodeMap[MCTPtr->NodeId].IsValid) {
151 // Memory map has not been calculated, no need to remap memory across node here.
152 // Only need to remap memory within the node.
153 NBPtr = &NBPtr[MCTPtr->NodeId];
154 NBPtr->FeatPtr->ExcludeDIMM (NBPtr);
156 // Need to remap memory across the whole system.
157 mmData.MemPtr = NBPtr->MemPtr;
158 mmData.mmSharedPtr = NBPtr->SharedPtr;
159 mmData.NBPtr = NBPtr;
160 mmData.TechPtr = (MEM_TECH_BLOCK *) (&NBPtr[NBPtr->MemPtr->DieCount]);
161 mmData.DieCount = NBPtr->MemPtr->DieCount;
162 if (!MemFeatMain.ExcludeDIMM (&mmData)) {
167 // If allocation fails, that means the code is not running at BSP.
168 // Parallel training is in process.
169 // Remap for parallel training will be done when control returns to BSP.
173 IDS_OPTION_HOOK (IDS_MEM_IGNORE_ERROR, &IgnoreErr, StdHeader);
177 SetMemError (AGESA_FATAL, MCTPtr);
178 // ErrorRecovery is FALSE
183 /*----------------------------------------------------------------------------
186 *----------------------------------------------------------------------------