]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Include/Protocol/SwapAddressRange.h
MdeModulePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / MdeModulePkg / Include / Protocol / SwapAddressRange.h
CommitLineData
85e923a5 1/** @file\r
d1102dba
LG
2The EFI_SWAP_ADDRESS_RANGE_PROTOCOL is used to abstract the swap operation of boot block\r
3and backup block of FV. This swap is especially needed when updating the boot block of FV. If a\r
4power failure happens during the boot block update, the swapped backup block (now the boot block)\r
5can boot the machine with the old boot block backed up in it. The swap operation is platform dependent, so\r
e9b67286 6other protocols such as FTW (Fault Tolerant Write) should use this protocol instead of handling hardware directly.\r
85e923a5 7\r
d1102dba 8Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>\r
9d510e61 9SPDX-License-Identifier: BSD-2-Clause-Patent\r
85e923a5
LG
10\r
11**/\r
12\r
13#ifndef _EFI_SWAP_ADDRESS_RANGE_PROTOCOL_H_\r
14#define _EFI_SWAP_ADDRESS_RANGE_PROTOCOL_H_\r
15\r
16#define EFI_SWAP_ADDRESS_RANGE_PROTOCOL_GUID \\r
17 { \\r
18 0x1259f60d, 0xb754, 0x468e, {0xa7, 0x89, 0x4d, 0xb8, 0x5d, 0x55, 0xe8, 0x7e } \\r
19 }\r
20\r
21//\r
22// Forward reference for pure ANSI compatability\r
23//\r
24typedef struct _EFI_SWAP_ADDRESS_RANGE_PROTOCOL EFI_SWAP_ADDRESS_RANGE_PROTOCOL;\r
25\r
26#define EFI_UNSUPPORT_LOCK 0\r
27#define EFI_SOFTWARE_LOCK 1\r
28#define EFI_HARDWARE_LOCK 2\r
29\r
30typedef UINT8 EFI_SWAP_LOCK_CAPABILITY;\r
31\r
32//\r
e9b67286 33// Protocol APIs\r
85e923a5
LG
34//\r
35\r
36/**\r
d1102dba
LG
37 This function gets the address range location of\r
38 boot block and backup block.\r
85e923a5 39\r
d1102dba 40 @param This Indicates the calling context.\r
64a80549 41 @param BootBlockBase The base address of current boot block.\r
42 @param BootBlockSize The size (in bytes) of current boot block.\r
43 @param BackupBlockBase The base address of current backup block.\r
44 @param BackupBlockSize The size (in bytes) of current backup block.\r
85e923a5 45\r
e40b7d5d 46 @retval EFI_SUCCESS The call was successful.\r
d1102dba 47\r
85e923a5
LG
48**/\r
49typedef\r
50EFI_STATUS\r
0c1a4aa6 51(EFIAPI *EFI_GET_RANGE_LOCATION)(\r
e40b7d5d
LG
52 IN EFI_SWAP_ADDRESS_RANGE_PROTOCOL *This,\r
53 OUT EFI_PHYSICAL_ADDRESS *BootBlockBase,\r
85e923a5 54 OUT UINTN *BootBlockSize,\r
e40b7d5d 55 OUT EFI_PHYSICAL_ADDRESS *BackupBlockBase,\r
85e923a5
LG
56 OUT UINTN *BackupBlockSize\r
57 );\r
58\r
59/**\r
60 This service checks if the boot block and backup block has been swapped.\r
61\r
d1102dba
LG
62 @param This Indicates the calling context.\r
63 @param SwapState True if the boot block and backup block has been swapped.\r
e40b7d5d 64 False if the boot block and backup block has not been swapped.\r
85e923a5 65\r
e40b7d5d 66 @retval EFI_SUCCESS The call was successful.\r
d1102dba 67\r
85e923a5
LG
68**/\r
69typedef\r
70EFI_STATUS\r
0c1a4aa6 71(EFIAPI *EFI_GET_SWAP_STATE)(\r
e40b7d5d 72 IN EFI_SWAP_ADDRESS_RANGE_PROTOCOL *This,\r
85e923a5
LG
73 OUT BOOLEAN *SwapState\r
74 );\r
75\r
76/**\r
77 This service swaps the boot block and backup block, or swaps them back.\r
78\r
d1102dba 79 It also acquires and releases software swap lock during operation. The setting of the new swap state\r
85e923a5
LG
80 is not affected by the old swap state.\r
81\r
d1102dba 82 @param This Indicates the calling context.\r
e40b7d5d 83 @param NewSwapState True to swap real boot block and backup block, False to swap them back.\r
85e923a5 84\r
e40b7d5d 85 @retval EFI_SUCCESS The call was successful.\r
64a80549 86 @retval EFI_ABORTED Set swap state error.\r
d1102dba 87\r
85e923a5
LG
88**/\r
89typedef\r
90EFI_STATUS\r
0c1a4aa6 91(EFIAPI *EFI_SET_SWAP_STATE)(\r
e40b7d5d 92 IN EFI_SWAP_ADDRESS_RANGE_PROTOCOL *This,\r
85e923a5
LG
93 IN BOOLEAN NewSwapState\r
94 );\r
95\r
96\r
97\r
98/**\r
e9b67286 99 This service checks if a Real Time Clock (RTC) power failure happened.\r
85e923a5 100\r
d1102dba 101 If parameter RtcPowerFailed is true after the function returns, RTC power supply failed or was removed.\r
e9b67286 102 It is recommended to check RTC power status before calling GetSwapState().\r
85e923a5 103\r
d1102dba
LG
104 @param This Indicates the calling context.\r
105 @param RtcPowerFailed True if the RTC (Real Time Clock) power failed or was removed.\r
85e923a5
LG
106\r
107 @retval EFI_SUCCESS The call was successful.\r
d1102dba 108\r
85e923a5
LG
109**/\r
110typedef\r
111EFI_STATUS\r
0c1a4aa6 112(EFIAPI *EFI_GET_RTC_POWER_STATUS)(\r
e40b7d5d 113 IN EFI_SWAP_ADDRESS_RANGE_PROTOCOL *This,\r
85e923a5
LG
114 OUT BOOLEAN *RtcPowerFailed\r
115 );\r
116\r
117/**\r
d1102dba 118 This service returns all lock methods for swap operations that the current platform\r
64a80549 119 supports. Could be software lock, hardware lock, or unsupport lock.\r
e40b7d5d 120 Note that software and hardware lock methods can be used simultaneously.\r
85e923a5 121\r
b4f26bb1 122 @param This Indicates the calling context.\r
d1102dba 123 @param LockCapability The current lock method for swap operations.\r
85e923a5
LG
124\r
125 @retval EFI_SUCCESS The call was successful.\r
d1102dba 126\r
85e923a5
LG
127**/\r
128typedef\r
129EFI_STATUS\r
0c1a4aa6 130(EFIAPI *EFI_GET_SWAP_LOCK_CAPABILITY)(\r
e40b7d5d
LG
131 IN EFI_SWAP_ADDRESS_RANGE_PROTOCOL *This,\r
132 OUT EFI_SWAP_LOCK_CAPABILITY *LockCapability\r
85e923a5
LG
133 );\r
134\r
135\r
136\r
137/**\r
64a80549 138 This service is used to acquire or release appointed kind of lock for Swap Address Range operations.\r
85e923a5 139\r
85e923a5
LG
140 Note that software and hardware lock mothod can be used simultaneously.\r
141\r
b4f26bb1 142 @param This Indicates the calling context.\r
85e923a5 143 @param LockCapability Indicates which lock to acquire or release.\r
64a80549 144 @param NewLockState True to acquire lock; False to release lock.\r
85e923a5
LG
145\r
146 @retval EFI_SUCCESS The call was successful.\r
d1102dba 147\r
85e923a5
LG
148**/\r
149typedef\r
150EFI_STATUS\r
0c1a4aa6 151(EFIAPI *EFI_SET_SWAP_LOCK)(\r
e40b7d5d 152 IN EFI_SWAP_ADDRESS_RANGE_PROTOCOL *This,\r
85e923a5
LG
153 IN EFI_SWAP_LOCK_CAPABILITY LockCapability,\r
154 IN BOOLEAN NewLockState\r
155 );\r
156\r
157struct _EFI_SWAP_ADDRESS_RANGE_PROTOCOL {\r
158 EFI_GET_RANGE_LOCATION GetRangeLocation; // has output parameters for base and length\r
159 EFI_GET_SWAP_STATE GetSwapState; // are ranges swapped or not\r
160 EFI_SET_SWAP_STATE SetSwapState; // swap or unswap ranges\r
161 EFI_GET_RTC_POWER_STATUS GetRtcPowerStatus; // checks RTC battery, or whatever...\r
162 EFI_GET_SWAP_LOCK_CAPABILITY GetSwapLockCapability; // Get TOP_SWAP lock capability,\r
163 EFI_SET_SWAP_LOCK SetSwapLock; // Set TOP_SWAP lock state\r
164};\r
165\r
166extern EFI_GUID gEfiSwapAddressRangeProtocolGuid;\r
167\r
168#endif\r