zbao | 7d94cf9 | 2012-07-02 14:19:14 +0800 | [diff] [blame] | 1 | /* $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 Wang | 641f00c | 2013-06-08 11:50:55 +0800 | [diff] [blame] | 17 | * Copyright (c) 2008 - 2012, Advanced Micro Devices, Inc. |
| 18 | * All rights reserved. |
zbao | 7d94cf9 | 2012-07-02 14:19:14 +0800 | [diff] [blame] | 19 | * |
Siyuan Wang | 641f00c | 2013-06-08 11:50:55 +0800 | [diff] [blame] | 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. |
zbao | 7d94cf9 | 2012-07-02 14:19:14 +0800 | [diff] [blame] | 30 | * |
Siyuan Wang | 641f00c | 2013-06-08 11:50:55 +0800 | [diff] [blame] | 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. |
zbao | 7d94cf9 | 2012-07-02 14:19:14 +0800 | [diff] [blame] | 41 | * *************************************************************************** |
| 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" |
| 53 | CODE_GROUP (G1_PEICC) |
| 54 | RDATA_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 | */ |
| 62 | extern CONST DISPATCH_TABLE DispatchTable[]; |
| 63 | extern 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 | */ |
| 75 | AGESA_STATUS |
| 76 | CALLCONV |
| 77 | AmdAgesaDispatcher ( |
| 78 | IN OUT VOID *ConfigPtr |
| 79 | ) |
| 80 | { |
| 81 | AGESA_STATUS Status; |
zbao | 7d94cf9 | 2012-07-02 14:19:14 +0800 | [diff] [blame] | 82 | MODULE_ENTRY ModuleEntry; |
| 83 | DISPATCH_TABLE *Entry; |
zbao | 7d94cf9 | 2012-07-02 14:19:14 +0800 | [diff] [blame] | 84 | |
| 85 | Status = AGESA_UNSUPPORTED; |
zbao | 7d94cf9 | 2012-07-02 14:19:14 +0800 | [diff] [blame] | 86 | ModuleEntry = NULL; |
zbao | 7d94cf9 | 2012-07-02 14:19:14 +0800 | [diff] [blame] | 87 | |
| 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 | |
zbao | 7d94cf9 | 2012-07-02 14:19:14 +0800 | [diff] [blame] | 105 | 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 | */ |
| 119 | AGESA_STATUS |
| 120 | CALLCONV |
| 121 | AmdAgesaCallout ( |
| 122 | IN UINT32 Func, |
Stefan Reinauer | 8d29dd1 | 2017-06-26 14:30:39 -0700 | [diff] [blame] | 123 | IN UINTN Data, |
zbao | 7d94cf9 | 2012-07-02 14:19:14 +0800 | [diff] [blame] | 124 | 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 | } |