1 | /** @file
|
---|
2 |
|
---|
3 | This library class defines a set of interfaces for how to process capsule image updates.
|
---|
4 |
|
---|
5 | Copyright (c) 2007 - 2019, Intel Corporation. All rights reserved.<BR>
|
---|
6 | SPDX-License-Identifier: BSD-2-Clause-Patent
|
---|
7 |
|
---|
8 | **/
|
---|
9 |
|
---|
10 | #ifndef __CAPSULE_LIB_H__
|
---|
11 | #define __CAPSULE_LIB_H__
|
---|
12 |
|
---|
13 | //
|
---|
14 | // BOOLEAN Variable to indicate whether system is in the capsule on disk state.
|
---|
15 | //
|
---|
16 | #define COD_RELOCATION_INFO_VAR_NAME L"CodRelocationInfo"
|
---|
17 |
|
---|
18 | /**
|
---|
19 | The firmware checks whether the capsule image is supported
|
---|
20 | by the CapsuleGuid in CapsuleHeader or if there is other specific information in
|
---|
21 | the capsule image.
|
---|
22 |
|
---|
23 | Caution: This function may receive untrusted input.
|
---|
24 |
|
---|
25 | @param CapsuleHeader Pointer to the UEFI capsule image to be checked.
|
---|
26 |
|
---|
27 | @retval EFI_SUCESS Input capsule is supported by firmware.
|
---|
28 | @retval EFI_UNSUPPORTED Input capsule is not supported by the firmware.
|
---|
29 | **/
|
---|
30 | EFI_STATUS
|
---|
31 | EFIAPI
|
---|
32 | SupportCapsuleImage (
|
---|
33 | IN EFI_CAPSULE_HEADER *CapsuleHeader
|
---|
34 | );
|
---|
35 |
|
---|
36 | /**
|
---|
37 | The firmware-specific implementation processes the capsule image
|
---|
38 | if it recognized the format of this capsule image.
|
---|
39 |
|
---|
40 | Caution: This function may receive untrusted input.
|
---|
41 |
|
---|
42 | @param CapsuleHeader Pointer to the UEFI capsule image to be processed.
|
---|
43 |
|
---|
44 | @retval EFI_SUCESS Capsule Image processed successfully.
|
---|
45 | @retval EFI_UNSUPPORTED Capsule image is not supported by the firmware.
|
---|
46 | **/
|
---|
47 | EFI_STATUS
|
---|
48 | EFIAPI
|
---|
49 | ProcessCapsuleImage (
|
---|
50 | IN EFI_CAPSULE_HEADER *CapsuleHeader
|
---|
51 | );
|
---|
52 |
|
---|
53 | /**
|
---|
54 |
|
---|
55 | This routine is called to process capsules.
|
---|
56 |
|
---|
57 | Caution: This function may receive untrusted input.
|
---|
58 |
|
---|
59 | The capsules reported in EFI_HOB_UEFI_CAPSULE are processed.
|
---|
60 | If there is no EFI_HOB_UEFI_CAPSULE, this routine does nothing.
|
---|
61 |
|
---|
62 | This routine should be called twice in BDS.
|
---|
63 | 1) The first call must be before EndOfDxe. The system capsules is processed.
|
---|
64 | If device capsule FMP protocols are exposted at this time and device FMP
|
---|
65 | capsule has zero EmbeddedDriverCount, the device capsules are processed.
|
---|
66 | Each individual capsule result is recorded in capsule record variable.
|
---|
67 | System may reset in this function, if reset is required by capsule and
|
---|
68 | all capsules are processed.
|
---|
69 | If not all capsules are processed, reset will be defered to second call.
|
---|
70 |
|
---|
71 | 2) The second call must be after EndOfDxe and after ConnectAll, so that all
|
---|
72 | device capsule FMP protocols are exposed.
|
---|
73 | The system capsules are skipped. If the device capsules are NOT processed
|
---|
74 | in first call, they are processed here.
|
---|
75 | Each individual capsule result is recorded in capsule record variable.
|
---|
76 | System may reset in this function, if reset is required by capsule
|
---|
77 | processed in first call and second call.
|
---|
78 |
|
---|
79 | @retval EFI_SUCCESS There is no error when processing capsules.
|
---|
80 | @retval EFI_OUT_OF_RESOURCES No enough resource to process capsules.
|
---|
81 |
|
---|
82 | **/
|
---|
83 | EFI_STATUS
|
---|
84 | EFIAPI
|
---|
85 | ProcessCapsules (
|
---|
86 | VOID
|
---|
87 | );
|
---|
88 |
|
---|
89 | /**
|
---|
90 | This routine is called to check if CapsuleOnDisk flag in OsIndications Variable
|
---|
91 | is enabled.
|
---|
92 |
|
---|
93 | @retval TRUE Flag is enabled
|
---|
94 | @retval FALSE Flag is not enabled
|
---|
95 |
|
---|
96 | **/
|
---|
97 | BOOLEAN
|
---|
98 | EFIAPI
|
---|
99 | CoDCheckCapsuleOnDiskFlag (
|
---|
100 | VOID
|
---|
101 | );
|
---|
102 |
|
---|
103 | /**
|
---|
104 | This routine is called to clear CapsuleOnDisk flags including OsIndications and BootNext variable.
|
---|
105 |
|
---|
106 | @retval EFI_SUCCESS All Capsule On Disk flags are cleared
|
---|
107 |
|
---|
108 | **/
|
---|
109 | EFI_STATUS
|
---|
110 | EFIAPI
|
---|
111 | CoDClearCapsuleOnDiskFlag (
|
---|
112 | VOID
|
---|
113 | );
|
---|
114 |
|
---|
115 | /**
|
---|
116 | Relocate Capsule on Disk from EFI system partition.
|
---|
117 |
|
---|
118 | Two solution to deliver Capsule On Disk:
|
---|
119 | Solution A: If PcdCapsuleInRamSupport is enabled, relocate Capsule On Disk to memory and call UpdateCapsule().
|
---|
120 | Solution B: If PcdCapsuleInRamSupport is disabled, relocate Capsule On Disk to a platform-specific NV storage
|
---|
121 | device with BlockIo protocol.
|
---|
122 |
|
---|
123 | Device enumeration like USB costs time, user can input MaxRetry to tell function to retry.
|
---|
124 | Function will stall 100ms between each retry.
|
---|
125 |
|
---|
126 | Side Effects:
|
---|
127 | Capsule Delivery Supported Flag in OsIndication variable and BootNext variable will be cleared.
|
---|
128 | Solution B: Content corruption. Block IO write directly touches low level write. Orignal partitions, file
|
---|
129 | systems of the relocation device will be corrupted.
|
---|
130 |
|
---|
131 | @param[in] MaxRetry Max Connection Retry. Stall 100ms between each connection try to ensure
|
---|
132 | devices like USB can get enumerated. Input 0 means no retry.
|
---|
133 |
|
---|
134 | @retval EFI_SUCCESS Capsule on Disk images are successfully relocated.
|
---|
135 |
|
---|
136 | **/
|
---|
137 | EFI_STATUS
|
---|
138 | EFIAPI
|
---|
139 | CoDRelocateCapsule (
|
---|
140 | UINTN MaxRetry
|
---|
141 | );
|
---|
142 |
|
---|
143 | /**
|
---|
144 | Remove the temp file from the root of EFI System Partition.
|
---|
145 | Device enumeration like USB costs time, user can input MaxRetry to tell function to retry.
|
---|
146 | Function will stall 100ms between each retry.
|
---|
147 |
|
---|
148 | @param[in] MaxRetry Max Connection Retry. Stall 100ms between each connection try to ensure
|
---|
149 | devices like USB can get enumerated. Input 0 means no retry.
|
---|
150 |
|
---|
151 | @retval EFI_SUCCESS Remove the temp file successfully.
|
---|
152 |
|
---|
153 | **/
|
---|
154 | EFI_STATUS
|
---|
155 | EFIAPI
|
---|
156 | CoDRemoveTempFile (
|
---|
157 | UINTN MaxRetry
|
---|
158 | );
|
---|
159 |
|
---|
160 | #endif
|
---|