8 * @xrefitem bom "File Content Label" "Release Content"
11 * @e \$Revision:$ @e \$Date:$
16 *****************************************************************************
18 * Copyright (c) 2011, Advanced Micro Devices, Inc.
19 * All rights reserved.
21 * Redistribution and use in source and binary forms, with or without
22 * modification, are permitted provided that the following conditions are met:
23 * * Redistributions of source code must retain the above copyright
24 * notice, this list of conditions and the following disclaimer.
25 * * Redistributions in binary form must reproduce the above copyright
26 * notice, this list of conditions and the following disclaimer in the
27 * documentation and/or other materials provided with the distribution.
28 * * Neither the name of Advanced Micro Devices, Inc. nor the names of
29 * its contributors may be used to endorse or promote products derived
30 * from this software without specific prior written permission.
32 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
33 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
34 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
35 * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
36 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
37 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
38 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
39 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
40 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
41 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
43 * ***************************************************************************
46 /*----------------------------------------------------------------------------------------
47 * M O D U L E S U S E D
48 *----------------------------------------------------------------------------------------
51 #include "SBPLATFORM.h"
54 /*----------------------------------------------------------------------------------------
55 * 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
56 *----------------------------------------------------------------------------------------
61 // Declaration of local functions
64 VOID saveConfigPointer (IN AMDSBCFG* pConfig);
65 VOID* VerifyImage (IN UINT64 Signature, IN VOID* ImagePtr);
66 VOID* LocateImage (IN UINT64 Signature);
68 /*----------------------------------------------------------------------------------------
69 * T Y P E D E F S A N D S T R U C T U R E S
70 *----------------------------------------------------------------------------------------
73 /*----------------------------------------------------------------------------------------
74 * E X P O R T E D F U N C T I O N S
75 *----------------------------------------------------------------------------------------
79 * AmdSbDispatcher - Dispatch Southbridge function
83 * @param[in] pConfig Southbridge configuration structure pointer.
95 CIM_IMAGE_ENTRY AltImageEntry;
99 tdValue = 0x32314130384253ULL;
104 Status = AGESA_UNSUPPORTED;
107 if ((UINT32) (UINTN) (((AMD_CONFIG_PARAMS*)pConfig)->AltImageBasePtr) != 0xffffffff ) {
108 if ( ((AMD_CONFIG_PARAMS*)pConfig)->AltImageBasePtr ) {
109 pAltImagePtr = VerifyImage ( tdValue, (VOID*) (UINTN) ((AMD_CONFIG_PARAMS*)pConfig)->AltImageBasePtr);
111 if ( pAltImagePtr == NULL ) {
112 pAltImagePtr = LocateImage ( tdValue );
114 if ( pAltImagePtr != NULL ) {
115 ((AMD_CONFIG_PARAMS*)pConfig)->ImageBasePtr = (UINT32) (UINTN) pAltImagePtr;
116 AltImageEntry = (CIM_IMAGE_ENTRY) (UINTN) ((UINT32) (UINTN) pAltImagePtr + (UINT32) (((AMD_IMAGE_HEADER*) (UINTN) pAltImagePtr)->EntryPointAddress));
117 (*AltImageEntry) (pConfig);
122 saveConfigPointer (pConfig);
124 if ( ((AMD_CONFIG_PARAMS*)pConfig)->Func == SB_POWERON_INIT ) {
125 sbPowerOnInit ((AMDSBCFG*) pConfig);
129 if ( ((AMD_CONFIG_PARAMS*)pConfig)->Func == SB_BEFORE_PCI_INIT ) {
130 sbBeforePciInit ((AMDSBCFG*)pConfig);
133 if ( ((AMD_CONFIG_PARAMS*)pConfig)->Func == SB_AFTER_PCI_INIT ) {
134 sbAfterPciInit ((AMDSBCFG*)pConfig);
137 if ( ((AMD_CONFIG_PARAMS*)pConfig)->Func == SB_MID_POST_INIT ) {
138 sbMidPostInit ((AMDSBCFG*)pConfig);
141 if ( ((AMD_CONFIG_PARAMS*)pConfig)->Func == SB_LATE_POST_INIT ) {
142 sbLatePost ((AMDSBCFG*)pConfig);
145 if ( ((AMD_CONFIG_PARAMS*)pConfig)->Func == SB_BEFORE_PCI_RESTORE_INIT ) {
146 sbBeforePciRestoreInit ((AMDSBCFG*)pConfig);
149 if ( ((AMD_CONFIG_PARAMS*)pConfig)->Func == SB_AFTER_PCI_RESTORE_INIT ) {
150 sbAfterPciRestoreInit ((AMDSBCFG*)pConfig);
153 if ( ((AMD_CONFIG_PARAMS*)pConfig)->Func == SB_SMM_SERVICE ) {
154 sbSmmService ((AMDSBCFG*)pConfig);
157 if ( ((AMD_CONFIG_PARAMS*)pConfig)->Func == SB_SMM_ACPION ) {
158 sbSmmAcpiOn ((AMDSBCFG*)pConfig);
161 if ( ((AMD_CONFIG_PARAMS*)pConfig)->Func == SB_EC_FANCONTROL ) {
162 sbECfancontrolservice((AMDSBCFG*)pConfig);;
169 * LocateImage - Locate Southbridge CIMx module
173 * @param[in] Signature Southbridge CIMx image signature.
183 ImagePtr = 0xffffffff - (IMAGE_ALIGN - 1);
185 while ( ImagePtr >= (0xfffffff - (NUM_IMAGE_LOCATION * IMAGE_ALIGN - 1)) ) {
189 Result = VerifyImage (Signature, (VOID*) ImagePtr);
191 if ( Result != NULL ) {
194 ImagePtr -= IMAGE_ALIGN;
200 * VerifyImage - Verify Southbridge CIMx module
203 * @param[in] Signature Southbridge CIMx image signature.
204 * @param[in] ImagePtr Southbridge CIMx image address.
213 UINT16 *TempImagePtr;
217 if ( (*((UINT32*)ImagePtr) == Int32FromChar('$', 'A', 'M', 'D') && ((CIMFILEHEADER*)ImagePtr)->CreatorID == Signature) ) {
218 //GetImage Image size
219 TempImagePtr = (UINT16*)ImagePtr;
220 for ( i = 0; i < (((CIMFILEHEADER*)ImagePtr)->ImageSize); i += 2 ) {
221 Sum = Sum + *TempImagePtr;
232 * saveConfigPointer - Verify Southbridge CIMx module
235 * @param[in] pConfig Southbridge configuration structure pointer.
247 ddValue = (UINT32) (UINTN)pConfig;
248 dbReg = SB_ECMOS_REG08;
250 for ( i = 0; i <= 3; i++ ) {
251 WriteIO (SB_IOMAP_REG72, AccWidthUint8, &dbReg);
252 WriteIO (SB_IOMAP_REG73, AccWidthUint8, (UINT8*)&ddValue);
253 ddValue = (ddValue >> 8);