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