5 * AMD CPU BrandId related functions and structures.
7 * Contains code that provides CPU BrandId information
9 * @xrefitem bom "File Content Label" "Release Content"
11 * @e sub-project: CPU/Family/0x15
12 * @e \$Revision: 55600 $ @e \$Date: 2011-06-23 12:39:18 -0600 (Thu, 23 Jun 2011) $
16 ******************************************************************************
18 * Copyright (C) 2012 Advanced Micro Devices, Inc.
19 * All rights reserved.
21 * Redistribution and use in source and binary forms, with or without
22 * modification, are permitted provided that the following conditions are met:
23 * * Redistributions of source code must retain the above copyright
24 * notice, this list of conditions and the following disclaimer.
25 * * Redistributions in binary form must reproduce the above copyright
26 * notice, this list of conditions and the following disclaimer in the
27 * documentation and/or other materials provided with the distribution.
28 * * Neither the name of Advanced Micro Devices, Inc. nor the names of
29 * its contributors may be used to endorse or promote products derived
30 * from this software without specific prior written permission.
32 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
33 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
34 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
35 * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
36 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
37 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
38 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
39 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
40 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
41 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
43 ******************************************************************************
46 /*----------------------------------------------------------------------------------------
47 * M O D U L E S U S E D
48 *----------------------------------------------------------------------------------------
52 #include "cpuRegisters.h"
53 #include "cpuFamilyTranslation.h"
54 #include "cpuEarlyInit.h"
55 #include "cpuServices.h"
56 #include "GeneralServices.h"
57 #include "OptionMultiSocket.h"
62 #define FILECODE PROC_CPU_FAMILY_0X15_CPUF15BRANDID_FILECODE
65 /*----------------------------------------------------------------------------------------
66 * D E F I N I T I O N S A N D M A C R O S
67 *----------------------------------------------------------------------------------------
69 #define NAME_STRING_ADDRESS_PORT 0x194
70 #define NAME_STRING_DATA_PORT 0x198
72 extern OPTION_MULTISOCKET_CONFIGURATION OptionMultiSocketConfiguration;
73 /*----------------------------------------------------------------------------------------
74 * T Y P E D E F S A N D S T R U C T U R E S
75 *----------------------------------------------------------------------------------------
77 /// A structure containing brand string
79 CONST CHAR8 *Stringstart; ///< The literal string
80 } CPU_F15_EXCEPTION_BRAND;
82 /// FAM15_BRAND_STRING_MSR
83 typedef struct _PROCESSOR_NAME_STRING {
84 UINT32 lo; ///< lower 32-bits of 64-bit value
85 UINT32 hi; ///< highest 32-bits of 64-bit value
86 } PROCESSOR_NAME_STRING;
88 /*----------------------------------------------------------------------------------------
89 * 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
90 *----------------------------------------------------------------------------------------
95 OUT UINT32 *ExceptionId,
96 IN AMD_CONFIG_PARAMS *StdHeader
100 F15SetBrandIdRegistersAtEarly (
101 IN CPU_SPECIFIC_SERVICES *FamilyServices,
102 IN AMD_CPU_EARLY_PARAMS *EarlyParams,
103 IN AMD_CONFIG_PARAMS *StdHeader
105 /*----------------------------------------------------------------------------------------
106 * E X P O R T E D F U N C T I O N S
107 *----------------------------------------------------------------------------------------
109 // This is an example, need to be updated once Processor Revision Guide define brand string exception
110 // Brand string is always 48 bytes
111 CONST CHAR8 ROMDATA str_Exception_0[48] = "AMD Phenom(tm) Octal-Core";
112 CONST CHAR8 ROMDATA str_Unprogrammed_Sample[48] = "AMD Unprogrammed Engineering Sample";
113 /*---------------------------------------------------------------------------------------
114 * T Y P E D E F S, S T R U C T U R E S, E N U M S
115 *---------------------------------------------------------------------------------------
117 CONST CPU_F15_EXCEPTION_BRAND ROMDATA CpuF15ExceptionBrandIdString[] =
122 /*---------------------------------------------------------------------------------------*/
124 * Set the Processor Name String register based on F5x194/198
126 * This function copies F5x198_x[B:0] to MSR_C001_00[35:30]
128 * @param[in] FamilyServices The current Family Specific Services.
129 * @param[in] EarlyParams Service parameters.
130 * @param[in] StdHeader Config handle for library and services.
134 F15SetBrandIdRegistersAtEarly (
135 IN CPU_SPECIFIC_SERVICES *FamilyServices,
136 IN AMD_CPU_EARLY_PARAMS *EarlyParams,
137 IN AMD_CONFIG_PARAMS *StdHeader
144 UINT64 *MsrNameStringPtrPtr;
147 if (IsCorePairPrimary (FirstCoreIsComputeUnitPrimary, StdHeader)) {
148 if (IsException (&ExceptionId, StdHeader)) {
149 ASSERT (ExceptionId < (sizeof (CpuF15ExceptionBrandIdString) / sizeof (CpuF15ExceptionBrandIdString[0])));
151 MsrNameStringPtrPtr = (UINT64 *) CpuF15ExceptionBrandIdString[ExceptionId].Stringstart;
153 OptionMultiSocketConfiguration.GetCurrPciAddr (&PciAddress, StdHeader);
154 PciAddress.Address.Function = FUNC_5;
155 PciAddress.Address.Register = NAME_STRING_ADDRESS_PORT;
156 // check if D18F5x198_x0 is 00000000h.
158 LibAmdPciWrite (AccessWidth32, PciAddress, &PciData, StdHeader);
159 PciAddress.Address.Register = NAME_STRING_DATA_PORT;
160 LibAmdPciRead (AccessWidth32, PciAddress, &PciData, StdHeader);
162 for (MsrIndex = 0; MsrIndex <= (MSR_CPUID_NAME_STRING5 - MSR_CPUID_NAME_STRING0); MsrIndex++) {
163 PciAddress.Address.Register = NAME_STRING_ADDRESS_PORT;
164 PciData = MsrIndex * 2;
165 LibAmdPciWrite (AccessWidth32, PciAddress, &PciData, StdHeader);
166 PciAddress.Address.Register = NAME_STRING_DATA_PORT;
167 LibAmdPciRead (AccessWidth32, PciAddress, &PciData, StdHeader);
168 ((PROCESSOR_NAME_STRING *) (&MsrData))->lo = PciData;
170 PciAddress.Address.Register = NAME_STRING_ADDRESS_PORT;
171 PciData = (MsrIndex * 2) + 1;
172 LibAmdPciWrite (AccessWidth32, PciAddress, &PciData, StdHeader);
173 PciAddress.Address.Register = NAME_STRING_DATA_PORT;
174 LibAmdPciRead (AccessWidth32, PciAddress, &PciData, StdHeader);
175 ((PROCESSOR_NAME_STRING *) (&MsrData))->hi = PciData;
177 LibAmdMsrWrite ((MsrIndex + MSR_CPUID_NAME_STRING0), &MsrData, StdHeader);
181 // It is unprogrammed (unfused) parts and use a name string of "AMD Unprogrammed Engineering Sample"
182 MsrNameStringPtrPtr = (UINT64 *) str_Unprogrammed_Sample;
185 // Put values into name MSRs, Always write the full 48 bytes
186 for (MsrIndex = MSR_CPUID_NAME_STRING0; MsrIndex <= MSR_CPUID_NAME_STRING5; MsrIndex++) {
187 LibAmdMsrWrite (MsrIndex, MsrNameStringPtrPtr, StdHeader);
188 MsrNameStringPtrPtr++;
193 /*---------------------------------------------------------------------------------------
194 * L O C A L F U N C T I O N S
195 *---------------------------------------------------------------------------------------
198 /*---------------------------------------------------------------------------------------*/
200 * Check if it's an exception
202 * For family 15h, brand string is obtained from F5x198_x[B:0], but there may be exceptions.
203 * This function checks if it's an exception.
205 * @param[out] ExceptionId Id of exception
206 * @param[in] StdHeader Config handle for library and services.
208 * @retval TRUE It's an exception
209 * @retval FALSE It's NOT an exception
214 OUT UINT32 *ExceptionId,
215 IN AMD_CONFIG_PARAMS *StdHeader
218 // This function will be updated, once Processor Revision Guide defines Fam15 brand string exception
219 *ExceptionId = 0xFFFF;