]>
Commit | Line | Data |
---|---|---|
1 | /** @file\r | |
2 | The EFI_SWAP_ADDRESS_RANGE_PROTOCOL is used to abstract the swap operation of boot block\r | |
3 | and backup block of FV. This swap is especially needed when updating the boot block of FV. If a\r | |
4 | power failure happens during the boot block update, the swapped backup block (now the boot block)\r | |
5 | can boot the machine with the old boot block backed up in it. The swap operation is platform dependent, so\r | |
6 | other protocols such as FTW (Fault Tolerant Write) should use this protocol instead of handling hardware directly.\r | |
7 | \r | |
8 | Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>\r | |
9 | SPDX-License-Identifier: BSD-2-Clause-Patent\r | |
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 | |
24 | typedef 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 | |
30 | typedef UINT8 EFI_SWAP_LOCK_CAPABILITY;\r | |
31 | \r | |
32 | //\r | |
33 | // Protocol APIs\r | |
34 | //\r | |
35 | \r | |
36 | /**\r | |
37 | This function gets the address range location of\r | |
38 | boot block and backup block.\r | |
39 | \r | |
40 | @param This Indicates the calling context.\r | |
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 | |
45 | \r | |
46 | @retval EFI_SUCCESS The call was successful.\r | |
47 | \r | |
48 | **/\r | |
49 | typedef\r | |
50 | EFI_STATUS\r | |
51 | (EFIAPI *EFI_GET_RANGE_LOCATION)(\r | |
52 | IN EFI_SWAP_ADDRESS_RANGE_PROTOCOL *This,\r | |
53 | OUT EFI_PHYSICAL_ADDRESS *BootBlockBase,\r | |
54 | OUT UINTN *BootBlockSize,\r | |
55 | OUT EFI_PHYSICAL_ADDRESS *BackupBlockBase,\r | |
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 | |
62 | @param This Indicates the calling context.\r | |
63 | @param SwapState True if the boot block and backup block has been swapped.\r | |
64 | False if the boot block and backup block has not been swapped.\r | |
65 | \r | |
66 | @retval EFI_SUCCESS The call was successful.\r | |
67 | \r | |
68 | **/\r | |
69 | typedef\r | |
70 | EFI_STATUS\r | |
71 | (EFIAPI *EFI_GET_SWAP_STATE)(\r | |
72 | IN EFI_SWAP_ADDRESS_RANGE_PROTOCOL *This,\r | |
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 | |
79 | It also acquires and releases software swap lock during operation. The setting of the new swap state\r | |
80 | is not affected by the old swap state.\r | |
81 | \r | |
82 | @param This Indicates the calling context.\r | |
83 | @param NewSwapState True to swap real boot block and backup block, False to swap them back.\r | |
84 | \r | |
85 | @retval EFI_SUCCESS The call was successful.\r | |
86 | @retval EFI_ABORTED Set swap state error.\r | |
87 | \r | |
88 | **/\r | |
89 | typedef\r | |
90 | EFI_STATUS\r | |
91 | (EFIAPI *EFI_SET_SWAP_STATE)(\r | |
92 | IN EFI_SWAP_ADDRESS_RANGE_PROTOCOL *This,\r | |
93 | IN BOOLEAN NewSwapState\r | |
94 | );\r | |
95 | \r | |
96 | \r | |
97 | \r | |
98 | /**\r | |
99 | This service checks if a Real Time Clock (RTC) power failure happened.\r | |
100 | \r | |
101 | If parameter RtcPowerFailed is true after the function returns, RTC power supply failed or was removed.\r | |
102 | It is recommended to check RTC power status before calling GetSwapState().\r | |
103 | \r | |
104 | @param This Indicates the calling context.\r | |
105 | @param RtcPowerFailed True if the RTC (Real Time Clock) power failed or was removed.\r | |
106 | \r | |
107 | @retval EFI_SUCCESS The call was successful.\r | |
108 | \r | |
109 | **/\r | |
110 | typedef\r | |
111 | EFI_STATUS\r | |
112 | (EFIAPI *EFI_GET_RTC_POWER_STATUS)(\r | |
113 | IN EFI_SWAP_ADDRESS_RANGE_PROTOCOL *This,\r | |
114 | OUT BOOLEAN *RtcPowerFailed\r | |
115 | );\r | |
116 | \r | |
117 | /**\r | |
118 | This service returns all lock methods for swap operations that the current platform\r | |
119 | supports. Could be software lock, hardware lock, or unsupport lock.\r | |
120 | Note that software and hardware lock methods can be used simultaneously.\r | |
121 | \r | |
122 | @param This Indicates the calling context.\r | |
123 | @param LockCapability The current lock method for swap operations.\r | |
124 | \r | |
125 | @retval EFI_SUCCESS The call was successful.\r | |
126 | \r | |
127 | **/\r | |
128 | typedef\r | |
129 | EFI_STATUS\r | |
130 | (EFIAPI *EFI_GET_SWAP_LOCK_CAPABILITY)(\r | |
131 | IN EFI_SWAP_ADDRESS_RANGE_PROTOCOL *This,\r | |
132 | OUT EFI_SWAP_LOCK_CAPABILITY *LockCapability\r | |
133 | );\r | |
134 | \r | |
135 | \r | |
136 | \r | |
137 | /**\r | |
138 | This service is used to acquire or release appointed kind of lock for Swap Address Range operations.\r | |
139 | \r | |
140 | Note that software and hardware lock mothod can be used simultaneously.\r | |
141 | \r | |
142 | @param This Indicates the calling context.\r | |
143 | @param LockCapability Indicates which lock to acquire or release.\r | |
144 | @param NewLockState True to acquire lock; False to release lock.\r | |
145 | \r | |
146 | @retval EFI_SUCCESS The call was successful.\r | |
147 | \r | |
148 | **/\r | |
149 | typedef\r | |
150 | EFI_STATUS\r | |
151 | (EFIAPI *EFI_SET_SWAP_LOCK)(\r | |
152 | IN EFI_SWAP_ADDRESS_RANGE_PROTOCOL *This,\r | |
153 | IN EFI_SWAP_LOCK_CAPABILITY LockCapability,\r | |
154 | IN BOOLEAN NewLockState\r | |
155 | );\r | |
156 | \r | |
157 | struct _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 | |
166 | extern EFI_GUID gEfiSwapAddressRangeProtocolGuid;\r | |
167 | \r | |
168 | #endif\r |