]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Include/Protocol/SwapAddressRange.h
MdeModulePkg/S3SmmInitDone.h: Fix copyright coding style error.
[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
LG
8Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>\r
9This program and the accompanying materials are licensed and made available under\r
10the terms and conditions of the BSD License that accompanies this distribution.\r
64a80549 11The full text of the license may be found at\r
d1102dba 12http://opensource.org/licenses/bsd-license.php.\r
64a80549 13\r
d1102dba
LG
14THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
15WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
85e923a5
LG
16\r
17**/\r
18\r
19#ifndef _EFI_SWAP_ADDRESS_RANGE_PROTOCOL_H_\r
20#define _EFI_SWAP_ADDRESS_RANGE_PROTOCOL_H_\r
21\r
22#define EFI_SWAP_ADDRESS_RANGE_PROTOCOL_GUID \\r
23 { \\r
24 0x1259f60d, 0xb754, 0x468e, {0xa7, 0x89, 0x4d, 0xb8, 0x5d, 0x55, 0xe8, 0x7e } \\r
25 }\r
26\r
27//\r
28// Forward reference for pure ANSI compatability\r
29//\r
30typedef struct _EFI_SWAP_ADDRESS_RANGE_PROTOCOL EFI_SWAP_ADDRESS_RANGE_PROTOCOL;\r
31\r
32#define EFI_UNSUPPORT_LOCK 0\r
33#define EFI_SOFTWARE_LOCK 1\r
34#define EFI_HARDWARE_LOCK 2\r
35\r
36typedef UINT8 EFI_SWAP_LOCK_CAPABILITY;\r
37\r
38//\r
e9b67286 39// Protocol APIs\r
85e923a5
LG
40//\r
41\r
42/**\r
d1102dba
LG
43 This function gets the address range location of\r
44 boot block and backup block.\r
85e923a5 45\r
d1102dba 46 @param This Indicates the calling context.\r
64a80549 47 @param BootBlockBase The base address of current boot block.\r
48 @param BootBlockSize The size (in bytes) of current boot block.\r
49 @param BackupBlockBase The base address of current backup block.\r
50 @param BackupBlockSize The size (in bytes) of current backup block.\r
85e923a5 51\r
e40b7d5d 52 @retval EFI_SUCCESS The call was successful.\r
d1102dba 53\r
85e923a5
LG
54**/\r
55typedef\r
56EFI_STATUS\r
0c1a4aa6 57(EFIAPI *EFI_GET_RANGE_LOCATION)(\r
e40b7d5d
LG
58 IN EFI_SWAP_ADDRESS_RANGE_PROTOCOL *This,\r
59 OUT EFI_PHYSICAL_ADDRESS *BootBlockBase,\r
85e923a5 60 OUT UINTN *BootBlockSize,\r
e40b7d5d 61 OUT EFI_PHYSICAL_ADDRESS *BackupBlockBase,\r
85e923a5
LG
62 OUT UINTN *BackupBlockSize\r
63 );\r
64\r
65/**\r
66 This service checks if the boot block and backup block has been swapped.\r
67\r
d1102dba
LG
68 @param This Indicates the calling context.\r
69 @param SwapState True if the boot block and backup block has been swapped.\r
e40b7d5d 70 False if the boot block and backup block has not been swapped.\r
85e923a5 71\r
e40b7d5d 72 @retval EFI_SUCCESS The call was successful.\r
d1102dba 73\r
85e923a5
LG
74**/\r
75typedef\r
76EFI_STATUS\r
0c1a4aa6 77(EFIAPI *EFI_GET_SWAP_STATE)(\r
e40b7d5d 78 IN EFI_SWAP_ADDRESS_RANGE_PROTOCOL *This,\r
85e923a5
LG
79 OUT BOOLEAN *SwapState\r
80 );\r
81\r
82/**\r
83 This service swaps the boot block and backup block, or swaps them back.\r
84\r
d1102dba 85 It also acquires and releases software swap lock during operation. The setting of the new swap state\r
85e923a5
LG
86 is not affected by the old swap state.\r
87\r
d1102dba 88 @param This Indicates the calling context.\r
e40b7d5d 89 @param NewSwapState True to swap real boot block and backup block, False to swap them back.\r
85e923a5 90\r
e40b7d5d 91 @retval EFI_SUCCESS The call was successful.\r
64a80549 92 @retval EFI_ABORTED Set swap state error.\r
d1102dba 93\r
85e923a5
LG
94**/\r
95typedef\r
96EFI_STATUS\r
0c1a4aa6 97(EFIAPI *EFI_SET_SWAP_STATE)(\r
e40b7d5d 98 IN EFI_SWAP_ADDRESS_RANGE_PROTOCOL *This,\r
85e923a5
LG
99 IN BOOLEAN NewSwapState\r
100 );\r
101\r
102\r
103\r
104/**\r
e9b67286 105 This service checks if a Real Time Clock (RTC) power failure happened.\r
85e923a5 106\r
d1102dba 107 If parameter RtcPowerFailed is true after the function returns, RTC power supply failed or was removed.\r
e9b67286 108 It is recommended to check RTC power status before calling GetSwapState().\r
85e923a5 109\r
d1102dba
LG
110 @param This Indicates the calling context.\r
111 @param RtcPowerFailed True if the RTC (Real Time Clock) power failed or was removed.\r
85e923a5
LG
112\r
113 @retval EFI_SUCCESS The call was successful.\r
d1102dba 114\r
85e923a5
LG
115**/\r
116typedef\r
117EFI_STATUS\r
0c1a4aa6 118(EFIAPI *EFI_GET_RTC_POWER_STATUS)(\r
e40b7d5d 119 IN EFI_SWAP_ADDRESS_RANGE_PROTOCOL *This,\r
85e923a5
LG
120 OUT BOOLEAN *RtcPowerFailed\r
121 );\r
122\r
123/**\r
d1102dba 124 This service returns all lock methods for swap operations that the current platform\r
64a80549 125 supports. Could be software lock, hardware lock, or unsupport lock.\r
e40b7d5d 126 Note that software and hardware lock methods can be used simultaneously.\r
85e923a5 127\r
b4f26bb1 128 @param This Indicates the calling context.\r
d1102dba 129 @param LockCapability The current lock method for swap operations.\r
85e923a5
LG
130\r
131 @retval EFI_SUCCESS The call was successful.\r
d1102dba 132\r
85e923a5
LG
133**/\r
134typedef\r
135EFI_STATUS\r
0c1a4aa6 136(EFIAPI *EFI_GET_SWAP_LOCK_CAPABILITY)(\r
e40b7d5d
LG
137 IN EFI_SWAP_ADDRESS_RANGE_PROTOCOL *This,\r
138 OUT EFI_SWAP_LOCK_CAPABILITY *LockCapability\r
85e923a5
LG
139 );\r
140\r
141\r
142\r
143/**\r
64a80549 144 This service is used to acquire or release appointed kind of lock for Swap Address Range operations.\r
85e923a5 145\r
85e923a5
LG
146 Note that software and hardware lock mothod can be used simultaneously.\r
147\r
b4f26bb1 148 @param This Indicates the calling context.\r
85e923a5 149 @param LockCapability Indicates which lock to acquire or release.\r
64a80549 150 @param NewLockState True to acquire lock; False to release lock.\r
85e923a5
LG
151\r
152 @retval EFI_SUCCESS The call was successful.\r
d1102dba 153\r
85e923a5
LG
154**/\r
155typedef\r
156EFI_STATUS\r
0c1a4aa6 157(EFIAPI *EFI_SET_SWAP_LOCK)(\r
e40b7d5d 158 IN EFI_SWAP_ADDRESS_RANGE_PROTOCOL *This,\r
85e923a5
LG
159 IN EFI_SWAP_LOCK_CAPABILITY LockCapability,\r
160 IN BOOLEAN NewLockState\r
161 );\r
162\r
163struct _EFI_SWAP_ADDRESS_RANGE_PROTOCOL {\r
164 EFI_GET_RANGE_LOCATION GetRangeLocation; // has output parameters for base and length\r
165 EFI_GET_SWAP_STATE GetSwapState; // are ranges swapped or not\r
166 EFI_SET_SWAP_STATE SetSwapState; // swap or unswap ranges\r
167 EFI_GET_RTC_POWER_STATUS GetRtcPowerStatus; // checks RTC battery, or whatever...\r
168 EFI_GET_SWAP_LOCK_CAPABILITY GetSwapLockCapability; // Get TOP_SWAP lock capability,\r
169 EFI_SET_SWAP_LOCK SetSwapLock; // Set TOP_SWAP lock state\r
170};\r
171\r
172extern EFI_GUID gEfiSwapAddressRangeProtocolGuid;\r
173\r
174#endif\r