Frank Vibrans | 2b4c831 | 2011-02-14 18:30:54 +0000 | [diff] [blame] | 1 | /* $NoKeywords:$ */ |
| 2 | /** |
| 3 | * @file |
| 4 | * |
| 5 | * S3 save/restore script |
| 6 | * |
| 7 | * |
| 8 | * |
| 9 | * @xrefitem bom "File Content Label" "Release Content" |
| 10 | * @e project: AGESA |
| 11 | * @e sub-project: GNB |
| 12 | * @e \$Revision: 35136 $ @e \$Date: 2010-07-16 11:29:48 +0800 (Fri, 16 Jul 2010) $ |
| 13 | * |
| 14 | */ |
| 15 | /* |
| 16 | ***************************************************************************** |
| 17 | * |
| 18 | * Copyright (c) 2011, Advanced Micro Devices, Inc. |
| 19 | * All rights reserved. |
Edward O'Callaghan | 1542a6f | 2014-07-06 19:24:06 +1000 | [diff] [blame] | 20 | * |
Frank Vibrans | 2b4c831 | 2011-02-14 18:30:54 +0000 | [diff] [blame] | 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. |
Edward O'Callaghan | 1542a6f | 2014-07-06 19:24:06 +1000 | [diff] [blame] | 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 |
Frank Vibrans | 2b4c831 | 2011-02-14 18:30:54 +0000 | [diff] [blame] | 30 | * from this software without specific prior written permission. |
Edward O'Callaghan | 1542a6f | 2014-07-06 19:24:06 +1000 | [diff] [blame] | 31 | * |
Frank Vibrans | 2b4c831 | 2011-02-14 18:30:54 +0000 | [diff] [blame] | 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. |
Edward O'Callaghan | 1542a6f | 2014-07-06 19:24:06 +1000 | [diff] [blame] | 42 | * |
Frank Vibrans | 2b4c831 | 2011-02-14 18:30:54 +0000 | [diff] [blame] | 43 | * *************************************************************************** |
| 44 | * |
| 45 | */ |
| 46 | |
| 47 | /*---------------------------------------------------------------------------------------- |
| 48 | * M O D U L E S U S E D |
| 49 | *---------------------------------------------------------------------------------------- |
| 50 | */ |
| 51 | #include "Porting.h" |
| 52 | #include "AMD.h" |
| 53 | #include "AGESA.h" |
| 54 | #include "Ids.h" |
| 55 | #include "amdlib.h" |
| 56 | #include "heapManager.h" |
| 57 | #include "S3SaveState.h" |
| 58 | #include "Filecode.h" |
| 59 | CODE_GROUP (G1_PEICC) |
| 60 | RDATA_GROUP (G1_PEICC) |
| 61 | |
| 62 | #define FILECODE PROC_COMMON_S3RESTORESTATE_FILECODE |
| 63 | /*---------------------------------------------------------------------------------------- |
| 64 | * D E F I N I T I O N S A N D M A C R O S |
| 65 | *---------------------------------------------------------------------------------------- |
| 66 | */ |
| 67 | |
| 68 | /*---------------------------------------------------------------------------------------- |
| 69 | * T Y P E D E F S A N D S T R U C T U R E S |
| 70 | *---------------------------------------------------------------------------------------- |
| 71 | */ |
| 72 | |
| 73 | extern S3_SCRIPT_CONFIGURATION OptionS3ScriptConfiguration; |
| 74 | extern S3_DISPATCH_FUNCTION_ENTRY S3DispatchFunctionTable[]; |
| 75 | /*---------------------------------------------------------------------------------------- |
| 76 | * 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 |
| 77 | *---------------------------------------------------------------------------------------- |
| 78 | */ |
| 79 | |
| 80 | |
| 81 | AGESA_STATUS |
| 82 | STATIC |
| 83 | S3RestoreStateFromTable ( |
| 84 | IN S3_SAVE_TABLE_HEADER *S3SaveTablePtr, |
| 85 | IN AMD_CONFIG_PARAMS *StdHeader |
| 86 | ); |
| 87 | |
| 88 | |
| 89 | |
| 90 | /*----------------------------------------------------------------------------------------*/ |
| 91 | /** |
| 92 | * Initialize S3 Script framework |
| 93 | * |
| 94 | * |
| 95 | * |
| 96 | * @param[in] StdHeader Pointer to standard header |
| 97 | */ |
| 98 | AGESA_STATUS |
| 99 | S3ScriptRestore ( |
| 100 | IN AMD_CONFIG_PARAMS *StdHeader |
| 101 | ) |
| 102 | { |
| 103 | return OptionS3ScriptConfiguration.Restore (StdHeader); |
| 104 | } |
| 105 | |
| 106 | |
| 107 | /*----------------------------------------------------------------------------------------*/ |
| 108 | /** |
| 109 | * Initialize S3 Script framework |
| 110 | * |
| 111 | * |
| 112 | * |
| 113 | * @param[in] StdHeader Pointer to standard header |
| 114 | */ |
| 115 | AGESA_STATUS |
| 116 | S3ScriptRestoreStateStub ( |
| 117 | IN AMD_CONFIG_PARAMS *StdHeader |
| 118 | ) |
| 119 | { |
| 120 | return AGESA_SUCCESS; |
| 121 | } |
| 122 | |
| 123 | |
| 124 | /*----------------------------------------------------------------------------------------*/ |
| 125 | /** |
| 126 | * Initialize S3 Script framework |
| 127 | * |
| 128 | * |
| 129 | * |
| 130 | * @param[in] StdHeader Pointer to standard header |
| 131 | */ |
| 132 | AGESA_STATUS |
| 133 | S3ScriptRestoreState ( |
| 134 | IN AMD_CONFIG_PARAMS *StdHeader |
| 135 | ) |
| 136 | { |
| 137 | AGESA_STATUS Status; |
| 138 | S3_SAVE_TABLE_HEADER *S3SaveTablePtr; |
| 139 | Status = S3ScriptGetS3SaveTable (StdHeader, &S3SaveTablePtr); |
| 140 | if (Status != AGESA_SUCCESS) { |
| 141 | IDS_ERROR_TRAP; |
| 142 | return AGESA_FATAL; |
| 143 | } |
| 144 | S3SaveTablePtr->Locked = TRUE; |
| 145 | Status = S3RestoreStateFromTable (S3SaveTablePtr, StdHeader); |
| 146 | return Status; |
| 147 | } |
| 148 | |
| 149 | |
| 150 | /*----------------------------------------------------------------------------------------*/ |
| 151 | /** |
| 152 | * Initialize S3 Script framework |
| 153 | * |
| 154 | * |
| 155 | * |
| 156 | * @param[in] S3SaveTablePtr Pointer to S3 Save Table |
| 157 | * @param[in] StdHeader Pointer to standard header |
| 158 | */ |
| 159 | AGESA_STATUS |
| 160 | STATIC |
| 161 | S3RestoreStateFromTable ( |
| 162 | IN S3_SAVE_TABLE_HEADER *S3SaveTablePtr, |
| 163 | IN AMD_CONFIG_PARAMS *StdHeader |
| 164 | ) |
| 165 | { |
| 166 | VOID *S3SaveTableRecordPtr; |
| 167 | PCI_ADDR PciAddress; |
| 168 | UINTN Index; |
| 169 | S3SaveTableRecordPtr = (UINT8 *) S3SaveTablePtr + sizeof (S3_SAVE_TABLE_HEADER); |
| 170 | IDS_HDT_CONSOLE (S3_TRACE, "Start S3 restore\n", ((S3_WRITE_OP_HEADER *) S3SaveTableRecordPtr)->Address); |
| 171 | while ((UINT8 *) S3SaveTableRecordPtr < ((UINT8 *) S3SaveTablePtr + S3SaveTablePtr->SaveOffset)) { |
| 172 | switch (*(UINT16 *) S3SaveTableRecordPtr) { |
| 173 | case SAVE_STATE_IO_WRITE_OPCODE: |
| 174 | S3_SCRIPT_DEBUG_CODE ( |
| 175 | IDS_HDT_CONSOLE (S3_TRACE, " S3 Restore: %s Address: 0x%08x Data: ", S3SaveDebugOpcodeString (StdHeader, *(UINT16 *) S3SaveTableRecordPtr), (UINT16) ((S3_WRITE_OP_HEADER *) S3SaveTableRecordPtr)->Address); |
| 176 | S3SaveDebugPrintHexArray (StdHeader, (UINT8 *) S3SaveTableRecordPtr + sizeof (S3_WRITE_OP_HEADER), 1, ((S3_WRITE_OP_HEADER *) S3SaveTableRecordPtr)->Width); |
| 177 | IDS_HDT_CONSOLE (S3_TRACE, "\n"); |
| 178 | ); |
| 179 | LibAmdIoWrite ( |
| 180 | ((S3_WRITE_OP_HEADER *) S3SaveTableRecordPtr)->Width, |
| 181 | (UINT16) ((S3_WRITE_OP_HEADER *) S3SaveTableRecordPtr)->Address, |
| 182 | (UINT8 *) S3SaveTableRecordPtr + sizeof (S3_WRITE_OP_HEADER), |
| 183 | StdHeader |
| 184 | ); |
| 185 | S3SaveTableRecordPtr = (UINT8 *) S3SaveTableRecordPtr + |
| 186 | sizeof (S3_WRITE_OP_HEADER) + |
| 187 | LibAmdAccessWidth (((S3_WRITE_OP_HEADER *) S3SaveTableRecordPtr)->Width); |
| 188 | break; |
| 189 | case SAVE_STATE_IO_READ_WRITE_OPCODE: |
| 190 | S3_SCRIPT_DEBUG_CODE ( |
| 191 | IDS_HDT_CONSOLE (S3_TRACE, " S3 Restore: %s Address: 0x%08x Data: ", S3SaveDebugOpcodeString (StdHeader, *(UINT16 *) S3SaveTableRecordPtr), (UINT16) ((S3_READ_WRITE_OP_HEADER*) S3SaveTableRecordPtr)->Address); |
| 192 | S3SaveDebugPrintHexArray ( |
| 193 | StdHeader, |
| 194 | (UINT8 *) S3SaveTableRecordPtr + sizeof (S3_READ_WRITE_OP_HEADER), |
| 195 | 1, |
| 196 | ((S3_READ_WRITE_OP_HEADER *) S3SaveTableRecordPtr)->Width |
| 197 | ); |
| 198 | IDS_HDT_CONSOLE (S3_TRACE, " Mask: "); |
| 199 | S3SaveDebugPrintHexArray ( |
| 200 | StdHeader, |
| 201 | (UINT8 *) S3SaveTableRecordPtr + sizeof (S3_READ_WRITE_OP_HEADER) + LibAmdAccessWidth (((S3_READ_WRITE_OP_HEADER *) S3SaveTableRecordPtr)->Width), |
| 202 | 1, |
| 203 | ((S3_READ_WRITE_OP_HEADER *) S3SaveTableRecordPtr)->Width |
| 204 | ); |
| 205 | IDS_HDT_CONSOLE (S3_TRACE, "\n"); |
| 206 | ); |
| 207 | LibAmdIoRMW ( |
| 208 | ((S3_READ_WRITE_OP_HEADER *) S3SaveTableRecordPtr)->Width, |
| 209 | (UINT16) ((S3_READ_WRITE_OP_HEADER*) S3SaveTableRecordPtr)->Address, |
| 210 | (UINT8 *) S3SaveTableRecordPtr + sizeof (S3_READ_WRITE_OP_HEADER), |
| 211 | (UINT8 *) S3SaveTableRecordPtr + sizeof (S3_READ_WRITE_OP_HEADER) + LibAmdAccessWidth (((S3_READ_WRITE_OP_HEADER *) S3SaveTableRecordPtr)->Width), |
| 212 | StdHeader |
| 213 | ); |
| 214 | S3SaveTableRecordPtr = (UINT8 *) S3SaveTableRecordPtr + |
| 215 | sizeof (S3_READ_WRITE_OP_HEADER) + |
| 216 | 2 * LibAmdAccessWidth (((S3_READ_WRITE_OP_HEADER *) S3SaveTableRecordPtr)->Width); |
| 217 | break; |
| 218 | case SAVE_STATE_MEM_WRITE_OPCODE: |
| 219 | S3_SCRIPT_DEBUG_CODE ( |
| 220 | IDS_HDT_CONSOLE (S3_TRACE, " S3 Restore: %s Address: 0x%08x Data: ", S3SaveDebugOpcodeString (StdHeader, *(UINT16 *) S3SaveTableRecordPtr), (UINT16) ((S3_WRITE_OP_HEADER *) S3SaveTableRecordPtr)->Address); |
| 221 | S3SaveDebugPrintHexArray (StdHeader, (UINT8 *) S3SaveTableRecordPtr + sizeof (S3_WRITE_OP_HEADER), 1, ((S3_WRITE_OP_HEADER *) S3SaveTableRecordPtr)->Width); |
| 222 | IDS_HDT_CONSOLE (S3_TRACE, "\n"); |
| 223 | ); |
| 224 | LibAmdMemWrite ( |
| 225 | ((S3_WRITE_OP_HEADER *) S3SaveTableRecordPtr)->Width, |
| 226 | ((S3_WRITE_OP_HEADER *) S3SaveTableRecordPtr)->Address, |
| 227 | (UINT8 *) S3SaveTableRecordPtr + sizeof (S3_WRITE_OP_HEADER), |
| 228 | StdHeader |
| 229 | ); |
| 230 | S3SaveTableRecordPtr = (UINT8 *) S3SaveTableRecordPtr + |
| 231 | sizeof (S3_WRITE_OP_HEADER) + |
| 232 | LibAmdAccessWidth (((S3_WRITE_OP_HEADER *) S3SaveTableRecordPtr)->Width); |
| 233 | break; |
| 234 | case SAVE_STATE_MEM_READ_WRITE_OPCODE: |
| 235 | S3_SCRIPT_DEBUG_CODE ( |
| 236 | IDS_HDT_CONSOLE (S3_TRACE, " S3 Restore: %s Address: 0x%08x Data: ", S3SaveDebugOpcodeString (StdHeader, *(UINT16 *) S3SaveTableRecordPtr), (UINT16) ((S3_READ_WRITE_OP_HEADER*) S3SaveTableRecordPtr)->Address); |
| 237 | S3SaveDebugPrintHexArray ( |
| 238 | StdHeader, |
| 239 | (UINT8 *) S3SaveTableRecordPtr + sizeof (S3_READ_WRITE_OP_HEADER), |
| 240 | 1, |
| 241 | ((S3_READ_WRITE_OP_HEADER *) S3SaveTableRecordPtr)->Width |
| 242 | ); |
| 243 | IDS_HDT_CONSOLE (S3_TRACE, " Mask: "); |
| 244 | S3SaveDebugPrintHexArray ( |
| 245 | StdHeader, |
| 246 | (UINT8 *) S3SaveTableRecordPtr + sizeof (S3_READ_WRITE_OP_HEADER) + LibAmdAccessWidth (((S3_READ_WRITE_OP_HEADER *) S3SaveTableRecordPtr)->Width), |
| 247 | 1, |
| 248 | ((S3_READ_WRITE_OP_HEADER *) S3SaveTableRecordPtr)->Width |
| 249 | ); |
| 250 | IDS_HDT_CONSOLE (S3_TRACE, "\n"); |
| 251 | ); |
| 252 | LibAmdMemRMW ( |
| 253 | ((S3_READ_WRITE_OP_HEADER *) S3SaveTableRecordPtr)->Width, |
| 254 | ((S3_READ_WRITE_OP_HEADER *) S3SaveTableRecordPtr)->Address, |
| 255 | (UINT8 *) S3SaveTableRecordPtr + sizeof (S3_READ_WRITE_OP_HEADER), |
| 256 | (UINT8 *) S3SaveTableRecordPtr + sizeof (S3_READ_WRITE_OP_HEADER) + LibAmdAccessWidth (((S3_READ_WRITE_OP_HEADER*) S3SaveTableRecordPtr)->Width), |
| 257 | StdHeader |
| 258 | ); |
| 259 | S3SaveTableRecordPtr = (UINT8 *) S3SaveTableRecordPtr + |
| 260 | sizeof (S3_READ_WRITE_OP_HEADER) + |
| 261 | 2 * LibAmdAccessWidth (((S3_READ_WRITE_OP_HEADER *) S3SaveTableRecordPtr)->Width); |
| 262 | break; |
| 263 | case SAVE_STATE_PCI_CONFIG_WRITE_OPCODE: |
| 264 | PciAddress.AddressValue = (UINT32) ((S3_WRITE_OP_HEADER *) S3SaveTableRecordPtr)->Address; |
| 265 | S3_SCRIPT_DEBUG_CODE ( |
| 266 | IDS_HDT_CONSOLE (S3_TRACE, " S3 Restore: %s Address: 0x%08x Data: ", S3SaveDebugOpcodeString (StdHeader, *(UINT16 *) S3SaveTableRecordPtr), (UINT16) ((S3_WRITE_OP_HEADER *) S3SaveTableRecordPtr)->Address); |
| 267 | S3SaveDebugPrintHexArray (StdHeader, (UINT8 *) S3SaveTableRecordPtr + sizeof (S3_WRITE_OP_HEADER), 1, ((S3_WRITE_OP_HEADER *) S3SaveTableRecordPtr)->Width); |
| 268 | IDS_HDT_CONSOLE (S3_TRACE, "\n"); |
| 269 | ); |
| 270 | LibAmdPciWrite ( |
| 271 | ((S3_WRITE_OP_HEADER *) S3SaveTableRecordPtr)->Width, |
| 272 | PciAddress, |
| 273 | (UINT8 *) S3SaveTableRecordPtr + sizeof (S3_WRITE_OP_HEADER), |
| 274 | StdHeader |
| 275 | ); |
| 276 | S3SaveTableRecordPtr = (UINT8 *) S3SaveTableRecordPtr + |
| 277 | sizeof (S3_WRITE_OP_HEADER) + |
| 278 | LibAmdAccessWidth (((S3_WRITE_OP_HEADER *) S3SaveTableRecordPtr)->Width); |
| 279 | break; |
| 280 | case SAVE_STATE_PCI_CONFIG_READ_WRITE_OPCODE: |
| 281 | PciAddress.AddressValue = (UINT32) ((S3_READ_WRITE_OP_HEADER *) S3SaveTableRecordPtr)->Address; |
| 282 | S3_SCRIPT_DEBUG_CODE ( |
| 283 | IDS_HDT_CONSOLE (S3_TRACE, " S3 Restore: %s Address: 0x%08x Data: ", S3SaveDebugOpcodeString (StdHeader, *(UINT16 *) S3SaveTableRecordPtr), (UINT16) ((S3_READ_WRITE_OP_HEADER*) S3SaveTableRecordPtr)->Address); |
| 284 | S3SaveDebugPrintHexArray ( |
| 285 | StdHeader, |
| 286 | (UINT8 *) S3SaveTableRecordPtr + sizeof (S3_READ_WRITE_OP_HEADER), |
| 287 | 1, |
| 288 | ((S3_READ_WRITE_OP_HEADER *) S3SaveTableRecordPtr)->Width |
| 289 | ); |
| 290 | IDS_HDT_CONSOLE (S3_TRACE, " Mask: "); |
| 291 | S3SaveDebugPrintHexArray ( |
| 292 | StdHeader, |
| 293 | (UINT8 *) S3SaveTableRecordPtr + sizeof (S3_READ_WRITE_OP_HEADER) + LibAmdAccessWidth (((S3_READ_WRITE_OP_HEADER *) S3SaveTableRecordPtr)->Width), |
| 294 | 1, |
| 295 | ((S3_READ_WRITE_OP_HEADER *) S3SaveTableRecordPtr)->Width |
| 296 | ); |
| 297 | IDS_HDT_CONSOLE (S3_TRACE, "\n"); |
| 298 | ); |
| 299 | LibAmdPciRMW ( |
| 300 | ((S3_READ_WRITE_OP_HEADER *) S3SaveTableRecordPtr)->Width, |
| 301 | PciAddress, |
| 302 | (UINT8 *) S3SaveTableRecordPtr + sizeof (S3_READ_WRITE_OP_HEADER), |
| 303 | (UINT8 *) S3SaveTableRecordPtr + sizeof (S3_READ_WRITE_OP_HEADER) + LibAmdAccessWidth (((S3_READ_WRITE_OP_HEADER *) S3SaveTableRecordPtr)->Width), |
| 304 | StdHeader |
| 305 | ); |
| 306 | S3SaveTableRecordPtr = (UINT8 *) S3SaveTableRecordPtr + |
| 307 | sizeof (S3_READ_WRITE_OP_HEADER) + |
| 308 | 2 * LibAmdAccessWidth (((S3_READ_WRITE_OP_HEADER *) S3SaveTableRecordPtr)->Width); |
| 309 | break; |
| 310 | case SAVE_STATE_STALL_OPCODE: |
| 311 | break; |
| 312 | case SAVE_STATE_INFORMATION_OPCODE: |
| 313 | IDS_HDT_CONSOLE (S3_TRACE, " S3 Restore: Info: [%s]\n", (UINT8 *) S3SaveTableRecordPtr + sizeof (S3_INFO_OP_HEADER)); |
| 314 | S3SaveTableRecordPtr = (UINT8 *) S3SaveTableRecordPtr + |
| 315 | sizeof (S3_INFO_OP_HEADER) + |
| 316 | ((S3_INFO_OP_HEADER*) S3SaveTableRecordPtr)->Length; |
| 317 | break; |
| 318 | case SAVE_STATE_DISPATCH_OPCODE: |
| 319 | S3_SCRIPT_DEBUG_CODE ( |
| 320 | IDS_HDT_CONSOLE (S3_TRACE, " S3 Restore: %s Function Id: 0x%02x, Context: ", S3SaveDebugOpcodeString (StdHeader, *(UINT16 *) S3SaveTableRecordPtr), ((S3_DISPATCH_OP_HEADER*) S3SaveTableRecordPtr)->FunctionId); |
| 321 | S3SaveDebugPrintHexArray ( |
| 322 | StdHeader, |
| 323 | (VOID*)((UINT8*) S3SaveTableRecordPtr + sizeof (S3_DISPATCH_OP_HEADER)), |
| 324 | ((S3_DISPATCH_OP_HEADER*) S3SaveTableRecordPtr)->Length, |
| 325 | AccessWidth8); |
| 326 | IDS_HDT_CONSOLE (S3_TRACE, "\n"); |
| 327 | ); |
| 328 | Index = 0; |
| 329 | while (S3DispatchFunctionTable[Index].FunctionId != 0) { |
| 330 | if (S3DispatchFunctionTable[Index].FunctionId == ((S3_DISPATCH_OP_HEADER*) S3SaveTableRecordPtr)->FunctionId) { |
| 331 | (S3DispatchFunctionTable[Index].Function) ( |
| 332 | StdHeader, |
| 333 | ((S3_DISPATCH_OP_HEADER*) S3SaveTableRecordPtr)->Length, |
| 334 | (VOID*)((UINT8*) S3SaveTableRecordPtr + sizeof (S3_DISPATCH_OP_HEADER)) |
| 335 | ); |
| 336 | break; |
| 337 | } |
| 338 | Index++; |
| 339 | } |
| 340 | ASSERT (S3DispatchFunctionTable[Index].FunctionId != 0); |
| 341 | S3SaveTableRecordPtr = (UINT8 *) S3SaveTableRecordPtr + |
| 342 | sizeof (S3_DISPATCH_OP_HEADER) + |
| 343 | ((S3_DISPATCH_OP_HEADER*) S3SaveTableRecordPtr)->Length; |
| 344 | break; |
| 345 | |
| 346 | case SAVE_STATE_IO_POLL_OPCODE: |
| 347 | S3_SCRIPT_DEBUG_CODE ( |
| 348 | IDS_HDT_CONSOLE (S3_TRACE, " S3 Restore: %s Address: 0x%04x Data: ", S3SaveDebugOpcodeString (StdHeader, *(UINT16 *) S3SaveTableRecordPtr), (UINT16) ((S3_POLL_OP_HEADER*) S3SaveTableRecordPtr)->Address); |
| 349 | S3SaveDebugPrintHexArray ( |
| 350 | StdHeader, |
| 351 | (UINT8 *) S3SaveTableRecordPtr + sizeof (S3_POLL_OP_HEADER), |
| 352 | 1, |
| 353 | ((S3_READ_WRITE_OP_HEADER *) S3SaveTableRecordPtr)->Width |
| 354 | ); |
| 355 | IDS_HDT_CONSOLE (S3_TRACE, " Mask: "); |
| 356 | S3SaveDebugPrintHexArray ( |
| 357 | StdHeader, |
| 358 | (UINT8 *) S3SaveTableRecordPtr + sizeof (S3_POLL_OP_HEADER) + LibAmdAccessWidth (((S3_POLL_OP_HEADER *) S3SaveTableRecordPtr)->Width), |
| 359 | 1, |
| 360 | ((S3_POLL_OP_HEADER *) S3SaveTableRecordPtr)->Width |
| 361 | ); |
| 362 | ) |
| 363 | LibAmdIoPoll ( |
| 364 | ((S3_POLL_OP_HEADER *) S3SaveTableRecordPtr)->Width, |
| 365 | (UINT16) ((S3_POLL_OP_HEADER *) S3SaveTableRecordPtr)->Address, |
| 366 | (UINT8 *) S3SaveTableRecordPtr + sizeof (S3_POLL_OP_HEADER), |
| 367 | (UINT8 *) S3SaveTableRecordPtr + sizeof (S3_POLL_OP_HEADER) + LibAmdAccessWidth (((S3_POLL_OP_HEADER*) S3SaveTableRecordPtr)->Width), |
| 368 | ((S3_POLL_OP_HEADER*) S3SaveTableRecordPtr)->Delay, |
| 369 | StdHeader |
| 370 | ); |
| 371 | S3SaveTableRecordPtr = (UINT8 *) S3SaveTableRecordPtr + |
| 372 | sizeof (S3_POLL_OP_HEADER) + |
| 373 | 2 * LibAmdAccessWidth (((S3_POLL_OP_HEADER *) S3SaveTableRecordPtr)->Width); |
| 374 | break; |
| 375 | case SAVE_STATE_MEM_POLL_OPCODE: |
| 376 | S3_SCRIPT_DEBUG_CODE ( |
| 377 | IDS_HDT_CONSOLE (S3_TRACE, " S3 Restore: %s Address: 0x%08x Data: ", S3SaveDebugOpcodeString (StdHeader, *(UINT16 *) S3SaveTableRecordPtr), (UINT32) ((S3_POLL_OP_HEADER*) S3SaveTableRecordPtr)->Address); |
| 378 | S3SaveDebugPrintHexArray ( |
| 379 | StdHeader, |
| 380 | (UINT8 *) S3SaveTableRecordPtr + sizeof (S3_POLL_OP_HEADER), |
| 381 | 1, |
| 382 | ((S3_POLL_OP_HEADER *) S3SaveTableRecordPtr)->Width |
| 383 | ); |
| 384 | IDS_HDT_CONSOLE (S3_TRACE, " Mask: "); |
| 385 | S3SaveDebugPrintHexArray ( |
| 386 | StdHeader, |
| 387 | (UINT8 *) S3SaveTableRecordPtr + sizeof (S3_POLL_OP_HEADER) + LibAmdAccessWidth (((S3_POLL_OP_HEADER *) S3SaveTableRecordPtr)->Width), |
| 388 | 1, |
| 389 | ((S3_POLL_OP_HEADER *) S3SaveTableRecordPtr)->Width |
| 390 | ); |
| 391 | ) |
| 392 | LibAmdMemPoll ( |
| 393 | ((S3_POLL_OP_HEADER *) S3SaveTableRecordPtr)->Width, |
| 394 | ((S3_POLL_OP_HEADER *) S3SaveTableRecordPtr)->Address, |
| 395 | (UINT8 *) S3SaveTableRecordPtr + sizeof (S3_POLL_OP_HEADER), |
| 396 | (UINT8 *) S3SaveTableRecordPtr + sizeof (S3_POLL_OP_HEADER) + LibAmdAccessWidth (((S3_POLL_OP_HEADER *) S3SaveTableRecordPtr)->Width), |
| 397 | ((S3_POLL_OP_HEADER *) S3SaveTableRecordPtr)->Delay, |
| 398 | StdHeader |
| 399 | ); |
| 400 | S3SaveTableRecordPtr = (UINT8 *) S3SaveTableRecordPtr + |
| 401 | sizeof (S3_POLL_OP_HEADER) + |
| 402 | 2 * LibAmdAccessWidth (((S3_POLL_OP_HEADER *) S3SaveTableRecordPtr)->Width); |
| 403 | break; |
| 404 | case SAVE_STATE_PCI_CONFIG_POLL_OPCODE: |
| 405 | PciAddress.AddressValue = (UINT32) ((S3_POLL_OP_HEADER *) S3SaveTableRecordPtr)->Address; |
| 406 | S3_SCRIPT_DEBUG_CODE ( |
| 407 | IDS_HDT_CONSOLE (S3_TRACE, " S3 Restore: %s Address: 0x%08x Data: ", S3SaveDebugOpcodeString (StdHeader, *(UINT16 *) S3SaveTableRecordPtr), (UINT32) ((S3_POLL_OP_HEADER*) S3SaveTableRecordPtr)->Address); |
| 408 | S3SaveDebugPrintHexArray ( |
| 409 | StdHeader, |
| 410 | (UINT8 *) S3SaveTableRecordPtr + sizeof (S3_POLL_OP_HEADER), |
| 411 | 1, |
| 412 | ((S3_POLL_OP_HEADER *) S3SaveTableRecordPtr)->Width |
| 413 | ); |
| 414 | IDS_HDT_CONSOLE (S3_TRACE, " Mask: "); |
| 415 | S3SaveDebugPrintHexArray ( |
| 416 | StdHeader, |
| 417 | (UINT8 *) S3SaveTableRecordPtr + sizeof (S3_POLL_OP_HEADER) + LibAmdAccessWidth (((S3_POLL_OP_HEADER *) S3SaveTableRecordPtr)->Width), |
| 418 | 1, |
| 419 | ((S3_POLL_OP_HEADER *) S3SaveTableRecordPtr)->Width |
| 420 | ); |
| 421 | ) |
| 422 | LibAmdPciPoll ( |
| 423 | ((S3_POLL_OP_HEADER *) S3SaveTableRecordPtr)->Width, |
| 424 | PciAddress, |
| 425 | (UINT8 *) S3SaveTableRecordPtr + sizeof (S3_POLL_OP_HEADER), |
| 426 | (UINT8 *) S3SaveTableRecordPtr + sizeof (S3_POLL_OP_HEADER) + LibAmdAccessWidth (((S3_POLL_OP_HEADER *) S3SaveTableRecordPtr)->Width), |
| 427 | ((S3_POLL_OP_HEADER *) S3SaveTableRecordPtr)->Delay, |
| 428 | StdHeader |
| 429 | ); |
| 430 | S3SaveTableRecordPtr = (UINT8 *) S3SaveTableRecordPtr + |
| 431 | sizeof (S3_POLL_OP_HEADER) + |
| 432 | 2 * LibAmdAccessWidth (((S3_POLL_OP_HEADER *) S3SaveTableRecordPtr)->Width); |
| 433 | break; |
| 434 | default: |
| 435 | IDS_HDT_CONSOLE (S3_TRACE, " ERROR!!! Invalid S3 restore opcode\n"); |
| 436 | ASSERT (FALSE); |
| 437 | return AGESA_ERROR; |
| 438 | } |
| 439 | } |
| 440 | IDS_HDT_CONSOLE (S3_TRACE, " End S3 Restore \n"); |
| 441 | return AGESA_SUCCESS; |
| 442 | } |
| 443 | |