]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Include/Protocol/SwapAddressRange.h
fix build error
[mirror_edk2.git] / MdeModulePkg / Include / Protocol / SwapAddressRange.h
CommitLineData
85e923a5
LG
1/** @file\r
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 any \r
e9b67286 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
6other protocols such as FTW (Fault Tolerant Write) should use this protocol instead of handling hardware directly.\r
85e923a5
LG
7\r
8Copyright (c) 2009, Intel Corporation \r
9All rights reserved. This program and the accompanying materials \r
10are licensed and made available under the terms and conditions of the BSD License \r
11which accompanies this distribution. The full text of the license may be found at \r
12http://opensource.org/licenses/bsd-license.php \r
13 \r
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
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
e9b67286 43 This function gets the address range location of \r
85e923a5
LG
44 boot block and backup block. \r
45\r
e40b7d5d
LG
46 @param This Indicates the calling context. \r
47 @param BootBlockBase Base address of current boot block.\r
48 @param BootBlockSize Size (in bytes) of current boot block.\r
49 @param BackupBlockBase Base address of current backup block.\r
50 @param BackupBlockSize Size (in bytes) of current backup block.\r
85e923a5 51\r
e40b7d5d 52 @retval EFI_SUCCESS The call was successful.\r
85e923a5
LG
53 \r
54**/\r
55typedef\r
56EFI_STATUS\r
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
e40b7d5d
LG
68 @param This Indicates the calling context. \r
69 @param SwapState True if the boot block and backup block has been swapped. \r
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
85e923a5
LG
73 \r
74**/\r
75typedef\r
76EFI_STATUS\r
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
e9b67286 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
e40b7d5d
LG
88 @param This Indicates the calling context. \r
89 @param NewSwapState True to swap real boot block and backup block, False to swap them back.\r
85e923a5 90\r
e40b7d5d
LG
91 @retval EFI_SUCCESS The call was successful.\r
92 @retval EFI_ABORTED Set swap state error\r
85e923a5
LG
93 \r
94**/\r
95typedef\r
96EFI_STATUS\r
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
e9b67286 107 If parameter RtcPowerFailed is true after the function returns, RTC power supply failed or was removed. \r
108 It is recommended to check RTC power status before calling GetSwapState().\r
85e923a5 109\r
b4f26bb1 110 @param This Indicates the calling context. \r
e9b67286 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
114 \r
115**/\r
116typedef\r
117EFI_STATUS\r
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
e9b67286 124 This service returns all lock methods for swap operations that the current platform supports. Could be software lock, hardware lock, or unsupport lock.\r
e40b7d5d 125 Note that software and hardware lock methods can be used simultaneously.\r
85e923a5 126\r
b4f26bb1 127 @param This Indicates the calling context.\r
e40b7d5d 128 @param LockCapability Current lock method for swap operation. \r
85e923a5
LG
129\r
130 @retval EFI_SUCCESS The call was successful.\r
131 \r
132**/\r
133typedef\r
134EFI_STATUS\r
135(EFIAPI *EFI_GET_SWAP_LOCK_CAPABILITY) (\r
e40b7d5d
LG
136 IN EFI_SWAP_ADDRESS_RANGE_PROTOCOL *This,\r
137 OUT EFI_SWAP_LOCK_CAPABILITY *LockCapability\r
85e923a5
LG
138 );\r
139\r
140\r
141\r
142/**\r
143 This service is used to acquire or release appointed kind of lock for Swap Address Range operation.\r
144\r
85e923a5
LG
145 Note that software and hardware lock mothod can be used simultaneously.\r
146\r
b4f26bb1 147 @param This Indicates the calling context.\r
85e923a5 148 @param LockCapability Indicates which lock to acquire or release.\r
b4f26bb1 149 @param NewLockState True to acquire lock, False to release lock.\r
85e923a5
LG
150\r
151 @retval EFI_SUCCESS The call was successful.\r
152 \r
153**/\r
154typedef\r
155EFI_STATUS\r
156(EFIAPI *EFI_SET_SWAP_LOCK) (\r
e40b7d5d 157 IN EFI_SWAP_ADDRESS_RANGE_PROTOCOL *This,\r
85e923a5
LG
158 IN EFI_SWAP_LOCK_CAPABILITY LockCapability,\r
159 IN BOOLEAN NewLockState\r
160 );\r
161\r
162struct _EFI_SWAP_ADDRESS_RANGE_PROTOCOL {\r
163 EFI_GET_RANGE_LOCATION GetRangeLocation; // has output parameters for base and length\r
164 EFI_GET_SWAP_STATE GetSwapState; // are ranges swapped or not\r
165 EFI_SET_SWAP_STATE SetSwapState; // swap or unswap ranges\r
166 EFI_GET_RTC_POWER_STATUS GetRtcPowerStatus; // checks RTC battery, or whatever...\r
167 EFI_GET_SWAP_LOCK_CAPABILITY GetSwapLockCapability; // Get TOP_SWAP lock capability,\r
168 EFI_SET_SWAP_LOCK SetSwapLock; // Set TOP_SWAP lock state\r
169};\r
170\r
171extern EFI_GUID gEfiSwapAddressRangeProtocolGuid;\r
172\r
173#endif\r