| 1 | /* SPDX-License-Identifier: BSD-3-Clause */ |
| 2 | |
| 3 | /* $NoKeywords:$ */ |
| 4 | /** |
| 5 | * @file |
| 6 | * |
| 7 | * AMD CPU Family Translation functions. |
| 8 | * |
| 9 | * |
| 10 | * @xrefitem bom "File Content Label" "Release Content" |
| 11 | * @e project: AGESA |
| 12 | * @e sub-project: CPU |
| 13 | * @e \$Revision$ @e \$Date$ |
| 14 | * |
| 15 | */ |
| 16 | /***************************************************************************** |
| 17 | * |
| 18 | * Copyright (c) 2008 - 2017, Advanced Micro Devices, Inc. |
| 19 | * All rights reserved. |
| 20 | * |
| 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. |
| 31 | * |
| 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. |
| 42 | * |
| 43 | ***************************************************************************/ |
| 44 | |
| 45 | #include <check_for_wrapper.h> |
| 46 | |
| 47 | #ifndef _CPU_FAMILY_TRANSLATION_H_ |
| 48 | #define _CPU_FAMILY_TRANSLATION_H_ |
| 49 | |
| 50 | /** |
| 51 | * @page cpuimplfss CPU Family Specific Services Implementation Guide |
| 52 | * |
| 53 | * CPU Family Specific Services provides access to supported family service functions and data, |
| 54 | * in a manner that isolates calling code from knowledge about particular families or which |
| 55 | * families are supported in the current build. |
| 56 | * |
| 57 | * @par Adding a Method to Family Specific Services |
| 58 | * |
| 59 | * To add a new method to Family Specific Services, follow these steps. |
| 60 | * <ul> |
| 61 | * <li> Create a typedef for the Method with the correct parameters and return type. |
| 62 | * |
| 63 | * <ul> |
| 64 | * <li> Name the method typedef (*PF_METHOD_NAME)(), where METHOD_NAME is the same name as the method table item, |
| 65 | * but with "_"'s and UPPERCASE, rather than mixed case. |
| 66 | * @n <tt> typedef VOID (*PF_METHOD_NAME)(); </tt> @n |
| 67 | * |
| 68 | * <li> [Optionally make the type F_<name> and provide a separate: |
| 69 | * @n <tt> typedef F_METHOD_NAME *PF_METHOD_NAME> </tt> @n |
| 70 | * and provide a single line "///" doxygen comment brief description on the PF_ type.] |
| 71 | * </ul> |
| 72 | * |
| 73 | * <li> The first parameter to @b all Family Specific Service Methods is @b required to be a reference to |
| 74 | * their Family Service struct. |
| 75 | * @n <tt> IN CPU_SPECIFIC_SERVICES *FamilySpecificServices </tt> @n |
| 76 | * |
| 77 | * <li> Provide a standard doxygen function preamble for the Method typedef. Begin the |
| 78 | * detailed description by provide a reference to the method instances page by including |
| 79 | * the lines below: |
| 80 | * @code |
| 81 | * * |
| 82 | * * @CpuServiceInstances |
| 83 | * * |
| 84 | * @endcode |
| 85 | * @note It is important to provide documentation for the method type, because the method may not |
| 86 | * have an implementation in any families supported by the current package. @n |
| 87 | * |
| 88 | * <li> Add to the CPU_SPECIFIC_SERVICES struct an item for the Method: |
| 89 | * @n <tt> PF_METHOD_NAME MethodName; ///< Method: description. </tt> @n |
| 90 | * </ul> |
| 91 | * |
| 92 | * @par Implementing a Family Specific Instance of the method. |
| 93 | * |
| 94 | * To implement an instance of a method for a specific family follow these steps. |
| 95 | * |
| 96 | * - In appropriate files in the family specific directory, implement the method with the return type |
| 97 | * and parameters matching the method typedef. |
| 98 | * |
| 99 | * - Name the function FnnMethodName(), where nn is the family number. |
| 100 | * |
| 101 | * - Create a doxygen function preamble for the method instance. Begin the detailed description with |
| 102 | * an Implements command to reference the method type and add this instance to the Method Instances page. |
| 103 | * @code |
| 104 | * * |
| 105 | * * @CpuServiceMethod{::F_METHOD_NAME}. |
| 106 | * * |
| 107 | * @endcode |
| 108 | * |
| 109 | * - To access other family specific services as part of the method implementation, the function |
| 110 | * @b must use FamilySpecificServices->OtherMethod(). Do not directly call other family specific |
| 111 | * routines, because in the table there may be overrides or this routine may be shared by multiple families. |
| 112 | * |
| 113 | * - Do @b not call Family translation services from a family specific instance. Use the parameter. |
| 114 | * |
| 115 | * - Add the instance to the family specific CPU_SPECIFIC_SERVICES instance. |
| 116 | * |
| 117 | * - If a family does not need an instance of the method use one of the CommonReturns from |
| 118 | * CommonReturns.h with the same return type. |
| 119 | * |
| 120 | * @par Invoking Family Specific Services. |
| 121 | * |
| 122 | * The following example shows how to invoke a family specific method. |
| 123 | * @n @code |
| 124 | * CPU_SPECIFIC_SERVICES *FamilyServices; |
| 125 | * |
| 126 | * GetCpuServicesOfCurrentCore (&FamilyServices, StdHeader); |
| 127 | * ASSERT (FamilyServices != NULL); |
| 128 | * FamilyServices->MethodName (FamilyServices, StdHeader); |
| 129 | * @endcode |
| 130 | * |
| 131 | */ |
| 132 | |
| 133 | |
| 134 | /*--------------------------------------------------------------------------------------- |
| 135 | * M I X E D (Definitions And Macros / Typedefs, Structures, Enums) |
| 136 | *--------------------------------------------------------------------------------------- |
| 137 | */ |
| 138 | /* #include "cpuPostInit.h" */ |
| 139 | /* #include "cpuEnvInit.h" */ |
| 140 | #include "cpuRegisters.h" |
| 141 | #include "cpuServices.h" |
| 142 | #include "Table.h" |
| 143 | #include "Ids.h" |
| 144 | /* #include "Topology.h" */ |
| 145 | |
| 146 | // Forward declaration needed for multi-structure mutual references. |
| 147 | AGESA_FORWARD_DECLARATION (CPU_SPECIFIC_SERVICES); |
| 148 | /*--------------------------------------------------------------------------------------- |
| 149 | * D E F I N I T I O N S A N D M A C R O S |
| 150 | *--------------------------------------------------------------------------------------- |
| 151 | */ |
| 152 | |
| 153 | /*--------------------------------------------------------------------------------------- |
| 154 | * T Y P E D E F S, S T R U C T U R E S, E N U M S |
| 155 | *--------------------------------------------------------------------------------------- |
| 156 | */ |
| 157 | |
| 158 | /** |
| 159 | * Disable the desired P-state. |
| 160 | * |
| 161 | * @CpuServiceInstances |
| 162 | * |
| 163 | * @param[in] FamilySpecificServices The current Family Specific Services. |
| 164 | * @param[in] StateNumber Hardware P-state number. |
| 165 | * @param[in] StdHeader Handle of Header for calling lib functions and services. |
| 166 | * |
| 167 | */ |
| 168 | typedef AGESA_STATUS F_CPU_DISABLE_PSTATE ( |
| 169 | IN CONST CPU_SPECIFIC_SERVICES *FamilySpecificServices, |
| 170 | IN UINT8 StateNumber, |
| 171 | IN AMD_CONFIG_PARAMS *StdHeader |
| 172 | ); |
| 173 | |
| 174 | /// Reference to a Method. |
| 175 | typedef F_CPU_DISABLE_PSTATE *PF_CPU_DISABLE_PSTATE; |
| 176 | |
| 177 | |
| 178 | /** |
| 179 | * Transition the current core to the desired P-state. |
| 180 | * |
| 181 | * @CpuServiceInstances |
| 182 | * |
| 183 | * @param[in] FamilySpecificServices The current Family Specific Services. |
| 184 | * @param[in] StateNumber Software P-state number. |
| 185 | * @param[in] WaitForChange Wait/don't wait for P-state change to complete. |
| 186 | * @param[in] StdHeader Handle of Header for calling lib functions and services. |
| 187 | * |
| 188 | */ |
| 189 | typedef AGESA_STATUS F_CPU_TRANSITION_PSTATE ( |
| 190 | IN CONST CPU_SPECIFIC_SERVICES *FamilySpecificServices, |
| 191 | IN UINT8 StateNumber, |
| 192 | IN BOOLEAN WaitForChange, |
| 193 | IN AMD_CONFIG_PARAMS *StdHeader |
| 194 | ); |
| 195 | |
| 196 | /// Reference to a Method. |
| 197 | typedef F_CPU_TRANSITION_PSTATE *PF_CPU_TRANSITION_PSTATE; |
| 198 | |
| 199 | |
| 200 | /** |
| 201 | * Get the desired P-state's maximum current required in milliamps. |
| 202 | * |
| 203 | * @CpuServiceInstances |
| 204 | * |
| 205 | * @param[in] FamilySpecificServices The current Family Specific Services. |
| 206 | * @param[in] StateNumber The desired hardware P-state number. |
| 207 | * @param[out] ProcIddMax The P-state's maximum current. |
| 208 | * @param[in] StdHeader Handle of Header for calling lib functions and services. |
| 209 | * |
| 210 | * @retval TRUE The P-state is enabled, and ProcIddMax is valid. |
| 211 | * @retval FALSE The P-state is disabled. |
| 212 | * |
| 213 | */ |
| 214 | typedef BOOLEAN F_CPU_GET_IDD_MAX ( |
| 215 | IN CONST CPU_SPECIFIC_SERVICES *FamilySpecificServices, |
| 216 | IN UINT8 StateNumber, |
| 217 | OUT UINT32 *ProcIddMax, |
| 218 | IN AMD_CONFIG_PARAMS *StdHeader |
| 219 | ); |
| 220 | |
| 221 | /// Reference to a Method. |
| 222 | typedef F_CPU_GET_IDD_MAX *PF_CPU_GET_IDD_MAX; |
| 223 | |
| 224 | |
| 225 | /** |
| 226 | * Returns the rate at which the current core's timestamp counter increments in megahertz. |
| 227 | * |
| 228 | * @CpuServiceInstances |
| 229 | * |
| 230 | * @param[in] FamilySpecificServices The current Family Specific Services. |
| 231 | * @param[out] FreqInMHz The rate at which the TSC increments in megahertz. |
| 232 | * @param[in] StdHeader Handle of Header for calling lib functions and services. |
| 233 | * |
| 234 | */ |
| 235 | typedef AGESA_STATUS F_CPU_GET_TSC_RATE ( |
| 236 | IN CONST CPU_SPECIFIC_SERVICES * FamilySpecificServices, |
| 237 | OUT UINT32 *FreqInMHz, |
| 238 | IN AMD_CONFIG_PARAMS *StdHeader |
| 239 | ); |
| 240 | |
| 241 | /// Reference to a Method. |
| 242 | typedef F_CPU_GET_TSC_RATE *PF_CPU_GET_TSC_RATE; |
| 243 | |
| 244 | |
| 245 | /** |
| 246 | * Returns the processor north bridge's clock rate in megahertz. |
| 247 | * |
| 248 | * @CpuServiceInstances |
| 249 | * |
| 250 | * @param[in] FamilySpecificServices The current Family Specific Services. |
| 251 | * @param[out] FreqInMHz The desired node's frequency in megahertz. |
| 252 | * @param[in] StdHeader Handle of Header for calling lib functions and services. |
| 253 | * |
| 254 | * @retval AGESA_SUCCESS FreqInMHz is valid. |
| 255 | */ |
| 256 | typedef AGESA_STATUS F_CPU_GET_NB_FREQ ( |
| 257 | IN CONST CPU_SPECIFIC_SERVICES *FamilySpecificServices, |
| 258 | OUT UINT32 *FreqInMHz, |
| 259 | IN AMD_CONFIG_PARAMS *StdHeader |
| 260 | ); |
| 261 | |
| 262 | /// Reference to a Method. |
| 263 | typedef F_CPU_GET_NB_FREQ *PF_CPU_GET_NB_FREQ; |
| 264 | |
| 265 | |
| 266 | /** |
| 267 | * Returns the node's minimum and maximum northbridge frequency. |
| 268 | * |
| 269 | * @CpuServiceInstances |
| 270 | * |
| 271 | * @param[in] FamilySpecificServices The current Family Specific Services. |
| 272 | * @param[in] PlatformConfig Platform profile/build option config structure. |
| 273 | * @param[in] PciAddress The segment, bus, and device numbers of the CPU in question. |
| 274 | * @param[out] MinFreqInMHz The minimum north bridge frequency. |
| 275 | * @param[out] MaxFreqInMHz The maximum north bridge frequency. |
| 276 | * @param[in] StdHeader Handle of Header for calling lib functions and services. |
| 277 | * |
| 278 | * @retval AGESA_STATUS Northbridge frequency is valid |
| 279 | */ |
| 280 | typedef AGESA_STATUS F_CPU_GET_MIN_MAX_NB_FREQ ( |
| 281 | IN CONST CPU_SPECIFIC_SERVICES *FamilySpecificServices, |
| 282 | IN PLATFORM_CONFIGURATION *PlatformConfig, |
| 283 | IN PCI_ADDR *PciAddress, |
| 284 | OUT UINT32 *MinFreqInMHz, |
| 285 | OUT UINT32 *MaxFreqInMHz, |
| 286 | IN AMD_CONFIG_PARAMS *StdHeader |
| 287 | ); |
| 288 | |
| 289 | /// Reference to a Method. |
| 290 | typedef F_CPU_GET_MIN_MAX_NB_FREQ *PF_CPU_GET_MIN_MAX_NB_FREQ; |
| 291 | |
| 292 | |
| 293 | /** |
| 294 | * Returns the processor north bridge's P-state settings. |
| 295 | * |
| 296 | * @CpuServiceInstances |
| 297 | * |
| 298 | * @param[in] FamilySpecificServices The current Family Specific Services. |
| 299 | * @param[in] PlatformConfig Platform profile/build option config structure. |
| 300 | * @param[in] PciAddress The segment, bus, and device numbers of the CPU in question. |
| 301 | * @param[in] NbPstate The NB P-state number to check. |
| 302 | * @param[out] FreqNumeratorInMHz The desired node's frequency numerator in megahertz. |
| 303 | * @param[out] FreqDivisor The desired node's frequency divisor. |
| 304 | * @param[out] VoltageInuV The desired node's voltage in microvolts. |
| 305 | * @param[in] StdHeader Handle of Header for calling lib functions and services. |
| 306 | * |
| 307 | * @retval TRUE NbPstate is valid |
| 308 | * @retval FALSE NbPstate is disabled or invalid |
| 309 | */ |
| 310 | typedef BOOLEAN F_CPU_GET_NB_PSTATE_INFO ( |
| 311 | IN CONST CPU_SPECIFIC_SERVICES *FamilySpecificServices, |
| 312 | IN PLATFORM_CONFIGURATION *PlatformConfig, |
| 313 | IN PCI_ADDR *PciAddress, |
| 314 | IN UINT32 NbPstate, |
| 315 | OUT UINT32 *FreqNumeratorInMHz, |
| 316 | OUT UINT32 *FreqDivisor, |
| 317 | OUT UINT32 *VoltageInuV, |
| 318 | IN AMD_CONFIG_PARAMS *StdHeader |
| 319 | ); |
| 320 | |
| 321 | /// Reference to a Method. |
| 322 | typedef F_CPU_GET_NB_PSTATE_INFO *PF_CPU_GET_NB_PSTATE_INFO; |
| 323 | |
| 324 | |
| 325 | /** |
| 326 | * Returns whether or not the NB frequency initialization sequence is required |
| 327 | * to be performed by the BIOS. |
| 328 | * |
| 329 | * @CpuServiceInstances |
| 330 | * |
| 331 | * @param[in] FamilySpecificServices The current Family Specific Services. |
| 332 | * @param[in] PciAddress The northbridge to query by pci base address. |
| 333 | * @param[out] NbVidUpdateAll Do all NbVids need to be updated as well. |
| 334 | * @param[in] StdHeader Handle of Header for calling lib functions and services. |
| 335 | * |
| 336 | */ |
| 337 | typedef BOOLEAN F_CPU_IS_NBCOF_INIT_NEEDED ( |
| 338 | IN CONST CPU_SPECIFIC_SERVICES *FamilySpecificServices, |
| 339 | IN PCI_ADDR *PciAddress, |
| 340 | OUT BOOLEAN *NbVidUpdateAll, |
| 341 | IN AMD_CONFIG_PARAMS *StdHeader |
| 342 | ); |
| 343 | |
| 344 | /// Reference to a Method. |
| 345 | typedef F_CPU_IS_NBCOF_INIT_NEEDED *PF_CPU_IS_NBCOF_INIT_NEEDED; |
| 346 | |
| 347 | |
| 348 | /** |
| 349 | * Get the desired NB P-state's maximum current required in milliamps. |
| 350 | * |
| 351 | * @CpuServiceInstances |
| 352 | * |
| 353 | * @param[in] FamilySpecificServices The current Family Specific Services. |
| 354 | * @param[in] StateNumber The desired hardware P-state number. |
| 355 | * @param[out] NbIddMax The NB P-state's maximum current. |
| 356 | * @param[in] StdHeader Handle of Header for calling lib functions and services. |
| 357 | * |
| 358 | * @retval TRUE The NB P-state is enabled, and NbIddMax is valid. |
| 359 | * @retval FALSE The NB P-state is disabled. |
| 360 | * |
| 361 | */ |
| 362 | typedef BOOLEAN F_CPU_GET_NB_IDD_MAX ( |
| 363 | IN CONST CPU_SPECIFIC_SERVICES *FamilySpecificServices, |
| 364 | IN UINT8 StateNumber, |
| 365 | OUT UINT32 *NbIddMax, |
| 366 | IN AMD_CONFIG_PARAMS *StdHeader |
| 367 | ); |
| 368 | |
| 369 | /// Reference to a Method. |
| 370 | typedef F_CPU_GET_NB_IDD_MAX *PF_CPU_GET_NB_IDD_MAX; |
| 371 | |
| 372 | |
| 373 | /** |
| 374 | * Launches the desired core from the reset vector. |
| 375 | * |
| 376 | * @CpuServiceInstances |
| 377 | * |
| 378 | * @param[in] FamilySpecificServices The current Family Specific Services. |
| 379 | * @param[in] CoreNumber The desired core's die relative core number. |
| 380 | * @param[in] StdHeader Handle of Header for calling lib functions and services. |
| 381 | * |
| 382 | * @retval TRUE The core was launched successfully. |
| 383 | * @retval FALSE The core was previously launched, or has a problem. |
| 384 | */ |
| 385 | typedef BOOLEAN F_CPU_AP_INITIAL_LAUNCH ( |
| 386 | IN CONST CPU_SPECIFIC_SERVICES *FamilySpecificServices, |
| 387 | IN UINT32 CoreNumber, |
| 388 | IN AMD_CONFIG_PARAMS *StdHeader |
| 389 | ); |
| 390 | |
| 391 | /// Reference to a Method. |
| 392 | typedef F_CPU_AP_INITIAL_LAUNCH *PF_CPU_AP_INITIAL_LAUNCH; |
| 393 | |
| 394 | |
| 395 | /** |
| 396 | * Returns the appropriate number of physical processor cores |
| 397 | * |
| 398 | * @CpuServiceInstances |
| 399 | * |
| 400 | * @param[in] FamilySpecificServices The current Family Specific Services. |
| 401 | * @param[in] StdHeader Handle of Header for calling lib functions and services. |
| 402 | * |
| 403 | * @return One-based number of physical cores on current processor |
| 404 | */ |
| 405 | typedef UINT8 F_CPU_NUMBER_OF_PHYSICAL_CORES ( |
| 406 | IN CONST CPU_SPECIFIC_SERVICES *FamilySpecificServices, |
| 407 | IN AMD_CONFIG_PARAMS *StdHeader |
| 408 | ); |
| 409 | |
| 410 | /// Reference to a Method. |
| 411 | typedef F_CPU_NUMBER_OF_PHYSICAL_CORES *PF_CPU_NUMBER_OF_PHYSICAL_CORES; |
| 412 | |
| 413 | |
| 414 | /** |
| 415 | * Get the AP core number from hardware. |
| 416 | * |
| 417 | * @CpuServiceInstances |
| 418 | * |
| 419 | * @param[in] FamilySpecificServices The current Family Specific Services. |
| 420 | * @param[in] StdHeader Handle of Header for calling lib functions and services. |
| 421 | * |
| 422 | * @return The AP's unique core number |
| 423 | */ |
| 424 | typedef UINT32 (F_CPU_GET_AP_CORE_NUMBER) ( |
| 425 | IN CONST CPU_SPECIFIC_SERVICES *FamilySpecificServices, |
| 426 | IN AMD_CONFIG_PARAMS *StdHeader |
| 427 | ); |
| 428 | |
| 429 | /// Reference to a method |
| 430 | typedef F_CPU_GET_AP_CORE_NUMBER *PF_CPU_GET_AP_CORE_NUMBER; |
| 431 | |
| 432 | |
| 433 | /** |
| 434 | * Core ID position in the initial APIC ID, reflected as a number zero or one. |
| 435 | */ |
| 436 | typedef enum { |
| 437 | CoreIdPositionZero, ///< Zero, the Core Id bits are the Most Significant bits. |
| 438 | CoreIdPositionOne, ///< One, the Core Id bits are the Least Significant bits. |
| 439 | CoreIdPositionMax ///< Limit check. |
| 440 | } CORE_ID_POSITION; |
| 441 | |
| 442 | /** |
| 443 | * Return a number zero or one, based on the Core ID position in the initial APIC Id. |
| 444 | * |
| 445 | * @CpuServiceInstances |
| 446 | * |
| 447 | * @param[in] FamilySpecificServices The current Family Specific Services. |
| 448 | * @param[in] StdHeader Handle of Header for calling lib functions and services. |
| 449 | * |
| 450 | * @retval CoreIdPositionZero Core Id is not low |
| 451 | * @retval CoreIdPositionOne Core Id is low |
| 452 | */ |
| 453 | typedef CORE_ID_POSITION F_CORE_ID_POSITION_IN_INITIAL_APIC_ID ( |
| 454 | IN CONST CPU_SPECIFIC_SERVICES *FamilySpecificServices, |
| 455 | IN AMD_CONFIG_PARAMS *StdHeader |
| 456 | ); |
| 457 | |
| 458 | /// Reference to a method |
| 459 | typedef F_CORE_ID_POSITION_IN_INITIAL_APIC_ID *PF_CORE_ID_POSITION_IN_INITIAL_APIC_ID; |
| 460 | |
| 461 | |
| 462 | /** |
| 463 | * Set Warm Reset Flag |
| 464 | * |
| 465 | * @CpuServiceInstances |
| 466 | * |
| 467 | * @param[in] FamilySpecificServices The current Family Specific Services. |
| 468 | * @param[in] StdHeader Header for library and services. |
| 469 | * @param[in] Request Value to set the flags to. |
| 470 | * |
| 471 | */ |
| 472 | typedef VOID (F_CPU_SET_WARM_RESET_FLAG) ( |
| 473 | IN CONST CPU_SPECIFIC_SERVICES *FamilySpecificServices, |
| 474 | IN AMD_CONFIG_PARAMS *StdHeader, |
| 475 | IN WARM_RESET_REQUEST *Request |
| 476 | ); |
| 477 | |
| 478 | /// Reference to a method |
| 479 | typedef F_CPU_SET_WARM_RESET_FLAG *PF_CPU_SET_WARM_RESET_FLAG; |
| 480 | |
| 481 | |
| 482 | /** |
| 483 | * Get Warm Reset Flag |
| 484 | * |
| 485 | * @CpuServiceInstances |
| 486 | * |
| 487 | * @param[in] FamilySpecificServices The current Family Specific Services. |
| 488 | * @param[in] StdHeader Header for library and services. |
| 489 | * @param[out] BiosRstDet Indicate warm reset status. |
| 490 | * |
| 491 | */ |
| 492 | typedef VOID (F_CPU_GET_WARM_RESET_FLAG) ( |
| 493 | IN CONST CPU_SPECIFIC_SERVICES *FamilySpecificServices, |
| 494 | IN AMD_CONFIG_PARAMS *StdHeader, |
| 495 | OUT WARM_RESET_REQUEST *Request |
| 496 | ); |
| 497 | |
| 498 | /// Reference to a method |
| 499 | typedef F_CPU_GET_WARM_RESET_FLAG *PF_CPU_GET_WARM_RESET_FLAG; |
| 500 | |
| 501 | |
| 502 | /** |
| 503 | * Returns a family specific table of information pointer and size. |
| 504 | * |
| 505 | * @CpuServiceInstances |
| 506 | * |
| 507 | * @param[in] FamilySpecificServices The current Family Specific Services. |
| 508 | * @param[out] FamilySpecificArray Pointer to the appropriate list for the core. |
| 509 | * @param[out] NumberOfElements Number of valid entries FamilySpecificArray. |
| 510 | * @param[in] StdHeader Handle of Header for calling lib functions and services. |
| 511 | * |
| 512 | */ |
| 513 | typedef VOID F_CPU_GET_FAMILY_SPECIFIC_ARRAY ( |
| 514 | IN CONST CPU_SPECIFIC_SERVICES *FamilySpecificServices, |
| 515 | OUT CONST VOID **FamilySpecificArray, |
| 516 | OUT UINT8 *NumberOfElements, |
| 517 | IN AMD_CONFIG_PARAMS *StdHeader |
| 518 | ); |
| 519 | |
| 520 | /// Reference to a Method. |
| 521 | typedef F_CPU_GET_FAMILY_SPECIFIC_ARRAY *PF_CPU_GET_FAMILY_SPECIFIC_ARRAY; |
| 522 | |
| 523 | |
| 524 | /** |
| 525 | * Get CPU Specific Platform Type Info. |
| 526 | * |
| 527 | * @CpuServiceInstances |
| 528 | * |
| 529 | * @param[in] FamilySpecificServices The current Family Specific Services. |
| 530 | * @param[in,out] FeaturesUnion The Features supported by this platform. |
| 531 | * @param[in] StdHeader Handle of Header for calling lib functions and services. |
| 532 | * |
| 533 | */ |
| 534 | typedef AGESA_STATUS F_CPU_GET_PLATFORM_TYPE_SPECIFIC_INFO ( |
| 535 | IN CONST CPU_SPECIFIC_SERVICES *FamilySpecificServices, |
| 536 | IN OUT PLATFORM_FEATS *FeaturesUnion, |
| 537 | IN AMD_CONFIG_PARAMS *StdHeader |
| 538 | ); |
| 539 | |
| 540 | /// Reference to a Method. |
| 541 | typedef F_CPU_GET_PLATFORM_TYPE_SPECIFIC_INFO *PF_CPU_GET_PLATFORM_TYPE_SPECIFIC_INFO; |
| 542 | |
| 543 | |
| 544 | /** |
| 545 | * Is the Northbridge PState feature enabled? |
| 546 | * |
| 547 | * @CpuServiceInstances |
| 548 | * |
| 549 | * @param[in] FamilySpecificServices The current Family Specific Services. |
| 550 | * @param[in] PlatformConfig Platform profile/build option config structure. |
| 551 | * @param[in] StdHeader Handle of Header for calling lib functions and services. |
| 552 | * |
| 553 | * @retval TRUE The NB PState feature is enabled. |
| 554 | * @retval FALSE The NB PState feature is not enabled. |
| 555 | */ |
| 556 | typedef BOOLEAN F_IS_NB_PSTATE_ENABLED ( |
| 557 | IN CONST CPU_SPECIFIC_SERVICES *FamilySpecificServices, |
| 558 | IN PLATFORM_CONFIGURATION *PlatformConfig, |
| 559 | IN AMD_CONFIG_PARAMS *StdHeader |
| 560 | ); |
| 561 | |
| 562 | /// Reference to a method |
| 563 | typedef F_IS_NB_PSTATE_ENABLED *PF_IS_NB_PSTATE_ENABLED; |
| 564 | |
| 565 | |
| 566 | /** |
| 567 | * Returns the register tables list |
| 568 | * |
| 569 | * @CpuServiceInstances |
| 570 | * |
| 571 | * @param[in] FamilyServices The current Family Specific Services. |
| 572 | * @param[in] StdHeader Config handle for library and services |
| 573 | * |
| 574 | */ |
| 575 | typedef REGISTER_TABLE_AT_GIVEN_TP *F_GET_REGISTER_TABLE_LIST ( |
| 576 | IN CONST CPU_SPECIFIC_SERVICES *FamilyServices, |
| 577 | IN AMD_CONFIG_PARAMS *StdHeader |
| 578 | ); |
| 579 | /// Reference to a Method. |
| 580 | typedef F_GET_REGISTER_TABLE_LIST *PF_GET_REGISTER_TABLE_LIST; |
| 581 | |
| 582 | |
| 583 | /** |
| 584 | * Returns the workaround tables that the executing core should |
| 585 | * process at the given point in time. |
| 586 | * |
| 587 | * @CpuServiceInstances |
| 588 | * |
| 589 | * @param[in] FamilyServices The current Family Specific Services. |
| 590 | * @param[out] NumberOfWorkaroundTableEntries Number of workaround table entries |
| 591 | * @param[in] StdHeader Config handle for library and services |
| 592 | * |
| 593 | */ |
| 594 | typedef F_FAM_SPECIFIC_WORKAROUND **F_GET_WORKAROUND_TABLE ( |
| 595 | IN CONST CPU_SPECIFIC_SERVICES *FamilyServices, |
| 596 | OUT UINT16 *NumberOfWorkaroundTableEntries, |
| 597 | IN AMD_CONFIG_PARAMS *StdHeader |
| 598 | ); |
| 599 | /// Reference to a Method. |
| 600 | typedef F_GET_WORKAROUND_TABLE *PF_GET_WORKAROUND_TABLE; |
| 601 | |
| 602 | |
| 603 | /// Cache Enable / Disable policy before giving control back to OS. |
| 604 | typedef enum { |
| 605 | InitCacheDisabled, ///<Disable cache CR0.CD bit |
| 606 | InitCacheEnabled ///<Enable cache CR0.CD bit |
| 607 | } FAMILY_CACHE_INIT_POLICY; |
| 608 | |
| 609 | |
| 610 | /** |
| 611 | * Performs an early initialization function on the executing core. |
| 612 | * |
| 613 | * @param[in] FamilyServices The current Family Specific Services. |
| 614 | * @param[in] EarlyParams CPU module early paramters. |
| 615 | * @param[in] StdHeader Config handle for library and services |
| 616 | * |
| 617 | */ |
| 618 | typedef VOID F_PERFORM_EARLY_INIT_ON_CORE ( |
| 619 | IN CONST CPU_SPECIFIC_SERVICES *FamilyServices, |
| 620 | IN AMD_CPU_EARLY_PARAMS *EarlyParams, |
| 621 | IN AMD_CONFIG_PARAMS *StdHeader |
| 622 | ); |
| 623 | /// Reference to a Method. |
| 624 | typedef F_PERFORM_EARLY_INIT_ON_CORE *PF_PERFORM_EARLY_INIT_ON_CORE; |
| 625 | |
| 626 | /** |
| 627 | * A struct that contains function pointer and function flag |
| 628 | * |
| 629 | * the flag indicates if the function need to be run. |
| 630 | */ |
| 631 | typedef struct _S_PERFORM_EARLY_INIT_ON_CORE { |
| 632 | PF_PERFORM_EARLY_INIT_ON_CORE PerformEarlyInitOnCore; ///< Function Pointer, which points to the function need to be run at early stage |
| 633 | UINT32 PerformEarlyInitFlag; ///< Function Flag, which indicates if the function need to be run. |
| 634 | } S_PERFORM_EARLY_INIT_ON_CORE; |
| 635 | |
| 636 | /** |
| 637 | * Returns the initialization steps that the executing core should |
| 638 | * perform at AmdInitEarly. |
| 639 | * |
| 640 | * @CpuServiceInstances |
| 641 | * |
| 642 | * @param[in] FamilyServices The current Family Specific Services. |
| 643 | * @param[out] Table Table of appropriate init steps for the executing core. |
| 644 | * @param[in] EarlyParams CPU module early paramters. |
| 645 | * @param[in] StdHeader Config handle for library and services |
| 646 | * |
| 647 | */ |
| 648 | typedef VOID F_GET_EARLY_INIT_TABLE ( |
| 649 | IN CONST CPU_SPECIFIC_SERVICES *FamilyServices, |
| 650 | OUT CONST S_PERFORM_EARLY_INIT_ON_CORE **Table, |
| 651 | IN AMD_CPU_EARLY_PARAMS *EarlyParams, |
| 652 | IN AMD_CONFIG_PARAMS *StdHeader |
| 653 | ); |
| 654 | /// Reference to a Method. |
| 655 | typedef F_GET_EARLY_INIT_TABLE *PF_GET_EARLY_INIT_TABLE; |
| 656 | |
| 657 | |
| 658 | /** |
| 659 | * Returns if it's SecureS3 |
| 660 | * |
| 661 | * @CpuServiceInstances |
| 662 | * |
| 663 | * @param[in] StdHeader Handle of Header for calling lib functions and services. |
| 664 | * |
| 665 | */ |
| 666 | typedef BOOLEAN F_IS_SECURE_S3 ( |
| 667 | IN AMD_CONFIG_PARAMS *StdHeader |
| 668 | ); |
| 669 | |
| 670 | /// Reference to a Method. |
| 671 | typedef F_IS_SECURE_S3 *PF_IS_SECURE_S3; |
| 672 | |
| 673 | |
| 674 | /** |
| 675 | * Returns a model specific list of logical IDs. |
| 676 | * |
| 677 | * @param[out] LogicalIdXlat Installed logical ID table. |
| 678 | * @param[out] NumberOfElements Number of entries in the Logical ID translate table. |
| 679 | * @param[out] LogicalFamily Base logical family bit mask. |
| 680 | * @param[out] HighestSupportedLogicalId Highest supported stepping |
| 681 | * @param[in] StdHeader Handle of Header for calling lib functions and services. |
| 682 | * |
| 683 | */ |
| 684 | typedef VOID F_CPU_GET_SUBFAMILY_ID_ARRAY ( |
| 685 | OUT CONST CPU_LOGICAL_ID_XLAT **LogicalIdXlat, |
| 686 | OUT UINT8 *NumberOfElements, |
| 687 | OUT UINT16 *LogicalFamily, |
| 688 | OUT UINT16 *HighestSupportedLogicalId, |
| 689 | IN AMD_CONFIG_PARAMS *StdHeader |
| 690 | ); |
| 691 | |
| 692 | /// Reference to a method. |
| 693 | typedef F_CPU_GET_SUBFAMILY_ID_ARRAY *PF_CPU_GET_SUBFAMILY_ID_ARRAY; |
| 694 | |
| 695 | |
| 696 | /*---------------------------------------------------------------------------------------*/ |
| 697 | /** |
| 698 | * Provide the interface to all cpu Family Specific Services. |
| 699 | * |
| 700 | * Use the methods or data in this struct to adapt the feature code to a specific cpu family or model (or stepping!). |
| 701 | * Each supported Family must provide an implementation for all methods in this interface, even if the |
| 702 | * implementation is a CommonReturn(). |
| 703 | * See CPU Family Specific Services Implementation Guide for adding new services. |
| 704 | */ |
| 705 | struct _CPU_SPECIFIC_SERVICES { // See the Forwaqrd Declaration above |
| 706 | UINT16 Revision; ///< Interface version |
| 707 | // Public Methods. |
| 708 | PF_CPU_DISABLE_PSTATE DisablePstate; ///< Method: Disable the desired P-state. |
| 709 | PF_CPU_TRANSITION_PSTATE TransitionPstate; ///< Method: Transition the current core to the desired P-state. |
| 710 | PF_CPU_GET_IDD_MAX GetProcIddMax; ///< Method: Gets P-state maximum current required. |
| 711 | PF_CPU_GET_TSC_RATE GetTscRate; ///< Method: Returns the rate at which the current core's timestamp counter increments in megahertz. |
| 712 | PF_CPU_GET_NB_FREQ GetCurrentNbFrequency; ///< Method: Returns the processor north bridge's clock rate in megahertz. |
| 713 | PF_CPU_GET_MIN_MAX_NB_FREQ GetMinMaxNbFrequency; ///< Method: Returns the node's minimum and maximum northbridge frequency. |
| 714 | PF_CPU_GET_NB_PSTATE_INFO GetNbPstateInfo; ///< Method: Returns information about the processor north bridge's P-states. |
| 715 | PF_CPU_IS_NBCOF_INIT_NEEDED IsNbCofInitNeeded; ///< Method: Returns whether or not the NB frequency initialization sequence is required to be performed by the BIOS. |
| 716 | PF_CPU_GET_NB_IDD_MAX GetNbIddMax; ///< Method: Gets NB P-state maximum current required. |
| 717 | PF_CPU_AP_INITIAL_LAUNCH LaunchApCore; ///< Method: Launches the desired core from the reset vector. |
| 718 | PF_CPU_NUMBER_OF_PHYSICAL_CORES GetNumberOfPhysicalCores; ///< Method: Get the number of physical cores of current processor. |
| 719 | PF_CPU_GET_AP_CORE_NUMBER GetApCoreNumber; ///< Method: Get the AP's core number from hardware. |
| 720 | PF_CORE_ID_POSITION_IN_INITIAL_APIC_ID CoreIdPositionInInitialApicId; ///< Method: Which bits in initial APIC Id are the Core Id. |
| 721 | PF_CPU_SET_WARM_RESET_FLAG SetWarmResetFlag; ///< Method: Set Warm Reset Flag. |
| 722 | PF_CPU_GET_WARM_RESET_FLAG GetWarmResetFlag; ///< Method: Get Warm Reset Flag. |
| 723 | PF_CPU_GET_FAMILY_SPECIFIC_ARRAY GetMicroCodePatchesStruct; ///< Method: Get microcode patches. |
| 724 | PF_CPU_GET_FAMILY_SPECIFIC_ARRAY GetMicrocodeEquivalenceTable; ///< Method: Get CPU equivalence for loading microcode patches. |
| 725 | PF_CPU_GET_FAMILY_SPECIFIC_ARRAY GetCacheInfo; ///< Method: Get setup for cache use and initialization. |
| 726 | PF_CPU_GET_FAMILY_SPECIFIC_ARRAY GetSysPmTableStruct; ///< Method: Get Power Management settings. |
| 727 | PF_CPU_GET_FAMILY_SPECIFIC_ARRAY GetWheaInitData; ///< Method: Get Whea Initial Data. |
| 728 | PF_CPU_GET_PLATFORM_TYPE_SPECIFIC_INFO GetPlatformTypeSpecificInfo; ///< Method: Get Specific platform Type features. |
| 729 | PF_IS_NB_PSTATE_ENABLED IsNbPstateEnabled; ///< Method: Get whether Northbridge PStates feature is enabled. |
| 730 | PF_DO_TABLE_ENTRY DoTableEntry[TableEntryTypeMax]; ///< Method: Table Entry Implementers |
| 731 | PF_GET_REGISTER_TABLE_LIST GetRegisterTableList; ///< Method: Returns the RegisterTableList. |
| 732 | PF_GET_WORKAROUND_TABLE GetWorkaroundTable; ///< Method: Returns the workaround tables |
| 733 | COMPUTE_UNIT_MAP *ComputeUnitMap; ///< Public Data: Translate compute unit core pairing, or NULL. |
| 734 | FAMILY_CACHE_INIT_POLICY InitCacheDisabled; ///< Public Data: Family related information. |
| 735 | PF_GET_EARLY_INIT_TABLE GetEarlyInitBeforeApLaunchOnCoreTable; ///< Method: Get the initialization steps needed before AP launch. |
| 736 | PF_GET_EARLY_INIT_TABLE GetEarlyInitAfterApLaunchOnCoreTable; ///< Method: Get the initialization steps needed after AP launch. |
| 737 | PF_IS_SECURE_S3 IsSecureS3; ///< Method: Check if it's SecureS3. |
| 738 | BOOLEAN PatchLoaderIsSharedByCU; ///< Public Data: Indicate if patch loader is shared by Compute Unit. |
| 739 | }; |
| 740 | |
| 741 | /** |
| 742 | * A Family Id and an interface to it's implementations of Family Specific Services. |
| 743 | * |
| 744 | * Note that this is a logical family id, which may specify family, model (or even stepping). |
| 745 | */ |
| 746 | typedef struct { |
| 747 | UINT64 Family; ///< The Family to which this interface belongs. |
| 748 | CONST VOID *TablePtr; ///< The interface to its Family Specific Services. |
| 749 | } CPU_SPECIFIC_SERVICES_XLAT; |
| 750 | |
| 751 | /** |
| 752 | * A collection of Family specific interfaces to Family Specific services. |
| 753 | */ |
| 754 | typedef struct { |
| 755 | UINT8 Elements; ///< The number of tables to search. |
| 756 | CONST CPU_SPECIFIC_SERVICES_XLAT *FamilyTable; ///< The family interfaces. |
| 757 | } CPU_FAMILY_SUPPORT_TABLE; |
| 758 | |
| 759 | /** |
| 760 | * Implement the translation of a logical CPU id to an id that can be used to get Family specific services. |
| 761 | */ |
| 762 | typedef struct { |
| 763 | UINT32 Family; ///< Provide translation for this family |
| 764 | CPU_LOGICAL_ID UnknownRevision; ///< In this family, unrecognized models (or steppings) are treated as though they were this model and stepping. |
| 765 | CONST PF_CPU_GET_SUBFAMILY_ID_ARRAY *SubFamilyIdTable; ///< Method: Get family specific model (and stepping) resolution. |
| 766 | UINT8 Elements; ///< The number of family specific model tables pointed to by SubFamilyIdTable |
| 767 | } CPU_LOGICAL_ID_FAMILY_XLAT; |
| 768 | |
| 769 | /** |
| 770 | * A collection of all available family id translations. |
| 771 | */ |
| 772 | typedef struct { |
| 773 | UINT8 Elements; ///< The number of family translation items to search. |
| 774 | CONST CPU_LOGICAL_ID_FAMILY_XLAT *FamilyIdTable; ///< The family translation items. |
| 775 | } CPU_FAMILY_ID_XLAT_TABLE; |
| 776 | |
| 777 | /*--------------------------------------------------------------------------------------- |
| 778 | * F U N C T I O N P R O T O T Y P E |
| 779 | *--------------------------------------------------------------------------------------- |
| 780 | */ |
| 781 | |
| 782 | /** |
| 783 | * Get a logical identifier for the specified processor, based on CPUID, but independent of CPUID formatting. |
| 784 | */ |
| 785 | VOID |
| 786 | GetLogicalIdOfSocket ( |
| 787 | IN UINT32 Socket, |
| 788 | OUT CPU_LOGICAL_ID *LogicalId, |
| 789 | IN AMD_CONFIG_PARAMS *StdHeader |
| 790 | ); |
| 791 | |
| 792 | /** |
| 793 | * Get a logical identifier for the executing core, based on CPUID, but independent of CPUID formatting. |
| 794 | */ |
| 795 | VOID |
| 796 | GetLogicalIdOfCurrentCore ( |
| 797 | OUT CPU_LOGICAL_ID *LogicalId, |
| 798 | IN AMD_CONFIG_PARAMS *StdHeader |
| 799 | ); |
| 800 | |
| 801 | /** |
| 802 | * Get a logical identifier for the specified CPUID value. |
| 803 | */ |
| 804 | VOID |
| 805 | GetLogicalIdFromCpuid ( |
| 806 | IN UINT32 RawCpuid, |
| 807 | OUT CPU_LOGICAL_ID *LogicalId, |
| 808 | IN AMD_CONFIG_PARAMS *StdHeader |
| 809 | ); |
| 810 | |
| 811 | /** |
| 812 | * Retrieves a pointer to the executing core's family specific services structure. |
| 813 | */ |
| 814 | VOID |
| 815 | GetCpuServicesOfCurrentCore ( |
| 816 | OUT CONST CPU_SPECIFIC_SERVICES **FunctionTable, |
| 817 | IN AMD_CONFIG_PARAMS *StdHeader |
| 818 | ); |
| 819 | |
| 820 | /** |
| 821 | * Retrieves a pointer to the executing core's family specific services structure. |
| 822 | */ |
| 823 | VOID |
| 824 | GetFeatureServicesOfCurrentCore ( |
| 825 | IN CPU_FAMILY_SUPPORT_TABLE *FamilyTable, |
| 826 | OUT CONST VOID **CpuServices, |
| 827 | IN AMD_CONFIG_PARAMS *StdHeader |
| 828 | ); |
| 829 | |
| 830 | /** |
| 831 | * Retrieves a pointer to the family specific services structure for a processor |
| 832 | * with the given logical ID. |
| 833 | */ |
| 834 | VOID |
| 835 | GetCpuServicesFromLogicalId ( |
| 836 | IN CPU_LOGICAL_ID *LogicalId, |
| 837 | OUT CONST CPU_SPECIFIC_SERVICES **FunctionTable, |
| 838 | IN AMD_CONFIG_PARAMS *StdHeader |
| 839 | ); |
| 840 | |
| 841 | /** |
| 842 | * Retrieves a pointer to the family specific services structure for a processor |
| 843 | * with the given logical ID. |
| 844 | */ |
| 845 | VOID |
| 846 | GetFeatureServicesFromLogicalId ( |
| 847 | IN CPU_FAMILY_SUPPORT_TABLE *FamilyTable, |
| 848 | IN CPU_LOGICAL_ID *LogicalId, |
| 849 | OUT CONST VOID **CpuServices, |
| 850 | IN AMD_CONFIG_PARAMS *StdHeader |
| 851 | ); |
| 852 | |
| 853 | /** |
| 854 | * Used by logical families which don't need a certain register setting table or other data array. |
| 855 | */ |
| 856 | VOID |
| 857 | GetEmptyArray ( |
| 858 | IN CONST CPU_SPECIFIC_SERVICES *FamilySpecificServices, |
| 859 | OUT CONST VOID **Empty, |
| 860 | OUT UINT8 *NumberOfElements, |
| 861 | IN AMD_CONFIG_PARAMS *StdHeader |
| 862 | ); |
| 863 | |
| 864 | #endif // _CPU_FAMILY_TRANSLATION_H_ |
| 865 |