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