Add the AMD Family10 Agesa code
[coreboot.git] / src / vendorcode / amd / agesa / f10 / Proc / Common / AmdLateRunApTask.c
1 /**
2  * @file
3  *
4  * AMD AGESA Basic Level Public APIs
5  *
6  * Contains basic Level Initialization routines.
7  *
8  * @xrefitem bom "File Content Label" "Release Content"
9  * @e project:      AGESA
10  * @e sub-project:  Interface
11  * @e \$Revision: 7735 $   @e \$Date: 2008-08-27 14:49:19 -0500 (Wed, 27 Aug 2008) $
12  *
13  */
14 /*****************************************************************************
15  *
16  * Copyright (c) 2011, Advanced Micro Devices, Inc.
17  * All rights reserved.
18  * 
19  * Redistribution and use in source and binary forms, with or without
20  * modification, are permitted provided that the following conditions are met:
21  *     * Redistributions of source code must retain the above copyright
22  *       notice, this list of conditions and the following disclaimer.
23  *     * Redistributions in binary form must reproduce the above copyright
24  *       notice, this list of conditions and the following disclaimer in the
25  *       documentation and/or other materials provided with the distribution.
26  *     * Neither the name of Advanced Micro Devices, Inc. nor the names of 
27  *       its contributors may be used to endorse or promote products derived 
28  *       from this software without specific prior written permission.
29  * 
30  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
31  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
32  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
33  * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
34  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
35  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
36  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
37  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
38  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
39  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40  * 
41  ******************************************************************************
42  */
43
44
45 /*----------------------------------------------------------------------------------------
46  *                             M O D U L E S    U S E D
47  *----------------------------------------------------------------------------------------
48  */
49 #include "AGESA.h"
50 #include "Ids.h"
51 #include "Options.h"
52 #include "heapManager.h"
53 #include "CreateStruct.h"
54 #include "Filecode.h"
55 #define FILECODE PROC_COMMON_AMDLATERUNAPTASK_FILECODE
56 /*----------------------------------------------------------------------------------------
57  *                   D E F I N I T I O N S    A N D    M A C R O S
58  *----------------------------------------------------------------------------------------
59  */
60
61
62 /*----------------------------------------------------------------------------------------
63  *                  T Y P E D E F S     A N D     S T R U C T U R E S
64  *----------------------------------------------------------------------------------------
65  */
66
67
68 /*----------------------------------------------------------------------------------------
69  *           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
70  *----------------------------------------------------------------------------------------
71  */
72
73
74 /*----------------------------------------------------------------------------------------
75  *                          E X P O R T E D    F U N C T I O N S
76  *----------------------------------------------------------------------------------------
77  */
78 extern CONST DISPATCH_TABLE ApDispatchTable[];
79
80 /*---------------------------------------------------------------------------------------*/
81 /**
82  * Application Processor perform a function as directed by the BSC.
83  *
84  * This is needed for an AP task that must run after AGESA has relinquished control
85  * of the APs to the IBV.
86  *
87  * @param[in]     AmdApExeParams  The interface struct for any required routine.
88  *
89  * @return        The most severe AGESA_STATUS returned by any called service.  Note
90  *                that this will be the return value passed back to the BSC as the
91  *                return value for the call out.
92  *
93  */
94 AGESA_STATUS
95 AmdLateRunApTask (
96   IN       AP_EXE_PARAMS  *AmdApExeParams
97   )
98 {
99   AGESA_STATUS        CalledAgesaStatus;
100   AGESA_STATUS        ApLateTaskStatus;
101   DISPATCH_TABLE      *Entry;
102
103   AGESA_TESTPOINT (TpIfAmdLateRunApTaskEntry, &AmdApExeParams->StdHeader);
104
105   ASSERT (AmdApExeParams != NULL);
106   ApLateTaskStatus = AGESA_SUCCESS;
107   CalledAgesaStatus = AGESA_UNSUPPORTED;
108
109   // Dispatch, if valid
110   Entry = (DISPATCH_TABLE *) ApDispatchTable;
111   while (Entry->FunctionId != 0) {
112     if (AmdApExeParams->FunctionNumber == Entry->FunctionId) {
113       CalledAgesaStatus = Entry->EntryPoint (AmdApExeParams);
114       break;
115     }
116     Entry++;
117   }
118
119   if (CalledAgesaStatus > ApLateTaskStatus) {
120     ApLateTaskStatus = CalledAgesaStatus;
121   }
122
123   AGESA_TESTPOINT (TpIfAmdLateRunApTaskExit, &AmdApExeParams->StdHeader);
124   return  ApLateTaskStatus;
125 }
126
127 /*---------------------------------------------------------------------------------------*/
128 /**
129  * Constructor for the AMD_LATE_RUN_AP_TASK function.
130  *
131  * This routine is responsible for setting default values for the
132  * input parameters needed by the AMD_S3_SAVE entry point.
133  *
134  * @param[in]     StdHeader      The standard header.
135  * @param[in,out] AmdApExeParams Required input parameters for the AMD_LATE_RUN_AP_TASK
136  *                               entry point.
137  *
138  * @retval        AGESA_SUCCESS  Always Succeeds.
139  *
140  */
141 AGESA_STATUS
142 AmdLateRunApTaskInitializer (
143   IN       AMD_CONFIG_PARAMS *StdHeader,
144   IN OUT   AP_EXE_PARAMS     *AmdApExeParams
145   )
146 {
147   ASSERT (StdHeader != NULL);
148   ASSERT (AmdApExeParams != NULL);
149
150   AmdApExeParams->StdHeader = *StdHeader;
151   AmdApExeParams->FunctionNumber = 0;
152   AmdApExeParams->RelatedDataBlock = NULL;
153   AmdApExeParams->RelatedBlockLength = 0;
154   return AGESA_SUCCESS;
155 }
156