zbao | 7d94cf9 | 2012-07-02 14:19:14 +0800 | [diff] [blame] | 1 | /* $NoKeywords:$ */ |
| 2 | /** |
| 3 | * @file |
| 4 | * |
| 5 | * merrhdl.c |
| 6 | * |
| 7 | * Memory error handling |
| 8 | * |
| 9 | * @xrefitem bom "File Content Label" "Release Content" |
| 10 | * @e project: AGESA |
| 11 | * @e sub-project: (Mem/Main) |
| 12 | * @e \$Revision: 63425 $ @e \$Date: 2011-12-22 11:24:10 -0600 (Thu, 22 Dec 2011) $ |
| 13 | * |
| 14 | **/ |
| 15 | /***************************************************************************** |
| 16 | * |
Siyuan Wang | 641f00c | 2013-06-08 11:50:55 +0800 | [diff] [blame] | 17 | * Copyright (c) 2008 - 2012, Advanced Micro Devices, Inc. |
| 18 | * All rights reserved. |
| 19 | * |
| 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. |
| 30 | * |
| 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. |
zbao | 7d94cf9 | 2012-07-02 14:19:14 +0800 | [diff] [blame] | 41 | * *************************************************************************** |
| 42 | * |
| 43 | */ |
| 44 | |
| 45 | /* |
| 46 | *---------------------------------------------------------------------------- |
| 47 | * MODULES USED |
| 48 | * |
| 49 | *---------------------------------------------------------------------------- |
| 50 | */ |
| 51 | |
| 52 | #include "AGESA.h" |
| 53 | #include "amdlib.h" |
| 54 | #include "Ids.h" |
| 55 | #include "OptionMemory.h" |
| 56 | #include "mm.h" |
| 57 | #include "mn.h" |
| 58 | #include "mt.h" |
| 59 | #include "heapManager.h" |
| 60 | #include "merrhdl.h" |
| 61 | #include "Filecode.h" |
| 62 | CODE_GROUP (G1_PEICC) |
| 63 | RDATA_GROUP (G1_PEICC) |
| 64 | |
| 65 | #define FILECODE PROC_MEM_MAIN_MERRHDL_FILECODE |
| 66 | |
| 67 | extern MEM_FEAT_BLOCK_MAIN MemFeatMain; |
| 68 | /*---------------------------------------------------------------------------- |
| 69 | * DEFINITIONS AND MACROS |
| 70 | * |
| 71 | *---------------------------------------------------------------------------- |
| 72 | */ |
| 73 | |
| 74 | /*---------------------------------------------------------------------------- |
| 75 | * TYPEDEFS AND STRUCTURES |
| 76 | * |
| 77 | *---------------------------------------------------------------------------- |
| 78 | */ |
| 79 | |
| 80 | /*---------------------------------------------------------------------------- |
| 81 | * PROTOTYPES OF LOCAL FUNCTIONS |
| 82 | * |
| 83 | *---------------------------------------------------------------------------- |
| 84 | */ |
| 85 | |
| 86 | /*---------------------------------------------------------------------------- |
| 87 | * EXPORTED FUNCTIONS |
| 88 | * |
| 89 | *---------------------------------------------------------------------------- |
| 90 | */ |
| 91 | |
| 92 | /* -----------------------------------------------------------------------------*/ |
| 93 | /** |
| 94 | * |
| 95 | * This function handle errors occur in memory code. |
| 96 | * |
| 97 | * |
| 98 | * @param[in,out] *MCTPtr - pointer to DIE_STRUCT. |
| 99 | * @param[in,out] DCT - DCT that needs to be handled. |
| 100 | * @param[in,out] ChipSelMask - Chip select mask that needs to be handled |
| 101 | * @param[in,out] *StdHeader - pointer to AMD_CONFIG_PARAMS |
| 102 | * |
| 103 | * @return TRUE - No fatal error occurs. |
| 104 | * @return FALSE - Fatal error occurs. |
| 105 | */ |
| 106 | BOOLEAN |
| 107 | MemErrHandle ( |
| 108 | IN DIE_STRUCT *MCTPtr, |
| 109 | IN UINT8 DCT, |
| 110 | IN UINT16 ChipSelMask, |
| 111 | IN AMD_CONFIG_PARAMS *StdHeader |
| 112 | ) |
| 113 | { |
| 114 | BOOLEAN ErrorRecovery; |
| 115 | BOOLEAN IgnoreErr; |
| 116 | DCT_STRUCT *DCTPtr; |
| 117 | UINT8 CurrentDCT; |
| 118 | LOCATE_HEAP_PTR LocHeap; |
| 119 | MEM_NB_BLOCK *NBPtr; |
| 120 | MEM_MAIN_DATA_BLOCK mmData; |
| 121 | |
| 122 | DCTPtr = MCTPtr->DctData; |
| 123 | ErrorRecovery = TRUE; |
| 124 | IgnoreErr = FALSE; |
| 125 | IDS_OPTION_HOOK (IDS_MEM_ERROR_RECOVERY, &ErrorRecovery, StdHeader); |
| 126 | |
| 127 | if (ErrorRecovery) { |
| 128 | if (DCT == EXCLUDE_ALL_DCT) { |
| 129 | // Exclude all DCTs on a node |
| 130 | for (CurrentDCT = 0; CurrentDCT < MCTPtr->DctCount; CurrentDCT++) { |
| 131 | DCTPtr[CurrentDCT].Timings.CsTestFail = DCTPtr[CurrentDCT].Timings.CsPresent; |
| 132 | } |
| 133 | } else if (ChipSelMask == EXCLUDE_ALL_CHIPSEL) { |
| 134 | // Exclude the specified DCT |
| 135 | DCTPtr[DCT].Timings.CsTestFail = DCTPtr[DCT].Timings.CsPresent; |
| 136 | } else { |
| 137 | // Exclude the chip select that has been marked out |
| 138 | DCTPtr[DCT].Timings.CsTestFail |= ChipSelMask & DCTPtr[DCT].Timings.CsPresent; |
| 139 | IDS_OPTION_HOOK (IDS_LOADCARD_ERROR_RECOVERY, &DCTPtr[DCT], StdHeader); |
| 140 | } |
| 141 | |
| 142 | // Exclude the failed dimm to recovery from error |
| 143 | if (MCTPtr->NodeMemSize != 0) { |
| 144 | LocHeap.BufferHandle = AMD_MEM_AUTO_HANDLE; |
| 145 | if (HeapLocateBuffer (&LocHeap, StdHeader) == AGESA_SUCCESS) { |
| 146 | // NB block has already been constructed by main block. |
| 147 | // No need to construct it here. |
| 148 | NBPtr = (MEM_NB_BLOCK *)LocHeap.BufferPtr; |
| 149 | if (!NBPtr->SharedPtr->NodeMap[MCTPtr->NodeId].IsValid) { |
| 150 | // Memory map has not been calculated, no need to remap memory across node here. |
| 151 | // Only need to remap memory within the node. |
| 152 | NBPtr = &NBPtr[MCTPtr->NodeId]; |
| 153 | NBPtr->FeatPtr->ExcludeDIMM (NBPtr); |
| 154 | } else { |
| 155 | // Need to remap memory across the whole system. |
| 156 | mmData.MemPtr = NBPtr->MemPtr; |
| 157 | mmData.mmSharedPtr = NBPtr->SharedPtr; |
| 158 | mmData.NBPtr = NBPtr; |
| 159 | mmData.TechPtr = (MEM_TECH_BLOCK *) (&NBPtr[NBPtr->MemPtr->DieCount]); |
| 160 | mmData.DieCount = NBPtr->MemPtr->DieCount; |
| 161 | if (!MemFeatMain.ExcludeDIMM (&mmData)) { |
| 162 | return FALSE; |
| 163 | } |
| 164 | } |
| 165 | } |
| 166 | // If allocation fails, that means the code is not running at BSP. |
| 167 | // Parallel training is in process. |
| 168 | // Remap for parallel training will be done when control returns to BSP. |
| 169 | } |
| 170 | return TRUE; |
| 171 | } else { |
| 172 | IDS_OPTION_HOOK (IDS_MEM_IGNORE_ERROR, &IgnoreErr, StdHeader); |
| 173 | if (IgnoreErr) { |
| 174 | return TRUE; |
| 175 | } |
| 176 | SetMemError (AGESA_FATAL, MCTPtr); |
| 177 | // ErrorRecovery is FALSE |
| 178 | return FALSE; |
| 179 | } |
| 180 | } |
| 181 | |
| 182 | /*---------------------------------------------------------------------------- |
| 183 | * LOCAL FUNCTIONS |
| 184 | * |
| 185 | *---------------------------------------------------------------------------- |
| 186 | */ |
| 187 | |