5 * AMD CPU Family Translation functions.
8 * @xrefitem bom "File Content Label" "Release Content"
11 * @e \$Revision: 49967 $ @e \$Date: 2011-03-31 11:15:12 +0800 (Thu, 31 Mar 2011) $
15 ******************************************************************************
17 * Copyright (c) 2011, Advanced Micro Devices, Inc.
18 * All rights reserved.
20 * Redistribution and use in source and binary forms, with or without
21 * modification, are permitted provided that the following conditions are met:
22 * * Redistributions of source code must retain the above copyright
23 * notice, this list of conditions and the following disclaimer.
24 * * Redistributions in binary form must reproduce the above copyright
25 * notice, this list of conditions and the following disclaimer in the
26 * documentation and/or other materials provided with the distribution.
27 * * Neither the name of Advanced Micro Devices, Inc. nor the names of
28 * its contributors may be used to endorse or promote products derived
29 * from this software without specific prior written permission.
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
32 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
33 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
34 * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
35 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
36 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
37 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
38 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
39 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
40 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
41 ******************************************************************************
44 #ifndef _CPU_FAMILY_TRANSLATION_H_
45 #define _CPU_FAMILY_TRANSLATION_H_
48 * @page cpuimplfss CPU Family Specific Services Implementation Guide
50 * CPU Family Specific Services provides access to supported family service functions and data,
51 * in a manner that isolates calling code from knowledge about particular families or which
52 * families are supported in the current build.
54 * @par Adding a Method to Family Specific Services
56 * To add a new method to Family Specific Services, follow these steps.
58 * <li> Create a typedef for the Method with the correct parameters and return type.
61 * <li> Name the method typedef (*PF_METHOD_NAME)(), where METHOD_NAME is the same name as the method table item,
62 * but with "_"'s and UPPERCASE, rather than mixed case.
63 * @n <tt> typedef VOID (*PF_METHOD_NAME)(); </tt> @n
65 * <li> [Optionally make the type F_<name> and provide a separate:
66 * @n <tt> typedef F_METHOD_NAME *PF_METHOD_NAME> </tt> @n
67 * and provide a single line "///" doxygen comment brief description on the PF_ type.]
70 * <li> The first parameter to @b all Family Specific Service Methods is @b required to be a reference to
71 * their Family Service struct.
72 * @n <tt> IN CPU_SPECIFIC_SERVICES *FamilySpecificServices </tt> @n
74 * <li> Provide a standard doxygen function preamble for the Method typedef. Begin the
75 * detailed description by provide a reference to the method instances page by including
79 * * @CpuServiceInstances
82 * @note It is important to provide documentation for the method type, because the method may not
83 * have an implementation in any families supported by the current package. @n
85 * <li> Add to the CPU_SPECIFIC_SERVICES struct an item for the Method:
86 * @n <tt> PF_METHOD_NAME MethodName; ///< Method: description. </tt> @n
89 * @par Implementing a Family Specific Instance of the method.
91 * To implement an instance of a method for a specific family follow these steps.
93 * - In appropriate files in the family specific directory, implement the method with the return type
94 * and parameters matching the method typedef.
96 * - Name the function FnnMethodName(), where nn is the family number.
98 * - Create a doxygen function preamble for the method instance. Begin the detailed description with
99 * an Implements command to reference the method type and add this instance to the Method Instances page.
102 * * @CpuServiceMethod{::F_METHOD_NAME}.
106 * - To access other family specific services as part of the method implementation, the function
107 * @b must use FamilySpecificServices->OtherMethod(). Do not directly call other family specific
108 * routines, because in the table there may be overrides or this routine may be shared by multiple families.
110 * - Do @b not call Family translation services from a family specific instance. Use the parameter.
112 * - Add the instance to the family specific CPU_SPECIFIC_SERVICES instance.
114 * - If a family does not need an instance of the method use one of the CommonReturns from
115 * CommonReturns.h with the same return type.
117 * @par Invoking Family Specific Services.
119 * The following example shows how to invoke a family specific method.
121 * CPU_SPECIFIC_SERVICES *FamilyServices;
123 * GetCpuServicesOfCurrentCore (&FamilyServices, StdHeader);
124 * ASSERT (FamilyServices != NULL);
125 * FamilyServices->MethodName (FamilyServices, StdHeader);
131 /*---------------------------------------------------------------------------------------
132 * M I X E D (Definitions And Macros / Typedefs, Structures, Enums)
133 *---------------------------------------------------------------------------------------
135 #include "cpuPostInit.h"
136 #include "cpuRegisters.h"
137 #include "cpuServices.h"
140 #include "Topology.h"
142 // Forward declaration needed for multi-structure mutual references.
143 AGESA_FORWARD_DECLARATION (CPU_SPECIFIC_SERVICES);
144 /*---------------------------------------------------------------------------------------
145 * D E F I N I T I O N S A N D M A C R O S
146 *---------------------------------------------------------------------------------------
149 /*---------------------------------------------------------------------------------------
150 * T Y P E D E F S, S T R U C T U R E S, E N U M S
151 *---------------------------------------------------------------------------------------
155 * Disable the desired P-state.
157 * @CpuServiceInstances
159 * @param[in] FamilySpecificServices The current Family Specific Services.
160 * @param[in] StateNumber Hardware P-state number.
161 * @param[in] StdHeader Handle of Header for calling lib functions and services.
164 typedef AGESA_STATUS F_CPU_DISABLE_PSTATE (
165 IN CPU_SPECIFIC_SERVICES *FamilySpecificServices,
166 IN UINT8 StateNumber,
167 IN AMD_CONFIG_PARAMS *StdHeader
170 /// Reference to a Method.
171 typedef F_CPU_DISABLE_PSTATE *PF_CPU_DISABLE_PSTATE;
174 * Transition the current core to the desired P-state.
176 * @CpuServiceInstances
178 * @param[in] FamilySpecificServices The current Family Specific Services.
179 * @param[in] StateNumber Software P-state number.
180 * @param[in] WaitForChange Wait/don't wait for P-state change to complete.
181 * @param[in] StdHeader Handle of Header for calling lib functions and services.
184 typedef AGESA_STATUS F_CPU_TRANSITION_PSTATE (
185 IN CPU_SPECIFIC_SERVICES *FamilySpecificServices,
186 IN UINT8 StateNumber,
187 IN BOOLEAN WaitForChange,
188 IN AMD_CONFIG_PARAMS *StdHeader
191 /// Reference to a Method.
192 typedef F_CPU_TRANSITION_PSTATE *PF_CPU_TRANSITION_PSTATE;
195 * Get the desired P-state's maximum current required in milliamps.
197 * @CpuServiceInstances
199 * @param[in] FamilySpecificServices The current Family Specific Services.
200 * @param[in] StateNumber The desired hardware P-state number.
201 * @param[out] ProcIddMax The P-state's maximum current.
202 * @param[in] StdHeader Handle of Header for calling lib functions and services.
204 * @retval TRUE The P-state is enabled, and ProcIddMax is valid.
205 * @retval FALSE The P-state is disabled.
208 typedef BOOLEAN F_CPU_GET_IDD_MAX (
209 IN CPU_SPECIFIC_SERVICES *FamilySpecificServices,
210 IN UINT8 StateNumber,
211 OUT UINT32 *ProcIddMax,
212 IN AMD_CONFIG_PARAMS *StdHeader
215 /// Reference to a Method.
216 typedef F_CPU_GET_IDD_MAX *PF_CPU_GET_IDD_MAX;
220 * Returns the rate at which the current core's timestamp counter increments in megahertz.
222 * @CpuServiceInstances
224 * @param[in] FamilySpecificServices The current Family Specific Services.
225 * @param[out] FreqInMHz The rate at which the TSC increments in megahertz.
226 * @param[in] StdHeader Handle of Header for calling lib functions and services.
229 typedef AGESA_STATUS F_CPU_GET_TSC_RATE (
230 IN CPU_SPECIFIC_SERVICES *FamilySpecificServices,
231 OUT UINT32 *FreqInMHz,
232 IN AMD_CONFIG_PARAMS *StdHeader
235 /// Reference to a Method.
236 typedef F_CPU_GET_TSC_RATE *PF_CPU_GET_TSC_RATE;
239 * Returns the processor north bridge's clock rate in megahertz.
241 * @CpuServiceInstances
243 * @param[in] FamilySpecificServices The current Family Specific Services.
244 * @param[out] FreqInMHz The desired node's frequency in megahertz.
245 * @param[in] StdHeader Handle of Header for calling lib functions and services.
247 * @retval AGESA_SUCCESS FreqInMHz is valid.
249 typedef AGESA_STATUS F_CPU_GET_NB_FREQ (
250 IN CPU_SPECIFIC_SERVICES *FamilySpecificServices,
251 OUT UINT32 *FreqInMHz,
252 IN AMD_CONFIG_PARAMS *StdHeader
255 /// Reference to a Method.
256 typedef F_CPU_GET_NB_FREQ *PF_CPU_GET_NB_FREQ;
259 * Returns the node's minimum and maximum northbridge frequency.
261 * @CpuServiceInstances
263 * @param[in] FamilySpecificServices The current Family Specific Services.
264 * @param[in] PlatformConfig Platform profile/build option config structure.
265 * @param[in] PciAddress The segment, bus, and device numbers of the CPU in question.
266 * @param[out] MinFreqInMHz The minimum north bridge frequency.
267 * @param[out] MaxFreqInMHz The maximum north bridge frequency.
268 * @param[in] StdHeader Handle of Header for calling lib functions and services.
270 * @retval AGESA_STATUS Northbridge frequency is valid
272 typedef AGESA_STATUS F_CPU_GET_MIN_MAX_NB_FREQ (
273 IN CPU_SPECIFIC_SERVICES *FamilySpecificServices,
274 IN PLATFORM_CONFIGURATION *PlatformConfig,
275 IN PCI_ADDR *PciAddress,
276 OUT UINT32 *MinFreqInMHz,
277 OUT UINT32 *MaxFreqInMHz,
278 IN AMD_CONFIG_PARAMS *StdHeader
281 /// Reference to a Method.
282 typedef F_CPU_GET_MIN_MAX_NB_FREQ *PF_CPU_GET_MIN_MAX_NB_FREQ;
285 * Returns the processor north bridge's P-state settings.
287 * @CpuServiceInstances
289 * @param[in] FamilySpecificServices The current Family Specific Services.
290 * @param[in] PlatformConfig Platform profile/build option config structure.
291 * @param[in] PciAddress The segment, bus, and device numbers of the CPU in question.
292 * @param[in] NbPstate The NB P-state number to check.
293 * @param[out] FreqNumeratorInMHz The desired node's frequency numerator in megahertz.
294 * @param[out] FreqDivisor The desired node's frequency divisor.
295 * @param[out] VoltageInuV The desired node's voltage in microvolts.
296 * @param[in] StdHeader Handle of Header for calling lib functions and services.
298 * @retval TRUE NbPstate is valid
299 * @retval FALSE NbPstate is disabled or invalid
301 typedef BOOLEAN F_CPU_GET_NB_PSTATE_INFO (
302 IN CPU_SPECIFIC_SERVICES *FamilySpecificServices,
303 IN PLATFORM_CONFIGURATION *PlatformConfig,
304 IN PCI_ADDR *PciAddress,
306 OUT UINT32 *FreqNumeratorInMHz,
307 OUT UINT32 *FreqDivisor,
308 OUT UINT32 *VoltageInuV,
309 IN AMD_CONFIG_PARAMS *StdHeader
312 /// Reference to a Method.
313 typedef F_CPU_GET_NB_PSTATE_INFO *PF_CPU_GET_NB_PSTATE_INFO;
316 * Returns whether or not the NB frequency initialization sequence is required
317 * to be performed by the BIOS.
319 * @CpuServiceInstances
321 * @param[in] FamilySpecificServices The current Family Specific Services.
322 * @param[in] PciAddress The northbridge to query by pci base address.
323 * @param[out] NbVidUpdateAll Do all NbVids need to be updated as well.
324 * @param[in] StdHeader Handle of Header for calling lib functions and services.
327 typedef BOOLEAN F_CPU_IS_NBCOF_INIT_NEEDED (
328 IN CPU_SPECIFIC_SERVICES *FamilySpecificServices,
329 IN PCI_ADDR *PciAddress,
330 OUT BOOLEAN *NbVidUpdateAll,
331 IN AMD_CONFIG_PARAMS *StdHeader
334 /// Reference to a Method.
335 typedef F_CPU_IS_NBCOF_INIT_NEEDED *PF_CPU_IS_NBCOF_INIT_NEEDED;
338 * Get the desired NB P-state's maximum current required in milliamps.
340 * @CpuServiceInstances
342 * @param[in] FamilySpecificServices The current Family Specific Services.
343 * @param[in] StateNumber The desired hardware P-state number.
344 * @param[out] NbIddMax The NB P-state's maximum current.
345 * @param[in] StdHeader Handle of Header for calling lib functions and services.
347 * @retval TRUE The NB P-state is enabled, and NbIddMax is valid.
348 * @retval FALSE The NB P-state is disabled.
351 typedef BOOLEAN F_CPU_GET_NB_IDD_MAX (
352 IN CPU_SPECIFIC_SERVICES *FamilySpecificServices,
353 IN UINT8 StateNumber,
354 OUT UINT32 *NbIddMax,
355 IN AMD_CONFIG_PARAMS *StdHeader
358 /// Reference to a Method.
359 typedef F_CPU_GET_NB_IDD_MAX *PF_CPU_GET_NB_IDD_MAX;
362 * Launches the desired core from the reset vector.
364 * @CpuServiceInstances
366 * @param[in] FamilySpecificServices The current Family Specific Services.
367 * @param[in] SocketNumber The desired core's socket number.
368 * @param[in] ModuleNumber The desired core's die number.
369 * @param[in] CoreNumber The desired core's die relative core number.
370 * @param[in] PrimaryCoreNumber SocketNumber / ModuleNumber's primary core number.
371 * @param[in] StdHeader Handle of Header for calling lib functions and services.
373 * @retval TRUE The core was launched successfully.
374 * @retval FALSE The core was previously launched, or has a problem.
376 typedef BOOLEAN F_CPU_AP_INITIAL_LAUNCH (
377 IN CPU_SPECIFIC_SERVICES *FamilySpecificServices,
378 IN UINT32 SocketNumber,
379 IN UINT32 ModuleNumber,
380 IN UINT32 CoreNumber,
381 IN UINT32 PrimaryCoreNumber,
382 IN AMD_CONFIG_PARAMS *StdHeader
385 /// Reference to a Method.
386 typedef F_CPU_AP_INITIAL_LAUNCH *PF_CPU_AP_INITIAL_LAUNCH;
389 * Returns the appropriate number of physical processor cores
391 * @CpuServiceInstances
393 * @param[in] FamilySpecificServices The current Family Specific Services.
394 * @param[in] StdHeader Handle of Header for calling lib functions and services.
396 * @return One-based number of physical cores on current processor
398 typedef UINT8 F_CPU_NUMBER_OF_PHYSICAL_CORES (
399 IN CPU_SPECIFIC_SERVICES *FamilySpecificServices,
400 IN AMD_CONFIG_PARAMS *StdHeader
403 /// Reference to a Method.
404 typedef F_CPU_NUMBER_OF_PHYSICAL_CORES *PF_CPU_NUMBER_OF_PHYSICAL_CORES;
407 * Returns a family specific table of information pointer and size.
409 * @CpuServiceInstances
411 * @param[in] FamilySpecificServices The current Family Specific Services.
412 * @param[out] FamilySpecificArray Pointer to the appropriate list for the core.
413 * @param[out] NumberOfElements Number of valid entries FamilySpecificArray.
414 * @param[in] StdHeader Handle of Header for calling lib functions and services.
417 typedef VOID F_CPU_GET_FAMILY_SPECIFIC_ARRAY (
418 IN CPU_SPECIFIC_SERVICES *FamilySpecificServices,
419 OUT CONST VOID **FamilySpecificArray,
420 OUT UINT8 *NumberOfElements,
421 IN AMD_CONFIG_PARAMS *StdHeader
424 /// Reference to a Method.
425 typedef F_CPU_GET_FAMILY_SPECIFIC_ARRAY *PF_CPU_GET_FAMILY_SPECIFIC_ARRAY;
428 * Returns a model specific list of logical IDs.
430 * @param[out] LogicalIdXlat Installed logical ID table.
431 * @param[out] NumberOfElements Number of entries in the Logical ID translate table.
432 * @param[out] LogicalFamily Base logical family bit mask.
433 * @param[in] StdHeader Handle of Header for calling lib functions and services.
436 typedef VOID F_CPU_GET_SUBFAMILY_ID_ARRAY (
437 OUT CONST CPU_LOGICAL_ID_XLAT **LogicalIdXlat,
438 OUT UINT8 *NumberOfElements,
439 OUT UINT64 *LogicalFamily,
440 IN AMD_CONFIG_PARAMS *StdHeader
443 /// Reference to a method.
444 typedef F_CPU_GET_SUBFAMILY_ID_ARRAY *PF_CPU_GET_SUBFAMILY_ID_ARRAY;
447 * Use the Mailbox Register to get the Ap Mailbox info for the current core.
449 * @CpuServiceInstances
451 * @param[in] FamilySpecificServices The current Family Specific Services.
452 * @param[out] ApMailboxInfo The AP Mailbox info
453 * @param[in] StdHeader Handle of Header for calling lib functions and services.
456 typedef VOID (F_CPU_AMD_GET_AP_MAILBOX_FROM_HARDWARE) (
457 IN CPU_SPECIFIC_SERVICES *FamilySpecificServices,
458 OUT AP_MAILBOXES *ApMailboxInfo,
459 IN AMD_CONFIG_PARAMS *StdHeader
462 /// Reference to a method
463 typedef F_CPU_AMD_GET_AP_MAILBOX_FROM_HARDWARE *PF_CPU_AMD_GET_AP_MAILBOX_FROM_HARDWARE;
466 * Set the AP core number in the AP's Mailbox.
468 * @CpuServiceInstances
470 * @param[in] FamilySpecificServices The current Family Specific Services.
471 * @param[in] Socket The AP's socket
472 * @param[in] Module The AP's module
473 * @param[in] ApCoreNumber The AP's unique core number
474 * @param[in] StdHeader Handle of Header for calling lib functions and services.
477 typedef VOID (F_CPU_SET_AP_CORE_NUMBER) (
478 IN CPU_SPECIFIC_SERVICES *FamilySpecificServices,
481 IN UINT32 ApCoreNumber,
482 IN AMD_CONFIG_PARAMS *StdHeader
485 /// Reference to a method
486 typedef F_CPU_SET_AP_CORE_NUMBER *PF_CPU_SET_AP_CORE_NUMBER;
489 * Get the AP core number from hardware.
491 * @CpuServiceInstances
493 * @param[in] FamilySpecificServices The current Family Specific Services.
494 * @param[in] StdHeader Handle of Header for calling lib functions and services.
496 * @return The AP's unique core number
498 typedef UINT32 (F_CPU_GET_AP_CORE_NUMBER) (
499 IN CPU_SPECIFIC_SERVICES *FamilySpecificServices,
500 IN AMD_CONFIG_PARAMS *StdHeader
503 /// Reference to a method
504 typedef F_CPU_GET_AP_CORE_NUMBER *PF_CPU_GET_AP_CORE_NUMBER;
507 * Move the AP's core number from the mailbox to hardware.
509 * @CpuServiceInstances
511 * @param[in] FamilySpecificServices The current Family Specific Services.
512 * @param[in] StdHeader Handle of Header for calling lib functions and services.
514 * @return The AP's unique core number
516 typedef VOID (F_CPU_TRANSFER_AP_CORE_NUMBER) (
517 IN CPU_SPECIFIC_SERVICES *FamilySpecificServices,
518 IN AMD_CONFIG_PARAMS *StdHeader
521 /// Reference to a method
522 typedef F_CPU_TRANSFER_AP_CORE_NUMBER *PF_CPU_TRANSFER_AP_CORE_NUMBER;
525 * Core ID position in the initial APIC ID, reflected as a number zero or one.
528 CoreIdPositionZero, ///< Zero, the Core Id bits are the Most Significant bits.
529 CoreIdPositionOne, ///< One, the Core Id bits are the Least Significant bits.
530 CoreIdPositionMax ///< Limit check.
534 * Return a number zero or one, based on the Core ID position in the initial APIC Id.
536 * @CpuServiceInstances
538 * @param[in] FamilySpecificServices The current Family Specific Services.
539 * @param[in] StdHeader Handle of Header for calling lib functions and services.
541 * @retval CoreIdPositionZero Core Id is not low
542 * @retval CoreIdPositionOne Core Id is low
544 typedef CORE_ID_POSITION F_CORE_ID_POSITION_IN_INITIAL_APIC_ID (
545 IN CPU_SPECIFIC_SERVICES *FamilySpecificServices,
546 IN AMD_CONFIG_PARAMS *StdHeader
549 /// Reference to a method
550 typedef F_CORE_ID_POSITION_IN_INITIAL_APIC_ID *PF_CORE_ID_POSITION_IN_INITIAL_APIC_ID;
553 * Get least common features set of all CPUs and save them to CPU_FEATURES_LIST
555 * @CpuServiceInstances
557 * @param[in] FamilySpecificServices The current Family Specific Services.
558 * @param[in,out] cpuFeatureListPtr The CPU Features List
559 * @param[in] StdHeader Handle of Header for calling lib functions and services.
562 typedef VOID (F_CPU_SAVE_FEATURES) (
563 IN CPU_SPECIFIC_SERVICES *FamilySpecificServices,
564 IN OUT CPU_FEATURES_LIST *cpuFeatureListPtr,
565 IN AMD_CONFIG_PARAMS *StdHeader
568 /// Reference to a method
569 typedef F_CPU_SAVE_FEATURES *PF_CPU_SAVE_FEATURES;
572 * Get least common features from CPU_FEATURES_LIST and write them to CPU
574 * @CpuServiceInstances
576 * @param[in] FamilySpecificServices The current Family Specific Services.
577 * @param[in,out] cpuFeatureListPtr The CPU Features List
578 * @param[in] StdHeader Handle of Header for calling lib functions and services.
581 typedef VOID (F_CPU_WRITE_FEATURES) (
582 IN CPU_SPECIFIC_SERVICES *FamilySpecificServices,
583 IN OUT CPU_FEATURES_LIST *cpuFeatureListPtr,
584 IN AMD_CONFIG_PARAMS *StdHeader
587 /// Reference to a method
588 typedef F_CPU_WRITE_FEATURES *PF_CPU_WRITE_FEATURES;
591 * Set Warm Reset Flag
593 * @CpuServiceInstances
595 * @param[in] FamilySpecificServices The current Family Specific Services.
596 * @param[in] StdHeader Header for library and services.
597 * @param[in] Request Value to set the flags to.
600 typedef VOID (F_CPU_SET_WARM_RESET_FLAG) (
601 IN CPU_SPECIFIC_SERVICES *FamilySpecificServices,
602 IN AMD_CONFIG_PARAMS *StdHeader,
603 IN WARM_RESET_REQUEST *Request
606 /// Reference to a method
607 typedef F_CPU_SET_WARM_RESET_FLAG *PF_CPU_SET_WARM_RESET_FLAG;
610 * Get Warm Reset Flag
612 * @CpuServiceInstances
614 * @param[in] FamilySpecificServices The current Family Specific Services.
615 * @param[in] StdHeader Header for library and services.
616 * @param[out] BiosRstDet Indicate warm reset status.
619 typedef VOID (F_CPU_GET_WARM_RESET_FLAG) (
620 IN CPU_SPECIFIC_SERVICES *FamilySpecificServices,
621 IN AMD_CONFIG_PARAMS *StdHeader,
622 OUT WARM_RESET_REQUEST *Request
625 /// Reference to a method
626 typedef F_CPU_GET_WARM_RESET_FLAG *PF_CPU_GET_WARM_RESET_FLAG;
630 * Get CPU Specific Platform Type Info.
632 * @CpuServiceInstances
634 * @param[in] FamilySpecificServices The current Family Specific Services.
635 * @param[in,out] FeaturesUnion The Features supported by this platform.
636 * @param[in] StdHeader Handle of Header for calling lib functions and services.
639 typedef AGESA_STATUS F_CPU_GET_PLATFORM_TYPE_SPECIFIC_INFO (
640 IN CPU_SPECIFIC_SERVICES *FamilySpecificServices,
641 IN OUT PLATFORM_FEATS *FeaturesUnion,
642 IN AMD_CONFIG_PARAMS *StdHeader
645 /// Reference to a Method.
646 typedef F_CPU_GET_PLATFORM_TYPE_SPECIFIC_INFO *PF_CPU_GET_PLATFORM_TYPE_SPECIFIC_INFO;
649 * Is the Northbridge PState feature enabled?
651 * @CpuServiceInstances
653 * @param[in] FamilySpecificServices The current Family Specific Services.
654 * @param[in] PlatformConfig Platform profile/build option config structure.
655 * @param[in] StdHeader Handle of Header for calling lib functions and services.
657 * @retval TRUE The NB PState feature is enabled.
658 * @retval FALSE The NB PState feature is not enabled.
660 typedef BOOLEAN F_IS_NB_PSTATE_ENABLED (
661 IN CPU_SPECIFIC_SERVICES *FamilySpecificServices,
662 IN PLATFORM_CONFIGURATION *PlatformConfig,
663 IN AMD_CONFIG_PARAMS *StdHeader
666 /// Reference to a method
667 typedef F_IS_NB_PSTATE_ENABLED *PF_IS_NB_PSTATE_ENABLED;
670 * Gets the next link with features matching the HT phy register table entry type features.
672 * @CpuServiceInstances
674 * @param[in] FamilySpecificServices The current Family Specific Services.
675 * @param[in,out] HtHostCapability Initially the PCI bus, device, function=0, offset=0;
676 * Each call returns the HT Host Capability function and offset;
677 * Caller may use it to access registers, but must @b not modify it;
678 * Each new call passes the previous value as input.
679 * @param[in,out] Link Initially zero, each call returns the link number; caller passes it back unmodified each call.
680 * @param[in] HtPhyLinkType Link type field from a register table entry to compare against
681 * @param[out] MatchedSublink1 TRUE: It is actually just sublink 1 that matches, FALSE: any other condition.
682 * @param[out] Frequency0 The frequency of sublink0 (200 MHz if not connected).
683 * @param[out] Frequency1 The frequency of sublink1 (200 MHz if not connected).
684 * @param[in] StdHeader Standard Head Pointer
686 * @retval TRUE Link matches
687 * @retval FALSE No more links
690 typedef BOOLEAN F_NEXT_LINK_HAS_HTFPY_FEATS (
691 IN CPU_SPECIFIC_SERVICES *FamilySpecificServices,
692 IN OUT PCI_ADDR *HtHostCapability,
694 IN HT_PHY_LINK_FEATS *HtPhyLinkType,
695 OUT BOOLEAN *MatchedSublink1,
696 OUT HT_FREQUENCIES *Frequency0,
697 OUT HT_FREQUENCIES *Frequency1,
698 IN AMD_CONFIG_PARAMS *StdHeader
700 /// Reference to a Method.
701 typedef F_NEXT_LINK_HAS_HTFPY_FEATS *PF_NEXT_LINK_HAS_HTFPY_FEATS;
704 * Applies an HT Phy read-modify-write based on an HT Phy register table entry.
706 * @CpuServiceInstances
708 * @param[in] FamilySpecificServices The current Family Specific Services.
709 * @param[in] HtPhyEntry HT Phy register table entry to apply
710 * @param[in] CapabilitySet The link's HT Host base address.
711 * @param[in] Link Zero based, node, link number (not package link), always a sublink0 link.
712 * @param[in] StdHeader Config handle for library and services
715 typedef VOID F_SET_HT_PHY_REGISTER (
716 IN CPU_SPECIFIC_SERVICES *FamilySpecificServices,
717 IN HT_PHY_TYPE_ENTRY_DATA *HtPhyEntry,
718 IN PCI_ADDR CapabilitySet,
720 IN AMD_CONFIG_PARAMS *StdHeader
722 /// Reference to a Method.
723 typedef F_SET_HT_PHY_REGISTER *PF_SET_HT_PHY_REGISTER;
726 * Performs an early initialization function on the executing core.
728 * @param[in] FamilyServices The current Family Specific Services.
729 * @param[in] EarlyParams CPU module early paramters.
730 * @param[in] StdHeader Config handle for library and services
733 typedef VOID F_PERFORM_EARLY_INIT_ON_CORE (
734 IN CPU_SPECIFIC_SERVICES *FamilyServices,
735 IN AMD_CPU_EARLY_PARAMS *EarlyParams,
736 IN AMD_CONFIG_PARAMS *StdHeader
738 /// Reference to a Method.
739 typedef F_PERFORM_EARLY_INIT_ON_CORE *PF_PERFORM_EARLY_INIT_ON_CORE;
742 * A struct that contains function pointer and function flag
744 * the flag indicates if the function need to be run.
746 typedef struct _S_PERFORM_EARLY_INIT_ON_CORE {
747 PF_PERFORM_EARLY_INIT_ON_CORE PerformEarlyInitOnCore; ///< Function Pointer, which points to the function need to be run at early stage
748 UINT32 PerformEarlyInitFlag; ///< Function Flag, which indicates if the function need to be run.
749 } S_PERFORM_EARLY_INIT_ON_CORE;
752 * Returns the initialization steps that the executing core should
753 * perform at AmdInitEarly.
755 * @CpuServiceInstances
757 * @param[in] FamilyServices The current Family Specific Services.
758 * @param[out] Table Table of appropriate init steps for the executing core.
759 * @param[in] EarlyParams CPU module early paramters.
760 * @param[in] StdHeader Config handle for library and services
763 typedef VOID F_GET_EARLY_INIT_TABLE (
764 IN CPU_SPECIFIC_SERVICES *FamilyServices,
765 OUT CONST S_PERFORM_EARLY_INIT_ON_CORE **Table,
766 IN AMD_CPU_EARLY_PARAMS *EarlyParams,
767 IN AMD_CONFIG_PARAMS *StdHeader
769 /// Reference to a Method.
770 typedef F_GET_EARLY_INIT_TABLE *PF_GET_EARLY_INIT_TABLE;
773 * Provide the features of the next HT link.
775 * @CpuServiceInstances
777 * This method is different than the HT Phy Features method, because for the phy registers
778 * sublink 1 matches and should be programmed if the link is ganged but for PCI config
779 * registers sublink 1 is reserved if the link is ganged.
781 * @param[in] FamilySpecificServices The current Family Specific Services.
782 * @param[in,out] Link The link number, for accessing non-capability set registers.
783 * Zero on initial call, and passed back unmodified on each subsequent call.
784 * @param[in,out] LinkBase IN: initially the node's PCI config base address, passed back on each call.
785 * OUT: the base HT Host capability PCI address for the link.
786 * @param[out] HtHostFeats The link's features.
787 * @param[in] StdHeader Standard Head Pointer
789 * @retval TRUE Valid link and features found.
790 * @retval FALSE No more links.
792 typedef BOOLEAN F_GET_NEXT_HT_LINK_FEATURES (
793 IN CPU_SPECIFIC_SERVICES *FamilySpecificServices,
795 IN OUT PCI_ADDR *LinkBase,
796 OUT HT_HOST_FEATS *HtHostFeats,
797 IN AMD_CONFIG_PARAMS *StdHeader
799 /// Reference to a Method.
800 typedef F_GET_NEXT_HT_LINK_FEATURES *PF_GET_NEXT_HT_LINK_FEATURES;
802 /// Cache Enable / Disable policy before giving control back to OS.
804 InitCacheDisabled, ///<Disable cache CR0.CD bit
805 InitCacheEnabled ///<Enable cache CR0.CD bit
806 } FAMILY_CACHE_INIT_POLICY;
809 /*---------------------------------------------------------------------------------------*/
811 * Provide the interface to all cpu Family Specific Services.
813 * Use the methods or data in this struct to adapt the feature code to a specific cpu family or model (or stepping!).
814 * Each supported Family must provide an implementation for all methods in this interface, even if the
815 * implementation is a CommonReturn().
816 * See CPU Family Specific Services Implementation Guide for adding new services.
818 struct _CPU_SPECIFIC_SERVICES { // See the Forwaqrd Declaration above
819 UINT16 Revision; ///< Interface version
821 PF_CPU_DISABLE_PSTATE DisablePstate; ///< Method: Disable the desired P-state.
822 PF_CPU_TRANSITION_PSTATE TransitionPstate; ///< Method: Transition the current core to the desired P-state.
823 PF_CPU_GET_IDD_MAX GetProcIddMax; ///< Method: Gets P-state maximum current required
824 PF_CPU_GET_TSC_RATE GetTscRate; ///< Method: Returns the rate at which the current core's timestamp counter increments in megahertz.
825 PF_CPU_GET_NB_FREQ GetCurrentNbFrequency; ///< Method: Returns the processor north bridge's clock rate in megahertz.
826 PF_CPU_GET_MIN_MAX_NB_FREQ GetMinMaxNbFrequency; ///< Method: Returns the node's minimum and maximum northbridge frequency.
827 PF_CPU_GET_NB_PSTATE_INFO GetNbPstateInfo; ///< Method: Returns information about the processor north bridge's P-states.
828 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.
829 PF_CPU_GET_NB_IDD_MAX GetNbIddMax; ///< Method: Gets NB P-state maximum current required
830 PF_CPU_AP_INITIAL_LAUNCH LaunchApCore; ///< Method: Launches the desired core from the reset vector.
831 PF_CPU_NUMBER_OF_PHYSICAL_CORES GetNumberOfPhysicalCores; ///< Method: Get the number of physical cores of current processor.
832 PF_CPU_AMD_GET_AP_MAILBOX_FROM_HARDWARE GetApMailboxFromHardware; ///< Method: Get the AP's topology info from the hardware mailbox.
833 PF_CPU_SET_AP_CORE_NUMBER SetApCoreNumber; ///< Method: Set the AP's core number to the hardware mailbox.
834 PF_CPU_GET_AP_CORE_NUMBER GetApCoreNumber; ///< Method: Get the AP's core number from hardware.
835 PF_CPU_TRANSFER_AP_CORE_NUMBER TransferApCoreNumber; ///< Method: Move the AP's core number from the mailbox to hardware.
836 PF_CORE_ID_POSITION_IN_INITIAL_APIC_ID CoreIdPositionInInitialApicId; ///< Method: Which bits in initial APIC Id are the Core Id.
837 PF_CPU_SAVE_FEATURES SaveFeatures; ///< Method: Get least common features set of all CPUs and save them to CPU_FEATURES_LIST
838 PF_CPU_WRITE_FEATURES WriteFeatures; ///< Method: Get least common features from CPU_FEATURES_LIST and write them to CPU
839 PF_CPU_SET_WARM_RESET_FLAG SetWarmResetFlag; ///< Method: Set Warm Reset Flag
840 PF_CPU_GET_WARM_RESET_FLAG GetWarmResetFlag; ///< Method: Get Warm Reset Flag
841 PF_CPU_GET_FAMILY_SPECIFIC_ARRAY GetBrandString1; ///< Method: Get a Brand String table
842 PF_CPU_GET_FAMILY_SPECIFIC_ARRAY GetBrandString2; ///< Method: Get a Brand String table
843 PF_CPU_GET_FAMILY_SPECIFIC_ARRAY GetMicroCodePatchesStruct; ///< Method: Get microcode patches
844 PF_CPU_GET_FAMILY_SPECIFIC_ARRAY GetMicrocodeEquivalenceTable; ///< Method: Get CPU equivalence for loading microcode patches.
845 PF_CPU_GET_FAMILY_SPECIFIC_ARRAY GetCacheInfo; ///< Method: Get setup for cache use and initialization.
846 PF_CPU_GET_FAMILY_SPECIFIC_ARRAY GetSysPmTableStruct; ///< Method: Get Power Management settings.
847 PF_CPU_GET_FAMILY_SPECIFIC_ARRAY GetWheaInitData; ///< Method: Get Whea Initial Data.
848 PF_CPU_GET_PLATFORM_TYPE_SPECIFIC_INFO GetPlatformTypeSpecificInfo; ///< Method: Get Specific platform Type features.
849 PF_IS_NB_PSTATE_ENABLED IsNbPstateEnabled; ///< Method: Get whether Northbridge PStates feature is enabled.
850 PF_NEXT_LINK_HAS_HTFPY_FEATS NextLinkHasHtPhyFeats; ///< Method: Iterate over HT Links matching features, for HT PHY entries.
851 PF_SET_HT_PHY_REGISTER SetHtPhyRegister; ///< Method: Set an Ht Phy register based on table entry.
852 PF_GET_NEXT_HT_LINK_FEATURES GetNextHtLinkFeatures; ///< Method: Iterate over HT links, returning link features.
853 REGISTER_TABLE **RegisterTableList; ///< Public Data: The available register tables.
854 TABLE_ENTRY_TYPE_DESCRIPTOR *TableEntryTypeDescriptors; ///< Public Data: implemented register table entry types.
855 PACKAGE_HTLINK_MAP PackageLinkMap; ///< Public Data: translate northbridge HT links to package level links, or NULL.
856 CORE_PAIR_MAP *CorePairMap; ///< Public Data: translate compute unit core pairing, or NULL.
857 FAMILY_CACHE_INIT_POLICY InitCacheDisabled; ///< public Data: Family related information.
858 PF_GET_EARLY_INIT_TABLE GetEarlyInitOnCoreTable; ///< Method: Get the initialization steps needed at AmdInitEarly.
862 * A Family Id and an interface to it's implementations of Family Specific Services.
864 * Note that this is a logical family id, which may specify family, model (or even stepping).
867 UINT64 Family; ///< The Family to which this interface belongs.
868 CONST VOID *TablePtr; ///< The interface to its Family Specific Services.
869 } CPU_SPECIFIC_SERVICES_XLAT;
872 * A collection of Family specific interfaces to Family Specific services.
875 UINT8 Elements; ///< The number of tables to search.
876 CONST CPU_SPECIFIC_SERVICES_XLAT *FamilyTable; ///< The family interfaces.
877 } CPU_FAMILY_SUPPORT_TABLE;
880 * Implement the translation of a logical CPU id to an id that can be used to get Family specific services.
883 UINT32 Family; ///< Provide translation for this family
884 CPU_LOGICAL_ID UnknownRevision; ///< In this family, unrecognized models (or steppings) are treated as though they were this model and stepping.
885 CONST PF_CPU_GET_SUBFAMILY_ID_ARRAY *SubFamilyIdTable; ///< Method: Get family specific model (and stepping) resolution.
886 UINT8 Elements; ///< The number of family specific model tables pointed to by SubFamilyIdTable
887 } CPU_LOGICAL_ID_FAMILY_XLAT;
890 * A collection of all available family id translations.
893 UINT8 Elements; ///< The number of family translation items to search.
894 CONST CPU_LOGICAL_ID_FAMILY_XLAT *FamilyIdTable; ///< The family translation items.
895 } CPU_FAMILY_ID_XLAT_TABLE;
897 /*---------------------------------------------------------------------------------------
898 * F U N C T I O N P R O T O T Y P E
899 *---------------------------------------------------------------------------------------
903 * Get a logical identifier for the specified processor, based on CPUID, but independent of CPUID formatting.
906 GetLogicalIdOfSocket (
908 OUT CPU_LOGICAL_ID *LogicalId,
909 IN AMD_CONFIG_PARAMS *StdHeader
913 * Get a logical identifier for the executing core, based on CPUID, but independent of CPUID formatting.
916 GetLogicalIdOfCurrentCore (
917 OUT CPU_LOGICAL_ID *LogicalId,
918 IN AMD_CONFIG_PARAMS *StdHeader
922 * Get a logical identifier for the specified CPUID value.
925 GetLogicalIdFromCpuid (
927 OUT CPU_LOGICAL_ID *LogicalId,
928 IN AMD_CONFIG_PARAMS *StdHeader
932 * Retrieves a pointer to the desired processor's family specific services structure.
935 GetCpuServicesOfSocket (
937 OUT CONST CPU_SPECIFIC_SERVICES **FunctionTable,
938 IN AMD_CONFIG_PARAMS *StdHeader
942 * Retrieves a pointer to the desired processor's family specific services structure.
945 GetFeatureServicesOfSocket (
946 IN CPU_FAMILY_SUPPORT_TABLE *FamilyTable,
948 OUT CONST VOID **CpuServices,
949 IN AMD_CONFIG_PARAMS *StdHeader
953 * Retrieves a pointer to the executing core's family specific services structure.
956 GetCpuServicesOfCurrentCore (
957 OUT CONST CPU_SPECIFIC_SERVICES **FunctionTable,
958 IN AMD_CONFIG_PARAMS *StdHeader
962 * Retrieves a pointer to the executing core's family specific services structure.
965 GetFeatureServicesOfCurrentCore (
966 IN CPU_FAMILY_SUPPORT_TABLE *FamilyTable,
967 OUT CONST VOID **CpuServices,
968 IN AMD_CONFIG_PARAMS *StdHeader
972 * Retrieves a pointer to the family specific services structure for a processor
973 * with the given logical ID.
976 GetCpuServicesFromLogicalId (
977 IN CPU_LOGICAL_ID *LogicalId,
978 OUT CONST CPU_SPECIFIC_SERVICES **FunctionTable,
979 IN AMD_CONFIG_PARAMS *StdHeader
983 * Retrieves a pointer to the family specific services structure for a processor
984 * with the given logical ID.
987 GetFeatureServicesFromLogicalId (
988 IN CPU_FAMILY_SUPPORT_TABLE *FamilyTable,
989 IN CPU_LOGICAL_ID *LogicalId,
990 OUT CONST VOID **CpuServices,
991 IN AMD_CONFIG_PARAMS *StdHeader
995 * Used by logical families which don't need a certain register setting table or other data array.
999 IN CPU_SPECIFIC_SERVICES *FamilySpecificServices,
1000 OUT CONST VOID **Empty,
1001 OUT UINT8 *NumberOfElements,
1002 IN AMD_CONFIG_PARAMS *StdHeader
1005 #endif // _CPU_FAMILY_TRANSLATION_H_