1 ;*****************************************************************************
2 ; AMD Generic Encapsulated Software Architecture
4 ; Workfile: arch2008.asm $Revision: 50871 $ $Date: 2011-04-14 15:39:51 -0600 (Thu, 14 Apr 2011) $
6 ; Description: ARCH2008.ASM - AGESA Architecture 2008 Wrapper Template
8 ;*****************************************************************************
10 ; Copyright (C) 2012 Advanced Micro Devices, Inc.
11 ; All rights reserved.
13 ; Redistribution and use in source and binary forms, with or without
14 ; modification, are permitted provided that the following conditions are met:
15 ; * Redistributions of source code must retain the above copyright
16 ; notice, this list of conditions and the following disclaimer.
17 ; * Redistributions in binary form must reproduce the above copyright
18 ; notice, this list of conditions and the following disclaimer in the
19 ; documentation and/or other materials provided with the distribution.
20 ; * Neither the name of Advanced Micro Devices, Inc. nor the names of
21 ; its contributors may be used to endorse or promote products derived
22 ; from this software without specific prior written permission.
24 ; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
25 ; ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26 ; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
27 ; DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
28 ; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29 ; (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30 ; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31 ; ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32 ; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33 ; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 ;*****************************************************************************
39 INCLUDE acwrapg.inc ; Necessary support file as part of wrapper, including but not limited to segment start/end macros.
40 INCLUDE acwrap.inc ; IBVs may specify host BIOS-specific include files required when building.
48 ;----------------------------------------------------------------------------
50 ;----------------------------------------------------------------------------
53 FuncName DD ? ; Call out function name
54 FuncPtr DW ? ; Call out function pointer
57 sOemEventHandler STRUCT
58 ClassCode DD ? ; AGESA event log sub-class code
59 FuncPtr DW ? ; Event handler function pointer
62 ;; A typical legacy BIOS implementation may require the E000 and F000 segments
64 EXE_CACHE_REGION_BASE_0 EQU 0E0000h
65 EXE_CACHE_REGION_SIZE_0 EQU 20000h
67 ;; In this sample implementation, the B1 and B2 images are placed next to each
68 ;; other in the BIOS ROM to help with the maximization of cached code.
69 EXE_CACHE_REGION_BASE_1 EQU AGESA_B1_ADDRESS
70 EXE_CACHE_REGION_SIZE_1 EQU 40000h
72 ;; The third region is not needed in our example.
73 EXE_CACHE_REGION_BASE_2 EQU 0
74 EXE_CACHE_REGION_SIZE_2 EQU 0
77 ;----------------------------------------------------------------------------
79 ; This segment is required to be present throughout all BIOS execution.
80 ;----------------------------------------------------------------------------
85 ;----------------------------------------------------------------------------
86 ; Instantiate the global descriptor table
87 ;----------------------------------------------------------------------------
89 AMD_BRIDGE_32_GDT AMD_GDT ; Instantiate the global descriptor table
90 ; required by the push-high mechanism.
93 ;----------------------------------------------------------------------------
94 ; Declare the external routines required in the persistent segment
95 ;----------------------------------------------------------------------------
97 ;+-------------------------------------------------------------------------
111 ; Near stub procedure. Simply perform a retn instruction.
113 EXTERN AmdDfltRet:NEAR
116 ;+-------------------------------------------------------------------------
130 ; Far stub procedure. Simply perform a retf instruction.
132 EXTERN AmdDfltRetFar:FAR
135 ;----------------------------------------------------------------------------
136 ; Declare the optional external routines in the persistent segment
137 ;----------------------------------------------------------------------------
139 ;+---------------------------------------------------------------------------
141 ; myModuleTypeMismatchHandler (Example)
144 ; ESI - Pointer to the EVENT_PARAMS structure of the failure.
145 ; [ESI].DataParam1 - Socket
146 ; [ESI].DataParam2 - DCT
147 ; [ESI].DataParam3 - Channel
148 ; [ESI].DataParam4 - 0x00000000
157 ; This procedure can be used to react to a memory module type
158 ; mismatch error discovered by the AGESA code. Actions taken
159 ; may include, but are not limited to:
160 ; Logging the event to NV for display later
161 ; Reset, excluding the mismatch on subsequent reboot
167 EXTERN myModuleTypeMismatchHandler(AmdDfltRet):NEAR
169 ;+---------------------------------------------------------------------------
171 ; oemPlatformConfigInit (Optional)
174 ; EDI - 32-bit flat pointer to the PLATFORM_CONFIGURATION to be
175 ; passed in to the next AGESA entry point.
178 ; IN PERFORMANCE_PROFILE PlatformProfile;
179 ; IN CPU_HT_DEEMPHASIS_LEVEL *PlatformDeemphasisList;
180 ; IN UINT8 CoreLevelingMode;
181 ; IN PLATFORM_C1E_MODES C1eMode;
182 ; IN UINT32 C1ePlatformData;
183 ; IN UINT32 C1ePlatformData1;
184 ; IN UINT32 C1ePlatformData2;
185 ; IN UINT32 C1ePlatformData3;
186 ; IN BOOLEAN UserOptionDmi;
187 ; IN BOOLEAN UserOptionPState;
188 ; IN BOOLEAN UserOptionSrat;
189 ; IN BOOLEAN UserOptionSlit;
190 ; IN BOOLEAN UserOptionWhea;
191 ; IN UINT32 PowerCeiling;
192 ; IN BOOLEAN PstateIndependent;
193 ; } PLATFORM_CONFIGURATION;
200 ; IN PLATFORM_DEEMPHASIS_LEVEL ReceiverDeemphasis;
201 ; IN PLATFORM_DEEMPHASIS_LEVEL DcvDeemphasis;
202 ; } CPU_HT_DEEMPHASIS_LEVEL;
205 ; IN PLATFORM_CONTROL_FLOW PlatformControlFlowMode;
206 ; IN BOOLEAN UseHtAssist;
207 ; IN BOOLEAN UseAtmMode;
208 ; IN BOOLEAN Use32ByteRefresh;
209 ; IN BOOLEAN UseVariableMctIsocPriority;
210 ; } PERFORMANCE_PROFILE;
219 ; Provide a single hook routine to modify the parameters of a
220 ; PLATFORM_CONFIGURATION structure before any entry point that
221 ; has such a structure as an input.
227 ; If your platform is running in UMA mode, the following code
229 ; mov (PLATFORM_CONFIGURATION PTR [edi]).PlatformProfile.PlatformControlFlowMode, UmaDr
231 EXTERN oemPlatformConfigInit(AmdDfltRetFar):FAR
233 ;+---------------------------------------------------------------------------
235 ; oemCallout (Optional)
238 ; ECX - Callout function number
239 ; EDX - Function-specific UINTN
240 ; ESI - Pointer to function specific data
243 ; EAX - Contains the AGESA_STATUS return code.
249 ; The default call out router function which resides in the same
250 ; segment as the push-high bridge code.
255 EXTERN oemCallout(AmdDfltRet):NEAR
258 ;----------------------------------------------------------------------------
259 ; Define the sample wrapper routines for the persistent segment
260 ;----------------------------------------------------------------------------
262 ;+---------------------------------------------------------------------------
267 ; EDX - A Real Mode FAR pointer using seg16:Offset16 format that
268 ; points to a local host environment call-out router. If
269 ; this pointer is not equal to zero, then this pointer is
270 ; used as the call-out router instead of the standard
271 ; OemCallout. This may be useful when the call-out router
272 ; is not located in the same segment as the AmdBridge32 and
273 ; AmdCallout16 routines.
274 ; ESI - A Flat Mode pointer (32-bit address) that points to the
275 ; configuration block (AMD_CONFIG_PARAMS) for the AGESA
279 ; EAX - Contains the AGESA_STATUS return code.
285 ; Execute an AGESA software function through the Push-High interface.
288 ; This procedure requires a stack. The host environment must use the
289 ; provided service function to establish the stack environment prior
290 ; to making the call to this procedure.
292 AmdBridge32 PROC FAR PUBLIC
293 AMD_BRIDGE_32 AMD_GDT ; use the macro for the body
298 ;+---------------------------------------------------------------------------
303 ; BX - Return address
306 ; EAX - Contains the AGESA_STATUS return code.
307 ; SS:ESP - Points to the private stack location for this processor core.
308 ; ECX - Upon success, contains this processor core's stack size in bytes.
311 ; EAX, ECX, EDX, EDI, ESI, ESP, DS, ES
314 ; This procedure is used to establish the stack within the host environment.
317 ; The host environment must use this procedure and not rely on any other
318 ; sources to create the stack region.
320 AmdEnableStack PROC NEAR PUBLIC
322 ;; EAX = AGESA_SUCCESS, The stack space has been allocated for this core.
323 ;; EAX = AGESA_WARNING, The stack has already been set up. SS:ESP is set
324 ;; to stack top, and ECX is the stack size in bytes.
329 ;+---------------------------------------------------------------------------
334 ; BX - Return address
337 ; EAX - Contains the AGESA_STATUS return code.
340 ; EAX, ECX, EDX, ESI, ESP
343 ; This procedure is used to remove the pre-memory stack from within the
345 ; The exit state for the BSP is described as follows:
346 ; Memory region 00000-9FFFF MTRRS are set as WB memory.
347 ; Processor Cache is enabled (CD bit is cleared).
348 ; MTRRs used for execution cache are kept.
349 ; Cache content is flushed (invalidated without write-back).
350 ; Any family-specific clean-up done.
351 ; The exit state for the APs is described as follows:
352 ; Memory region 00000-9FFFF MTRRS are set as WB memory.
353 ; Memory region A0000-DFFFF MTRRS are set as UC IO.
354 ; Memory region E0000-FFFFF MTRRS are set as UC memory.
355 ; MTRRs used for execution cache are cleared.
356 ; Processor Cache is disabled (CD bit is set).
357 ; Top-of-Memory (TOM) set to the system top of memory as determined
358 ; by the memory initialization routines.
359 ; System lock command is enabled.
360 ; Any family-specific clean-up done.
363 ; The host environment must use this procedure and not rely on any other
364 ; sources to break down the stack region.
365 ; If executing in 16-bit code, the host environment must establish the
366 ; "Big Real" mode of 32-bit addressing of data.
368 AmdDisableStack PROC NEAR PUBLIC
370 ;; EAX = AGESA_SUCCESS, The stack space has been disabled for this core.
375 ;+---------------------------------------------------------------------------
382 ; [esp+16] - Configuration Block
383 ; [esp+4] - Return address to AGESA
386 ; EAX - Contains the AGESA_STATUS return code.
392 ; Execute callback from the push-high interface.
397 AmdCallout16 PROC FAR PUBLIC ; declare the procedure
398 AMD_CALLOUT_16 oemCallout ; use the macro for the body
403 ;+---------------------------------------------------------------------------
405 ; AmdProcessAgesaErrors (Optional)
408 ; AL - Heap status of the AGESA entry point that was just invoked.
409 ; EBX - AGESA image base address.
410 ; EDX - Segment / Offset of the appropriate callout router function.
419 ; This procedure is used to handle any errors that may have occurred
420 ; during an AGESA entry point.
425 AmdProcessAgesaErrors PROC FAR PUBLIC
426 LOCAL localCpuInterfaceBlock:EVENT_PARAMS
432 lea esi, localCpuInterfaceBlock
435 ; Fill default config block
436 mov (EVENT_PARAMS PTR [esi]).StdHeader.Func, AMD_READ_EVENT_LOG
437 mov (EVENT_PARAMS PTR [esi]).StdHeader.ImageBasePtr, ebx
438 mov (EVENT_PARAMS PTR [esi]).StdHeader.AltImageBasePtr, 0
439 mov (EVENT_PARAMS PTR [esi]).StdHeader.HeapStatus, al
440 mov edi, SEG AmdCallout16
442 add edi, OFFSET AmdCallout16
443 mov (EVENT_PARAMS PTR [esi]).StdHeader.CalloutPtr, edi
445 ; Flush the event log searching for, and handling all monitored events
451 .if (eax == AGESA_SUCCESS)
452 mov eax, (EVENT_PARAMS PTR [esi]).EventInfo
454 lea di, cs:AgesaEventTable
457 cmp di, OFFSET cs:AgesaEventTableEnd
460 cmp eax, cs:[di].sOemEventHandler.ClassCode
462 add di, SIZEOF sOemEventHandler
466 mov bx, cs:[di].sOemEventHandler.FuncPtr
479 AmdProcessAgesaErrors ENDP
482 ;----------------------------------------------------------------------------
483 ; Define the error handler table
484 ;----------------------------------------------------------------------------
486 AgesaEventTable LABEL BYTE
487 ;; Add entries as desired
491 sOemEventHandler <MEM_ERROR_MODULE_TYPE_MISMATCH_DIMM, OFFSET myModuleTypeMismatchHandler>
492 AgesaEventTableEnd LABEL BYTE
500 ;----------------------------------------------------------------------------
502 ; This segment resides in the classic 'boot-block,' and is used
504 ;----------------------------------------------------------------------------
509 ;----------------------------------------------------------------------------
510 ; Declare the external routines required in the recovery segment
511 ;----------------------------------------------------------------------------
513 ;+---------------------------------------------------------------------------
515 ; myReadSPDRecovery (Required for proper recovery mode operation)
518 ; ESI - Pointer to an AGESA_READ_SPD_PARAMS structure.
521 ; IN OUT AMD_CONFIG_PARAMS StdHeader;
523 ; IN UINT8 MemChannelId;
525 ; IN OUT UINT8 *Buffer;
526 ; IN OUT MEM_DATA_STRUCT *MemData;
527 ; } AGESA_READ_SPD_PARAMS;
530 ; EAX - Contains the AGESA_STATUS return code.
531 ; AGESA_SUCCESS Indicates the SPD block for the indicated
532 ; DIMM was read successfully.
533 ; AGESA_BOUNDS_CHK The specified DIMM is not present.
534 ; AGESA_UNSUPPORTED This is a required function, so this
535 ; value being returned causes a critical
536 ; error response value from the AGESA
537 ; software function and no memory initialized.
538 ; AGESA_ERROR The DIMM SPD read process has generated
539 ; communication errors.
545 ; This call out reads a block of memory SPD data and places it
546 ; into the provided buffer.
551 EXTERN myReadSPDRecovery:NEAR
554 ;----------------------------------------------------------------------------
555 ; Define the sample wrapper routines for the recovery segment
556 ;----------------------------------------------------------------------------
558 ;+---------------------------------------------------------------------------
560 ; AmdInitResetWrapper
563 ; DS - 0000 with 4 gigabyte access
564 ; ES - 0000 with 4 gigabyte access
573 ; A minimal initialization of the processor core is performed. This
574 ; procedure must be called by all processor cores. The code path
575 ; separates the BSP from the APs and performs a separate and appropriate
576 ; list of tasks for each class of core.
577 ; For the BSP, the following actions are performed:
578 ; Internal heap sub-system initialization
579 ; Primary non-coherent HyperTransportT link initialization
580 ; Return to the host environment to test for Recovery Mode.
581 ; The AP processor cores do not participate in the recovery process.
582 ; However, they execute this routine after being released to execute
583 ; by the BSP during the main boot process. Their actions include the
585 ; Internal heap sub-system initialization
586 ; Proceed to a wait loop waiting for commands from the BSP
588 ; For the cache regions, up to three regions of execution cache can be
589 ; allocated following the following rules:
590 ; 1. Once a region is allocated, it cannot be de-allocated. However, it
592 ; 2. At most, two of the three regions can be located above 1 MByte. A
593 ; region failing this rule is ignored.
594 ; 3. All region addresses must be at or above the 0x000D0000 linear
595 ; address. A region failing this rule is ignored.
596 ; 4. The address is aligned on a 32-KByte boundary. Starting addresses
597 ; is rounded down to the nearest 32-Kbyte boundary.
598 ; 5. The execution cache size must be a multiple of 32 KByte. Size is
599 ; rounded up to the next multiple of 32 KByte.
600 ; 6. A region must not span either the 1-MByte boundary or the 4-GByte
601 ; boundary. Allocated size is truncated to not span the boundary.
602 ; 7. The granted cached execution regions, address, and size are calculated
603 ; based on the available cache resources of the processor core.
604 ; Allocations are made up to the limit of cache available on the
605 ; installed processor.
606 ; Warning: Enabling instruction cache outside of this interface can cause
610 ; This procedure is expected to be executed soon after a system reset
611 ; for the main boot path or resume path of execution.
613 ; This procedure requires a stack.
615 ; Because the heap system is not yet operational at the point of the
616 ; interface call, the host environment must allocate the storage for
617 ; the AMD_RESET_PARAMS structure before making the first call to
618 ; AmdCreateStruct. This is the ByHost method of allocation.
620 AmdInitResetWrapper PROC NEAR PUBLIC
621 local localCfgBlock:AMD_INTERFACE_PARAMS
622 local localResetParams:AMD_RESET_PARAMS
626 ; Prepare for the call to initialize the input parameters for AmdInitReset
630 lea esi, localCfgBlock
632 mov (AMD_INTERFACE_PARAMS ptr [esi]).StdHeader.ImageBasePtr, AGESA_B1_ADDRESS
633 mov (AMD_INTERFACE_PARAMS ptr [esi]).StdHeader.Func, AMD_CREATE_STRUCT
634 mov (AMD_INTERFACE_PARAMS ptr [esi]).StdHeader.AltImageBasePtr, 0
635 mov edx, SEG AmdCallout16
637 add edx, OFFSET AmdCallout16
638 mov (AMD_INTERFACE_PARAMS ptr [esi]).StdHeader.CalloutPtr, edx
640 ; Use the 'ByHost' allocation method because the heap has not been initialized as of yet.
641 mov (AMD_INTERFACE_PARAMS ptr [esi]).AgesaFunctionName, AMD_INIT_RESET
642 mov (AMD_INTERFACE_PARAMS ptr [esi]).AllocationMethod, ByHost
643 mov (AMD_INTERFACE_PARAMS ptr [esi]).NewStructSize, sizeof AMD_RESET_PARAMS
644 lea edx, localResetParams
647 mov (AMD_INTERFACE_PARAMS ptr [esi]).NewStructPtr, edx
648 mov dx, SEG AmdCalloutRouterRecovery
650 mov dx, OFFSET AmdCalloutRouterRecovery
656 ; The structure has been initialized. Now modify the default settings as desired.
658 ; Allocate the execution cache to maximize the amount of code in ROM that is cached.
659 ; Placing the B1 and B2 images near one another is a good way to ensure the AGESA code
661 mov (AMD_RESET_PARAMS ptr [esi]).CacheRegion.ExeCacheStartAddr, EXE_CACHE_REGION_BASE_0
662 mov (AMD_RESET_PARAMS ptr [esi]).CacheRegion.ExeCacheSize, EXE_CACHE_REGION_SIZE_0
663 mov (AMD_RESET_PARAMS ptr [esi + sizeof EXECUTION_CACHE_REGION]).CacheRegion.ExeCacheStartAddr, EXE_CACHE_REGION_BASE_1
664 mov (AMD_RESET_PARAMS ptr [esi + sizeof EXECUTION_CACHE_REGION]).CacheRegion.ExeCacheSize, EXE_CACHE_REGION_SIZE_1
665 mov (AMD_RESET_PARAMS ptr [esi + (2 * sizeof EXECUTION_CACHE_REGION)]).CacheRegion.ExeCacheStartAddr, EXE_CACHE_REGION_BASE_2
666 mov (AMD_RESET_PARAMS ptr [esi + (2 * sizeof EXECUTION_CACHE_REGION)]).CacheRegion.ExeCacheSize, EXE_CACHE_REGION_SIZE_2
668 ; Call in to the AmdInitReset entry point
673 ;; EAX = AGESA_STATUS
674 ;; AGESA_SUCCESS Early initialization completed successfully.
675 ;; AGESA_WARNING One or more of the execution cache allocation
676 ;; rules were violated, but an adjustment was made
677 ;; and space was allocated.
678 ;; AGESA_ERROR One or more of the execution cache allocation rules
679 ;; were violated, which resulted in a requested cache
680 ;; region to not be allocated.
681 ;; The storage space allocated for the AMD_RESET_PARAMS
682 ;; structure is insufficient.
684 .if (eax != AGESA_SUCCESS)
685 mov al, (AMD_RESET_PARAMS ptr [esi]).StdHeader.HeapStatus
686 mov ebx, AGESA_B1_ADDRESS
687 call AmdProcessAgesaErrors
691 ;; Here are what the MTRRs should look like based off of the CacheRegions specified above:
694 ;; Name Address Value
695 ;; ---------------- -------- ----------------
696 ;; MTRRfix4k_E0000 0000026C 0505050505050505
697 ;; MTRRfix4k_E8000 0000026D 0505050505050505
698 ;; MTRRfix4k_F0000 0000026E 0505050505050505
699 ;; MTRRfix4k_F8000 0000026F 0505050505050505
700 ;; MTRRdefType 000002FF 0000000000000C00
702 ;; Variable-Range MTRRs and IO Range
703 ;; MTRRphysBase(n) MTRRphysMask(n)
704 ;; ----------------- -----------------
705 ;; n=0 0000000000000000 0000000000000000
706 ;; n=1 0000000000000000 0000000000000000
707 ;; n=2 0000000000000000 0000000000000000
708 ;; n=3 0000000000000000 0000000000000000
709 ;; n=4 0000000000000000 0000000000000000
710 ;; n=5 Heap Base (Varies by core) 0000FFFFFFFF0800
711 ;; n=6 AGESA_B1_ADDRESS | 6 0000FFFFFFFC0800
712 ;; n=7 0000000000000000 0000000000000000
715 ;; Because the allocation method is 'ByHost,' the call to AMD_RELEASE_STRUCT is
716 ;; not necessary. Stack space reclamation is left up to the host BIOS.
722 AmdInitResetWrapper ENDP
725 ;+---------------------------------------------------------------------------
727 ; AmdInitRecoveryWrapper
730 ; DS - 0000 with 4 gigabyte access
731 ; ES - 0000 with 4 gigabyte access
740 ; Perform a minimum initialization of the processor and memory to
741 ; support a recovery mode flash ROM update.
742 ; For the BSP, the following actions are performed:
743 ; Configuration of CPU core for recovery process
744 ; Minimal initialization of some memory
745 ; The AP processor cores do not participate in the recovery process.
746 ; No actions or tasks are performed by the AP cores for this time point.
749 ; This procedure requires a stack. The host environment must use one of
750 ; the provided service functions to establish the stack environment prior
751 ; to making the call to this procedure.
753 AmdInitRecoveryWrapper PROC NEAR PUBLIC
754 local localCfgBlock:AMD_INTERFACE_PARAMS
758 ; Prepare for the call to create and initialize the input parameters for AmdInitRecovery
762 lea esi, localCfgBlock
764 mov (AMD_INTERFACE_PARAMS ptr [esi]).StdHeader.ImageBasePtr, AGESA_B1_ADDRESS
765 mov (AMD_INTERFACE_PARAMS ptr [esi]).StdHeader.Func, AMD_CREATE_STRUCT
766 mov (AMD_INTERFACE_PARAMS ptr [esi]).StdHeader.AltImageBasePtr, 0
767 mov edx, SEG AmdCallout16
769 add edx, OFFSET AmdCallout16
770 mov (AMD_INTERFACE_PARAMS ptr [esi]).StdHeader.CalloutPtr, edx
772 mov (AMD_INTERFACE_PARAMS ptr [esi]).AgesaFunctionName, AMD_INIT_RECOVERY
773 mov (AMD_INTERFACE_PARAMS ptr [esi]).AllocationMethod, PreMemHeap
774 mov (AMD_INTERFACE_PARAMS ptr [esi]).NewStructSize, 0
776 mov dx, SEG AmdCalloutRouterRecovery
778 mov dx, OFFSET AmdCalloutRouterRecovery
783 mov esi, (AMD_INTERFACE_PARAMS ptr [esi]).NewStructPtr
785 ; The structure has been initialized. Now modify the default settings as desired.
788 ; Call in to the AmdInitRecovery entry point
793 ;; EAX = AGESA_STATUS
794 ;; AGESA_SUCCESS The function has completed successfully.
795 ;; AGESA_WARNING One or more of the allocation rules were violated,
796 ;; but an adjustment was made and space was allocated.
797 ;; AGESA_ERROR One or more of the allocation rules were violated,
798 ;; which resulted in a requested cache region to not be
800 ;; AGESA_FATAL No memory was found in the system.
802 .if (eax != AGESA_SUCCESS)
803 mov al, (AMD_RECOVERY_PARAMS ptr [esi]).StdHeader.HeapStatus
804 mov ebx, AGESA_B1_ADDRESS
805 call AmdProcessAgesaErrors
808 ; Allow AGESA to free the space used by AmdInitRecovery
810 mov (AMD_INTERFACE_PARAMS ptr [esi]).StdHeader.Func, AMD_RELEASE_STRUCT
815 AmdInitRecoveryWrapper ENDP
818 ;+---------------------------------------------------------------------------
820 ; AmdCalloutRouterRecovery
823 ; ECX - Callout function number
824 ; EDX - Function-specific UINTN
825 ; ESI - Pointer to function specific data
828 ; EAX - Contains the AGESA_STATUS return code.
834 ; The call out router function for AmdInitReset and
840 AmdCalloutRouterRecovery PROC FAR PUBLIC USES ECX EBX ESI BX DI DS ES
844 lea di, cs:CalloutRouterTableRecovery
845 mov eax, AGESA_UNSUPPORTED
848 cmp di, OFFSET cs:CalloutRouterTableRecoveryEnd
849 jae amdCpuCalloutExit ; exit with AGESA_UNSUPPORTED
850 cmp ecx, cs:[di].sOemCallout.FuncName
852 add di, SIZEOF sOemCallout
856 mov bx, cs:[di].sOemCallout.FuncPtr
861 AmdCalloutRouterRecovery ENDP
864 ;----------------------------------------------------------------------------
865 ; Define the callout dispatch table for the recovery segment
866 ;----------------------------------------------------------------------------
868 CalloutRouterTableRecovery LABEL BYTE
869 ;; Standard B1 implementations only need the SPD reader call out function to be implemented.
870 sOemCallout <AGESA_READ_SPD, OFFSET myReadSPDRecovery>
871 CalloutRouterTableRecoveryEnd LABEL BYTE
878 ;----------------------------------------------------------------------------
880 ; This segment must be uncompressed in the ROM image.
881 ;----------------------------------------------------------------------------
886 ;----------------------------------------------------------------------------
887 ; Declare the external routines required in the recovery segment
888 ;----------------------------------------------------------------------------
890 ;+---------------------------------------------------------------------------
892 ; myReadSPDPremem (Required)
895 ; ESI - Pointer to an AGESA_READ_SPD_PARAMS structure
898 ; IN OUT AMD_CONFIG_PARAMS StdHeader;
900 ; IN UINT8 MemChannelId;
902 ; IN OUT UINT8 *Buffer;
903 ; IN OUT MEM_DATA_STRUCT *MemData;
904 ; } AGESA_READ_SPD_PARAMS;
907 ; EAX - Contains the AGESA_STATUS return code.
908 ; AGESA_SUCCESS Indicates the SPD block for the indicated
909 ; DIMM was read successfully.
910 ; AGESA_BOUNDS_CHK The specified DIMM is not present.
911 ; AGESA_UNSUPPORTED This is a required function, so this
912 ; value being returned causes a critical
913 ; error response value from the AGESA
914 ; software function and no memory initialized.
915 ; AGESA_ERROR The DIMM SPD read process has generated
916 ; communication errors.
922 ; This call out reads a block of memory SPD data and places it
923 ; into the provided buffer.
928 EXTERN myReadSPDPremem:NEAR
930 ;+-------------------------------------------------------------------------
944 ; Near stub procedure in the prememory segment. Simply perform a
947 EXTERN AmdDfltRetPremem:NEAR
949 ;+---------------------------------------------------------------------------
951 ; myDoReset (Required)
955 ; 1 - Warm reset whenever
956 ; 2 - Cold reset whenever
957 ; 3 - Warm reset immediately
958 ; 4 - Cold reset immediately
959 ; ESI - Pointer to an AMD_CONFIG_PARAMS structure.
962 ; EAX - Contains the AGESA_STATUS return code.
963 ; AGESA_SUCCESS The function has completed successfully.
964 ; AGESA_UNSUPPORTED This is a required function, so this
965 ; value being returned causes a critical
966 ; error response value from the AGESA
973 ; This host environment function must initiate the specified type
976 ; Implementation of this function by the host environment is
977 ; REQUIRED. Some host environments may record this as a request
978 ; allowing other elements in the system to perform some additional
979 ; tasks before the actual reset is issued.
982 ; The AMD processor contains 3 bits (BiosRstDet[2:0]) in a PCI
983 ; register (F0x6C Link Initialization Control Register) that
984 ; indicate the reset status. These bits are reserved for use by
985 ; the AGESA software and should not be modified by the host
988 EXTERN myDoReset:NEAR
991 ;+---------------------------------------------------------------------------
993 ; myGetNonVolatileS3Context (Required for proper S3 operation)
999 ; EBX - Pointer to the non-volatile S3 context block
1000 ; ECX - Size in bytes of the non-volatile S3 context block
1006 ; The host environment must return the pointer to the data
1007 ; saved during the mySaveNonVolatileS3Context routine.
1012 EXTERN myGetNonVolatileS3Context:NEAR
1015 ;----------------------------------------------------------------------------
1016 ; Declare the optional external routines in the prememory segment
1017 ;----------------------------------------------------------------------------
1019 ;+---------------------------------------------------------------------------
1021 ; myAgesaHookBeforeExitSelfRefresh (Optional)
1024 ; Prior to this hook, AGESA will display - AGESA_TESTPOINT - 44h
1025 ; ESI - Pointer to a data structure containing the memory information
1028 ; After returning control to AGESA, AGESA will display: - AGESA_TESTPOINT - 45h
1029 ; EAX - Contains the AGESA_STATUS return code
1030 ; AGESA_SUCCESS The function has completed successfully
1031 ; AGESA_UNSUPPORTED This function is not implemented by the host environment
1032 ; AGESA_WARNING A non-critical issue has occued in the host environment
1038 ; General purpose hook called before the exiting self refresh
1039 ; This procedure is called once per channel
1041 ; Implementation of this function is optional for the host environment
1042 ; This call-out is an opportunity for the host environment to make dynamic
1043 ; modifications to the memory timing settings specific to the board or host
1044 ; environment before exiting self refresh on S3 resume
1047 ; This procedure is called before the exit self refresh bit is set in the resume
1048 ; sequence. The host environment must initiate the OS restart process. This procedure
1049 ; requires a stack. The host environment must establish the stack environment prior
1050 ; to making the call to this procedure
1052 EXTERN myAgesaHookBeforeExitSelfRefresh(AmdDfltRetPremem):NEAR
1055 ;+---------------------------------------------------------------------------
1057 ; myHookBeforeDramInit (Optional)
1060 ; Prior to this hook, AGESA will display - AGESA_TESTPOINT - 40h
1061 ; ESI - Pointer to a data structure containing the memory information
1064 ; After returning control to AGESA, AGESA will display - AGESA_TESTPOINT - 41h
1065 ; EAX - Contains the AGESA_STATUS return code.
1066 ; AGESA_SUCCESS The function has completed successfully.
1067 ; AGESA_UNSUPPORTED This function is not implemented by the host environment
1073 ; General-purpose hook called before the DRAM_Init bit is set. Called
1076 ; Implementation of this function is optional for the host environment
1077 ; This call-out is an opportunity for the host environment to make
1078 ; dynamic modifications to the memory timing settings specific to the
1079 ; board or host environment
1084 EXTERN myHookBeforeDramInit(AmdDfltRetPremem):NEAR
1087 ;+---------------------------------------------------------------------------
1089 ; myHookBeforeDQSTraining (Optional)
1092 ; Prior to this hook, AGESA will display - AGESA_TESTPOINT - 42h
1093 ; ESI - Pointer to a data structure containing the memory information.
1096 ; After returning control to AGESA, AGESA will display - AGESA_TESTPOINT - 43h
1097 ; EAX - Contains the AGESA_STATUS return code.
1098 ; AGESA_SUCCESS The function has completed successfully.
1099 ; AGESA_UNSUPPORTED This function is not implemented by the
1106 ; General-purpose hook called just before the memory training processes
1107 ; begin. Called once per MCT.
1109 ; Implementation of this function is optional for the host environment.
1110 ; This call-out is an opportunity for the host environment to make
1111 ; dynamic modifications to the memory timing settings specific to the
1112 ; board or host environment.
1114 ; The host environment may also use this call-out for some board-
1115 ; specific features that should be activated at this time point,
1117 ; Low voltage DIMMs-the host environment should set the recommended
1118 ; voltages found in the memory data structure for each memory
1119 ; channel. This needs to occur before training begins.
1124 EXTERN myHookBeforeDQSTraining(AmdDfltRetPremem):NEAR
1127 ;----------------------------------------------------------------------------
1128 ; Define the sample wrapper routines for the prememory segment
1129 ;----------------------------------------------------------------------------
1131 ;+---------------------------------------------------------------------------
1133 ; AmdInitEarlyWrapper
1136 ; On Entry to "AmdInitEarly" AGESA will display AGESA_TESTPOINT - C4h
1137 ; DS - 0000 with 4 gigabyte access
1138 ; ES - 0000 with 4 gigabyte access
1141 ; On Exit from "AmdInitEarly" AGESA will display AGESA_TESTPOINT - C5h
1148 ; A full initialization of the processor is performed. Action details
1149 ; differ for the BSP and AP processor cores.
1150 ; For the BSP, the following actions are performed:
1151 ; Full HyperTransportT link initialization, coherent and non-coherent
1152 ; Processor register loading
1153 ; Microcode patch load
1154 ; Errata workaround processing
1155 ; Launch all processor cores
1156 ; Configure the processor power management capabilities
1157 ; Request a warm reset if needed
1158 ; For the AP, the following actions are performed:
1159 ; Processor register loading
1160 ; Microcode patch load
1161 ; Errata workaround processing
1162 ; Configure the processor power management capabilities
1165 ; This procedure is expected to be called before main memory initialization
1166 ; and before the system warm reset. Prior to this, the basic configuration
1167 ; done by the AmdInitReset routine must be completed.
1169 ; This procedure requires a stack. The host environment must use one of the
1170 ; provided service functions to establish the stack environment prior to
1171 ; making the call to this procedure.
1173 ; The processes performed at this time point require communication between
1176 ; The host environment must recognize that all processor cores are running
1177 ; in parallel and avoid activities that might interfere with the core-to-core
1178 ; communication, such as modifying the MTRR settings or writing to the APIC
1181 AmdInitEarlyWrapper PROC NEAR PUBLIC
1182 local localCfgBlock:AMD_INTERFACE_PARAMS
1186 ; Prepare for the call to create and initialize the input parameters for AmdInitEarly
1190 lea esi, localCfgBlock
1192 mov (AMD_INTERFACE_PARAMS ptr [esi]).StdHeader.ImageBasePtr, AGESA_B2_ADDRESS
1193 mov (AMD_INTERFACE_PARAMS ptr [esi]).StdHeader.Func, AMD_CREATE_STRUCT
1194 mov (AMD_INTERFACE_PARAMS ptr [esi]).StdHeader.AltImageBasePtr, 0
1195 mov edx, SEG AmdCallout16
1197 add edx, OFFSET AmdCallout16
1198 mov (AMD_INTERFACE_PARAMS ptr [esi]).StdHeader.CalloutPtr, edx
1200 mov (AMD_INTERFACE_PARAMS ptr [esi]).AgesaFunctionName, AMD_INIT_EARLY
1201 mov (AMD_INTERFACE_PARAMS ptr [esi]).AllocationMethod, PreMemHeap
1202 mov (AMD_INTERFACE_PARAMS ptr [esi]).NewStructSize, 0
1204 mov dx, SEG AmdCalloutRouterPremem
1206 mov dx, OFFSET AmdCalloutRouterPremem
1211 mov esi, (AMD_INTERFACE_PARAMS ptr [esi]).NewStructPtr
1213 ; The structure has been initialized. Now modify the default settings as desired.
1216 add edi, (SIZEOF AMD_CONFIG_PARAMS + (3 * (SIZEOF EXECUTION_CACHE_REGION)))
1217 call oemPlatformConfigInit
1219 ; Call in to the AmdInitEarly entry point
1224 ;; EAX = AGESA_STATUS
1225 ;; AGESA_SUCCESS The function has completed successfully.
1226 ;; AGESA_ALERT An HyperTransportT link CRC error was observed.
1227 ;; AGESA_WARNING One of more of the allocation rules were violated,
1228 ;; but an adjustment was made and space was allocated.
1229 ;; Or a HyperTransport device does not have the expected
1230 ;; capabilities, or unusable redundant HyperTransport
1231 ;; links were found.
1232 ;; AGESA_ERROR One or more of the allocation rules were violated, which
1233 ;; resulted in a requested cache region to not be allocated.
1234 ;; Or, a HyperTransport device failed to initialize.
1235 ;; AGESA_CRITICAL An illegal or unsupported mixture of processor types was
1236 ;; found, or the processors installed were found to have an
1237 ;; insufficient MP capability rating for this platform.
1239 .if (eax != AGESA_SUCCESS)
1240 mov al, (AMD_EARLY_PARAMS ptr [esi]).StdHeader.HeapStatus
1241 mov ebx, AGESA_B2_ADDRESS
1242 call AmdProcessAgesaErrors
1245 ; Allow AGESA to free the space used by AmdInitEarly
1247 mov (AMD_INTERFACE_PARAMS ptr [esi]).StdHeader.Func, AMD_RELEASE_STRUCT
1253 AmdInitEarlyWrapper ENDP
1256 ;+---------------------------------------------------------------------------
1258 ; AmdInitPostWrapper
1261 ; On Entry to "AmdInitPost" AGESA will display AGESA_TESTPOINT - C6h
1262 ; DS - 0000 with 4 gigabyte access
1263 ; ES - 0000 with 4 gigabyte access
1266 ; On Exit from "AmdInitPost" AGESA will display AGESA_TESTPOINT - C7h
1273 ; The main system memory is located, initialized, and brought on-line.
1274 ; The processor(s) are prepared for full operation and control by the
1275 ; host environment. Action details differ for the BSP and AP processor
1277 ; For the BSP, the following actions are performed:
1278 ; Full memory initialization and configuration. BSP is the master for
1279 ; this process and may delegate some tasks to APs.
1280 ; AP collection of data for use later.
1281 ; Transfer the HOBs including the artifact data out of the pre-memory
1282 ; cache storage into a temporary holding buffer in the main memory.
1283 ; Check the BIST status of the BSP
1284 ; Shut down the APs.
1285 ; Prepare for the host environment to begin main boot activity.
1286 ; Disable the pre-memory stack.
1287 ; For the APs, the following actions are performed:
1288 ; Report core identity information.
1289 ; Execute indicated memory initialization processes as directed.
1290 ; Check the BIST status of the AP
1291 ; Disable the pre-memory stack.
1292 ; Prepare to halt, giving control to host environment.
1293 ; The entire range of system memory is enabled for Write-Back cache.
1294 ; The fixed MTRRs and the variable MTRRs[7:6] are not changed in order
1295 ; to leave in place any flash ROM region currently set for Write-Protect
1299 ; This procedure is called after the host environment has determined that
1300 ; a normal boot to operating system should be performed after any system
1301 ; warm reset is completed and after the configuration done by AmdInitEarly
1304 ; This procedure requires a stack. The host environment must use one of the
1305 ; provided service functions to establish the stack environment prior to
1306 ; making the call to this procedure.
1308 ; The processes performed at this time point require communication between
1309 ; processor cores. The host environment must recognize that all processor
1310 ; cores are running in parallel and avoid activities that might interfere
1311 ; with the core-to-core communication, such as modifying the MTRR settings
1312 ; or writing to the APIC registers.
1314 AmdInitPostWrapper PROC NEAR PUBLIC
1315 local localCfgBlock:AMD_INTERFACE_PARAMS
1319 ; Prepare for the call to create and initialize the input parameters for AmdInitPost
1323 lea esi, localCfgBlock
1325 mov (AMD_INTERFACE_PARAMS ptr [esi]).StdHeader.ImageBasePtr, AGESA_B2_ADDRESS
1326 mov (AMD_INTERFACE_PARAMS ptr [esi]).StdHeader.Func, AMD_CREATE_STRUCT
1327 mov (AMD_INTERFACE_PARAMS ptr [esi]).StdHeader.AltImageBasePtr, 0
1328 mov edx, SEG AmdCallout16
1330 add edx, OFFSET AmdCallout16
1331 mov (AMD_INTERFACE_PARAMS ptr [esi]).StdHeader.CalloutPtr, edx
1333 mov (AMD_INTERFACE_PARAMS ptr [esi]).AgesaFunctionName, AMD_INIT_POST
1334 mov (AMD_INTERFACE_PARAMS ptr [esi]).AllocationMethod, PreMemHeap
1335 mov (AMD_INTERFACE_PARAMS ptr [esi]).NewStructSize, 0
1337 mov dx, SEG AmdCalloutRouterPremem
1339 mov dx, OFFSET AmdCalloutRouterPremem
1344 mov esi, (AMD_INTERFACE_PARAMS ptr [esi]).NewStructPtr
1346 ; The structure has been initialized. Now modify the default settings as desired.
1349 add edi, SIZEOF AMD_CONFIG_PARAMS
1350 call oemPlatformConfigInit
1352 ; Call in to the AmdInitPost entry point
1357 ;; EAX = AGESA_STATUS
1358 ;; AGESA_SUCCESS The function has completed successfully.
1359 ;; AGESA_ALERT A BIST error was found on one of the cores.
1360 ;; AGESA_WARNING HT Assist feature is running sub-optimally.
1361 ;; AGESA_FATAL Memory initialization failed.
1363 .if (eax != AGESA_SUCCESS)
1364 mov al, (AMD_POST_PARAMS ptr [esi]).StdHeader.HeapStatus
1365 mov ebx, AGESA_B2_ADDRESS
1366 call AmdProcessAgesaErrors
1369 ; Allow AGESA to free the space used by AmdInitPost
1371 mov (AMD_INTERFACE_PARAMS ptr [esi]).StdHeader.Func, AMD_RELEASE_STRUCT
1377 AmdInitPostWrapper ENDP
1380 ;+---------------------------------------------------------------------------
1382 ; AmdInitResumeWrapper
1385 ; On Entry to "AmdInitResume" AGESA will display AGESA_TESTPOINT - D0h
1386 ; DS - 0000 with 4 gigabyte access
1387 ; ES - 0000 with 4 gigabyte access
1390 ; On Exit from "AmdInitResume" AGESA will display AGESA_TESTPOINT - D1h
1397 ; This procedure initializes or re-initializes the silicon components
1398 ; for the resume boot path. For the processor, main memory is brought
1399 ; out of self-refresh mode. This procedure will use the context data
1400 ; in the NvStorage area of the input structure to re-start the main
1401 ; memory. The host environment must fill the AMD_S3_PARAMS NvStorage
1402 ; and VolatileStorage pointers and related size elements to describe
1403 ; the location of the context data. Note that for this procedure, the
1404 ; two data areas do not need to be contained in one buffer zone, they
1405 ; can be anywhere in the accessible memory address space. If the host
1406 ; environment uses a non-volatile storage device accessed on the system
1407 ; address bus such as flashROM, then the context data does not need to
1408 ; be moved prior to this call. If the host environment uses a non-
1409 ; volatile storage device not located on the system address bus (e.g.
1410 ; CMOS or SSEPROM) then the host environment must transfer the context
1411 ; data to a buffer in main memory prior to calling this procedure.
1414 ; The host environment must have determined that the system should take
1415 ; the resume path prior to calling this procedure. The configuration
1416 ; done by AmdInitEarly and any necessary warm reset must be complete.
1417 ; After this procedure, execution proceeds to general system restoration.
1419 ; This procedure requires a stack. The host environment must use one of
1420 ; the provided service functions to establish the stack environment prior
1421 ; to making the call to this procedure.
1423 AmdInitResumeWrapper PROC NEAR PUBLIC
1424 local localCfgBlock:AMD_INTERFACE_PARAMS
1428 ; Prepare for the call to create and initialize the input parameters for AmdInitResume
1432 lea esi, localCfgBlock
1434 mov (AMD_INTERFACE_PARAMS ptr [esi]).StdHeader.ImageBasePtr, AGESA_B2_ADDRESS
1435 mov (AMD_INTERFACE_PARAMS ptr [esi]).StdHeader.Func, AMD_CREATE_STRUCT
1436 mov (AMD_INTERFACE_PARAMS ptr [esi]).StdHeader.AltImageBasePtr, 0
1437 mov edx, SEG AmdCallout16
1439 add edx, OFFSET AmdCallout16
1440 mov (AMD_INTERFACE_PARAMS ptr [esi]).StdHeader.CalloutPtr, edx
1442 mov (AMD_INTERFACE_PARAMS ptr [esi]).AgesaFunctionName, AMD_INIT_RESUME
1443 mov (AMD_INTERFACE_PARAMS ptr [esi]).AllocationMethod, PreMemHeap
1444 mov (AMD_INTERFACE_PARAMS ptr [esi]).NewStructSize, 0
1446 mov dx, SEG AmdCalloutRouterPremem
1448 mov dx, OFFSET AmdCalloutRouterPremem
1453 mov esi, (AMD_INTERFACE_PARAMS ptr [esi]).NewStructPtr
1455 ; The structure has been initialized. Now modify the default settings as desired.
1458 add edi, (SIZEOF AMD_CONFIG_PARAMS + SIZEOF AMD_S3_PARAMS)
1459 call oemPlatformConfigInit
1461 call myGetNonVolatileS3Context
1462 mov (AMD_RESUME_PARAMS ptr [esi]).S3DataBlock.NvStorage, ebx
1463 mov (AMD_RESUME_PARAMS ptr [esi]).S3DataBlock.NvStorageSize, ecx
1465 ; Call in to the AmdInitResume entry point
1470 ;; EAX = AGESA_STATUS
1471 ;; AGESA_SUCCESS Re-initialization has been completed successfully.
1472 .if (eax != AGESA_SUCCESS)
1473 mov al, (AMD_RESUME_PARAMS ptr [esi]).StdHeader.HeapStatus
1474 mov ebx, AGESA_B2_ADDRESS
1475 call AmdProcessAgesaErrors
1479 ; Allow AGESA to free the space used by AmdInitResume
1481 mov (AMD_INTERFACE_PARAMS ptr [esi]).StdHeader.Func, AMD_RELEASE_STRUCT
1487 AmdInitResumeWrapper ENDP
1490 ;+---------------------------------------------------------------------------
1492 ; AmdCalloutRouterPremem
1495 ; ECX - Callout function number
1496 ; EDX - Function-specific UINTN
1497 ; ESI - Pointer to function specific data
1500 ; EAX - Contains the AGESA_STATUS return code.
1506 ; The call out router function for AmdInitEarly,
1507 ; AmdInitPost, and AmdInitResume.
1512 AmdCalloutRouterPremem PROC FAR PUBLIC USES ECX EBX ESI BX DI DS ES
1516 lea di, cs:CalloutRouterTablePremem
1517 mov eax, AGESA_UNSUPPORTED
1520 cmp di, OFFSET cs:CalloutRouterTablePrememEnd
1521 jae amdCpuCalloutExit ; exit with AGESA_UNSUPPORTED
1522 cmp ecx, cs:[di].sOemCallout.FuncName
1524 add di, SIZEOF sOemCallout
1528 mov bx, cs:[di].sOemCallout.FuncPtr
1533 AmdCalloutRouterPremem ENDP
1536 ;----------------------------------------------------------------------------
1537 ; Define the callout dispatch table for the prememory segment
1538 ;----------------------------------------------------------------------------
1540 CalloutRouterTablePremem LABEL BYTE
1541 ;; Add entries as desired.
1542 sOemCallout <AGESA_READ_SPD, OFFSET myReadSPDPremem>
1543 sOemCallout <AGESA_HOOKBEFORE_DRAM_INIT, OFFSET myHookBeforeDramInit>
1544 sOemCallout <AGESA_HOOKBEFORE_DQS_TRAINING, OFFSET myHookBeforeDQSTraining>
1545 sOemCallout <AGESA_HOOKBEFORE_EXIT_SELF_REF, OFFSET myAgesaHookBeforeExitSelfRefresh>
1546 sOemCallout <AGESA_DO_RESET, OFFSET myDoReset>
1547 sOemCallout <AGESA_EXTERNAL____TRAIN_VREF_CHANGE, OFFSET my__TrainVrefChange>
1548 CalloutRouterTablePrememEnd LABEL BYTE
1555 ;----------------------------------------------------------------------------
1557 ; This segment may be decompressed and run from system RAM.
1558 ;----------------------------------------------------------------------------
1563 ;----------------------------------------------------------------------------
1564 ; Declare the external routines required in the POST segment
1565 ;----------------------------------------------------------------------------
1567 ;+---------------------------------------------------------------------------
1569 ; myAllocateBuffer (Required)
1572 ; Prior to this hook, AGESA will display - AGESA_TESTPOINT - E2h
1573 ; ESI - Pointer to an AGESA_BUFFER_PARAMS structure.
1576 ; IN OUT AMD_CONFIG_PARAMS StdHeader;
1577 ; IN UINT32 BufferLength;
1578 ; IN UINT32 BufferHandle;
1579 ; OUT VOID *BufferPointer;
1580 ; } AGESA_BUFFER_PARAMS;
1583 ; After this hook, AGESA will display - AGESA_TESTPOINT - E3h
1584 ; EAX - Contains the AGESA_STATUS return code.
1585 ; AGESA_SUCCESS The requested size of memory has been
1586 ; successfully allocated.
1587 ; AGESA_UNSUPPORTED This is a required function, so this
1588 ; value being returned causes a critical
1589 ; error response value from the AGESA
1590 ; software function.
1591 ; AGESA_ERROR Less than the requested amount of memory
1598 ; This function is used after main memory has been initialized
1599 ; and the host environment has taken control of memory allocation.
1600 ; This function must allocate a buffer of the requested size or
1601 ; larger. This function is required to be implemented by the host
1605 ; The following call-outs must work together in the host system.
1606 ; Parameters of the same name have the same function and must be
1607 ; treated the same in each function:
1608 ; AgesaAllocateBuffer
1609 ; AgesaDeallocateBuffer
1612 ; The host environment may need to reserve a location in the buffer
1613 ; to store any host environment specific value(s). The returned
1614 ; pointer must not include this reserved space. The host environment
1615 ; on the AgesaDeallocateBuffer call needs to account for the reserved
1616 ; space. This reserved space may be an identifier or the "handle"
1617 ; used to identify the specific memory block.
1619 EXTERN myAllocateBuffer:NEAR
1621 ;+---------------------------------------------------------------------------
1623 ; myDeallocateBuffer (Required)
1626 ; Prior to this hook, AGESA will display - AGESA_TESTPOINT - E4h
1627 ; ESI - Pointer to an AGESA_BUFFER_PARAMS structure.
1630 ; IN OUT AMD_CONFIG_PARAMS StdHeader;
1631 ; IN UINT32 BufferLength;
1632 ; IN UINT32 BufferHandle;
1633 ; OUT VOID *BufferPointer;
1634 ; } AGESA_BUFFER_PARAMS;
1637 ; After this hook, AGESA will display - AGESA_TESTPOINT - E5h
1638 ; EAX - Contains the AGESA_STATUS return code.
1639 ; AGESA_SUCCESS The function has completed successfully.
1640 ; AGESA_BOUNDS_CHK The BufferHandle is invalid. The AGESA
1641 ; software continues with its function.
1642 ; AGESA_UNSUPPORTED This is a required function, so this
1643 ; value being returned causes a critical
1644 ; error response value from the AGESA
1645 ; software function.
1651 ; This function is used after main memory has been initialized
1652 ; and the host environment has taken control of memory allocation.
1653 ; This function releases a valid working buffer. This function is
1654 ; required for the host environment to implement.
1657 ; The following call-outs must work together in the host system.
1658 ; Parameters of the same name have the same function and must be
1659 ; treated the same in each function:
1660 ; AgesaAllocateBuffer
1661 ; AgesaDeallocateBuffer
1665 EXTERN myDeallocateBuffer:NEAR
1667 ;+---------------------------------------------------------------------------
1669 ; myLocateBuffer (Required)
1672 ; Prior to this hook, AGESA will display - AGESA_TESTPOINT - E6h
1673 ; ESI - Pointer to an AGESA_BUFFER_PARAMS structure.
1676 ; IN OUT AMD_CONFIG_PARAMS StdHeader;
1677 ; IN UINT32 BufferLength;
1678 ; IN UINT32 BufferHandle;
1679 ; OUT VOID *BufferPointer;
1680 ; } AGESA_BUFFER_PARAMS;
1683 ; After this hook, AGESA will display - AGESA_TESTPOINT - E7h
1684 ; EAX - Contains the AGESA_STATUS return code.
1685 ; AGESA_SUCCESS The function has completed successfully.
1686 ; AGESA_BOUNDS_CHK The presented handle is invalid or the
1687 ; buffer could not be located.
1693 ; This function is used after main memory has been initialized
1694 ; and the host environment has taken control of memory allocation.
1695 ; This function must locate the buffer related to the indicated
1696 ; handle and return the address of the buffer and its length.
1697 ; This function is required to be implemented in the host
1701 ; The following call-outs must work together in the host system.
1702 ; Parameters of the same name have the same function and must be
1703 ; treated the same in each function:
1704 ; AgesaAllocateBuffer
1705 ; AgesaDeallocateBuffer
1709 EXTERN myLocateBuffer:NEAR
1712 ;+---------------------------------------------------------------------------
1714 ; myRunFuncOnAp (Required)
1717 ; EDX - Local APIC ID of the target core.
1726 ; The host environment must route execution to the target AP and
1727 ; have that AP call the AmdLateRunApTaskWrapper routine defined
1733 EXTERN myRunFuncOnAp:NEAR
1735 ;+---------------------------------------------------------------------------
1737 ; mySaveNonVolatileS3Context (Required for proper S3 operation)
1740 ; EBX - Pointer to the non-volatile S3 context block
1741 ; ECX - Size in bytes of the non-volatile S3 context block
1750 ; The host environment must save the non-volatile data to an area
1751 ; that will not lose context while in the ACPI S3 sleep state, but
1752 ; cannot be placed in system RAM. This data will need to be
1753 ; available during the call to AmdInitResume.
1758 EXTERN mySaveNonVolatileS3Context:NEAR
1760 ;+---------------------------------------------------------------------------
1762 ; mySaveVolatileS3Context (Required for proper S3 operation)
1765 ; EBX - Pointer to the volatile S3 context block
1766 ; ECX - Size in bytes of the volatile S3 context block
1775 ; The host environment must save the volatile data to an area
1776 ; that will not lose context while in the ACPI S3 sleep state.
1777 ; This data will need to be available during the call to
1783 EXTERN mySaveVolatileS3Context:NEAR
1785 ;+---------------------------------------------------------------------------
1787 ; myGetVolatileS3Context (Required for proper S3 operation)
1793 ; EBX - Pointer to the volatile S3 context block
1794 ; ECX - Size in bytes of the volatile S3 context block
1800 ; The host environment must return the pointer to the data
1801 ; saved during the mySaveVolatileS3Context routine.
1806 EXTERN myGetVolatileS3Context:NEAR
1809 ;----------------------------------------------------------------------------
1810 ; Define the sample wrapper routines for the POST segment
1811 ;----------------------------------------------------------------------------
1813 ;+---------------------------------------------------------------------------
1818 ; On Entry to "AmdInitEnv" AGESA will display AGESA_TESTPOINT - C8h
1819 ; DS - 0000 with 4 gigabyte access
1820 ; ES - 0000 with 4 gigabyte access
1823 ; On Exit from "AmdInitEnv" AGESA will display AGESA_TESTPOINT - C9h
1830 ; This procedure uses the AgesaAllocateBuffer call-out to acquire
1831 ; permanent buffer space for the UEFI Hand-Off Blocks (HOBs). This
1832 ; is also known as, or includes, artifact data being used by the
1833 ; AGESA software. Upon entry to this procedure, the data is being
1834 ; held in a temporary memory location and it must be moved to a
1835 ; location controlled and protected by the host environment.
1837 ; These actions are performed by the BSP. The APs are not assigned
1838 ; any tasks at this time point.
1841 ; This procedure must be called after full memory is initialized and
1842 ; the host environment has taken control of main memory allocation.
1843 ; This procedure should be called before the PCI enumeration takes
1844 ; place and as soon as possible after the host environment memory
1845 ; allocation sub-system has started.
1847 ; This procedure requires a stack. The host environment must use one
1848 ; of the provided service functions to establish the stack environment
1849 ; prior to making the call to this procedure.
1851 AmdInitEnvWrapper PROC NEAR PUBLIC
1852 local localCfgBlock:AMD_INTERFACE_PARAMS
1856 ; Prepare for the call to create and initialize the input parameters for AmdInitEnv
1860 lea esi, localCfgBlock
1862 mov (AMD_INTERFACE_PARAMS ptr [esi]).StdHeader.ImageBasePtr, AGESA_B2_ADDRESS
1863 mov (AMD_INTERFACE_PARAMS ptr [esi]).StdHeader.Func, AMD_CREATE_STRUCT
1864 mov (AMD_INTERFACE_PARAMS ptr [esi]).StdHeader.AltImageBasePtr, 0
1865 mov edx, SEG AmdCallout16
1867 add edx, OFFSET AmdCallout16
1868 mov (AMD_INTERFACE_PARAMS ptr [esi]).StdHeader.CalloutPtr, edx
1870 mov (AMD_INTERFACE_PARAMS ptr [esi]).AgesaFunctionName, AMD_INIT_ENV
1871 mov (AMD_INTERFACE_PARAMS ptr [esi]).AllocationMethod, PostMemDram
1872 mov (AMD_INTERFACE_PARAMS ptr [esi]).NewStructSize, 0
1874 mov dx, SEG AmdCalloutRouterPost
1876 mov dx, OFFSET AmdCalloutRouterPost
1881 mov esi, (AMD_INTERFACE_PARAMS ptr [esi]).NewStructPtr
1883 ; The structure has been initialized. Now modify the default settings as desired.
1886 add edi, SIZEOF AMD_CONFIG_PARAMS
1887 call oemPlatformConfigInit
1889 ; Call in to the AmdInitEnv entry point
1894 ;; EAX = AGESA_STATUS
1895 ;; AGESA_SUCCESS The function has completed successfully.
1896 ;; AGESA_ERROR The artifact data could not be found or the host
1897 ;; environment failed to allocate sufficient buffer space.
1899 .if (eax != AGESA_SUCCESS)
1900 mov al, (AMD_ENV_PARAMS ptr [esi]).StdHeader.HeapStatus
1901 mov ebx, AGESA_B2_ADDRESS
1902 call AmdProcessAgesaErrors
1905 ; Allow AGESA to free the space used by AmdInitEnv
1907 mov (AMD_INTERFACE_PARAMS ptr [esi]).StdHeader.Func, AMD_RELEASE_STRUCT
1913 AmdInitEnvWrapper ENDP
1916 ;+---------------------------------------------------------------------------
1921 ; On Entry to "AmdInitMid" AGESA will display AGESA_TESTPOINT - CAh
1922 ; DS - 0000 with 4 gigabyte access
1923 ; ES - 0000 with 4 gigabyte access
1926 ; On Exit from "AmdInitMid" AGESA will display AGESA_TESTPOINT - CBh
1933 ; This procedure call performs special configuration requirements for
1934 ; the graphics display hardware.
1936 ; These actions are performed by the BSP. The APs are not assigned any
1937 ; tasks at this time point.
1940 ; This procedure must be called after PCI enumeration has allocated
1941 ; resources, but before the video BIOS call is performed.
1943 ; This procedure requires a stack. The host environment must use one
1944 ; of the provided service functions to establish the stack environment
1945 ; prior to making the call to this procedure.
1947 AmdInitMidWrapper PROC NEAR PUBLIC
1948 local localCfgBlock:AMD_INTERFACE_PARAMS
1952 ; Prepare for the call to create and initialize the input parameters for AmdInitMid
1956 lea esi, localCfgBlock
1958 mov (AMD_INTERFACE_PARAMS ptr [esi]).StdHeader.ImageBasePtr, AGESA_B2_ADDRESS
1959 mov (AMD_INTERFACE_PARAMS ptr [esi]).StdHeader.Func, AMD_CREATE_STRUCT
1960 mov (AMD_INTERFACE_PARAMS ptr [esi]).StdHeader.AltImageBasePtr, 0
1961 mov edx, SEG AmdCallout16
1963 add edx, OFFSET AmdCallout16
1964 mov (AMD_INTERFACE_PARAMS ptr [esi]).StdHeader.CalloutPtr, edx
1966 mov (AMD_INTERFACE_PARAMS ptr [esi]).AgesaFunctionName, AMD_INIT_MID
1967 mov (AMD_INTERFACE_PARAMS ptr [esi]).AllocationMethod, PostMemDram
1968 mov (AMD_INTERFACE_PARAMS ptr [esi]).NewStructSize, 0
1970 mov dx, SEG AmdCalloutRouterPost
1972 mov dx, OFFSET AmdCalloutRouterPost
1977 mov esi, (AMD_INTERFACE_PARAMS ptr [esi]).NewStructPtr
1979 ; The structure has been initialized. Now modify the default settings as desired.
1982 add edi, SIZEOF AMD_CONFIG_PARAMS
1983 call oemPlatformConfigInit
1985 ; Call in to the AmdInitMid entry point
1990 ;; EAX = AGESA_STATUS
1991 ;; AGESA_SUCCESS The function has completed successfully.
1993 .if (eax != AGESA_SUCCESS)
1994 mov al, (AMD_MID_PARAMS ptr [esi]).StdHeader.HeapStatus
1995 mov ebx, AGESA_B2_ADDRESS
1996 call AmdProcessAgesaErrors
1999 ; Allow AGESA to free the space used by AmdInitMid
2001 mov (AMD_INTERFACE_PARAMS ptr [esi]).StdHeader.Func, AMD_RELEASE_STRUCT
2008 AmdInitMidWrapper ENDP
2011 ;+---------------------------------------------------------------------------
2013 ; AmdInitLateWrapper
2016 ; On Entry to "AmdInitLate" AGESA will display AGESA_TESTPOINT - CCh
2017 ; DS - 0000 with 4 gigabyte access
2018 ; ES - 0000 with 4 gigabyte access
2021 ; On Exit from "AmdInitLate" AGESA will display AGESA_TESTPOINT - CDh
2028 ; The main purpose of this function is to generate informational
2029 ; data tables used by the operating system. The individual tables
2030 ; can be selected for generation through the user selection entries
2031 ; on the input parameters.
2033 ; This routine uses the Call-Out AgesaAllocateBuffer to allocate a
2034 ; buffer of the proper size to contain the data.
2036 ; The code path separates the BSP from the APs and perform a separate
2037 ; and appropriate list of tasks for each class of core.
2038 ; For the BSP, the following actions are performed:
2039 ; Allocate buffer space for the tables.
2040 ; Generate the table contents.
2041 ; Make sure that the CPU is in a known good power state before
2042 ; proceeding to boot the OS.
2043 ; For the APs, the following actions are performed:
2044 ; Final register settings preparing for entry to OS.
2045 ; Establish the final PState for entry to OS.
2048 ; This routine is expected to be executed late in the boot sequence
2049 ; after main memory has been initialized, after PCI enumeration has
2050 ; completed, after the host environment ACPI sub-system has started,
2051 ; after the host environment has taken control of the APs, but just
2052 ; before the start of OS boot.
2054 ; The host environment must provide the required call-outs listed in
2055 ; the "Required Call-Out Procedures" section of the AGESA interface
2056 ; specification to provide the buffer space in main memory and execute
2057 ; code on the APs. The host environment must register the created ACPI
2058 ; table in the main ACPI pointer tables. This may require moving the
2059 ; generated tables to another location in memory.
2061 ; This procedure requires a stack. The host environment must establish
2062 ; the stack environment prior to making the call to this procedure.
2063 ; Some functions depend upon the preservation of the heap data across
2064 ; the shift from pre-memory environment to a post-memory environment.
2065 ; If that data was not preserved, then those functions cannot complete
2066 ; and an error is returned.
2068 AmdInitLateWrapper PROC NEAR PUBLIC
2069 local localCfgBlock:AMD_INTERFACE_PARAMS
2073 ; Prepare for the call to create and initialize the input parameters for AmdInitLate
2077 lea esi, localCfgBlock
2079 mov (AMD_INTERFACE_PARAMS ptr [esi]).StdHeader.ImageBasePtr, AGESA_B2_ADDRESS
2080 mov (AMD_INTERFACE_PARAMS ptr [esi]).StdHeader.Func, AMD_CREATE_STRUCT
2081 mov (AMD_INTERFACE_PARAMS ptr [esi]).StdHeader.AltImageBasePtr, 0
2082 mov edx, SEG AmdCallout16
2084 add edx, OFFSET AmdCallout16
2085 mov (AMD_INTERFACE_PARAMS ptr [esi]).StdHeader.CalloutPtr, edx
2087 mov (AMD_INTERFACE_PARAMS ptr [esi]).AgesaFunctionName, AMD_INIT_LATE
2088 mov (AMD_INTERFACE_PARAMS ptr [esi]).AllocationMethod, PostMemDram
2089 mov (AMD_INTERFACE_PARAMS ptr [esi]).NewStructSize, 0
2091 mov dx, SEG AmdCalloutRouterPost
2093 mov dx, OFFSET AmdCalloutRouterPost
2098 mov esi, (AMD_INTERFACE_PARAMS ptr [esi]).NewStructPtr
2100 ; The structure has been initialized. Now modify the default settings as desired.
2103 add edi, SIZEOF AMD_CONFIG_PARAMS
2104 call oemPlatformConfigInit
2106 ; Call in to the AmdInitLate entry point
2111 ;; EAX = AGESA_STATUS
2112 ;; AGESA_SUCCESS The function has completed successfully.
2114 ;; AGESA_ERROR The system could not allocate the needed amount of
2115 ;; buffer space; or could not locate the artifact data block in
2116 ;; memory. Likely cause: the host environment may not have preserved
2117 ;; the data properly.
2119 .if (eax != AGESA_SUCCESS)
2120 mov al, (AMD_LATE_PARAMS ptr [esi]).StdHeader.HeapStatus
2121 mov ebx, AGESA_B2_ADDRESS
2122 call AmdProcessAgesaErrors
2126 mov ax, SEG AmdAcpiSratPointer
2129 mov ebx, (AMD_LATE_PARAMS ptr [esi]).AcpiSrat
2130 mov es:AmdAcpiSratPointer, ebx
2131 mov eax, DWORD PTR [ebx + 4]
2132 mov es:AmdAcpiSratSize, eax
2134 mov ebx, (AMD_LATE_PARAMS ptr [esi]).AcpiSlit
2135 mov es:AmdAcpiSlitPointer, ebx
2136 mov eax, DWORD PTR [ebx + 4]
2137 mov es:AmdAcpiSlitSize, eax
2139 mov ebx, (AMD_LATE_PARAMS ptr [esi]).AcpiPState
2140 mov es:AmdAcpiSsdtPointer, ebx
2141 mov eax, DWORD PTR [ebx + 4]
2142 mov es:AmdAcpiSsdtSize, eax
2146 mov ebx, (AMD_LATE_PARAMS ptr [esi]).AcpiWheaMce
2147 mov es:AmdAcpiWheaMcePointer, ebx
2148 mov ax, WORD PTR [ebx]
2149 mov es:AmdAcpiWheaMceSize, eax
2151 mov ebx, (AMD_LATE_PARAMS ptr [esi]).AcpiWheaMce
2152 mov es:AmdAcpiWheaCmcPointer, ebx
2153 mov ax, WORD PTR [ebx]
2154 mov es:AmdAcpiWheaCmcSize, eax
2156 mov eax, (AMD_LATE_PARAMS ptr [esi]).DmiTable
2157 mov es:AmdDmiInfoPointer, eax
2161 ; Allow AGESA to free the space used by AmdInitLate
2163 mov (AMD_INTERFACE_PARAMS ptr [esi]).StdHeader.Func, AMD_RELEASE_STRUCT
2169 AmdInitLateWrapper ENDP
2172 ;+---------------------------------------------------------------------------
2177 ; On Entry to "AmdS3Save" AGESA will display AGESA_TESTPOINT - CEh
2178 ; DS - 0000 with 4 gigabyte access
2179 ; ES - 0000 with 4 gigabyte access
2182 ; On Entry to "AmdS3Save" AGESA will display AGESA_TESTPOINT - CFh
2189 ; This procedure saves critical registers and/or configuration
2190 ; information for preservation across a system suspend mode. All
2191 ; actions needed to prepare the processor for suspend mode is
2192 ; performed, however this procedure does NOT initiate the suspend
2193 ; process. The host environment is expected to perform that duty.
2195 ; These actions are performed by the BSP. The APs are not assigned
2196 ; any tasks at this time point.
2198 ; The initializer routine will NULL out the save area pointers and
2199 ; sizes. This procedure will determine the size of storage needed
2200 ; for all the processor context, and make a call out to the environment
2201 ; for allocation of one buffer to store all of the data. Upon exit, the
2202 ; pointers and sizes within the AMD_S3_PARAMS structure will be updated
2203 ; with the appropriate addresses within the buffer that was allocated.
2204 ; The host environment is expected to then transfer the data pointed to
2205 ; by NvStorage to a non-volatile storage area, and the data pointed to
2206 ; by VolatileStorage to either a non-volatile storage area or system
2207 ; RAM that retains its content across suspend.
2210 ; The host environment must initiate the suspend process.
2212 ; This procedure requires a stack. The host environment must establish
2213 ; the stack environment prior to making the call to this procedure.
2215 AmdS3SaveWrapper PROC NEAR PUBLIC
2216 local localCfgBlock:AMD_INTERFACE_PARAMS
2220 ; Prepare for the call to create and initialize the input parameters for AmdS3Save
2224 lea esi, localCfgBlock
2226 mov (AMD_INTERFACE_PARAMS ptr [esi]).StdHeader.ImageBasePtr, AGESA_B2_ADDRESS
2227 mov (AMD_INTERFACE_PARAMS ptr [esi]).StdHeader.Func, AMD_CREATE_STRUCT
2228 mov (AMD_INTERFACE_PARAMS ptr [esi]).StdHeader.AltImageBasePtr, 0
2229 mov edx, SEG AmdCallout16
2231 add edx, OFFSET AmdCallout16
2232 mov (AMD_INTERFACE_PARAMS ptr [esi]).StdHeader.CalloutPtr, edx
2234 mov (AMD_INTERFACE_PARAMS ptr [esi]).AgesaFunctionName, AMD_S3_SAVE
2235 mov (AMD_INTERFACE_PARAMS ptr [esi]).AllocationMethod, PostMemDram
2236 mov (AMD_INTERFACE_PARAMS ptr [esi]).NewStructSize, 0
2238 mov dx, SEG AmdCalloutRouterPost
2240 mov dx, OFFSET AmdCalloutRouterPost
2245 mov esi, (AMD_INTERFACE_PARAMS ptr [esi]).NewStructPtr
2247 ; The structure has been initialized. Now modify the default settings as desired.
2250 add edi, (SIZEOF AMD_CONFIG_PARAMS + SIZEOF AMD_S3_PARAMS)
2251 call oemPlatformConfigInit
2253 ; Call in to the AmdS3Save entry point
2258 ;; EAX = AGESA_STATUS
2259 ;; AGESA_SUCCESS All suspend duties have been completed successfully.
2261 .if (eax != AGESA_SUCCESS)
2262 mov al, (AMD_S3SAVE_PARAMS ptr [esi]).StdHeader.HeapStatus
2263 mov ebx, AGESA_B2_ADDRESS
2264 call AmdProcessAgesaErrors
2267 mov ecx, (AMD_S3SAVE_PARAMS ptr [esi]).S3DataBlock.NvStorageSize
2269 mov ebx, (AMD_S3SAVE_PARAMS ptr [esi]).S3DataBlock.NvStorage
2270 call mySaveNonVolatileS3Context
2273 mov ecx, (AMD_S3SAVE_PARAMS ptr [esi]).S3DataBlock.VolatileStorageSize
2275 mov ebx, (AMD_S3SAVE_PARAMS ptr [esi]).S3DataBlock.VolatileStorage
2276 call mySaveVolatileS3Context
2279 ; Allow AGESA to free the space used by AmdS3Save
2281 mov (AMD_INTERFACE_PARAMS ptr [esi]).StdHeader.Func, AMD_RELEASE_STRUCT
2287 AmdS3SaveWrapper ENDP
2290 ;+---------------------------------------------------------------------------
2292 ; AmdS3LateRestoreWrapper
2295 ; On Entry to "AmdS3LateRestore" AGESA will display AGESA_TESTPOINT - D2h
2296 ; DS - 0000 with 4 gigabyte access
2297 ; ES - 0000 with 4 gigabyte access
2300 ; On Exit from "AmdS3LateRestore" AGESA will display AGESA_TESTPOINT - D3h
2307 ; This procedure restores the processor state, reloads critical
2308 ; silicon component registers, and performs any re-initialization
2309 ; required by the silicon. This procedure will use the context data
2310 ; in the VolatileStorage area of the input structure to restore the
2311 ; processor registers.
2313 ; The host environment must fill the AMD_S3_PARAMS NvStorage and
2314 ; VolatileStorage pointers and related size elements to describe
2315 ; the location of the context data. Note that for this procedure,
2316 ; the two data areas do not need to be contained in one buffer zone,
2317 ; they can be anywhere in the accessible memory address space. If
2318 ; the host environment uses a non-volatile storage device accessed
2319 ; on the system address bus such as flashROM, then the context data
2320 ; does not need to be moved prior to this call. If the host
2321 ; environment uses a non-volatile storage device not located on the
2322 ; system address bus (e.g. CMOS or SSEPROM) then the host environment
2323 ; must transfer the context data to a buffer in main memory prior to
2324 ; calling this procedure.
2326 ; These actions are performed by the BSP. The APs are not assigned
2327 ; any tasks at this time point.
2330 ; This procedure is called late in the resume sequence, after the
2331 ; PCI control space is restored and just before resuming operating
2334 ; The host environment must initiate the OS restart process.
2336 ; This procedure requires a stack. The host environment must establish
2337 ; the stack environment prior to making the call to this procedure.
2339 AmdS3LateRestoreWrapper PROC NEAR PUBLIC
2340 local localCfgBlock:AMD_INTERFACE_PARAMS
2344 ; Prepare for the call to create and initialize the input parameters for AmdS3LateRestore
2348 lea esi, localCfgBlock
2350 mov (AMD_INTERFACE_PARAMS ptr [esi]).StdHeader.ImageBasePtr, AGESA_B2_ADDRESS
2351 mov (AMD_INTERFACE_PARAMS ptr [esi]).StdHeader.Func, AMD_CREATE_STRUCT
2352 mov (AMD_INTERFACE_PARAMS ptr [esi]).StdHeader.AltImageBasePtr, 0
2353 mov edx, SEG AmdCallout16
2355 add edx, OFFSET AmdCallout16
2356 mov (AMD_INTERFACE_PARAMS ptr [esi]).StdHeader.CalloutPtr, edx
2358 mov (AMD_INTERFACE_PARAMS ptr [esi]).AgesaFunctionName, AMD_S3LATE_RESTORE
2359 mov (AMD_INTERFACE_PARAMS ptr [esi]).AllocationMethod, PostMemDram
2360 mov (AMD_INTERFACE_PARAMS ptr [esi]).NewStructSize, 0
2362 mov dx, SEG AmdCalloutRouterPost
2364 mov dx, OFFSET AmdCalloutRouterPost
2369 mov esi, (AMD_INTERFACE_PARAMS ptr [esi]).NewStructPtr
2371 ; The structure has been initialized. Now modify the default settings as desired.
2374 add edi, (SIZEOF AMD_CONFIG_PARAMS + SIZEOF AMD_S3_PARAMS)
2375 call oemPlatformConfigInit
2377 call myGetVolatileS3Context
2378 mov (AMD_S3LATE_PARAMS ptr [esi]).S3DataBlock.VolatileStorage, ebx
2379 mov (AMD_S3LATE_PARAMS ptr [esi]).S3DataBlock.VolatileStorageSize, ecx
2381 ; Call in to the AmdS3LateRestore entry point
2386 ;; EAX = AGESA_STATUS
2387 ;; AGESA_SUCCESS All resume processes have been completed successfully.
2389 .if (eax != AGESA_SUCCESS)
2390 mov al, (AMD_S3LATE_PARAMS ptr [esi]).StdHeader.HeapStatus
2391 mov ebx, AGESA_B2_ADDRESS
2392 call AmdProcessAgesaErrors
2395 ; Allow AGESA to free the space used by AmdS3LateRestore
2397 mov (AMD_INTERFACE_PARAMS ptr [esi]).StdHeader.Func, AMD_RELEASE_STRUCT
2402 AmdS3LateRestoreWrapper ENDP
2405 ;+---------------------------------------------------------------------------
2407 ; AmdLateRunApTaskWrapper
2410 ; Prior to this hook, AGESA will display - AGESA_TESTPOINT - D4h
2411 ; DS - 0000 with 4 gigabyte access
2412 ; ES - 0000 with 4 gigabyte access
2415 ; After this hook, AGESA will display - AGESA_TESTPOINT - D5h
2422 ; This entry point is tightly connected with the "AgesaRunFcnOnAp"
2423 ; call out. The AGESA software will call the call-out "AgesaRunFcnOnAp";
2424 ; the host environment will then call this entry point to have the AP
2425 ; execute the requested function. This is needed late in the Post and
2426 ; Resume branches for running an AP task since the AGESA software has
2427 ; relinquished control of the APs to the host environment.
2430 ; The host environment must implement the"AgesaRunFcnOnAp" call-out
2431 ; and route execution to the target AP.
2433 AmdLateRunApTaskWrapper PROC NEAR PUBLIC
2434 local localCfgBlock:AMD_INTERFACE_PARAMS
2438 ; Prepare for the call to create and initialize the input parameters for AmdLateRunApTask
2442 lea esi, localCfgBlock
2444 mov (AMD_INTERFACE_PARAMS ptr [esi]).StdHeader.ImageBasePtr, AGESA_B2_ADDRESS
2445 mov (AMD_INTERFACE_PARAMS ptr [esi]).StdHeader.Func, AMD_CREATE_STRUCT
2446 mov (AMD_INTERFACE_PARAMS ptr [esi]).StdHeader.AltImageBasePtr, 0
2447 mov edx, SEG AmdCallout16
2449 add edx, OFFSET AmdCallout16
2450 mov (AMD_INTERFACE_PARAMS ptr [esi]).StdHeader.CalloutPtr, edx
2452 mov (AMD_INTERFACE_PARAMS ptr [esi]).AgesaFunctionName, AMD_LATE_RUN_AP_TASK
2453 mov (AMD_INTERFACE_PARAMS ptr [esi]).AllocationMethod, PostMemDram
2454 mov (AMD_INTERFACE_PARAMS ptr [esi]).NewStructSize, 0
2456 mov dx, SEG AmdCalloutRouterPost
2458 mov dx, OFFSET AmdCalloutRouterPost
2463 mov esi, (AMD_INTERFACE_PARAMS ptr [esi]).NewStructPtr
2465 ; The structure has been initialized. Now modify the default settings as desired.
2468 mov ax, SEG AmdRunCodeOnApDataPointer
2470 mov eax, es:AmdRunCodeOnApDataPointer
2471 mov (AP_EXE_PARAMS PTR [esi]).RelatedDataBlock, eax
2472 mov eax, es:AmdRunCodeOnApDataSize
2473 mov (AP_EXE_PARAMS PTR [esi]).RelatedBlockLength, eax
2474 mov eax, es:AmdRunCodeOnApFunction
2475 mov (AP_EXE_PARAMS PTR [esi]).FunctionNumber, eax
2478 ; Call in to the AmdLateRunApTask dispatcher
2483 ;; EAX = AGESA_STATUS
2485 mov bx, SEG AmdRunCodeOnApStatus
2487 mov es:AmdRunCodeOnApStatus, eax
2490 ; Allow AGESA to free the space used by AmdLateRunApTask
2492 mov (AMD_INTERFACE_PARAMS ptr [esi]).StdHeader.Func, AMD_RELEASE_STRUCT
2498 AmdLateRunApTaskWrapper ENDP
2501 ;+---------------------------------------------------------------------------
2503 ; AmdRunFuncOnAp (Required)
2506 ; Prior to this hook, AGESA will display - AGESA_TESTPOINT - E8h
2507 ; EDX - Local APIC ID of the target core.
2508 ; ESI - Pointer to an AP_EXE_PARAMS structure.
2511 ; IN OUT AMD_CONFIG_PARAMS StdHeader;
2512 ; IN UINT32 FunctionNumber;
2513 ; IN VOID *RelatedDataBlock;
2514 ; IN UINT32 RelatedDataBlockLength;
2518 ; After this hook, AGESA will display - AGESA_TESTPOINT - E9h
2519 ; EAX - Contains the AGESA_STATUS return code.
2520 ; AGESA_SUCCESS The function has completed successfully.
2521 ; AGESA_UNSUPPORTED This is a required function, so this value
2522 ; being returned causes a critical error
2523 ; response value from the AGESAT software
2524 ; function and no memory initialized.
2525 ; AGESA_WARNING The AP did not respond.
2531 ; This function is used after main memory has been initialized
2532 ; and the host environment has taken control of AP task dispatching.
2533 ; This function must cause the indicated function code to be executed
2534 ; upon the specified Application Processor. This procedure must be
2535 ; executed in 32-bit mode. This function is required to be implemented
2536 ; in the host environment.
2539 ; The host environment must route execution to the target AP and
2540 ; have that AP call the"AmdLateRunApTask" entry point.
2542 AmdRunFuncOnAp PROC NEAR PUBLIC
2545 mov ax, SEG AmdRunCodeOnApDataPointer
2547 mov eax, (AP_EXE_PARAMS PTR [esi]).RelatedDataBlock
2548 mov es:AmdRunCodeOnApDataPointer, eax
2549 mov eax, (AP_EXE_PARAMS PTR [esi]).RelatedBlockLength
2550 mov es:AmdRunCodeOnApDataSize, eax
2551 mov eax, (AP_EXE_PARAMS PTR [esi]).FunctionNumber
2552 mov es:AmdRunCodeOnApFunction, eax
2553 mov eax, AGESA_UNSUPPORTED
2554 mov es:AmdRunCodeOnApStatus, eax
2560 mov ax, SEG AmdRunCodeOnApStatus
2562 mov eax, es:AmdRunCodeOnApStatus
2569 ;+---------------------------------------------------------------------------
2571 ; AmdCalloutRouterPost
2574 ; ECX - Callout function number
2575 ; EDX - Function-specific UINTN
2576 ; ESI - Pointer to function specific data
2579 ; EAX - Contains the AGESA_STATUS return code.
2585 ; The call out router function for AmdInitEnv,
2586 ; AmdInitMid, AmdInitLate, AmdS3Save, and
2592 AmdCalloutRouterPost PROC FAR PUBLIC USES ECX EBX ESI BX DI DS ES
2596 lea di, cs:CalloutRouterTablePost
2597 mov eax, AGESA_UNSUPPORTED
2600 cmp di, OFFSET cs:CalloutRouterTablePostEnd
2601 jae amdCpuCalloutExit ; exit with AGESA_UNSUPPORTED
2602 cmp ecx, cs:[di].sOemCallout.FuncName
2604 add di, SIZEOF sOemCallout
2608 mov bx, cs:[di].sOemCallout.FuncPtr
2613 AmdCalloutRouterPost ENDP
2616 ;----------------------------------------------------------------------------
2617 ; Define the callout dispatch table for the POST segment
2618 ;----------------------------------------------------------------------------
2620 CalloutRouterTablePost LABEL BYTE
2621 ;; Add entries as desired.
2622 sOemCallout <AGESA_ALLOCATE_BUFFER, OFFSET myAllocateBuffer>
2623 sOemCallout <AGESA_DEALLOCATE_BUFFER, OFFSET myDeallocateBuffer>
2624 sOemCallout <AGESA_LOCATE_BUFFER, OFFSET myLocateBuffer>
2625 sOemCallout <AGESA_RUNFUNC_ONAP, OFFSET AmdRunFuncOnAp>
2626 CalloutRouterTablePostEnd LABEL BYTE
2631 ;----------------------------------------------------------------------------
2633 ; This segment must be writable, and present at the time that
2634 ; AmdInitLate is run.
2635 ;----------------------------------------------------------------------------
2639 ;; Data used to store pointers for later use by the host environment.
2640 PUBLIC AmdAcpiSratPointer
2641 PUBLIC AmdAcpiSratSize
2642 PUBLIC AmdAcpiSlitPointer
2643 PUBLIC AmdAcpiSlitSize
2644 PUBLIC AmdAcpiSsdtPointer
2645 PUBLIC AmdAcpiSsdtSize
2646 PUBLIC AmdAcpiWheaMcePointer
2647 PUBLIC AmdAcpiWheaMceSize
2648 PUBLIC AmdAcpiWheaCmcPointer
2649 PUBLIC AmdAcpiWheaCmcSize
2650 PUBLIC AmdDmiInfoPointer
2651 AmdAcpiSratPointer DWORD ?
2652 AmdAcpiSratSize DWORD ?
2653 AmdAcpiSlitPointer DWORD ?
2654 AmdAcpiSlitSize DWORD ?
2655 AmdAcpiSsdtPointer DWORD ?
2656 AmdAcpiSsdtSize DWORD ?
2657 AmdAcpiWheaMcePointer DWORD ?
2658 AmdAcpiWheaMceSize DWORD ?
2659 AmdAcpiWheaCmcPointer DWORD ?
2660 AmdAcpiWheaCmcSize DWORD ?
2661 AmdDmiInfoPointer DWORD ?
2663 ;; Data used for communication between the AP and the BSP.
2664 PUBLIC AmdRunCodeOnApDataPointer
2665 PUBLIC AmdRunCodeOnApDataSize
2666 PUBLIC AmdRunCodeOnApFunction
2667 PUBLIC AmdRunCodeOnApStatus
2668 AmdRunCodeOnApDataPointer DWORD ?
2669 AmdRunCodeOnApDataSize DWORD ?
2670 AmdRunCodeOnApFunction DWORD ?
2671 AmdRunCodeOnApStatus DWORD ?