blob: c33d09ce0628433233b112d09801ab53ee890703 [file] [log] [blame]
zbao7d94cf92012-07-02 14:19:14 +08001/* $NoKeywords:$ */
2/**
3 * @file
4 *
5 * AMD binary block interface
6 *
7 * Contains the block entry function dispatcher
8 *
9 * @xrefitem bom "File Content Label" "Release Content"
10 * @e project: AGESA
11 * @e sub-project: Legacy
12 * @e \$Revision: 63425 $ @e \$Date: 2011-12-22 11:24:10 -0600 (Thu, 22 Dec 2011) $
13 *
14 */
15/*****************************************************************************
16 *
Siyuan Wang641f00c2013-06-08 11:50:55 +080017 * Copyright (c) 2008 - 2012, Advanced Micro Devices, Inc.
18 * All rights reserved.
zbao7d94cf92012-07-02 14:19:14 +080019 *
Siyuan Wang641f00c2013-06-08 11:50:55 +080020 * 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.
zbao7d94cf92012-07-02 14:19:14 +080030 *
Siyuan Wang641f00c2013-06-08 11:50:55 +080031 * 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.
zbao7d94cf92012-07-02 14:19:14 +080041 * ***************************************************************************
42 */
43
44/*----------------------------------------------------------------------------------------
45 * M O D U L E S U S E D
46 *----------------------------------------------------------------------------------------
47 */
48#include "AGESA.h"
49#include "amdlib.h"
50#include "Dispatcher.h"
51#include "Options.h"
52#include "Filecode.h"
53CODE_GROUP (G1_PEICC)
54RDATA_GROUP (G1_PEICC)
55
56#define FILECODE LEGACY_PROC_DISPATCHER_FILECODE
57
58/*----------------------------------------------------------------------------------------
59 * D E F I N I T I O N S A N D M A C R O S
60 *----------------------------------------------------------------------------------------
61 */
62extern CONST DISPATCH_TABLE DispatchTable[];
63extern AMD_MODULE_HEADER mCpuModuleID;
64
65/*---------------------------------------------------------------------------------------*/
66/**
67 * The Dispatcher is the entry point into the AGESA software. It takes a function
68 * number as entry parameter in order to invoke the published function
69 *
70 * @param[in,out] ConfigPtr
71 *
72 * @return AGESA Status.
73 *
74 */
75AGESA_STATUS
76CALLCONV
77AmdAgesaDispatcher (
78 IN OUT VOID *ConfigPtr
79 )
80{
81 AGESA_STATUS Status;
zbao7d94cf92012-07-02 14:19:14 +080082 MODULE_ENTRY ModuleEntry;
83 DISPATCH_TABLE *Entry;
zbao7d94cf92012-07-02 14:19:14 +080084
85 Status = AGESA_UNSUPPORTED;
zbao7d94cf92012-07-02 14:19:14 +080086 ModuleEntry = NULL;
zbao7d94cf92012-07-02 14:19:14 +080087
88 Entry = (DISPATCH_TABLE *) DispatchTable;
89 while (Entry->FunctionId != 0) {
90 if ((((AMD_CONFIG_PARAMS *) ConfigPtr)->Func) == Entry->FunctionId) {
91 Status = Entry->EntryPoint (ConfigPtr);
92 break;
93 }
94 Entry++;
95 }
96
97 // 2. Try next dispatcher if possible, and we have not already got status back
98 if ((mCpuModuleID.NextBlock != NULL) && (Status == AGESA_UNSUPPORTED)) {
99 ModuleEntry = (MODULE_ENTRY) /* (UINT64) */ mCpuModuleID.NextBlock->ModuleDispatcher;
100 if (ModuleEntry != NULL) {
101 Status = (*ModuleEntry) (ConfigPtr);
102 }
103 }
104
zbao7d94cf92012-07-02 14:19:14 +0800105 return (Status);
106}
107
108/*---------------------------------------------------------------------------------------*/
109/**
110 * The host environment interface of callout.
111 *
112 * @param[in] Func
113 * @param[in] Data
114 * @param[in,out] ConfigPtr
115 *
116 * @return The AGESA Status returned from the callout.
117 *
118 */
119AGESA_STATUS
120CALLCONV
121AmdAgesaCallout (
122 IN UINT32 Func,
Stefan Reinauer8d29dd12017-06-26 14:30:39 -0700123 IN UINTN Data,
zbao7d94cf92012-07-02 14:19:14 +0800124 IN OUT VOID *ConfigPtr
125 )
126{
127 UINT32 Result;
128 Result = AGESA_UNSUPPORTED;
129 if (((AMD_CONFIG_PARAMS *) ConfigPtr)->CalloutPtr == NULL) {
130 return Result;
131 }
132
133 Result = (((AMD_CONFIG_PARAMS *) ConfigPtr)->CalloutPtr) (Func, Data, ConfigPtr);
134 return (Result);
135}