8 * @xrefitem bom "File Content Label" "Release Content"
11 * @e \$Revision:$ @e \$Date:$
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.
42 ;*********************************************************************************/
43 /*----------------------------------------------------------------------------------------
44 * M O D U L E S U S E D
45 *----------------------------------------------------------------------------------------
48 #include "SbPlatform.h"
52 /*----------------------------------------------------------------------------------------
53 * P R O T O T Y P E S O F L O C A L F U N C T I O N S
54 *----------------------------------------------------------------------------------------
59 // Declaration of local functions
62 VOID saveConfigPointer (IN AMDSBCFG* pConfig);
63 VOID* VerifyImage (IN UINT64 Signature, IN VOID* ImagePtr);
64 VOID* LocateImage (IN UINT64 Signature);
66 /*----------------------------------------------------------------------------------------
67 * T Y P E D E F S A N D S T R U C T U R E S
68 *----------------------------------------------------------------------------------------
71 /*----------------------------------------------------------------------------------------
72 * E X P O R T E D F U N C T I O N S
73 *----------------------------------------------------------------------------------------
77 * AmdSbDispatcher - Dispatch Southbridge function
81 * @param[in] pConfig Southbridge configuration structure pointer.
94 CIM_IMAGE_ENTRY AltImageEntry;
99 Status = AGESA_UNSUPPORTED;
100 tdValue = 0x313141324E4448ull;
106 Status = AGESA_UNSUPPORTED;
107 TRACE ((DMSG_SB_TRACE, "CIM - Hudson-2 Entry\n"));
110 if ((UINT32) (UINTN) (((AMD_CONFIG_PARAMS*)pConfig)->AltImageBasePtr) != 0xffffffff ) {
111 if ( ((AMD_CONFIG_PARAMS*)pConfig)->AltImageBasePtr ) {
112 pAltImagePtr = VerifyImage ( tdValue, (VOID*) (UINTN) ((AMD_CONFIG_PARAMS*)pConfig)->AltImageBasePtr);
114 if ( pAltImagePtr == NULL ) {
115 pAltImagePtr = LocateImage ( tdValue );
117 if ( pAltImagePtr != NULL ) {
118 ((AMD_CONFIG_PARAMS*)pConfig)->ImageBasePtr = (UINT32) (UINTN) pAltImagePtr;
119 AltImageEntry = (CIM_IMAGE_ENTRY) (UINTN) ((UINT32) (UINTN) pAltImagePtr + (UINT32) (((AMD_IMAGE_HEADER*) (UINTN) pAltImagePtr)->EntryPointAddress));
120 (*AltImageEntry) (pConfig);
125 saveConfigPointer (pConfig);
127 if ( ((AMD_CONFIG_PARAMS*)pConfig)->Func == SB_POWERON_INIT ) {
128 sbPowerOnInit ((AMDSBCFG*) pConfig);
132 if ( ((AMD_CONFIG_PARAMS*)pConfig)->Func == SB_BEFORE_PCI_INIT ) {
133 sbBeforePciInit ((AMDSBCFG*)pConfig);
136 if ( ((AMD_CONFIG_PARAMS*)pConfig)->Func == SB_AFTER_PCI_INIT ) {
137 sbAfterPciInit ((AMDSBCFG*)pConfig);
140 if ( ((AMD_CONFIG_PARAMS*)pConfig)->Func == SB_MID_POST_INIT ) {
141 sbMidPostInit ((AMDSBCFG*)pConfig);
144 if ( ((AMD_CONFIG_PARAMS*)pConfig)->Func == SB_LATE_POST_INIT ) {
145 sbLatePost ((AMDSBCFG*)pConfig);
148 if ( ((AMD_CONFIG_PARAMS*)pConfig)->Func == SB_BEFORE_PCI_RESTORE_INIT ) {
149 sbBeforePciRestoreInit ((AMDSBCFG*)pConfig);
152 if ( ((AMD_CONFIG_PARAMS*)pConfig)->Func == SB_AFTER_PCI_RESTORE_INIT ) {
153 sbAfterPciRestoreInit ((AMDSBCFG*)pConfig);
156 if ( ((AMD_CONFIG_PARAMS*)pConfig)->Func == SB_SMM_SERVICE ) {
157 sbSmmService ((AMDSBCFG*)pConfig);
160 if ( ((AMD_CONFIG_PARAMS*)pConfig)->Func == SB_SMM_ACPION ) {
161 sbSmmAcpiOn ((AMDSBCFG*)pConfig);
164 if ( ((AMD_CONFIG_PARAMS*)pConfig)->Func == SB_EC_FANCONTROL ) {
165 sbECfancontrolservice ((AMDSBCFG*)pConfig);
168 TRACE ((DMSG_SB_TRACE, "CIMx - SB Exit\n"));
173 * LocateImage - Locate Southbridge CIMx module
177 * @param[in] Signature Southbridge CIMx image signature.
187 ImagePtr = 0xffffffff - (IMAGE_ALIGN - 1);
189 while ( ImagePtr >= (0xfffffff - (NUM_IMAGE_LOCATION * IMAGE_ALIGN - 1)) ) {
193 Result = VerifyImage (Signature, (VOID*) (__int64)ImagePtr);
195 if ( Result != NULL ) {
198 ImagePtr -= IMAGE_ALIGN;
204 * VerifyImage - Verify Southbridge CIMx module
207 * @param[in] Signature Southbridge CIMx image signature.
208 * @param[in] ImagePtr Southbridge CIMx image address.
217 UINT16 *TempImagePtr;
221 // if ( (*((UINT32*)ImagePtr) == 'DMA$' && ((CIMFILEHEADER*)ImagePtr)->CreatorID == Signature) ) {
222 if ( (*((UINT32*)ImagePtr) == Int32FromChar('D', 'M', 'A', '$') && ((CIMFILEHEADER*)ImagePtr)->CreatorID == Signature) ) {
223 //GetImage Image size
224 TempImagePtr = (UINT16*)ImagePtr;
225 for ( i = 0; i < (((CIMFILEHEADER*)ImagePtr)->ImageSize); i += 2 ) {
226 Sum = Sum + *TempImagePtr;
237 * saveConfigPointer - Verify Southbridge CIMx module
240 * @param[in] pConfig Southbridge configuration structure pointer.
252 ddValue = (UINT32) (UINTN)pConfig;
253 dbReg = SB_ECMOS_REG08;
255 for ( i = 0; i <= 3; i++ ) {
256 WriteIO (SB_IOMAP_REG72, AccWidthUint8, &dbReg);
257 WriteIO (SB_IOMAP_REG73, AccWidthUint8, (UINT8*)&ddValue);
258 ddValue = (ddValue >> 8);