AGESA F15: AMD family15 AGESA code
[coreboot.git] / src / vendorcode / amd / agesa / f15 / Proc / CPU / Family / 0x10 / RevD / HY / F10HyInitEarlyTable.c
1 /* $NoKeywords:$ */
2 /**
3  * @file
4  *
5  * Implements the workaround for erratum 419.
6  *
7  * Returns the table of initialization steps to perform at
8  * AmdInitEarly.
9  *
10  * @xrefitem bom "File Content Label" "Release Content"
11  * @e project:      AGESA
12  * @e sub-project:  CPU/FAMILY/0x10/RevD/HY
13  * @e \$Revision: 56279 $   @e \$Date: 2011-07-11 13:11:28 -0600 (Mon, 11 Jul 2011) $
14  *
15  */
16 /*
17  ******************************************************************************
18  *
19  * Copyright (C) 2012 Advanced Micro Devices, Inc.
20  * All rights reserved.
21  *
22  * Redistribution and use in source and binary forms, with or without
23  * modification, are permitted provided that the following conditions are met:
24  *     * Redistributions of source code must retain the above copyright
25  *       notice, this list of conditions and the following disclaimer.
26  *     * Redistributions in binary form must reproduce the above copyright
27  *       notice, this list of conditions and the following disclaimer in the
28  *       documentation and/or other materials provided with the distribution.
29  *     * Neither the name of Advanced Micro Devices, Inc. nor the names of
30  *       its contributors may be used to endorse or promote products derived
31  *       from this software without specific prior written permission.
32  *
33  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
34  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
35  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
36  * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
37  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
38  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
39  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
40  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
41  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
42  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
43  *
44  ******************************************************************************
45  */
46
47 /*----------------------------------------------------------------------------------------
48  *                             M O D U L E S    U S E D
49  *----------------------------------------------------------------------------------------
50  */
51 #include "AGESA.h"
52 #include "amdlib.h"
53 #include "cpuRegisters.h"
54 #include "cpuFamilyTranslation.h"
55 #include "F10PackageType.h"
56 #include "cpuEarlyInit.h"
57 #include "Filecode.h"
58 CODE_GROUP (G1_PEICC)
59 RDATA_GROUP (G2_PEI)
60
61 #define FILECODE PROC_CPU_FAMILY_0X10_REVD_HY_F10HYINITEARLYTABLE_FILECODE
62
63
64 /*----------------------------------------------------------------------------------------
65  *                   D E F I N I T I O N S    A N D    M A C R O S
66  *----------------------------------------------------------------------------------------
67  */
68
69 /*----------------------------------------------------------------------------------------
70  *                  T Y P E D E F S     A N D     S T R U C T U  R E S
71  *----------------------------------------------------------------------------------------
72  */
73
74 /*----------------------------------------------------------------------------------------
75  *           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
76  *----------------------------------------------------------------------------------------
77  */
78
79 VOID
80 GetF10HyEarlyInitOnCoreTable (
81   IN       CPU_SPECIFIC_SERVICES                *FamilyServices,
82      OUT   CONST S_PERFORM_EARLY_INIT_ON_CORE  **Table,
83   IN       AMD_CPU_EARLY_PARAMS                 *EarlyParams,
84   IN       AMD_CONFIG_PARAMS                    *StdHeader
85   );
86
87 /*----------------------------------------------------------------------------------------
88  *                          E X P O R T E D    F U N C T I O N S
89  *----------------------------------------------------------------------------------------
90  */
91 extern F_PERFORM_EARLY_INIT_ON_CORE McaInitializationAtEarly;
92 extern F_PERFORM_EARLY_INIT_ON_CORE SetRegistersFromTablesAtEarly;
93 extern F_PERFORM_EARLY_INIT_ON_CORE SetBrandIdRegistersAtEarly;
94 extern F_PERFORM_EARLY_INIT_ON_CORE LocalApicInitializationAtEarly;
95 extern F_PERFORM_EARLY_INIT_ON_CORE LoadMicrocodePatchAtEarly;
96 extern F_GET_EARLY_INIT_TABLE GetF10EarlyInitOnCoreTable;
97
98 CONST S_PERFORM_EARLY_INIT_ON_CORE ROMDATA F10HyC32D0EarlyInitOnCoreTable[] =
99 {
100   {McaInitializationAtEarly, PERFORM_EARLY_ANY_CONDITION},
101   {SetRegistersFromTablesAtEarly, PERFORM_EARLY_ANY_CONDITION},
102   {LocalApicInitializationAtEarly, PERFORM_EARLY_ANY_CONDITION},
103   {LoadMicrocodePatchAtEarly, PERFORM_EARLY_WARM_RESET},
104   {SetBrandIdRegistersAtEarly, PERFORM_EARLY_ANY_CONDITION},
105   {NULL, 0}
106 };
107
108 /*------------------------------------------------------------------------------------*/
109 /**
110  * Initializer routine that may be invoked at AmdCpuEarly to return the steps
111  * appropriate for the executing Rev D core.
112  *
113  *  @CpuServiceMethod{::F_GET_EARLY_INIT_TABLE}.
114  *
115  * @param[in]       FamilyServices    The current Family Specific Services.
116  * @param[out]      Table             Table of appropriate init steps for the executing core.
117  * @param[in]       EarlyParams       Service Interface structure to initialize.
118  * @param[in]       StdHeader         Opaque handle to standard config header.
119  *
120  */
121 VOID
122 GetF10HyEarlyInitOnCoreTable (
123   IN       CPU_SPECIFIC_SERVICES                *FamilyServices,
124      OUT   CONST S_PERFORM_EARLY_INIT_ON_CORE  **Table,
125   IN       AMD_CPU_EARLY_PARAMS                 *EarlyParams,
126   IN       AMD_CONFIG_PARAMS                    *StdHeader
127   )
128 {
129   UINT32         ProcessorPackageType;
130   CPU_LOGICAL_ID LogicalId;
131
132   GetLogicalIdOfCurrentCore (&LogicalId, StdHeader);
133   ProcessorPackageType = LibAmdGetPackageType (StdHeader);
134
135   // Check if this CPU is affected by erratum 419.
136   if (((LogicalId.Revision & AMD_F10_HY_SCM_D0) != 0) && ((ProcessorPackageType & (PACKAGE_TYPE_G34 | PACKAGE_TYPE_FR2_FR5_FR6)) == 0)) {
137     // Return initialization steps such that the microcode patch is applied before
138     // brand string determination is performed.
139     *Table = F10HyC32D0EarlyInitOnCoreTable;
140   } else {
141     // No workaround is necessary.  Return the standard table.
142     GetF10EarlyInitOnCoreTable (FamilyServices, Table, EarlyParams, StdHeader);
143   }
144 }