- //\r
- // Copy the scratch buffer into the boot script. When replayed, this\r
- // EFI_BOOT_SCRIPT_MEM_WRITE_OPCODE will restore the current contents of the\r
- // scratch buffer, in-place.\r
- //\r
- Status = S3SaveState->Write (\r
- S3SaveState, // This\r
- EFI_BOOT_SCRIPT_MEM_WRITE_OPCODE, // OpCode\r
- EfiBootScriptWidthUint8, // Width\r
- (UINT64)(UINTN)ScratchBuffer, // Address\r
- sizeof *ScratchBuffer, // Count\r
- (VOID*)ScratchBuffer // Buffer\r
- );\r
- if (EFI_ERROR (Status)) {\r
- DEBUG ((DEBUG_ERROR, "%a:%d: EFI_BOOT_SCRIPT_MEM_WRITE_OPCODE: %r\n",\r
- __FUNCTION__, __LINE__, Status));\r
- goto FatalError;\r
- }\r
-\r
- //\r
- // Append an opcode that will write the address of the scratch buffer to the\r
- // fw_cfg DMA address register, which consists of two 32-bit IO ports. The\r
- // second (highest address, least significant) write will start the transfer.\r
- //\r
- AccessAddress = SwapBytes64 ((UINTN)&ScratchBuffer->Access);\r
- Status = S3SaveState->Write (\r
- S3SaveState, // This\r
- EFI_BOOT_SCRIPT_IO_WRITE_OPCODE, // OpCode\r
- EfiBootScriptWidthUint32, // Width\r
- (UINT64)FW_CFG_IO_DMA_ADDRESS, // Address\r
- (UINTN)2, // Count\r
- &AccessAddress // Buffer\r
- );\r
- if (EFI_ERROR (Status)) {\r
- DEBUG ((DEBUG_ERROR, "%a:%d: EFI_BOOT_SCRIPT_IO_WRITE_OPCODE: %r\n",\r
- __FUNCTION__, __LINE__, Status));\r
- goto FatalError;\r
- }\r