]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleCache.c
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / MdeModulePkg / Universal / CapsuleRuntimeDxe / CapsuleCache.c
1 /** @file
2 Flush the cache is required for most architectures while do capsule
3 update. It is not support at Runtime.
4
5 Copyright (c) 2018, Linaro, Ltd. All rights reserved.<BR>
6 Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
7
8 SPDX-License-Identifier: BSD-2-Clause-Patent
9
10 **/
11
12 #include "CapsuleService.h"
13
14 #include <Library/CacheMaintenanceLib.h>
15
16 /**
17 Writes Back a range of data cache lines covering a set of capsules in memory.
18
19 Writes Back the data cache lines specified by ScatterGatherList.
20
21 @param ScatterGatherList Physical address of the data structure that
22 describes a set of capsules in memory
23
24 **/
25 VOID
26 CapsuleCacheWriteBack (
27 IN EFI_PHYSICAL_ADDRESS ScatterGatherList
28 )
29 {
30 EFI_CAPSULE_BLOCK_DESCRIPTOR *Desc;
31
32 if (!EfiAtRuntime ()) {
33 Desc = (EFI_CAPSULE_BLOCK_DESCRIPTOR *)(UINTN)ScatterGatherList;
34 do {
35 WriteBackDataCacheRange (
36 (VOID *)(UINTN)Desc,
37 (UINTN)sizeof (*Desc)
38 );
39
40 if (Desc->Length > 0) {
41 WriteBackDataCacheRange (
42 (VOID *)(UINTN)Desc->Union.DataBlock,
43 (UINTN)Desc->Length
44 );
45 Desc++;
46 } else if (Desc->Union.ContinuationPointer > 0) {
47 Desc = (EFI_CAPSULE_BLOCK_DESCRIPTOR *)(UINTN)Desc->Union.ContinuationPointer;
48 }
49 } while (Desc->Length > 0 || Desc->Union.ContinuationPointer > 0);
50
51 WriteBackDataCacheRange (
52 (VOID *)(UINTN)Desc,
53 (UINTN)sizeof (*Desc)
54 );
55 }
56 }