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 - 2018, Intel Corporation. All rights reserved.<BR>
|
---|
9 | SPDX-License-Identifier: BSD-2-Clause-Patent
|
---|
10 |
|
---|
11 | **/
|
---|
12 |
|
---|
13 | #ifndef _EFI_SWAP_ADDRESS_RANGE_PROTOCOL_H_
|
---|
14 | #define _EFI_SWAP_ADDRESS_RANGE_PROTOCOL_H_
|
---|
15 |
|
---|
16 | #define EFI_SWAP_ADDRESS_RANGE_PROTOCOL_GUID \
|
---|
17 | { \
|
---|
18 | 0x1259f60d, 0xb754, 0x468e, {0xa7, 0x89, 0x4d, 0xb8, 0x5d, 0x55, 0xe8, 0x7e } \
|
---|
19 | }
|
---|
20 |
|
---|
21 | //
|
---|
22 | // Forward reference for pure ANSI compatability
|
---|
23 | //
|
---|
24 | typedef struct _EFI_SWAP_ADDRESS_RANGE_PROTOCOL EFI_SWAP_ADDRESS_RANGE_PROTOCOL;
|
---|
25 |
|
---|
26 | #define EFI_UNSUPPORT_LOCK 0
|
---|
27 | #define EFI_SOFTWARE_LOCK 1
|
---|
28 | #define EFI_HARDWARE_LOCK 2
|
---|
29 |
|
---|
30 | typedef UINT8 EFI_SWAP_LOCK_CAPABILITY;
|
---|
31 |
|
---|
32 | //
|
---|
33 | // Protocol APIs
|
---|
34 | //
|
---|
35 |
|
---|
36 | /**
|
---|
37 | This function gets the address range location of
|
---|
38 | boot block and backup block.
|
---|
39 |
|
---|
40 | @param This Indicates the calling context.
|
---|
41 | @param BootBlockBase The base address of current boot block.
|
---|
42 | @param BootBlockSize The size (in bytes) of current boot block.
|
---|
43 | @param BackupBlockBase The base address of current backup block.
|
---|
44 | @param BackupBlockSize The size (in bytes) of current backup block.
|
---|
45 |
|
---|
46 | @retval EFI_SUCCESS The call was successful.
|
---|
47 |
|
---|
48 | **/
|
---|
49 | typedef
|
---|
50 | EFI_STATUS
|
---|
51 | (EFIAPI *EFI_GET_RANGE_LOCATION)(
|
---|
52 | IN EFI_SWAP_ADDRESS_RANGE_PROTOCOL *This,
|
---|
53 | OUT EFI_PHYSICAL_ADDRESS *BootBlockBase,
|
---|
54 | OUT UINTN *BootBlockSize,
|
---|
55 | OUT EFI_PHYSICAL_ADDRESS *BackupBlockBase,
|
---|
56 | OUT UINTN *BackupBlockSize
|
---|
57 | );
|
---|
58 |
|
---|
59 | /**
|
---|
60 | This service checks if the boot block and backup block has been swapped.
|
---|
61 |
|
---|
62 | @param This Indicates the calling context.
|
---|
63 | @param SwapState True if the boot block and backup block has been swapped.
|
---|
64 | False if the boot block and backup block has not been swapped.
|
---|
65 |
|
---|
66 | @retval EFI_SUCCESS The call was successful.
|
---|
67 |
|
---|
68 | **/
|
---|
69 | typedef
|
---|
70 | EFI_STATUS
|
---|
71 | (EFIAPI *EFI_GET_SWAP_STATE)(
|
---|
72 | IN EFI_SWAP_ADDRESS_RANGE_PROTOCOL *This,
|
---|
73 | OUT BOOLEAN *SwapState
|
---|
74 | );
|
---|
75 |
|
---|
76 | /**
|
---|
77 | This service swaps the boot block and backup block, or swaps them back.
|
---|
78 |
|
---|
79 | It also acquires and releases software swap lock during operation. The setting of the new swap state
|
---|
80 | is not affected by the old swap state.
|
---|
81 |
|
---|
82 | @param This Indicates the calling context.
|
---|
83 | @param NewSwapState True to swap real boot block and backup block, False to swap them back.
|
---|
84 |
|
---|
85 | @retval EFI_SUCCESS The call was successful.
|
---|
86 | @retval EFI_ABORTED Set swap state error.
|
---|
87 |
|
---|
88 | **/
|
---|
89 | typedef
|
---|
90 | EFI_STATUS
|
---|
91 | (EFIAPI *EFI_SET_SWAP_STATE)(
|
---|
92 | IN EFI_SWAP_ADDRESS_RANGE_PROTOCOL *This,
|
---|
93 | IN BOOLEAN NewSwapState
|
---|
94 | );
|
---|
95 |
|
---|
96 | /**
|
---|
97 | This service checks if a Real Time Clock (RTC) power failure happened.
|
---|
98 |
|
---|
99 | If parameter RtcPowerFailed is true after the function returns, RTC power supply failed or was removed.
|
---|
100 | It is recommended to check RTC power status before calling GetSwapState().
|
---|
101 |
|
---|
102 | @param This Indicates the calling context.
|
---|
103 | @param RtcPowerFailed True if the RTC (Real Time Clock) power failed or was removed.
|
---|
104 |
|
---|
105 | @retval EFI_SUCCESS The call was successful.
|
---|
106 |
|
---|
107 | **/
|
---|
108 | typedef
|
---|
109 | EFI_STATUS
|
---|
110 | (EFIAPI *EFI_GET_RTC_POWER_STATUS)(
|
---|
111 | IN EFI_SWAP_ADDRESS_RANGE_PROTOCOL *This,
|
---|
112 | OUT BOOLEAN *RtcPowerFailed
|
---|
113 | );
|
---|
114 |
|
---|
115 | /**
|
---|
116 | This service returns all lock methods for swap operations that the current platform
|
---|
117 | supports. Could be software lock, hardware lock, or unsupport lock.
|
---|
118 | Note that software and hardware lock methods can be used simultaneously.
|
---|
119 |
|
---|
120 | @param This Indicates the calling context.
|
---|
121 | @param LockCapability The current lock method for swap operations.
|
---|
122 |
|
---|
123 | @retval EFI_SUCCESS The call was successful.
|
---|
124 |
|
---|
125 | **/
|
---|
126 | typedef
|
---|
127 | EFI_STATUS
|
---|
128 | (EFIAPI *EFI_GET_SWAP_LOCK_CAPABILITY)(
|
---|
129 | IN EFI_SWAP_ADDRESS_RANGE_PROTOCOL *This,
|
---|
130 | OUT EFI_SWAP_LOCK_CAPABILITY *LockCapability
|
---|
131 | );
|
---|
132 |
|
---|
133 | /**
|
---|
134 | This service is used to acquire or release appointed kind of lock for Swap Address Range operations.
|
---|
135 |
|
---|
136 | Note that software and hardware lock mothod can be used simultaneously.
|
---|
137 |
|
---|
138 | @param This Indicates the calling context.
|
---|
139 | @param LockCapability Indicates which lock to acquire or release.
|
---|
140 | @param NewLockState True to acquire lock; False to release lock.
|
---|
141 |
|
---|
142 | @retval EFI_SUCCESS The call was successful.
|
---|
143 |
|
---|
144 | **/
|
---|
145 | typedef
|
---|
146 | EFI_STATUS
|
---|
147 | (EFIAPI *EFI_SET_SWAP_LOCK)(
|
---|
148 | IN EFI_SWAP_ADDRESS_RANGE_PROTOCOL *This,
|
---|
149 | IN EFI_SWAP_LOCK_CAPABILITY LockCapability,
|
---|
150 | IN BOOLEAN NewLockState
|
---|
151 | );
|
---|
152 |
|
---|
153 | struct _EFI_SWAP_ADDRESS_RANGE_PROTOCOL {
|
---|
154 | EFI_GET_RANGE_LOCATION GetRangeLocation; // has output parameters for base and length
|
---|
155 | EFI_GET_SWAP_STATE GetSwapState; // are ranges swapped or not
|
---|
156 | EFI_SET_SWAP_STATE SetSwapState; // swap or unswap ranges
|
---|
157 | EFI_GET_RTC_POWER_STATUS GetRtcPowerStatus; // checks RTC battery, or whatever...
|
---|
158 | EFI_GET_SWAP_LOCK_CAPABILITY GetSwapLockCapability; // Get TOP_SWAP lock capability,
|
---|
159 | EFI_SET_SWAP_LOCK SetSwapLock; // Set TOP_SWAP lock state
|
---|
160 | };
|
---|
161 |
|
---|
162 | extern EFI_GUID gEfiSwapAddressRangeProtocolGuid;
|
---|
163 |
|
---|
164 | #endif
|
---|