7 * Feature which performs Memory DQS training on each node with each node training
8 * its own memory through code running on a core in the associated processor.
9 * This way memory can be trained in parallel by more than one processor.
11 * This file contains the C32 specific parallel training function.
13 * @xrefitem bom "File Content Label" "Release Content"
15 * @e sub-project: (Mem/NB/C32)
16 * @e \$Revision: 54775 $ @e \$Date: 2011-06-12 21:05:26 -0600 (Sun, 12 Jun 2011) $
19 /*****************************************************************************
21 * Copyright (C) 2012 Advanced Micro Devices, Inc.
22 * All rights reserved.
24 * Redistribution and use in source and binary forms, with or without
25 * modification, are permitted provided that the following conditions are met:
26 * * Redistributions of source code must retain the above copyright
27 * notice, this list of conditions and the following disclaimer.
28 * * Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * * Neither the name of Advanced Micro Devices, Inc. nor the names of
32 * its contributors may be used to endorse or promote products derived
33 * from this software without specific prior written permission.
35 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
36 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
37 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
38 * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
39 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
40 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
41 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
42 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
43 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
44 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
46 * ***************************************************************************
54 #include "AdvancedApi.h"
56 #include "OptionMemory.h"
61 #include "cpuRegisters.h"
62 #include "cpuServices.h"
63 #include "GeneralServices.h"
64 #include "cpuFamilyTranslation.h"
65 #include "cpuApicUtilities.h"
66 #include "mfParallelTraining.h"
67 #include "heapManager.h"
72 #define FILECODE PROC_MEM_NB_C32_MNPARTRAINC32_FILECODE
73 /*-----------------------------------------------------------------------------
76 *-----------------------------------------------------------------------------
79 MemFParallelTrainingC32 (
80 IN OUT MEM_NB_BLOCK *NBPtr
85 MemConstructRemoteNBBlockC32 (
86 IN OUT MEM_NB_BLOCK *NBPtr,
87 IN DIE_STRUCT *MCTPtr,
88 IN MEM_FEAT_BLOCK_NB *FeatPtr
90 /* -----------------------------------------------------------------------------*/
94 * This is the training function which set up the environment for remote
95 * training on the ap and launches the remote routine.
97 * @param[in,out] *NBPtr - Pointer to the MEM_NB_BLOCK
99 * @return TRUE - Launch training on AP successfully.
100 * @return FALSE - Fail to launch training on AP.
103 MemFParallelTrainingC32 (
104 IN OUT MEM_NB_BLOCK *NBPtr
107 AMD_CONFIG_PARAMS *StdHeader;
109 REMOTE_TRAINING_ENV *EnvPtr;
110 AP_TASK TrainingTask;
121 ALLOCATE_HEAP_PARAMS AllocHeapParams;
123 StdHeader = &(NBPtr->MemPtr->StdHeader);
124 MCTPtr = NBPtr->MCTPtr;
125 Socket = MCTPtr->SocketId;
126 Module = MCTPtr->DieId;
129 // Allocate buffer for REMOTE_TRAINING_ENV
131 MctDataSize = MAX_DCTS_PER_NODE_C32 * (
132 sizeof (DCT_STRUCT) + (
133 MAX_CHANNELS_PER_DCT_C32 * (sizeof (CH_DEF_STRUCT) + sizeof (MEM_PS_BLOCK))
136 AllocHeapParams.RequestedBufferSize = MctDataSize + sizeof (REMOTE_TRAINING_ENV);
137 AllocHeapParams.BufferHandle = GENERATE_MEM_HANDLE (ALLOC_PAR_TRN_HANDLE, Socket, Module, 0);
138 AllocHeapParams.Persist = HEAP_LOCAL_CACHE;
139 if (HeapAllocateBuffer (&AllocHeapParams, StdHeader) == AGESA_SUCCESS) {
140 EnvPtr = (REMOTE_TRAINING_ENV *) AllocHeapParams.BufferPtr;
141 AllocHeapParams.BufferPtr += sizeof (REMOTE_TRAINING_ENV);
144 // Setup Remote training environment
146 LibAmdMemCopy (&(EnvPtr->StdHeader), StdHeader, sizeof (AMD_CONFIG_PARAMS), StdHeader);
147 LibAmdMemCopy (&(EnvPtr->DieStruct), MCTPtr, sizeof (DIE_STRUCT), StdHeader);
148 for (p = 0; p < MAX_PLATFORM_TYPES; p++) {
149 EnvPtr->GetPlatformCfg[p] = NBPtr->MemPtr->GetPlatformCfg[p];
151 EnvPtr->ErrorHandling = NBPtr->MemPtr->ErrorHandling;
152 EnvPtr->NBBlockCtor = MemConstructRemoteNBBlockC32;
153 EnvPtr->FeatPtr = NBPtr->FeatPtr;
154 EnvPtr->HoleBase = NBPtr->RefPtr->HoleBase;
155 EnvPtr->BottomIo = NBPtr->RefPtr->BottomIo;
156 EnvPtr->UmaSize = NBPtr->RefPtr->UmaSize;
157 EnvPtr->SysLimit = NBPtr->RefPtr->SysLimit;
158 EnvPtr->TableBasedAlterations = NBPtr->RefPtr->TableBasedAlterations;
159 EnvPtr->PlatformMemoryConfiguration = NBPtr->RefPtr->PlatformMemoryConfiguration;
161 LibAmdMemCopy (AllocHeapParams.BufferPtr, MCTPtr->DctData, MctDataSize, StdHeader);
164 // Get Socket, Core of the BSP
166 IdentifyCore (StdHeader, &BspSocket, &BspModule, &BspCore, &Status);
167 EnvPtr->BspSocket = ((UINT8)BspSocket & 0x000000FF);
168 EnvPtr->BspCore = ((UINT8)BspCore & 0x000000FF);
171 // Set up the remote task structure
173 TrainingTask.DataTransfer.DataPtr = EnvPtr;
174 TrainingTask.DataTransfer.DataSizeInDwords = (UINT16) (AllocHeapParams.RequestedBufferSize + 3) / 4;
175 TrainingTask.DataTransfer.DataTransferFlags = 0;
176 TrainingTask.ExeFlags = 0;
177 TrainingTask.FuncAddress.PfApTaskI = (PF_AP_TASK_I)MemFParallelTraining;
180 // Get Target AP Core
182 GetGivenModuleCoreRange (Socket, Module, &LowCore, &HighCore, StdHeader);
183 APCore = (UINT8) (LowCore & 0x000000FF);
186 // Launch Remote Training
188 ApUtilRunCodeOnSocketCore (Socket, APCore, &TrainingTask, StdHeader);
190 HeapDeallocateBuffer (AllocHeapParams.BufferHandle, StdHeader);
194 PutEventLog (AGESA_FATAL, MEM_ERROR_HEAP_ALLOCATE_FOR_REMOTE_TRAINING_ENV, NBPtr->Node, 0, 0, 0, StdHeader);
195 SetMemError (AGESA_FATAL, MCTPtr);
196 ASSERT(FALSE); // Could not allocated heap space for "REMOTE_TRAINING_ENV"
203 MemConstructRemoteNBBlockC32 (
204 IN OUT MEM_NB_BLOCK *NBPtr,
205 IN DIE_STRUCT *MCTPtr,
206 IN MEM_FEAT_BLOCK_NB *FeatPtr
209 CPU_SPECIFIC_SERVICES *FamilySpecificServices;
211 NBPtr->MCTPtr = MCTPtr;
212 NBPtr->PciAddr.AddressValue = MCTPtr->PciAddr.AddressValue;
214 MemNInitNBDataC32 (NBPtr);
216 FeatPtr->InitCPG (NBPtr);
217 NBPtr->FeatPtr = FeatPtr;
218 FeatPtr->InitHwRxEn (NBPtr);
219 MemNSwitchDCTNb (NBPtr, 0);
221 //----------------------------------------------------------------------------
222 // Get TSC rate of the this AP
223 //----------------------------------------------------------------------------
224 GetCpuServicesOfCurrentCore ((CONST CPU_SPECIFIC_SERVICES **)&FamilySpecificServices, &NBPtr->MemPtr->StdHeader);
225 FamilySpecificServices->GetTscRate (FamilySpecificServices, &NBPtr->MemPtr->TscRate, &NBPtr->MemPtr->StdHeader);