summaryrefslogtreecommitdiff
path: root/src/vendorcode/amd/agesa/f15tn/Proc/IDS/Control
diff options
context:
space:
mode:
Diffstat (limited to 'src/vendorcode/amd/agesa/f15tn/Proc/IDS/Control')
-rw-r--r--src/vendorcode/amd/agesa/f15tn/Proc/IDS/Control/IdsCtrl.c855
-rw-r--r--src/vendorcode/amd/agesa/f15tn/Proc/IDS/Control/IdsLib32.asm362
-rw-r--r--src/vendorcode/amd/agesa/f15tn/Proc/IDS/Control/IdsLib64.asm369
-rw-r--r--src/vendorcode/amd/agesa/f15tn/Proc/IDS/Control/IdsNvToCmos.c442
-rw-r--r--src/vendorcode/amd/agesa/f15tn/Proc/IDS/Control/IdsNvToCmos.h110
5 files changed, 2138 insertions, 0 deletions
diff --git a/src/vendorcode/amd/agesa/f15tn/Proc/IDS/Control/IdsCtrl.c b/src/vendorcode/amd/agesa/f15tn/Proc/IDS/Control/IdsCtrl.c
new file mode 100644
index 0000000000..c0e0cbcac4
--- /dev/null
+++ b/src/vendorcode/amd/agesa/f15tn/Proc/IDS/Control/IdsCtrl.c
@@ -0,0 +1,855 @@
+/* $NoKeywords:$ */
+/**
+ * @file
+ *
+ * AMD Integrated Debug Option Backend Routines
+ *
+ * Contains AMD AGESA debug macros and library functions
+ *
+ * @xrefitem bom "File Content Label" "Release Content"
+ * @e project: AGESA
+ * @e sub-project: IDS
+ * @e \$Revision: 63425 $ @e \$Date: 2011-12-22 11:24:10 -0600 (Thu, 22 Dec 2011) $
+ */
+/*****************************************************************************
+ * Copyright 2008 - 2012 ADVANCED MICRO DEVICES, INC. All Rights Reserved.
+ *
+ * AMD is granting you permission to use this software (the Materials)
+ * pursuant to the terms and conditions of your Software License Agreement
+ * with AMD. This header does *NOT* give you permission to use the Materials
+ * or any rights under AMD's intellectual property. Your use of any portion
+ * of these Materials shall constitute your acceptance of those terms and
+ * conditions. If you do not agree to the terms and conditions of the Software
+ * License Agreement, please do not use any portion of these Materials.
+ *
+ * CONFIDENTIALITY: The Materials and all other information, identified as
+ * confidential and provided to you by AMD shall be kept confidential in
+ * accordance with the terms and conditions of the Software License Agreement.
+ *
+ * LIMITATION OF LIABILITY: THE MATERIALS AND ANY OTHER RELATED INFORMATION
+ * PROVIDED TO YOU BY AMD ARE PROVIDED "AS IS" WITHOUT ANY EXPRESS OR IMPLIED
+ * WARRANTY OF ANY KIND, INCLUDING BUT NOT LIMITED TO WARRANTIES OF
+ * MERCHANTABILITY, NONINFRINGEMENT, TITLE, FITNESS FOR ANY PARTICULAR PURPOSE,
+ * OR WARRANTIES ARISING FROM CONDUCT, COURSE OF DEALING, OR USAGE OF TRADE.
+ * IN NO EVENT SHALL AMD OR ITS LICENSORS BE LIABLE FOR ANY DAMAGES WHATSOEVER
+ * (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF PROFITS, BUSINESS
+ * INTERRUPTION, OR LOSS OF INFORMATION) ARISING OUT OF AMD'S NEGLIGENCE,
+ * GROSS NEGLIGENCE, THE USE OF OR INABILITY TO USE THE MATERIALS OR ANY OTHER
+ * RELATED INFORMATION PROVIDED TO YOU BY AMD, EVEN IF AMD HAS BEEN ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGES. BECAUSE SOME JURISDICTIONS PROHIBIT THE
+ * EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES,
+ * THE ABOVE LIMITATION MAY NOT APPLY TO YOU.
+ *
+ * AMD does not assume any responsibility for any errors which may appear in
+ * the Materials or any other related information provided to you by AMD, or
+ * result from use of the Materials or any related information.
+ *
+ * You agree that you will not reverse engineer or decompile the Materials.
+ *
+ * NO SUPPORT OBLIGATION: AMD is not obligated to furnish, support, or make any
+ * further information, software, technical information, know-how, or show-how
+ * available to you. Additionally, AMD retains the right to modify the
+ * Materials at any time, without notice, and is not obligated to provide such
+ * modified Materials to you.
+ *
+ * U.S. GOVERNMENT RESTRICTED RIGHTS: The Materials are provided with
+ * "RESTRICTED RIGHTS." Use, duplication, or disclosure by the Government is
+ * subject to the restrictions as set forth in FAR 52.227-14 and
+ * DFAR252.227-7013, et seq., or its successor. Use of the Materials by the
+ * Government constitutes acknowledgement of AMD's proprietary rights in them.
+ *
+ * EXPORT ASSURANCE: You agree and certify that neither the Materials, nor any
+ * direct product thereof will be exported directly or indirectly, into any
+ * country prohibited by the United States Export Administration Act and the
+ * regulations thereunder, without the required authorization from the U.S.
+ * government nor will be used for any purpose prohibited by the same.
+ ******************************************************************************
+ */
+/*----------------------------------------------------------------------------------------
+ * M O D U L E S U S E D
+ *----------------------------------------------------------------------------------------
+ */
+
+#include "AGESA.h"
+#include "Ids.h"
+#include "Topology.h"
+#include "htFeat.h"
+#include "IdsHt.h"
+#include "amdlib.h"
+#include "mm.h"
+#include "mn.h"
+#include "cpuRegisters.h"
+#include "heapManager.h"
+#include "cpuFamilyTranslation.h"
+#include "GeneralServices.h"
+#include "IdsLib.h"
+#include "IdsNvToCmos.h"
+#include "Filecode.h"
+#ifdef __IDS_EXTENDED__
+ #include IDS_EXT_INCLUDE (IdsInternalLib)
+#endif
+CODE_GROUP (G1_PEICC)
+RDATA_GROUP (G1_PEICC)
+
+#define FILECODE PROC_IDS_CONTROL_IDSCTRL_FILECODE
+
+/*----------------------------------------------------------------------------
+ * EXPORTED FUNCTIONS
+ *
+ *----------------------------------------------------------------------------
+ */
+
+
+extern CONST IDS_FAMILY_FEAT_STRUCT* ROMDATA IdsContorlFeats[];
+
+
+/**
+ * IDS option hooking function dispatcher.
+ *
+ * This is the top level interface for IDS option Backend code.
+ *
+ * @param[in] IdsOption IDS indicator value, see @ref AGESA_IDS_OPTION
+ * @param[in,out] DataPtr Data pointer.
+ * @param[in,out] StdHeader The Pointer of AMD_CONFIG_PARAMS.
+ *
+ * @retval IDS_SUCCESS Backend function is called successfully.
+ * @retval IDS_UNSUPPORTED No Backend function is found.
+ **/
+IDS_STATUS
+AmdIdsCtrlDispatcher (
+ IN AGESA_IDS_OPTION IdsOption,
+ IN OUT VOID *DataPtr,
+ IN OUT AMD_CONFIG_PARAMS *StdHeader
+ )
+{
+ IDS_NV_ITEM *IdsNvPtr;
+ IDS_STATUS ReturnFlag;
+ IDS_STATUS ExtendedFlag;
+
+ IdsNvPtr = NULL;
+ ReturnFlag = IDS_SUCCESS;
+
+ ASSERT (StdHeader != NULL);
+ if (AmdGetIdsNvTable ((VOID **) &IdsNvPtr, StdHeader) != AGESA_SUCCESS) {
+ IDS_HDT_CONSOLE (IDS_TRACE , "IDS initialize\n");
+ AmdIdsCtrlInitialize (StdHeader);
+ AmdGetIdsNvTable ((VOID **) &IdsNvPtr, StdHeader);
+ }
+
+ if (IdsNvPtr != NULL) {
+ ReturnFlag = IdsParseFeatTbl (IdsOption, IdsContorlFeats, DataPtr, IdsNvPtr, StdHeader);
+ ExtendedFlag = IDS_EXTENDED_HOOK (IdsOption, DataPtr, IdsNvPtr, StdHeader);
+ if (ExtendedFlag != IDS_SUCCESS) {
+ ReturnFlag = IDS_UNSUPPORTED;
+ }
+ }
+ return ReturnFlag;
+}
+
+/**
+ * Ids code for parse IDS feat table.
+ *
+ * Feat table in IDS is used to decribe the IDS support feat and its according family,handler.
+ *
+ * @param[in] PIdsFeatTbl point to Ids Feat table
+ * @param[in] IdsOption IDS indicator value, see @ref AGESA_IDS_OPTION
+ * @param[in,out] DataPtr Data pointer.
+ * @param[in] IdsNvPtr Ids Nvram pointer.
+ * @param[in,out] StdHeader The Pointer of AMD_CONFIG_PARAMS.
+ *
+ * @retval IDS_SUCCESS Backend function is called successfully.
+ * @retval IDS_UNSUPPORTED No Backend function is found.
+ **/
+IDS_STATUS
+IdsParseFeatTbl (
+ IN AGESA_IDS_OPTION IdsOption,
+ IN CONST IDS_FAMILY_FEAT_STRUCT * PIdsFeatTbl[],
+ IN OUT VOID *DataPtr,
+ IN IDS_NV_ITEM *IdsNvPtr,
+ IN OUT AMD_CONFIG_PARAMS *StdHeader
+ )
+{
+ UINT16 i;
+ AGESA_STATUS Tmpsts;
+ CPU_LOGICAL_ID CpuLogicalId;
+ BOOLEAN No_Check_Bsp;
+ CONST IDS_FAMILY_FEAT_STRUCT *PIdsFeat;
+ IDS_STATUS ReturnFlag;
+
+ ReturnFlag = IDS_SUCCESS;
+
+ for (i = 0; PIdsFeatTbl[i] != NULL; i++) {
+ PIdsFeat = PIdsFeatTbl[i];
+ //Does specified IdsOption reached
+ if (PIdsFeat->IdsOption == IdsOption) {
+ //check if bsp only
+ if (PIdsFeat->IsBsp) {
+ No_Check_Bsp = 0;
+ } else {
+ No_Check_Bsp = 1;
+ }
+ if (No_Check_Bsp || IsBsp (StdHeader, &Tmpsts)) {
+ //Does Family Match required
+ GetLogicalIdOfCurrentCore (&CpuLogicalId, StdHeader);
+ if ((CpuLogicalId.Family) & (PIdsFeat->CpuFamily)) {
+ //Excute the code for specific Ids Feat
+ IDS_HDT_CONSOLE (IDS_TRACE, "\tIDS Excute HookPoint [%x] Start\n", IdsOption);
+ ReturnFlag = PIdsFeat->pf_idsoption (DataPtr, StdHeader, IdsNvPtr);
+ IDS_HDT_CONSOLE (IDS_TRACE, "\tIDS Excute HookPoint [%x] End\n", IdsOption);
+ }
+ }
+ }
+ }
+ return ReturnFlag;
+}
+
+/**
+ *
+ * IDS Object Initialization
+ *
+ * Initializer routine that will be invoked by the wrapper to initialize
+ * the data buffer in heap for the IDS object. It includes IDS control
+ * structure, IDS mem table and IDS GRA table.
+ *
+ * @param[in,out] StdHeader The Pointer of IDS Initial Parameter
+ *
+ * @retval AGESA_SUCCESS Success to init IDS Object.
+ * @retval AGESA_ERROR Fail to init IDS Object.
+ *
+ **/
+
+#ifdef IDS_HEAP_2STAGES
+ #define IDS_HEAP_PERSIST_EARLY HEAP_LOCAL_CACHE
+ #define IDS_HEAP_ASSERTION_LATE
+#else
+ #define IDS_HEAP_PERSIST_EARLY HEAP_SYSTEM_MEM
+ #define IDS_HEAP_ASSERTION_LATE ASSERT(FALSE)
+#endif
+
+AGESA_STATUS
+AmdIdsCtrlInitialize (
+ IN OUT AMD_CONFIG_PARAMS *StdHeader
+ )
+{
+ AGESA_STATUS status;
+ AGESA_STATUS IgnoreStatus;
+ UINT16 NvTblSize;
+ UINT16 i;
+ IDS_NV_ITEM IdsNvTable[IDS_NUM_NV_ITEM];
+ IDS_NV_ITEM *NvTable;
+ IDS_NV_ITEM *NvPtr;
+ IDS_CONTROL_STRUCT *IdsCtrlPtr;
+ IDS_CALLOUT_STRUCT IdsCalloutData;
+ ALLOCATE_HEAP_PARAMS AllocHeapParams;
+ UINT16 MemTblSize;
+ UINT8 HeapPersist;
+
+ NvTblSize = 0;
+ MemTblSize = 0;
+ HeapPersist = HEAP_SYSTEM_MEM;
+ //Heap status with HEAP_LOCAL_CACHE, will allocate heap with HEAP_LOCAL_CACHE
+ //with HEAP_TEMP_MEM HEAP_SYSTEM_MEM HEAP_DO_NOT_EXIST_ANYMORE HEAP_S3_RESUME
+ // with allocate with HEAP_SYSTEM_MEM
+ if (StdHeader->HeapStatus == HEAP_LOCAL_CACHE) {
+ MemTblSize = IDS_MAX_MEM_ITEMS;
+ HeapPersist = IDS_HEAP_PERSIST_EARLY;
+ } else if ((StdHeader->HeapStatus == HEAP_DO_NOT_EXIST_YET) || (StdHeader->HeapStatus == HEAP_DO_NOT_EXIST_ANYMORE)) {
+ return AGESA_ERROR;
+ } else {
+ IDS_HEAP_ASSERTION_LATE;
+ }
+
+ IdsCalloutData.IdsNvPtr = IdsNvTable;
+ IdsCalloutData.StdHeader = *StdHeader;
+ IdsCalloutData.Reserved = FALSE;
+//init IDS_CALLOUT_STRUCT before calling out, give NVITEM default value
+ for (i = AGESA_IDS_EXT_ID_START; i < IDS_NUM_NV_ITEM; i++) {
+ IdsNvTable[i].IdsNvId = i;
+ IdsNvTable[i].IdsNvValue = AGESA_IDS_DFT_VAL;
+ }
+
+ AGESA_TESTPOINT (TpIfBeforeGetIdsData, StdHeader);
+ if (AgesaGetIdsData (IDS_CALLOUT_INIT, &IdsCalloutData) == AGESA_SUCCESS) {
+ IDS_HDT_CONSOLE (IDS_TRACE , "Get IDS options from CBS Done\n");
+ NvTable = IdsCalloutData.IdsNvPtr;
+ NvPtr = NvTable;
+ while (NvPtr->IdsNvId != AGESA_IDS_NV_END) {
+ IDS_HDT_CONSOLE (IDS_TRACE , "\tIDS_ID (%X) = %X\n", NvPtr->IdsNvId, NvPtr->IdsNvValue);
+ NvTblSize ++;
+ NvPtr ++;
+ }
+ NvTblSize ++;
+
+ AllocHeapParams.RequestedBufferSize = sizeof (IDS_CONTROL_STRUCT);
+ AllocHeapParams.RequestedBufferSize += NvTblSize * sizeof (IDS_NV_ITEM);
+ AllocHeapParams.RequestedBufferSize += MemTblSize * sizeof (MEM_TABLE_ALIAS);
+ AllocHeapParams.RequestedBufferSize += IDS_EXTENDED_HEAP_SIZE;
+ AllocHeapParams.BufferHandle = IDS_CONTROL_HANDLE;
+ AllocHeapParams.Persist = HeapPersist;
+
+ //
+ // Allocate data buffer in heap
+ //
+ if (HeapAllocateBuffer (&AllocHeapParams, (AMD_CONFIG_PARAMS *) StdHeader) == AGESA_SUCCESS) {
+ //
+ // Initialize IDS Date Buffer
+ //
+ IdsCtrlPtr = (IDS_CONTROL_STRUCT *) AllocHeapParams.BufferPtr;
+ IdsCtrlPtr->IgnoreIdsDefault = (BOOLEAN) IdsCalloutData.Reserved;
+ IdsCtrlPtr->IdsHeapMemSize = AllocHeapParams.RequestedBufferSize;
+ IdsCtrlPtr->IdsNvTableOffset = sizeof (IDS_CONTROL_STRUCT);
+ IdsCtrlPtr->IdsMemTableOffset = IdsCtrlPtr->IdsNvTableOffset + NvTblSize * sizeof (IDS_NV_ITEM);
+ IdsCtrlPtr->IdsExtendOffset = IdsCtrlPtr->IdsMemTableOffset + MemTblSize * sizeof (MEM_TABLE_ALIAS);
+
+ NvPtr = (IDS_NV_ITEM *) (AllocHeapParams.BufferPtr + IdsCtrlPtr->IdsNvTableOffset);
+ for (i = 0; i < NvTblSize ; i++) {
+ NvPtr->IdsNvId = NvTable->IdsNvId;
+ NvPtr->IdsNvValue = NvTable->IdsNvValue;
+ NvPtr ++;
+ NvTable ++;
+ }
+ status = AGESA_SUCCESS;
+ } else {
+ status = AGESA_ERROR;
+ }
+ } else {
+ if (!IsBsp (StdHeader, &IgnoreStatus)) {
+ status = IDS_AP_GET_NV_FROM_CMOS (StdHeader);
+ } else {
+ IDS_HDT_CONSOLE (IDS_TRACE , "Get IDS options from CBS Fail\n");
+ status = AGESA_ERROR;
+ }
+ }
+ AGESA_TESTPOINT (TpIfAfterGetIdsData, StdHeader);
+
+ return status;
+}
+/**
+ * IDS Backend Function for Target Pstate
+ *
+ *
+ * @param[in,out] DataPtr The Pointer of AMD_CPU_EARLY_PARAMS.
+ * @param[in,out] StdHeader The Pointer of AMD_CONFIG_PARAMS.
+ * @param[in] IdsNvPtr The Pointer of NV Table.
+ *
+ * @retval IDS_SUCCESS Backend function is called successfully.
+ * @retval IDS_UNSUPPORTED No Backend function is found.
+ *
+ **/
+IDS_STATUS
+IdsSubTargetPstate (
+ IN OUT VOID *DataPtr,
+ IN OUT AMD_CONFIG_PARAMS *StdHeader,
+ IN IDS_NV_ITEM *IdsNvPtr
+ )
+{
+ IDS_STATUS tarpst;
+ CPU_SPECIFIC_SERVICES *FamilySpecificServices;
+
+ IDS_NV_READ_SKIP (tarpst, AGESA_IDS_NV_TARGET_PSTATE, IdsNvPtr, StdHeader) {
+ GetCpuServicesOfCurrentCore ((CONST CPU_SPECIFIC_SERVICES **)&FamilySpecificServices, StdHeader);
+ FamilySpecificServices->TransitionPstate (FamilySpecificServices, (UINT8) tarpst, (BOOLEAN) FALSE, StdHeader);
+ }
+ return IDS_SUCCESS;
+}
+
+/**
+ * IDS Backend Function for HdtOut
+ *
+ *
+ * @param[in,out] DataPtr The Pointer of AMD_CPU_EARLY_PARAMS.
+ * @param[in,out] StdHeader The Pointer of AMD_CONFIG_PARAMS.
+ * @param[in] IdsNvPtr The Pointer of NV Table.
+ *
+ * @retval IDS_SUCCESS Backend function is called successfully.
+ * @retval IDS_UNSUPPORTED No Backend function is found.
+ *
+ **/
+IDS_STATUS
+IdsSubHdtOut (
+ IN OUT VOID *DataPtr,
+ IN OUT AMD_CONFIG_PARAMS *StdHeader,
+ IN IDS_NV_ITEM *IdsNvPtr
+ )
+{
+ IDS_STATUS idsvalue;
+
+//set HDTOUT En/Dis
+ IDS_NV_READ_SKIP (idsvalue, AGESA_IDS_NV_HDTOUT, IdsNvPtr, StdHeader) {
+//if HDTOUT set to enable, set the corresponding DR2 flag to 0x99cc
+ if (idsvalue == 1) {
+ LibAmdWriteCpuReg (DR2_REG, 0x99cc);
+ }
+ }
+ return IDS_SUCCESS;
+}
+
+/**
+ * IDS Backend Function for Power down mode
+ *
+ * @param[in,out] DataPtr The Pointer of AMD_POST_PARAMS.
+ * @param[in,out] StdHeader The Pointer of AMD_CONFIG_PARAMS.
+ * @param[in] IdsNvPtr The Pointer of NV Table.
+ *
+ * @retval IDS_SUCCESS Backend function is called successfully.
+ * @retval IDS_UNSUPPORTED No Backend function is found.
+ *
+ **/
+IDS_STATUS
+IdsSubPowerDownCtrl (
+ IN OUT VOID *DataPtr,
+ IN OUT AMD_CONFIG_PARAMS *StdHeader,
+ IN IDS_NV_ITEM *IdsNvPtr
+ )
+{
+ AMD_POST_PARAMS *PostParamsPtr;
+ MEM_PARAMETER_STRUCT *RefPtr;
+ IDS_STATUS idsvalue;
+ MEM_DATA_STRUCT * memdataptr;
+
+ PostParamsPtr = (AMD_POST_PARAMS *)DataPtr;
+ memdataptr = PostParamsPtr->MemConfig.MemData;
+ RefPtr = memdataptr->ParameterListPtr;
+
+ IDS_NV_READ_SKIP (idsvalue, AGESA_IDS_NV_MEMORY_POWER_DOWN, IdsNvPtr, StdHeader) {
+ //if the idsvalue isn't auto do the override
+ if (idsvalue < (IDS_STATUS)0x2) {
+ RefPtr->EnablePowerDown = (BOOLEAN) idsvalue;
+ }
+ }
+ return IDS_SUCCESS;
+}
+
+/**
+ * Backend Function for IDS Option Hook Point: IDS_UCODE
+ *
+ * This function is used to disable UCode Installation if IDS Option disables ucode.
+ * The method is to force the number of total patches to ZERO.
+ *
+ * @param[in,out] DataPtr The Pointer of Data to Override.
+ * @param[in,out] StdHeader The Pointer of AGESA Header.
+ * @param[in] IdsNvPtr The Pointer of NV Table.
+ *
+ * @retval IDS_SUCCESS Backend function is called successfully.
+ * @retval IDS_UNSUPPORTED No Backend function is found.
+ *
+ **/
+IDS_STATUS
+IdsSubUCode (
+ IN OUT VOID *DataPtr,
+ IN OUT AMD_CONFIG_PARAMS *StdHeader,
+ IN IDS_NV_ITEM *IdsNvPtr
+ )
+{
+ IDS_STATUS status;
+ IDS_STATUS NvValue;
+ UINT8 ** pUcodeptr;
+
+ pUcodeptr = (UINT8 **) DataPtr;
+ status = IDS_SUCCESS;
+ IDS_NV_READ_SKIP (NvValue, AGESA_IDS_NV_UCODE, IdsNvPtr, StdHeader) {
+ //Disabled
+ if (NvValue == 0) {
+ status = IDS_UNSUPPORTED;
+ }
+ }
+
+ IDS_EXTENDED_CODE (
+ IdsGetBvmUcodeBase (pUcodeptr, StdHeader);
+ )
+
+ return status;
+}
+
+/**
+ * IDS Backend Function for Post P-State
+ *
+ * This function is used to set Post P-State which are CPU specifically.
+ *
+ * @param[in,out] DataPtr The Pointer of AMD_CPU_EARLY_PARAMS.
+ * @param[in,out] StdHeader The Pointer of AMD_CONFIG_PARAMS.
+ * @param[in] IdsNvPtr The Pointer of NV Table.
+ *
+ * @retval IDS_SUCCESS Backend function is called successfully.
+ * @retval IDS_UNSUPPORTED No Backend function is found.
+ *
+ **/
+IDS_STATUS
+IdsSubPostPState (
+ IN OUT VOID *DataPtr,
+ IN OUT AMD_CONFIG_PARAMS *StdHeader,
+ IN IDS_NV_ITEM *IdsNvPtr
+ )
+{
+ AMD_CPU_EARLY_PARAMS *PCpuEarlyParams;
+ IDS_STATUS idsvalue;
+ UINT8 curpstatesnum;
+
+ PCpuEarlyParams = (AMD_CPU_EARLY_PARAMS *)DataPtr;
+ curpstatesnum = IdsGetNumPstatesFamCommon (StdHeader);
+ idsvalue = AmdIdsNvReader (AGESA_IDS_NV_POSTPSTATE, IdsNvPtr, StdHeader);
+
+ if (idsvalue < (IDS_STATUS) (curpstatesnum + 3)) {
+ switch (idsvalue) {
+ case (IDS_STATUS) 0x0:
+ // Auto
+ break;
+ case (IDS_STATUS) 0x1:
+ // Maximum Performance
+ PCpuEarlyParams->MemInitPState = 0;
+ break;
+ case (IDS_STATUS) 0x2:
+ // Minimum Performance
+ PCpuEarlyParams->MemInitPState = curpstatesnum - 1;
+ break;
+ default:
+ PCpuEarlyParams->MemInitPState = (UINT8) (idsvalue - 3);
+ break;
+ }
+ }
+ return IDS_SUCCESS;
+}
+
+
+
+/**
+ * IDS Backend Function for Memory Mode Unganged
+ *
+ * This function is used to override Memory Mode Unganged.
+ *
+ * @param[in,out] DataPtr The Pointer of AMD_POST_PARAMS.
+ * @param[in,out] StdHeader The Pointer of AMD_CONFIG_PARAMS.
+ * @param[in] IdsNvPtr The Pointer of NV Table.
+ *
+ * @retval IDS_SUCCESS Backend function is called successfully.
+ * @retval IDS_UNSUPPORTED No Backend function is found.
+ *
+ **/
+IDS_STATUS
+IdsSubGangingMode (
+ IN OUT VOID *DataPtr,
+ IN OUT AMD_CONFIG_PARAMS *StdHeader,
+ IN IDS_NV_ITEM *IdsNvPtr
+ )
+{
+ IDS_STATUS GangingMode;
+ IDS_NV_READ_SKIP (GangingMode, AGESA_IDS_NV_DCT_GANGING_MODE, IdsNvPtr, StdHeader) {
+ *((UINT8 *)DataPtr) = (UINT8) GangingMode;
+ }
+ return IDS_SUCCESS;
+}
+
+/**
+ * IDS Backend Function for Power Down Mode
+ *
+ * This function is used to override Power Down Mode.
+ *
+ * @param[in,out] DataPtr The Pointer of AMD_POST_PARAMS.
+ * @param[in,out] StdHeader The Pointer of AMD_CONFIG_PARAMS.
+ * @param[in] IdsNvPtr The Pointer of NV Table.
+ *
+ * @retval IDS_SUCCESS Backend function is called successfully.
+ * @retval IDS_UNSUPPORTED No Backend function is found.
+ *
+ **/
+IDS_STATUS
+IdsSubPowerDownMode (
+ IN OUT VOID *DataPtr,
+ IN OUT AMD_CONFIG_PARAMS *StdHeader,
+ IN IDS_NV_ITEM *IdsNvPtr
+ )
+{
+ IDS_STATUS PowerDownMode;
+ PowerDownMode = AmdIdsNvReader (AGESA_IDS_NV_MEMORY_POWER_DOWN_MODE, IdsNvPtr, StdHeader);
+ if (PowerDownMode < (IDS_STATUS)0x2) {
+ *((UINT8 *) DataPtr) = (UINT8)PowerDownMode;
+ }
+ return IDS_SUCCESS;
+}
+
+/**
+ * IDS Backend Function for Burst Length32
+ *
+ * This function is used to override Burst Length32.
+ *
+ * @param[in,out] DataPtr The Pointer of AMD_POST_PARAMS.
+ * @param[in,out] StdHeader The Pointer of AMD_CONFIG_PARAMS.
+ * @param[in] IdsNvPtr The Pointer of NV Table.
+ *
+ * @retval IDS_SUCCESS Backend function is called successfully.
+ * @retval IDS_UNSUPPORTED No Backend function is found.
+ *
+ **/
+IDS_STATUS
+IdsSubBurstLength32 (
+ IN OUT VOID *DataPtr,
+ IN OUT AMD_CONFIG_PARAMS *StdHeader,
+ IN IDS_NV_ITEM *IdsNvPtr
+ )
+{
+ IDS_STATUS BurstLength32;
+ BurstLength32 = AmdIdsNvReader (AGESA_IDS_NV_DRAM_BURST_LENGTH32, IdsNvPtr, StdHeader);
+ if (BurstLength32 < (IDS_STATUS)0x2) {
+ *((UINT8 *) DataPtr) = (UINT8)BurstLength32;
+ }
+ return IDS_SUCCESS;
+}
+
+/**
+ * IDS Backend Function for All Memory Clks Enable
+ *
+ * This function is used to override All Memory Clks Enable
+ *
+ * @param[in,out] DataPtr The Pointer of AMD_POST_PARAMS.
+ * @param[in,out] StdHeader The Pointer of AMD_CONFIG_PARAMS.
+ * @param[in] IdsNvPtr The Pointer of NV Table.
+ *
+ * @retval IDS_SUCCESS Backend function is called successfully.
+ * @retval IDS_UNSUPPORTED No Backend function is found.
+ *
+ **/
+IDS_STATUS
+IdsSubAllMemClkEn (
+ IN OUT VOID *DataPtr,
+ IN OUT AMD_CONFIG_PARAMS *StdHeader,
+ IN IDS_NV_ITEM *IdsNvPtr
+ )
+{
+ IDS_STATUS AllMemClkEn;
+
+ AllMemClkEn = AmdIdsNvReader (AGESA_IDS_NV_ALL_MEMCLKS , IdsNvPtr, StdHeader);
+ if (AllMemClkEn < (IDS_STATUS)0x2) {
+ *((UINT8 *) DataPtr) = (UINT8)AllMemClkEn;
+ }
+
+ return IDS_SUCCESS;
+}
+
+/**
+ * IDS Backend Function for Dll Shut Down
+ *
+ * This function is used to override Dll Shut Down Option
+ *
+ * @param[in,out] DataPtr The Pointer of AMD_POST_PARAMS.
+ * @param[in,out] StdHeader The Pointer of AMD_CONFIG_PARAMS.
+ * @param[in] IdsNvPtr The Pointer of NV Table.
+ *
+ * @retval IDS_SUCCESS Backend function is called successfully.
+ * @retval IDS_UNSUPPORTED No Backend function is found.
+ *
+ **/
+IDS_STATUS
+IdsSubDllShutDownSR (
+ IN OUT VOID *DataPtr,
+ IN OUT AMD_CONFIG_PARAMS *StdHeader,
+ IN IDS_NV_ITEM *IdsNvPtr
+ )
+{
+ IDS_STATUS DllShutDownSR;
+ IDS_NV_READ_SKIP (DllShutDownSR, AGESA_IDS_NV_DLL_SHUT_DOWN , IdsNvPtr, StdHeader) {
+ *((UINT8 *) DataPtr) = (UINT8)DllShutDownSR;
+ }
+ return IDS_SUCCESS;
+}
+
+/**
+ * IDS Backend Function for HT Link Configuration
+ *
+ * Provide the nv settings to the HT code in the form of a port override list.
+ * Create the list on the heap, so the HT code doesn't have to keep asking for it.
+ *
+ * @param[out] Data A reference to the HT Port Override List
+ * @param[in] StdHeader Header for library and services.
+ * @param[in] IdsNvPtr The Pointer of NV Table.
+ *
+ * @retval IDS_SUCCESS Backend function is called successfully.
+ * @retval IDS_UNSUPPORTED No Backend function is found.
+ *
+ */
+IDS_STATUS
+IdsSubHtLinkControl (
+ OUT VOID *Data,
+ IN AMD_CONFIG_PARAMS *StdHeader,
+ IN IDS_NV_ITEM *IdsNvPtr
+ )
+{
+ ALLOCATE_HEAP_PARAMS AllocHeapParams;
+ HTIDS_PORT_OVERRIDE_LIST *ListReference;
+ HTIDS_PORT_OVERRIDE_LIST PortOverrideList;
+ UINT32 HTlinkSocket;
+ UINT32 HTlinkPort;
+ UINT32 HTlinkFre;
+ UINT32 HTlinkWidthIn;
+ UINT32 HTlinkWidthOut;
+
+ ASSERT (IdsNvPtr != NULL);
+ ASSERT (Data != NULL);
+
+ ListReference = Data;
+ *ListReference = NULL;
+ // Allocated the number of portlist override option sets supported (currently 2) plus 1 more for terminal.
+ AllocHeapParams.RequestedBufferSize = (sizeof (HTIDS_PORT_OVERRIDE) * 3);
+ AllocHeapParams.BufferHandle = IDS_HT_DATA_HANDLE;
+ AllocHeapParams.Persist = HEAP_LOCAL_CACHE;
+ if (HeapAllocateBuffer (&AllocHeapParams, StdHeader) == AGESA_SUCCESS) {
+ PortOverrideList = (HTIDS_PORT_OVERRIDE_LIST) AllocHeapParams.BufferPtr;
+ LibAmdMemFill (PortOverrideList, HT_LIST_TERMINAL, AllocHeapParams.RequestedBufferSize, StdHeader);
+ *ListReference = PortOverrideList;
+
+ HTlinkSocket = AmdIdsNvReader (AGESA_IDS_NV_HTLINKSOCKET, IdsNvPtr, StdHeader);
+ if (HTlinkSocket != IDS_UNSUPPORTED) {
+ switch (HTlinkSocket) {
+ case (UINT32) 0xE:
+ HTlinkSocket = 0xFE;
+ break;
+ case (UINT32) 0xF:
+ HTlinkSocket = 0xFF;
+ break;
+ default:
+ break;
+ }
+ PortOverrideList->Socket = (UINT8) HTlinkSocket;
+ }
+ HTlinkPort = AmdIdsNvReader (AGESA_IDS_NV_HTLINKPORT, IdsNvPtr, StdHeader);
+ if (HTlinkPort != IDS_UNSUPPORTED) {
+ switch (HTlinkPort) {
+ case (UINT32) 0xC:
+ HTlinkPort = 0xFC;
+ break;
+ case (UINT32) 0xD:
+ HTlinkPort = 0xFD;
+ break;
+ case (UINT32) 0xE:
+ HTlinkPort = 0xFE;
+ break;
+ case (UINT32) 0xF:
+ HTlinkPort = 0xFF;
+ break;
+ default:
+ break;
+ }
+ PortOverrideList->Link = (UINT8) HTlinkPort;
+ }
+ HTlinkFre = AmdIdsNvReader (AGESA_IDS_NV_HTLINKFREQ, IdsNvPtr, StdHeader);
+ if (HTlinkFre != IDS_UNSUPPORTED) {
+ switch (HTlinkFre) {
+ case (UINT32) 0x1F:
+ HTlinkFre = 0xFF;
+ break;
+ default:
+ break;
+ }
+ PortOverrideList->Frequency = (UINT8) HTlinkFre;
+ }
+ HTlinkWidthIn = AmdIdsNvReader (AGESA_IDS_NV_HTLINKWIDTHIN , IdsNvPtr, StdHeader);
+ if (HTlinkWidthIn != IDS_UNSUPPORTED) {
+ switch (HTlinkWidthIn) {
+ case (UINT32) 0x0:
+ HTlinkWidthIn = 8;
+ break;
+ case (UINT32) 0x01:
+ HTlinkWidthIn = 16;
+ break;
+ case (UINT32) 0x04:
+ HTlinkWidthIn = 2;
+ break;
+ case (UINT32) 0x5:
+ HTlinkWidthIn = 4;
+ break;
+ case (UINT32) 0x7:
+ HTlinkWidthIn = 0xFF;
+ break;
+ default:
+ break;
+ }
+ PortOverrideList->WidthIn = (UINT8) HTlinkWidthIn;
+ }
+ HTlinkWidthOut = AmdIdsNvReader (AGESA_IDS_NV_HTLINKWIDTHOUT, IdsNvPtr, StdHeader);
+ if (HTlinkWidthOut != IDS_UNSUPPORTED) {
+ switch (HTlinkWidthOut) {
+ case (UINT32) 0x0:
+ HTlinkWidthOut = 8;
+ break;
+ case (UINT32) 0x01:
+ HTlinkWidthOut = 16;
+ break;
+ case (UINT32) 0x04:
+ HTlinkWidthOut = 2;
+ break;
+ case (UINT32) 0x5:
+ HTlinkWidthOut = 4;
+ break;
+ case (UINT32) 0x7:
+ HTlinkWidthOut = 0xFF;
+ break;
+ default:
+ break;
+ }
+ PortOverrideList->WidthOut = (UINT8) HTlinkWidthOut;
+ }
+ if (PortOverrideList->Link == 0xFC) {
+ // force both internal and external links
+ // switch first PortOverride to force External
+ HTlinkPort = 0xFE; //Match external
+ PortOverrideList->Link = (UINT8) HTlinkPort;
+
+ // read all settings from first override list except Link
+ HTlinkSocket = PortOverrideList->Socket;
+ HTlinkPort = 0xFD; //Match internal
+ HTlinkFre = PortOverrideList->Frequency;
+ HTlinkWidthIn = PortOverrideList->WidthIn;
+ HTlinkWidthOut = PortOverrideList->WidthOut;
+
+ // copy settings into second override list
+ PortOverrideList++;
+
+ PortOverrideList->Socket = (UINT8) HTlinkSocket;
+ PortOverrideList->Link = (UINT8) HTlinkPort;
+ PortOverrideList->Frequency = (UINT8) HTlinkFre;
+ PortOverrideList->WidthIn = (UINT8) HTlinkWidthIn;
+ PortOverrideList->WidthOut = (UINT8) HTlinkWidthOut;
+ }
+ }
+ return IDS_SUCCESS;
+}
+/**
+ * IDS Backend Function for Select Platform Power Policy
+ *
+ * Parameters:
+ * @param[in,out] DataPtr The Pointer of PLATFORM_CONFIGURATION.
+ * @param[in,out] StdHeader AMD standard header config param
+ * @param[in] IdsNvPtr The Pointer of NV Table.
+ *
+ * @retval AGESA_SUCCESS Always Succeeds.
+ *
+ */
+IDS_STATUS
+IdsSubPowerPolicyOverride (
+ IN OUT VOID *DataPtr,
+ IN OUT AMD_CONFIG_PARAMS *StdHeader,
+ IN IDS_NV_ITEM *IdsNvPtr
+ )
+{
+ PLATFORM_CONFIGURATION *PlatformConfig;
+ IDS_STATUS NvValue;
+
+ PlatformConfig = (PLATFORM_CONFIGURATION *)DataPtr;
+
+ IDS_NV_READ_SKIP (NvValue, AGESA_IDS_NV_POWER_POLICY, IdsNvPtr, StdHeader) {
+ switch (NvValue) {
+ case IDS_POWER_POLICY_PERFORMANCE:
+ PlatformConfig->PlatformProfile.PlatformPowerPolicy = Performance;
+ break;
+ case IDS_POWER_POLICY_POWER:
+ PlatformConfig->PlatformProfile.PlatformPowerPolicy = BatteryLife;
+ break;
+ case IDS_POWER_POLICY_AUTO:
+ break;
+ default:
+ ASSERT (FALSE);
+ break;
+ }
+ }
+
+ return IDS_SUCCESS;
+}
diff --git a/src/vendorcode/amd/agesa/f15tn/Proc/IDS/Control/IdsLib32.asm b/src/vendorcode/amd/agesa/f15tn/Proc/IDS/Control/IdsLib32.asm
new file mode 100644
index 0000000000..9615e853cd
--- /dev/null
+++ b/src/vendorcode/amd/agesa/f15tn/Proc/IDS/Control/IdsLib32.asm
@@ -0,0 +1,362 @@
+;/**
+; * @file
+; *
+; * Ids Assembly library 32bit
+; *
+; * @xrefitem bom "File Content Label" "Release Content"
+; * @e project: AGESA
+; * @e sub-project: IDS
+; * @e \$Revision: 14305 $ @e \$Date: 2009-05-24 02:20:55 +0800 (Sun, 24 May 2009) $
+; */
+;*****************************************************************************
+;
+; Copyright 2008 - 2012 ADVANCED MICRO DEVICES, INC. All Rights Reserved.
+;
+; AMD is granting you permission to use this software (the Materials)
+; pursuant to the terms and conditions of your Software License Agreement
+; with AMD. This header does *NOT* give you permission to use the Materials
+; or any rights under AMD's intellectual property. Your use of any portion
+; of these Materials shall constitute your acceptance of those terms and
+; conditions. If you do not agree to the terms and conditions of the Software
+; License Agreement, please do not use any portion of these Materials.
+;
+; CONFIDENTIALITY: The Materials and all other information, identified as
+; confidential and provided to you by AMD shall be kept confidential in
+; accordance with the terms and conditions of the Software License Agreement.
+;
+; LIMITATION OF LIABILITY: THE MATERIALS AND ANY OTHER RELATED INFORMATION
+; PROVIDED TO YOU BY AMD ARE PROVIDED "AS IS" WITHOUT ANY EXPRESS OR IMPLIED
+; WARRANTY OF ANY KIND, INCLUDING BUT NOT LIMITED TO WARRANTIES OF
+; MERCHANTABILITY, NONINFRINGEMENT, TITLE, FITNESS FOR ANY PARTICULAR PURPOSE,
+; OR WARRANTIES ARISING FROM CONDUCT, COURSE OF DEALING, OR USAGE OF TRADE.
+; IN NO EVENT SHALL AMD OR ITS LICENSORS BE LIABLE FOR ANY DAMAGES WHATSOEVER
+; (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF PROFITS, BUSINESS
+; INTERRUPTION, OR LOSS OF INFORMATION) ARISING OUT OF AMD'S NEGLIGENCE,
+; GROSS NEGLIGENCE, THE USE OF OR INABILITY TO USE THE MATERIALS OR ANY OTHER
+; RELATED INFORMATION PROVIDED TO YOU BY AMD, EVEN IF AMD HAS BEEN ADVISED OF
+; THE POSSIBILITY OF SUCH DAMAGES. BECAUSE SOME JURISDICTIONS PROHIBIT THE
+; EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES,
+; THE ABOVE LIMITATION MAY NOT APPLY TO YOU.
+;
+; AMD does not assume any responsibility for any errors which may appear in
+; the Materials or any other related information provided to you by AMD, or
+; result from use of the Materials or any related information.
+;
+; You agree that you will not reverse engineer or decompile the Materials.
+;
+; NO SUPPORT OBLIGATION: AMD is not obligated to furnish, support, or make any
+; further information, software, technical information, know-how, or show-how
+; available to you. Additionally, AMD retains the right to modify the
+; Materials at any time, without notice, and is not obligated to provide such
+; modified Materials to you.
+;
+; U.S. GOVERNMENT RESTRICTED RIGHTS: The Materials are provided with
+; "RESTRICTED RIGHTS." Use, duplication, or disclosure by the Government is
+; subject to the restrictions as set forth in FAR 52.227-14 and
+; DFAR252.227-7013, et seq., or its successor. Use of the Materials by the
+; Government constitutes acknowledgement of AMD's proprietary rights in them.
+;
+; EXPORT ASSURANCE: You agree and certify that neither the Materials, nor any
+; direct product thereof will be exported directly or indirectly, into any
+; country prohibited by the United States Export Administration Act and the
+; regulations thereunder, without the required authorization from the U.S.
+; government nor will be used for any purpose prohibited by the same.
+;*****************************************************************************
+
+.586p
+.model flat
+ASSUME FS:NOTHING
+.code
+public IdsDelay
+IdsDelay PROC NEAR C USES EAX EDX
+Local targetedx:dword, targeteax:dword
+ rdtsc
+;set target time
+ add eax,1500000000
+ adc edx,0
+ mov targetedx,edx
+ mov targeteax,eax
+
+ rdtsc
+;set "Si!=0" skip below loop
+ .while(1)
+ .if(si != 0)
+ jmp delay_exit
+ .endif
+ .if(edx > targetedx)
+ jmp delay_exit
+ .elseif (edx == targetedx)
+ .if(eax > targeteax)
+ jmp delay_exit
+ .endif
+ .endif
+ rdtsc
+ .endw
+delay_exit:
+ ret
+IdsDelay ENDP
+;/*++
+;
+;Routine Description:
+;
+; IdsErrorStop -- Function for Assert
+;
+;Arguments:
+; Filecode
+;
+;Returns:
+;
+; None
+;
+;--*/
+public IdsErrorStop
+IdsErrorStop PROC NEAR C filecode:dword
+local tmpebx:dword,tmpedx:dword
+ pushad
+
+ mov si,0 ; Si is used as control flag, "Si!=0" skip postcode loop
+; send debug port 1st, then fire SimNow breakpoint
+ mov ax, 0deadh
+ out 0e0h, ax
+ mov eax, filecode
+ out 84h, eax
+ mov eax, 0BACCD00Bh ; Backdoor in SimNow
+ mov ebx, 2 ; Select breakpoint feature
+ cpuid
+
+ mov ebx,0dead0000h
+ mov edx,filecode
+ ror edx,16
+ mov bx,dx
+ mov dx,0
+;ebx:edx = deadxxxxyyyy0000 xxxx is the filecode yyyy is the line num
+ mov tmpebx,ebx
+ mov tmpedx,edx
+
+ xor eax,eax
+ mov cl,6
+
+ .while((cl != 0) && (si == 0))
+ .if(cl <= 2)
+ shld eax,edx,8
+ shl edx,8
+ .else
+ shld eax,ebx,8
+ shl ebx,8
+ .endif
+
+ out 80h,eax
+ call IdsDelay
+ dec cl
+ .if(cl == 0)
+ mov cl,6
+ mov ebx,tmpebx
+ mov edx,tmpedx
+ .endif
+ .endw
+
+ popad
+ xor eax,eax
+ ret
+IdsErrorStop endp
+
+;/*---------------------------------------------------------------------------------------*/
+;/**
+; * Stop CPU
+; *
+; *
+; *
+; */
+IDS_STOP_HERE MACRO
+@@:
+ jmp short @b
+ENDM
+
+;======================================================================
+; IdsExceptionHandler: Simply performs a jmp $ and IRET.
+;
+; In:
+; None
+;
+; Out:
+; None
+;
+; Destroyed:
+; None
+;
+;======================================================================
+PUBLIC _IdsExceptionHandler
+PUBLIC _SizeIdtDescriptor
+PUBLIC _SizeTotalIdtDescriptors
+
+; Size of each exception MUST be the same
+Exception00:
+ push eax
+ mov al, 00h
+ jmp near ptr CommonHandler
+; Size of each exception MUST be the same
+Exception01:
+ push eax
+ mov al, 01h
+ jmp near ptr CommonHandler
+; Size of each exception MUST be the same
+Exception02:
+ push eax
+ mov al, 02h
+ jmp near ptr CommonHandler
+; Size of each exception MUST be the same
+Exception03:
+ push eax
+ mov al, 03h
+ jmp near ptr CommonHandler
+; Size of each exception MUST be the same
+Exception04:
+ push eax
+ mov al, 04h
+ jmp near ptr CommonHandler
+; Size of each exception MUST be the same
+Exception05:
+ push eax
+ mov al, 05h
+ jmp near ptr CommonHandler
+; Size of each exception MUST be the same
+Exception06:
+ push eax
+ mov al, 06h
+ jmp near ptr CommonHandler
+; Size of each exception MUST be the same
+Exception07:
+ push eax
+ mov al, 07h
+ jmp near ptr CommonHandler
+; Size of each exception MUST be the same
+Exception08:
+ push eax
+ mov al, 08h
+ jmp near ptr CommonHandler
+; Size of each exception MUST be the same
+Exception09:
+ push eax
+ mov al, 09h
+ jmp near ptr CommonHandler
+; Size of each exception MUST be the same
+Exception10:
+ push eax
+ mov al, 10h
+ jmp near ptr CommonHandler
+; Size of each exception MUST be the same
+Exception11:
+ push eax
+ mov al, 11h
+ jmp near ptr CommonHandler
+; Size of each exception MUST be the same
+Exception12:
+ push eax
+ mov al, 12h
+ jmp near ptr CommonHandler
+; Size of each exception MUST be the same
+Exception13:
+ push eax
+ mov al, 13h
+ jmp near ptr CommonHandler
+; Size of each exception MUST be the same
+Exception14:
+ push eax
+ mov al, 14h
+ jmp near ptr CommonHandler
+; Size of each exception MUST be the same
+Exception15:
+ push eax
+ mov al, 15h
+ jmp near ptr CommonHandler
+; Size of each exception MUST be the same
+Exception16:
+ push eax
+ mov al, 16h
+ jmp near ptr CommonHandler
+; Size of each exception MUST be the same
+Exception17:
+ push eax
+ mov al, 17h
+ jmp near ptr CommonHandler
+; Size of each exception MUST be the same
+Exception18:
+ push eax
+ mov al, 18h
+ jmp near ptr CommonHandler
+; Size of each exception MUST be the same
+Exception19:
+ push eax
+ mov al, 19h
+ jmp near ptr CommonHandler
+; Size of each exception MUST be the same
+Exception20:
+ push eax
+ mov al, 20h
+ jmp near ptr CommonHandler
+; Size of each exception MUST be the same
+Exception21:
+ push eax
+ mov al, 21h
+ jmp near ptr CommonHandler
+; Size of each exception MUST be the same
+Exception22:
+ push eax
+ mov al, 22h
+ jmp near ptr CommonHandler
+; Size of each exception MUST be the same
+Exception23:
+ push eax
+ mov al, 23h
+ jmp near ptr CommonHandler
+; Size of each exception MUST be the same
+Exception24:
+ push eax
+ mov al, 24h
+ jmp near ptr CommonHandler
+; Size of each exception MUST be the same
+Exception25:
+ push eax
+ mov al, 25h
+ jmp near ptr CommonHandler
+; Size of each exception MUST be the same
+Exception26:
+ push eax
+ mov al, 26
+ jmp near ptr CommonHandler
+; Size of each exception MUST be the same
+Exception27:
+ push eax
+ mov al, 27h
+ jmp near ptr CommonHandler
+; Size of each exception MUST be the same
+Exception28:
+ push eax
+ mov al, 28h
+ jmp near ptr CommonHandler
+; Size of each exception MUST be the same
+Exception29:
+ push eax
+ mov al, 29h
+ jmp near ptr CommonHandler
+; Size of each exception MUST be the same
+Exception30:
+ push eax
+ mov al, 30h
+ jmp near ptr CommonHandler
+; Size of each exception MUST be the same
+Exception31:
+ push eax
+ mov al, 31h
+ jmp near ptr CommonHandler
+CommonHandler:
+ out 80h, al
+ pop eax
+ IDS_STOP_HERE
+ iretd
+
+_IdsExceptionHandler dq offset Exception00
+_SizeIdtDescriptor dd (offset Exception01 - offset Exception00)
+_SizeTotalIdtDescriptors dd (offset CommonHandler - offset Exception00)
+
+END
diff --git a/src/vendorcode/amd/agesa/f15tn/Proc/IDS/Control/IdsLib64.asm b/src/vendorcode/amd/agesa/f15tn/Proc/IDS/Control/IdsLib64.asm
new file mode 100644
index 0000000000..2651494e4f
--- /dev/null
+++ b/src/vendorcode/amd/agesa/f15tn/Proc/IDS/Control/IdsLib64.asm
@@ -0,0 +1,369 @@
+;/**
+; * @file
+; *
+; * Ids Assembly library 64bit
+; *
+; *
+; * @xrefitem bom "File Content Label" "Release Content"
+; * @e project: AGESA
+; * @e sub-project: IDS
+; * @e \$Revision: 14126 $ @e \$Date: 2009-05-21 23:02:32 +0800 (Thu, 21 May 2009) $
+; */
+;*****************************************************************************
+;
+; Copyright 2008 - 2012 ADVANCED MICRO DEVICES, INC. All Rights Reserved.
+;
+; AMD is granting you permission to use this software (the Materials)
+; pursuant to the terms and conditions of your Software License Agreement
+; with AMD. This header does *NOT* give you permission to use the Materials
+; or any rights under AMD's intellectual property. Your use of any portion
+; of these Materials shall constitute your acceptance of those terms and
+; conditions. If you do not agree to the terms and conditions of the Software
+; License Agreement, please do not use any portion of these Materials.
+;
+; CONFIDENTIALITY: The Materials and all other information, identified as
+; confidential and provided to you by AMD shall be kept confidential in
+; accordance with the terms and conditions of the Software License Agreement.
+;
+; LIMITATION OF LIABILITY: THE MATERIALS AND ANY OTHER RELATED INFORMATION
+; PROVIDED TO YOU BY AMD ARE PROVIDED "AS IS" WITHOUT ANY EXPRESS OR IMPLIED
+; WARRANTY OF ANY KIND, INCLUDING BUT NOT LIMITED TO WARRANTIES OF
+; MERCHANTABILITY, NONINFRINGEMENT, TITLE, FITNESS FOR ANY PARTICULAR PURPOSE,
+; OR WARRANTIES ARISING FROM CONDUCT, COURSE OF DEALING, OR USAGE OF TRADE.
+; IN NO EVENT SHALL AMD OR ITS LICENSORS BE LIABLE FOR ANY DAMAGES WHATSOEVER
+; (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF PROFITS, BUSINESS
+; INTERRUPTION, OR LOSS OF INFORMATION) ARISING OUT OF AMD'S NEGLIGENCE,
+; GROSS NEGLIGENCE, THE USE OF OR INABILITY TO USE THE MATERIALS OR ANY OTHER
+; RELATED INFORMATION PROVIDED TO YOU BY AMD, EVEN IF AMD HAS BEEN ADVISED OF
+; THE POSSIBILITY OF SUCH DAMAGES. BECAUSE SOME JURISDICTIONS PROHIBIT THE
+; EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES,
+; THE ABOVE LIMITATION MAY NOT APPLY TO YOU.
+;
+; AMD does not assume any responsibility for any errors which may appear in
+; the Materials or any other related information provided to you by AMD, or
+; result from use of the Materials or any related information.
+;
+; You agree that you will not reverse engineer or decompile the Materials.
+;
+; NO SUPPORT OBLIGATION: AMD is not obligated to furnish, support, or make any
+; further information, software, technical information, know-how, or show-how
+; available to you. Additionally, AMD retains the right to modify the
+; Materials at any time, without notice, and is not obligated to provide such
+; modified Materials to you.
+;
+; U.S. GOVERNMENT RESTRICTED RIGHTS: The Materials are provided with
+; "RESTRICTED RIGHTS." Use, duplication, or disclosure by the Government is
+; subject to the restrictions as set forth in FAR 52.227-14 and
+; DFAR252.227-7013, et seq., or its successor. Use of the Materials by the
+; Government constitutes acknowledgement of AMD's proprietary rights in them.
+;
+; EXPORT ASSURANCE: You agree and certify that neither the Materials, nor any
+; direct product thereof will be exported directly or indirectly, into any
+; country prohibited by the United States Export Administration Act and the
+; regulations thereunder, without the required authorization from the U.S.
+; government nor will be used for any purpose prohibited by the same.
+;*****************************************************************************
+
+.code
+IdsDelay PROC
+ push rax
+ push rdx
+ push rbx
+ xor rax,rax
+ xor rdx,rdx
+ rdtsc
+;set target time
+ add eax,1500000000
+ adc edx,0
+ shl rdx,32
+ add rdx,rax
+ mov rbx,rdx
+;rbx store the target
+;set "Si!=0" skip below loop
+__loop:
+ cmp si,0
+ jnz __loopexit
+ rdtsc
+ shl rdx,32
+ add rdx,rax
+ cmp rdx,rbx
+ jae __loopexit
+ jmp __loop
+__loopexit:
+ pop rbx
+ pop rdx
+ pop rax
+ ret
+IdsDelay ENDP
+;/*++
+;
+;Routine Description:
+;
+; IdsErrorStop -- Function for Assert
+;
+;Arguments:
+; Filecode
+;
+;Returns:
+;
+; None
+;
+;--*/
+public IdsErrorStop
+IdsErrorStop PROC
+;As x64 calling convention RCX is used as input parameters
+ push rcx
+ push rbx
+ push si
+ push dx
+ push rbx
+
+ mov si,0 ; Si is used as control flag, "Si!=0" skip postcode loop
+; send debug port 1st, then fire SimNow breakpoint
+ mov ax, 0deadh
+ out 0e0h, ax
+ mov eax, ecx
+ out 84h, eax
+ mov eax, 0BACCD00Bh ; Backdoor in SimNow
+ mov ebx, 2 ; Select breakpoint feature
+ cpuid
+
+ mov rax,0dead00000000h
+ or rcx,rax
+;rcx= 0dead__FILECODE
+ shl rcx,16
+;rcx= 0dead__FILECODE__0000
+ mov rbx,rcx
+
+ xor rax,rax
+ mov dl,6
+
+IdsErrorStopLoop:
+ cmp dl,0
+ jz IdsErrorStopExit
+ cmp si,0
+ jnz IdsErrorStopExit
+
+ shld rax,rcx,8
+ shl rcx,8
+ out 80h,eax
+ call IdsDelay
+
+ dec dl
+ cmp dl,0
+ jnz _nextloop
+ mov dl,6
+ mov rcx,rbx
+_nextloop:
+ jmp IdsErrorStopLoop
+IdsErrorStopExit:
+ pop rbx
+ pop dx
+ pop si
+ pop rbx
+ pop rcx
+ xor rax,rax
+ ret
+IdsErrorStop endp
+
+;/*---------------------------------------------------------------------------------------*/
+;/**
+; * Stop CPU
+; *
+; *
+; *
+; */
+IDS_STOP_HERE MACRO
+@@:
+ jmp short @b
+ENDM
+
+;======================================================================
+; IdsExceptionHandler: Simply performs a jmp $ and IRET.
+;
+; In:
+; None
+;
+; Out:
+; None
+;
+; Destroyed:
+; None
+;
+;======================================================================
+PUBLIC IdsExceptionHandler
+PUBLIC SizeIdtDescriptor
+PUBLIC SizeTotalIdtDescriptors
+
+; Size of each exception MUST be the same
+Exception00:
+ push rax
+ mov al, 00h
+ jmp near ptr CommonHandler
+; Size of each exception MUST be the same
+Exception01:
+ push rax
+ mov al, 01h
+ jmp near ptr CommonHandler
+; Size of each exception MUST be the same
+Exception02:
+ push rax
+ mov al, 02h
+ jmp near ptr CommonHandler
+; Size of each exception MUST be the same
+Exception03:
+ push rax
+ mov al, 03h
+ jmp near ptr CommonHandler
+; Size of each exception MUST be the same
+Exception04:
+ push rax
+ mov al, 04h
+ jmp near ptr CommonHandler
+; Size of each exception MUST be the same
+Exception05:
+ push rax
+ mov al, 05h
+ jmp near ptr CommonHandler
+; Size of each exception MUST be the same
+Exception06:
+ push rax
+ mov al, 06h
+ jmp near ptr CommonHandler
+; Size of each exception MUST be the same
+Exception07:
+ push rax
+ mov al, 07h
+ jmp near ptr CommonHandler
+; Size of each exception MUST be the same
+Exception08:
+ push rax
+ mov al, 08h
+ jmp near ptr CommonHandler
+; Size of each exception MUST be the same
+Exception09:
+ push rax
+ mov al, 09h
+ jmp near ptr CommonHandler
+; Size of each exception MUST be the same
+Exception10:
+ push rax
+ mov al, 10h
+ jmp near ptr CommonHandler
+; Size of each exception MUST be the same
+Exception11:
+ push rax
+ mov al, 11h
+ jmp near ptr CommonHandler
+; Size of each exception MUST be the same
+Exception12:
+ push rax
+ mov al, 12h
+ jmp near ptr CommonHandler
+; Size of each exception MUST be the same
+Exception13:
+ push rax
+ mov al, 13h
+ jmp near ptr CommonHandler
+; Size of each exception MUST be the same
+Exception14:
+ push rax
+ mov al, 14h
+ jmp near ptr CommonHandler
+; Size of each exception MUST be the same
+Exception15:
+ push rax
+ mov al, 15h
+ jmp near ptr CommonHandler
+; Size of each exception MUST be the same
+Exception16:
+ push rax
+ mov al, 16h
+ jmp near ptr CommonHandler
+; Size of each exception MUST be the same
+Exception17:
+ push rax
+ mov al, 17h
+ jmp near ptr CommonHandler
+; Size of each exception MUST be the same
+Exception18:
+ push rax
+ mov al, 18h
+ jmp near ptr CommonHandler
+; Size of each exception MUST be the same
+Exception19:
+ push rax
+ mov al, 19h
+ jmp near ptr CommonHandler
+; Size of each exception MUST be the same
+Exception20:
+ push rax
+ mov al, 20h
+ jmp near ptr CommonHandler
+; Size of each exception MUST be the same
+Exception21:
+ push rax
+ mov al, 21h
+ jmp near ptr CommonHandler
+; Size of each exception MUST be the same
+Exception22:
+ push rax
+ mov al, 22h
+ jmp near ptr CommonHandler
+; Size of each exception MUST be the same
+Exception23:
+ push rax
+ mov al, 23h
+ jmp near ptr CommonHandler
+; Size of each exception MUST be the same
+Exception24:
+ push rax
+ mov al, 24h
+ jmp near ptr CommonHandler
+; Size of each exception MUST be the same
+Exception25:
+ push rax
+ mov al, 25h
+ jmp near ptr CommonHandler
+; Size of each exception MUST be the same
+Exception26:
+ push rax
+ mov al, 26
+ jmp near ptr CommonHandler
+; Size of each exception MUST be the same
+Exception27:
+ push rax
+ mov al, 27h
+ jmp near ptr CommonHandler
+; Size of each exception MUST be the same
+Exception28:
+ push rax
+ mov al, 28h
+ jmp near ptr CommonHandler
+; Size of each exception MUST be the same
+Exception29:
+ push rax
+ mov al, 29h
+ jmp near ptr CommonHandler
+; Size of each exception MUST be the same
+Exception30:
+ push rax
+ mov al, 30h
+ jmp near ptr CommonHandler
+; Size of each exception MUST be the same
+Exception31:
+ push rax
+ mov al, 31h
+ jmp near ptr CommonHandler
+CommonHandler:
+ out 80h, al
+ pop rax
+ IDS_STOP_HERE
+ iretq
+
+IdsExceptionHandler dq offset Exception00
+SizeIdtDescriptor dd (offset Exception01 - offset Exception00)
+SizeTotalIdtDescriptors dd (offset CommonHandler - offset Exception00)
+
+END
+
diff --git a/src/vendorcode/amd/agesa/f15tn/Proc/IDS/Control/IdsNvToCmos.c b/src/vendorcode/amd/agesa/f15tn/Proc/IDS/Control/IdsNvToCmos.c
new file mode 100644
index 0000000000..b9a69b7863
--- /dev/null
+++ b/src/vendorcode/amd/agesa/f15tn/Proc/IDS/Control/IdsNvToCmos.c
@@ -0,0 +1,442 @@
+/* $NoKeywords:$ */
+/**
+ * @file
+ *
+ * AMD Integrated Debug library Routines
+ *
+ * Contains AMD AGESA debug macros and library functions
+ *
+ * @xrefitem bom "File Content Label" "Release Content"
+ * @e project: AGESA
+ * @e sub-project: IDS
+ * @e \$Revision: 63425 $ @e \$Date: 2011-12-22 11:24:10 -0600 (Thu, 22 Dec 2011) $
+ */
+/*****************************************************************************
+ * Copyright 2008 - 2012 ADVANCED MICRO DEVICES, INC. All Rights Reserved.
+ *
+ * AMD is granting you permission to use this software (the Materials)
+ * pursuant to the terms and conditions of your Software License Agreement
+ * with AMD. This header does *NOT* give you permission to use the Materials
+ * or any rights under AMD's intellectual property. Your use of any portion
+ * of these Materials shall constitute your acceptance of those terms and
+ * conditions. If you do not agree to the terms and conditions of the Software
+ * License Agreement, please do not use any portion of these Materials.
+ *
+ * CONFIDENTIALITY: The Materials and all other information, identified as
+ * confidential and provided to you by AMD shall be kept confidential in
+ * accordance with the terms and conditions of the Software License Agreement.
+ *
+ * LIMITATION OF LIABILITY: THE MATERIALS AND ANY OTHER RELATED INFORMATION
+ * PROVIDED TO YOU BY AMD ARE PROVIDED "AS IS" WITHOUT ANY EXPRESS OR IMPLIED
+ * WARRANTY OF ANY KIND, INCLUDING BUT NOT LIMITED TO WARRANTIES OF
+ * MERCHANTABILITY, NONINFRINGEMENT, TITLE, FITNESS FOR ANY PARTICULAR PURPOSE,
+ * OR WARRANTIES ARISING FROM CONDUCT, COURSE OF DEALING, OR USAGE OF TRADE.
+ * IN NO EVENT SHALL AMD OR ITS LICENSORS BE LIABLE FOR ANY DAMAGES WHATSOEVER
+ * (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF PROFITS, BUSINESS
+ * INTERRUPTION, OR LOSS OF INFORMATION) ARISING OUT OF AMD'S NEGLIGENCE,
+ * GROSS NEGLIGENCE, THE USE OF OR INABILITY TO USE THE MATERIALS OR ANY OTHER
+ * RELATED INFORMATION PROVIDED TO YOU BY AMD, EVEN IF AMD HAS BEEN ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGES. BECAUSE SOME JURISDICTIONS PROHIBIT THE
+ * EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES,
+ * THE ABOVE LIMITATION MAY NOT APPLY TO YOU.
+ *
+ * AMD does not assume any responsibility for any errors which may appear in
+ * the Materials or any other related information provided to you by AMD, or
+ * result from use of the Materials or any related information.
+ *
+ * You agree that you will not reverse engineer or decompile the Materials.
+ *
+ * NO SUPPORT OBLIGATION: AMD is not obligated to furnish, support, or make any
+ * further information, software, technical information, know-how, or show-how
+ * available to you. Additionally, AMD retains the right to modify the
+ * Materials at any time, without notice, and is not obligated to provide such
+ * modified Materials to you.
+ *
+ * U.S. GOVERNMENT RESTRICTED RIGHTS: The Materials are provided with
+ * "RESTRICTED RIGHTS." Use, duplication, or disclosure by the Government is
+ * subject to the restrictions as set forth in FAR 52.227-14 and
+ * DFAR252.227-7013, et seq., or its successor. Use of the Materials by the
+ * Government constitutes acknowledgement of AMD's proprietary rights in them.
+ *
+ * EXPORT ASSURANCE: You agree and certify that neither the Materials, nor any
+ * direct product thereof will be exported directly or indirectly, into any
+ * country prohibited by the United States Export Administration Act and the
+ * regulations thereunder, without the required authorization from the U.S.
+ * government nor will be used for any purpose prohibited by the same.
+ ******************************************************************************
+ */
+/*----------------------------------------------------------------------------------------
+ * M O D U L E S U S E D
+ *----------------------------------------------------------------------------------------
+ */
+
+#include "AGESA.h"
+#include "Ids.h"
+#include "IdsLib.h"
+#include "amdlib.h"
+#include "heapManager.h"
+#include "IdsNvToCmos.h"
+#include "Filecode.h"
+CODE_GROUP (G1_PEICC)
+RDATA_GROUP (G1_PEICC)
+
+#define FILECODE PROC_IDS_CONTROL_IDSNVTOCMOS_FILECODE
+
+/*----------------------------------------------------------------------------
+ * DEFINITIONS AND MACROS
+ *
+ *----------------------------------------------------------------------------
+ */
+
+/*----------------------------------------------------------------------------
+ * EXPORTED FUNCTIONS
+ *
+ *----------------------------------------------------------------------------
+ */
+extern IDS_NV_TO_CMOS gIdsNVToCmos[];
+
+/**
+ *
+ * Read CMOS
+ *
+ * @param[in] IndexPort Index port of access CMOS
+ * @param[in] DataPort Data port of access CMOS
+ * @param[in] Index Index of CMOS
+ * @param[in,out] Value Point to Value
+ * @param[in,out] StdHeader The Pointer of Standard Header.
+ *
+ **/
+VOID
+IdsReadCmos (
+ IN UINT16 IndexPort,
+ IN UINT16 DataPort,
+ IN UINT16 Index,
+ IN OUT UINT8 *Value,
+ IN OUT AMD_CONFIG_PARAMS *StdHeader
+ )
+{
+ LibAmdIoWrite (AccessWidth8, IndexPort, &Index, StdHeader);
+ LibAmdIoRead (AccessWidth8, DataPort, Value, StdHeader);
+}
+/**
+ *
+ * Write CMOS
+ *
+ * @param[in] IndexPort Index port of access CMOS
+ * @param[in] DataPort Data port of access CMOS
+ * @param[in] Index Index of CMOS
+ * @param[in,out] Value Point to Value
+ * @param[in,out] StdHeader The Pointer of Standard Header.
+ *
+ **/
+VOID
+IdsWriteCmos (
+ IN UINT16 IndexPort,
+ IN UINT16 DataPort,
+ IN UINT16 Index,
+ IN OUT UINT8 *Value,
+ IN OUT AMD_CONFIG_PARAMS *StdHeader
+ )
+{
+ LibAmdIoWrite (AccessWidth8, IndexPort, &Index, StdHeader);
+ LibAmdIoWrite (AccessWidth8, DataPort, Value, StdHeader);
+}
+/**
+ *
+ * Get IDS CMOS save region in the AGESA Heap.
+ *
+ * @param[in,out] IdsCmosRegion The Pointer of IDS CMOS save address in heap.
+ * @param[in,out] StdHeader The Pointer of Standard Header.
+ *
+ * @retval AGESA_SUCCESS Success to get the pointer of NV Table.
+ * @retval AGESA_ERROR Fail to get the pointer of NV Table.
+ **/
+AGESA_STATUS
+AmdGetIdsCmosSaveRegion (
+ IN OUT VOID **IdsCmosRegion,
+ IN OUT AMD_CONFIG_PARAMS *StdHeader
+ )
+{
+ AGESA_STATUS status;
+ LOCATE_HEAP_PTR LocateHeapStructPtr;
+ ALLOCATE_HEAP_PARAMS AllocHeapParams;
+
+ LocateHeapStructPtr.BufferHandle = IDS_NV_TO_CMOS_HANDLE;
+ LocateHeapStructPtr.BufferPtr = NULL;
+ status = HeapLocateBuffer (&LocateHeapStructPtr, StdHeader);
+ if (status == AGESA_SUCCESS) {
+ *IdsCmosRegion = LocateHeapStructPtr.BufferPtr;
+ } else {
+ //Allocated the heap when can't located
+ AllocHeapParams.RequestedBufferSize = IDS_CMOS_REGION_END - IDS_CMOS_REGION_START + 1;
+ AllocHeapParams.BufferHandle = IDS_NV_TO_CMOS_HANDLE;
+ AllocHeapParams.Persist = HEAP_LOCAL_CACHE;
+ status = HeapAllocateBuffer (&AllocHeapParams, (AMD_CONFIG_PARAMS *) StdHeader);
+ if (status == AGESA_SUCCESS) {
+ *IdsCmosRegion = AllocHeapParams.BufferPtr;
+ }
+ }
+ return status;
+}
+
+
+/**
+ * IDS Backend Function for save BSP's NV heap to CMOS
+ *
+ *
+ * @param[in,out] StdHeader The Pointer of AMD_CONFIG_PARAMS.
+ *
+ * @retval IDS_SUCCESS Backend function is called successfully.
+ * @retval IDS_UNSUPPORTED No Backend function is found.
+ *
+ **/
+IDS_STATUS
+IdsCheckCmosValid (
+ IN OUT AMD_CONFIG_PARAMS *StdHeader
+ )
+{
+ UINT8 CmosIndex;
+ UINT8 TmpValue;
+ UINT8 Len;
+ UINT8 Sum;
+ CmosIndex = IDS_CMOS_REGION_SIGNATURE_OFFSET;
+ //Validate the Signature
+ IdsReadCmos (IDS_CMOS_INDEX_PORT, IDS_CMOS_DATA_PORT, CmosIndex, &TmpValue, StdHeader);
+ if (TmpValue != 'N') {
+ return IDS_UNSUPPORTED;
+ }
+
+ CmosIndex++;
+ IdsReadCmos (IDS_CMOS_INDEX_PORT, IDS_CMOS_DATA_PORT, CmosIndex, &TmpValue, StdHeader);
+ if (TmpValue != 'V') {
+ return IDS_UNSUPPORTED;
+ }
+
+ CmosIndex = IDS_CMOS_REGION_LENGTH_OFFSET;
+ IdsReadCmos (IDS_CMOS_INDEX_PORT, IDS_CMOS_DATA_PORT, CmosIndex, &Len, StdHeader);
+ if (Len > (IDS_CMOS_REGION_END - IDS_CMOS_REGION_START - IDS_NV_TO_CMOS_HEADER_SIZE + 1)) {
+ return IDS_UNSUPPORTED;
+ }
+ Sum = 0;
+ CmosIndex = IDS_CMOS_REGION_CHECKSUM_OFFSET;
+ for (; CmosIndex < IDS_CMOS_REGION_DATA_OFFSET + Len; CmosIndex++) {
+ IdsReadCmos (IDS_CMOS_INDEX_PORT, IDS_CMOS_DATA_PORT, CmosIndex, &TmpValue, StdHeader);
+ Sum = (UINT8) (Sum + TmpValue);
+ }
+ if (Sum != 0) {
+ return IDS_UNSUPPORTED;
+ }
+ return IDS_SUCCESS;
+}
+
+/**
+ *
+ * AP get NV from CMOS
+ *
+ * If Ap Can't get Nv Data from Callout, Try to Create NV heap via the
+ * CMOS data area save by BSP previous
+
+ *
+ * @param[in,out] StdHeader The Pointer of IDS Initial Parameter
+ *
+ * @retval AGESA_SUCCESS Success to get the NV from CMOS
+ * @retval AGESA_ERROR Fail to get
+ *
+ **/
+AGESA_STATUS
+AmdIdsApGetNvFromCmos (
+ IN OUT AMD_CONFIG_PARAMS *StdHeader
+ )
+{
+ AGESA_STATUS status;
+ ALLOCATE_HEAP_PARAMS AllocHeapParams;
+ IDS_CONTROL_STRUCT *IdsCtrlPtr;
+ UINT8 CmosIndex;
+ UINT8 TmpValue;
+ UINT8 TmpU16Value;
+ UINT8 k;
+ UINT16 i;
+ IDS_NV_ITEM *NvPtr;
+ UINT8 Len;
+ status = AGESA_ERROR;
+ if (IdsCheckCmosValid (StdHeader) == IDS_SUCCESS) {
+ AllocHeapParams.RequestedBufferSize = sizeof (IDS_CONTROL_STRUCT);
+ AllocHeapParams.RequestedBufferSize += (IDS_CMOS_REGION_END - IDS_CMOS_REGION_START - IDS_NV_TO_CMOS_HEADER_SIZE + 2) * sizeof (IDS_NV_ITEM) ;
+ AllocHeapParams.BufferHandle = IDS_CONTROL_HANDLE;
+ AllocHeapParams.Persist = HEAP_LOCAL_CACHE;
+
+ //
+ // Allocate data buffer in heap
+ //
+ status = HeapAllocateBuffer (&AllocHeapParams, (AMD_CONFIG_PARAMS *) StdHeader);
+ if (status == AGESA_SUCCESS) {
+ IdsCtrlPtr = (IDS_CONTROL_STRUCT *) AllocHeapParams.BufferPtr;
+ IdsCtrlPtr->IgnoreIdsDefault = TRUE;
+ IdsCtrlPtr->IdsHeapMemSize = AllocHeapParams.RequestedBufferSize;
+ IdsCtrlPtr->IdsNvTableOffset = sizeof (IDS_CONTROL_STRUCT);
+ NvPtr = (IDS_NV_ITEM *) (AllocHeapParams.BufferPtr + IdsCtrlPtr->IdsNvTableOffset);
+ i = 0;
+ CmosIndex = IDS_CMOS_REGION_LENGTH_OFFSET;
+ IdsReadCmos (IDS_CMOS_INDEX_PORT, IDS_CMOS_DATA_PORT, CmosIndex, &Len, StdHeader);
+ CmosIndex = IDS_CMOS_REGION_DATA_OFFSET;
+ while ((gIdsNVToCmos[i].Length != IDS_NV_TO_CMOS_LEN_END) &&
+ (gIdsNVToCmos[i].IDS_NV_ID != IDS_NV_TO_CMOS_ID_END) &&
+ (CmosIndex <= IDS_CMOS_REGION_END) &&
+ (Len-- > 0)) {
+ if (gIdsNVToCmos[i].Length == IDS_NV_TO_CMOS_LEN_BYTE || gIdsNVToCmos[i].Length == IDS_NV_TO_CMOS_LEN_WORD) {
+ TmpU16Value = 0;
+ for (k = 0; k < gIdsNVToCmos[i].Length; k++, CmosIndex++) {
+ IdsReadCmos (IDS_CMOS_INDEX_PORT, IDS_CMOS_DATA_PORT, CmosIndex, &TmpValue, StdHeader);
+ TmpU16Value |= (UINT16)TmpValue << (k * 8);
+ }
+ if ((TmpU16Value != IDS_NV_TO_CMOS_BYTE_IGNORED && (gIdsNVToCmos[i].Length == IDS_NV_TO_CMOS_LEN_BYTE)) ||
+ (TmpU16Value != IDS_NV_TO_CMOS_WORD_IGNORED && (gIdsNVToCmos[i].Length == IDS_NV_TO_CMOS_LEN_WORD))) {
+ NvPtr->IdsNvId = gIdsNVToCmos[i].IDS_NV_ID;
+ NvPtr->IdsNvValue = TmpU16Value;
+ NvPtr ++;
+ }
+ }
+ i++;
+ }
+ NvPtr->IdsNvId = AGESA_IDS_NV_END;
+ }
+ }
+ return status;
+}
+
+/**
+ * IDS Backend Function for Restore CMOS
+ *
+ *
+ * @param[in,out] DataPtr NULL
+ * @param[in,out] StdHeader The Pointer of AMD_CONFIG_PARAMS.
+ * @param[in] IdsNvPtr The Pointer of NV Table.
+ *
+ * @retval IDS_SUCCESS Backend function is called successfully.
+ * @retval IDS_UNSUPPORTED No Backend function is found.
+ *
+ **/
+IDS_STATUS
+IdsSubRestoreCmos (
+ IN OUT VOID *DataPtr,
+ IN OUT AMD_CONFIG_PARAMS *StdHeader,
+ IN IDS_NV_ITEM *IdsNvPtr
+ )
+{
+ UINT8 *PCmosSave;
+ UINT8 CmosIndex;
+
+ //Save CMOS to BSP heap
+ if (AmdGetIdsCmosSaveRegion ((VOID **) &PCmosSave, StdHeader) == AGESA_SUCCESS) {
+ for (CmosIndex = IDS_CMOS_REGION_START; CmosIndex <= IDS_CMOS_REGION_END; CmosIndex++, PCmosSave++) {
+ IdsWriteCmos (IDS_CMOS_INDEX_PORT, IDS_CMOS_DATA_PORT, CmosIndex, PCmosSave, StdHeader);
+ }
+ }
+ return IDS_SUCCESS;
+}
+/**
+ * IDS Backend Function for save BSP's NV heap to CMOS
+ *
+ *
+ * @param[in,out] DataPtr NULL
+ * @param[in,out] StdHeader The Pointer of AMD_CONFIG_PARAMS.
+ * @param[in] IdsNvPtr The Pointer of NV Table.
+ *
+ * @retval IDS_SUCCESS Backend function is called successfully.
+ * @retval IDS_UNSUPPORTED No Backend function is found.
+ *
+ **/
+IDS_STATUS
+IdsSubSaveBspNvHeapToCmos (
+ IN OUT VOID *DataPtr,
+ IN OUT AMD_CONFIG_PARAMS *StdHeader,
+ IN IDS_NV_ITEM *IdsNvPtr
+ )
+{
+ UINT8 i;
+ UINT8 k;
+ UINT8 CmosIndex;
+ UINT8 TmpValue;
+ UINT8 Sum;
+ UINT8 Len;
+ UINT8 *PCmosSave;
+ IDS_STATUS IdsNvValue;
+
+ //Save CMOS to BSP heap
+ if (AmdGetIdsCmosSaveRegion ((VOID **) &PCmosSave, StdHeader) == AGESA_SUCCESS) {
+ for (CmosIndex = IDS_CMOS_REGION_START; CmosIndex <= IDS_CMOS_REGION_END; CmosIndex++) {
+ IdsReadCmos (IDS_CMOS_INDEX_PORT, IDS_CMOS_DATA_PORT, CmosIndex, &TmpValue, StdHeader);
+ *(PCmosSave++) = TmpValue;
+ }
+ //The CMOS Region is saved to heap,Now we can save BSP NV to CMOS
+ i = 0;
+ CmosIndex = IDS_CMOS_REGION_SIGNATURE_OFFSET;
+ //CMOS Map
+ // **********************************************************************************
+ // Field | Offset | Description
+ // **********************************************************************************
+ // Signature | 0 | 'NV' specify the IDS Cmos save region
+ // **********************************************************************************
+ // Length | 2 | Actual Length of all save NV, may less than platform
+ // | | define
+ // **********************************************************************************
+ // CheckSum | 3 | CheckSum of all NV fields exclue Signature & Length
+ // **********************************************************************************
+ // NVSaveRegion | 4 | Nv Save Region
+ // **********************************************************************************
+ // Set Signature 'NV';
+ TmpValue = 'N';
+ IdsWriteCmos (IDS_CMOS_INDEX_PORT, IDS_CMOS_DATA_PORT, CmosIndex, &TmpValue, StdHeader);
+ CmosIndex++;
+ TmpValue = 'V';
+ IdsWriteCmos (IDS_CMOS_INDEX_PORT, IDS_CMOS_DATA_PORT, CmosIndex, &TmpValue, StdHeader);
+
+ CmosIndex = IDS_CMOS_REGION_DATA_OFFSET;
+ Sum = 0;
+ Len = 0;
+ while ((gIdsNVToCmos[i].Length != IDS_NV_TO_CMOS_LEN_END) &&
+ (gIdsNVToCmos[i].IDS_NV_ID != IDS_NV_TO_CMOS_ID_END) &&
+ (CmosIndex <= IDS_CMOS_REGION_END)) {
+ //Get NV Value length
+ if (gIdsNVToCmos[i].Length == IDS_NV_TO_CMOS_LEN_BYTE || gIdsNVToCmos[i].Length == IDS_NV_TO_CMOS_LEN_WORD) {
+ IdsNvValue = AmdIdsNvReader (gIdsNVToCmos[i].IDS_NV_ID, IdsNvPtr, StdHeader);
+ for (k = 0; k < gIdsNVToCmos[i].Length; k++) {
+ TmpValue = (UINT8) ((IdsNvValue >> (8 * k)) & 0xFF);
+ Sum = (UINT8) (Sum + TmpValue);
+ Len++;
+ IdsWriteCmos (IDS_CMOS_INDEX_PORT, IDS_CMOS_DATA_PORT, CmosIndex, &TmpValue, StdHeader);
+ CmosIndex++;
+ }
+ } else {
+ ASSERT (FALSE);
+ }
+ i++;
+ }
+ CmosIndex = IDS_CMOS_REGION_LENGTH_OFFSET;
+ IdsWriteCmos (IDS_CMOS_INDEX_PORT, IDS_CMOS_DATA_PORT, CmosIndex, &Len, StdHeader);
+ CmosIndex = IDS_CMOS_REGION_CHECKSUM_OFFSET;
+ TmpValue = (UINT8) (0x100 - Sum);
+ IdsWriteCmos (IDS_CMOS_INDEX_PORT, IDS_CMOS_DATA_PORT, CmosIndex, &TmpValue, StdHeader);
+ }
+ return IDS_SUCCESS;
+}
+
+CONST IDS_FAMILY_FEAT_STRUCT ROMDATA IdsFeatNvToCmosSaveBlock =
+{
+ IDS_FEAT_NV_TO_CMOS,
+ IDS_BSP_ONLY,
+ IDS_CPU_Early_Override,
+ IDS_FAMILY_ALL,
+ IdsSubSaveBspNvHeapToCmos
+};
+
+CONST IDS_FAMILY_FEAT_STRUCT ROMDATA IdsFeatNvToCmosRestoreBlock =
+{
+ IDS_FEAT_NV_TO_CMOS,
+ IDS_BSP_ONLY,
+ IDS_BEFORE_AP_EARLY_HALT,
+ IDS_FAMILY_ALL,
+ IdsSubRestoreCmos
+};
+
+
diff --git a/src/vendorcode/amd/agesa/f15tn/Proc/IDS/Control/IdsNvToCmos.h b/src/vendorcode/amd/agesa/f15tn/Proc/IDS/Control/IdsNvToCmos.h
new file mode 100644
index 0000000000..4e2a41f0d1
--- /dev/null
+++ b/src/vendorcode/amd/agesa/f15tn/Proc/IDS/Control/IdsNvToCmos.h
@@ -0,0 +1,110 @@
+/* $NoKeywords:$ */
+/**
+ * @file
+ *
+ * AMD Integrated Debug library Routines
+ *
+ * Contains AMD AGESA debug macros and library functions
+ *
+ * @xrefitem bom "File Content Label" "Release Content"
+ * @e project: AGESA
+ * @e sub-project: IDS
+ * @e \$Revision: 63425 $ @e \$Date: 2011-12-22 11:24:10 -0600 (Thu, 22 Dec 2011) $
+ */
+/*****************************************************************************
+ * Copyright 2008 - 2012 ADVANCED MICRO DEVICES, INC. All Rights Reserved.
+ *
+ * AMD is granting you permission to use this software (the Materials)
+ * pursuant to the terms and conditions of your Software License Agreement
+ * with AMD. This header does *NOT* give you permission to use the Materials
+ * or any rights under AMD's intellectual property. Your use of any portion
+ * of these Materials shall constitute your acceptance of those terms and
+ * conditions. If you do not agree to the terms and conditions of the Software
+ * License Agreement, please do not use any portion of these Materials.
+ *
+ * CONFIDENTIALITY: The Materials and all other information, identified as
+ * confidential and provided to you by AMD shall be kept confidential in
+ * accordance with the terms and conditions of the Software License Agreement.
+ *
+ * LIMITATION OF LIABILITY: THE MATERIALS AND ANY OTHER RELATED INFORMATION
+ * PROVIDED TO YOU BY AMD ARE PROVIDED "AS IS" WITHOUT ANY EXPRESS OR IMPLIED
+ * WARRANTY OF ANY KIND, INCLUDING BUT NOT LIMITED TO WARRANTIES OF
+ * MERCHANTABILITY, NONINFRINGEMENT, TITLE, FITNESS FOR ANY PARTICULAR PURPOSE,
+ * OR WARRANTIES ARISING FROM CONDUCT, COURSE OF DEALING, OR USAGE OF TRADE.
+ * IN NO EVENT SHALL AMD OR ITS LICENSORS BE LIABLE FOR ANY DAMAGES WHATSOEVER
+ * (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF PROFITS, BUSINESS
+ * INTERRUPTION, OR LOSS OF INFORMATION) ARISING OUT OF AMD'S NEGLIGENCE,
+ * GROSS NEGLIGENCE, THE USE OF OR INABILITY TO USE THE MATERIALS OR ANY OTHER
+ * RELATED INFORMATION PROVIDED TO YOU BY AMD, EVEN IF AMD HAS BEEN ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGES. BECAUSE SOME JURISDICTIONS PROHIBIT THE
+ * EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES,
+ * THE ABOVE LIMITATION MAY NOT APPLY TO YOU.
+ *
+ * AMD does not assume any responsibility for any errors which may appear in
+ * the Materials or any other related information provided to you by AMD, or
+ * result from use of the Materials or any related information.
+ *
+ * You agree that you will not reverse engineer or decompile the Materials.
+ *
+ * NO SUPPORT OBLIGATION: AMD is not obligated to furnish, support, or make any
+ * further information, software, technical information, know-how, or show-how
+ * available to you. Additionally, AMD retains the right to modify the
+ * Materials at any time, without notice, and is not obligated to provide such
+ * modified Materials to you.
+ *
+ * U.S. GOVERNMENT RESTRICTED RIGHTS: The Materials are provided with
+ * "RESTRICTED RIGHTS." Use, duplication, or disclosure by the Government is
+ * subject to the restrictions as set forth in FAR 52.227-14 and
+ * DFAR252.227-7013, et seq., or its successor. Use of the Materials by the
+ * Government constitutes acknowledgement of AMD's proprietary rights in them.
+ *
+ * EXPORT ASSURANCE: You agree and certify that neither the Materials, nor any
+ * direct product thereof will be exported directly or indirectly, into any
+ * country prohibited by the United States Export Administration Act and the
+ * regulations thereunder, without the required authorization from the U.S.
+ * government nor will be used for any purpose prohibited by the same.
+ ******************************************************************************
+ */
+#ifndef _IDSNVTOCMOS_H_
+#define _IDSNVTOCMOS_H_
+AGESA_STATUS
+AmdGetIdsCmosSaveRegion (
+ IN OUT VOID **IdsCmosRegion,
+ IN OUT AMD_CONFIG_PARAMS *StdHeader
+ );
+
+IDS_STATUS
+IdsCheckCmosValid (
+ IN OUT AMD_CONFIG_PARAMS *StdHeader
+ );
+
+AGESA_STATUS
+AmdIdsApGetNvFromCmos (
+ IN OUT AMD_CONFIG_PARAMS *StdHeader
+ );
+
+IDS_STATUS
+IdsSubRestoreCmos (
+ IN OUT VOID *DataPtr,
+ IN OUT AMD_CONFIG_PARAMS *StdHeader,
+ IN IDS_NV_ITEM *IdsNvPtr
+ );
+
+IDS_STATUS
+IdsSubSaveBspNvHeapToCmos (
+ IN OUT VOID *DataPtr,
+ IN OUT AMD_CONFIG_PARAMS *StdHeader,
+ IN IDS_NV_ITEM *IdsNvPtr
+ );
+
+#define IDS_NV_TO_CMOS_HEADER_SIZE 4
+
+#define IDS_CMOS_REGION_SIGNATURE_OFFSET IDS_CMOS_REGION_START
+#define IDS_CMOS_REGION_LENGTH_OFFSET (IDS_CMOS_REGION_START + 2)
+#define IDS_CMOS_REGION_CHECKSUM_OFFSET (IDS_CMOS_REGION_START + 3)
+#define IDS_CMOS_REGION_DATA_OFFSET (IDS_CMOS_REGION_START + 4)
+
+#define IDS_NV_TO_CMOS_BYTE_IGNORED 0xFF
+#define IDS_NV_TO_CMOS_WORD_IGNORED 0xFFFF
+#endif //_IDSNVTOCMOS_H_
+