• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 a
4 power failure happens during the boot block update, the swapped backup block (now the boot block)
5 can boot the machine with the old boot block backed up 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 hardware directly.
7 
8 Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
9 This program and the accompanying materials are licensed and made available under
10 the terms and conditions of the BSD License that accompanies this distribution.
11 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 // Protocol APIs
40 //
41 
42 /**
43   This function gets the address range location of
44   boot block and backup block.
45 
46   @param This             Indicates the calling context.
47   @param BootBlockBase    The base address of current boot block.
48   @param BootBlockSize    The size (in bytes) of current boot block.
49   @param BackupBlockBase  The base address of current backup block.
50   @param BackupBlockSize  The size (in bytes) of current backup block.
51 
52   @retval EFI_SUCCESS  The call was successful.
53 
54 **/
55 typedef
56 EFI_STATUS
57 (EFIAPI *EFI_GET_RANGE_LOCATION)(
58   IN EFI_SWAP_ADDRESS_RANGE_PROTOCOL            *This,
59   OUT EFI_PHYSICAL_ADDRESS                      *BootBlockBase,
60   OUT UINTN                                     *BootBlockSize,
61   OUT EFI_PHYSICAL_ADDRESS                      *BackupBlockBase,
62   OUT UINTN                                     *BackupBlockSize
63   );
64 
65 /**
66   This service checks if the boot block and backup block has been swapped.
67 
68   @param This          Indicates the calling context.
69   @param SwapState     True if the boot block and backup block has been swapped.
70                        False if the boot block and backup block has not been swapped.
71 
72   @retval EFI_SUCCESS  The call was successful.
73 
74 **/
75 typedef
76 EFI_STATUS
77 (EFIAPI *EFI_GET_SWAP_STATE)(
78   IN EFI_SWAP_ADDRESS_RANGE_PROTOCOL            *This,
79   OUT BOOLEAN                                   *SwapState
80   );
81 
82 /**
83   This service swaps the boot block and backup block, or swaps them back.
84 
85   It also acquires and releases software swap lock during operation. The setting of the new swap state
86   is not affected by the old swap state.
87 
88   @param This            Indicates the calling context.
89   @param NewSwapState    True to swap real boot block and backup block, False to swap them back.
90 
91   @retval EFI_SUCCESS  The call was successful.
92   @retval EFI_ABORTED  Set swap state error.
93 
94 **/
95 typedef
96 EFI_STATUS
97 (EFIAPI *EFI_SET_SWAP_STATE)(
98   IN EFI_SWAP_ADDRESS_RANGE_PROTOCOL            *This,
99   IN BOOLEAN                                    NewSwapState
100   );
101 
102 
103 
104 /**
105   This service checks if a Real Time Clock (RTC) power failure happened.
106 
107   If parameter RtcPowerFailed is true after the function returns, RTC power supply failed or was removed.
108   It is recommended to check RTC power status before calling GetSwapState().
109 
110   @param This             Indicates the calling context.
111   @param RtcPowerFailed   True if the RTC (Real Time Clock) power failed or was removed.
112 
113   @retval EFI_SUCCESS The call was successful.
114 
115 **/
116 typedef
117 EFI_STATUS
118 (EFIAPI *EFI_GET_RTC_POWER_STATUS)(
119   IN EFI_SWAP_ADDRESS_RANGE_PROTOCOL            *This,
120   OUT BOOLEAN                                   *RtcPowerFailed
121   );
122 
123 /**
124   This service returns all lock methods for swap operations that the current platform
125   supports. Could be software lock, hardware lock, or unsupport lock.
126   Note that software and hardware lock methods can be used simultaneously.
127 
128   @param This             Indicates the calling context.
129   @param LockCapability   The current lock method for swap operations.
130 
131   @retval EFI_SUCCESS The call was successful.
132 
133 **/
134 typedef
135 EFI_STATUS
136 (EFIAPI *EFI_GET_SWAP_LOCK_CAPABILITY)(
137   IN EFI_SWAP_ADDRESS_RANGE_PROTOCOL            *This,
138   OUT EFI_SWAP_LOCK_CAPABILITY                  *LockCapability
139   );
140 
141 
142 
143 /**
144   This service is used to acquire or release appointed kind of lock for Swap Address Range operations.
145 
146   Note that software and hardware lock mothod can be used simultaneously.
147 
148   @param This              Indicates the calling context.
149   @param LockCapability    Indicates which lock to acquire or release.
150   @param NewLockState      True to acquire lock; False to release lock.
151 
152   @retval EFI_SUCCESS The call was successful.
153 
154 **/
155 typedef
156 EFI_STATUS
157 (EFIAPI *EFI_SET_SWAP_LOCK)(
158   IN EFI_SWAP_ADDRESS_RANGE_PROTOCOL            *This,
159   IN EFI_SWAP_LOCK_CAPABILITY                   LockCapability,
160   IN BOOLEAN                                    NewLockState
161   );
162 
163 struct _EFI_SWAP_ADDRESS_RANGE_PROTOCOL {
164   EFI_GET_RANGE_LOCATION        GetRangeLocation;       // has output parameters for base and length
165   EFI_GET_SWAP_STATE            GetSwapState;           // are ranges swapped or not
166   EFI_SET_SWAP_STATE            SetSwapState;           // swap or unswap ranges
167   EFI_GET_RTC_POWER_STATUS      GetRtcPowerStatus;      // checks RTC battery, or whatever...
168   EFI_GET_SWAP_LOCK_CAPABILITY  GetSwapLockCapability;  // Get TOP_SWAP lock capability,
169   EFI_SET_SWAP_LOCK             SetSwapLock;            // Set TOP_SWAP lock state
170 };
171 
172 extern EFI_GUID gEfiSwapAddressRangeProtocolGuid;
173 
174 #endif
175