]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - MdeModulePkg/Include/Protocol/SwapAddressRange.h
Patch from open source community for CryptoPkg to allow it to build for ARM using...
[mirror_edk2.git] / MdeModulePkg / Include / Protocol / SwapAddressRange.h
... / ...
CommitLineData
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 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
6other protocols such as FTW (Fault Tolerant Write) should use this protocol instead of handling hardware directly.\r
7\r
8Copyright (c) 2009 - 2010, 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
11The 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
39// Protocol APIs\r
40//\r
41\r
42/**\r
43 This function gets the address range location of \r
44 boot block and backup block. \r
45\r
46 @param This Indicates the calling context. \r
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
51\r
52 @retval EFI_SUCCESS The call was successful.\r
53 \r
54**/\r
55typedef\r
56EFI_STATUS\r
57(EFIAPI *EFI_GET_RANGE_LOCATION)(\r
58 IN EFI_SWAP_ADDRESS_RANGE_PROTOCOL *This,\r
59 OUT EFI_PHYSICAL_ADDRESS *BootBlockBase,\r
60 OUT UINTN *BootBlockSize,\r
61 OUT EFI_PHYSICAL_ADDRESS *BackupBlockBase,\r
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
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
71\r
72 @retval EFI_SUCCESS The call was successful.\r
73 \r
74**/\r
75typedef\r
76EFI_STATUS\r
77(EFIAPI *EFI_GET_SWAP_STATE)(\r
78 IN EFI_SWAP_ADDRESS_RANGE_PROTOCOL *This,\r
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
85 It also acquires and releases software swap lock during operation. The setting of the new swap state \r
86 is not affected by the old swap state.\r
87\r
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
90\r
91 @retval EFI_SUCCESS The call was successful.\r
92 @retval EFI_ABORTED Set swap state error.\r
93 \r
94**/\r
95typedef\r
96EFI_STATUS\r
97(EFIAPI *EFI_SET_SWAP_STATE)(\r
98 IN EFI_SWAP_ADDRESS_RANGE_PROTOCOL *This,\r
99 IN BOOLEAN NewSwapState\r
100 );\r
101\r
102\r
103\r
104/**\r
105 This service checks if a Real Time Clock (RTC) power failure happened.\r
106\r
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
109\r
110 @param This Indicates the calling context. \r
111 @param RtcPowerFailed True if the RTC (Real Time Clock) power failed or was removed. \r
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
119 IN EFI_SWAP_ADDRESS_RANGE_PROTOCOL *This,\r
120 OUT BOOLEAN *RtcPowerFailed\r
121 );\r
122\r
123/**\r
124 This service returns all lock methods for swap operations that the current platform \r
125 supports. Could be software lock, hardware lock, or unsupport lock.\r
126 Note that software and hardware lock methods can be used simultaneously.\r
127\r
128 @param This Indicates the calling context.\r
129 @param LockCapability The current lock method for swap operations. \r
130\r
131 @retval EFI_SUCCESS The call was successful.\r
132 \r
133**/\r
134typedef\r
135EFI_STATUS\r
136(EFIAPI *EFI_GET_SWAP_LOCK_CAPABILITY)(\r
137 IN EFI_SWAP_ADDRESS_RANGE_PROTOCOL *This,\r
138 OUT EFI_SWAP_LOCK_CAPABILITY *LockCapability\r
139 );\r
140\r
141\r
142\r
143/**\r
144 This service is used to acquire or release appointed kind of lock for Swap Address Range operations.\r
145\r
146 Note that software and hardware lock mothod can be used simultaneously.\r
147\r
148 @param This Indicates the calling context.\r
149 @param LockCapability Indicates which lock to acquire or release.\r
150 @param NewLockState True to acquire lock; False to release lock.\r
151\r
152 @retval EFI_SUCCESS The call was successful.\r
153 \r
154**/\r
155typedef\r
156EFI_STATUS\r
157(EFIAPI *EFI_SET_SWAP_LOCK)(\r
158 IN EFI_SWAP_ADDRESS_RANGE_PROTOCOL *This,\r
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