]> git.proxmox.com Git - mirror_edk2.git/blame - Nt32Pkg/PlatformBdsDxe/Generic/Capsules.c
Set default guid tool path for Lzma and Tiano compress tool.
[mirror_edk2.git] / Nt32Pkg / PlatformBdsDxe / Generic / Capsules.c
CommitLineData
bc11b829 1/*++\r
2\r
3Copyright (c) 2006, Intel Corporation \r
4All rights reserved. This program and the accompanying materials \r
5are licensed and made available under the terms and conditions of the BSD License \r
6which accompanies this distribution. The full text of the license may be found at \r
7http://opensource.org/licenses/bsd-license.php \r
8 \r
9THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
10WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
11\r
12Module Name:\r
13\r
14 Capsules.c\r
15\r
16Abstract:\r
17\r
18 BDS routines to handle capsules.\r
19\r
20--*/\r
21\r
22\r
23//\r
24// Include common header file for this module.\r
25//\r
26#include "CommonHeader.h"\r
27\r
28#include <Common/FlashMap.H>\r
29\r
30VOID\r
31BdsLockFv (\r
32 IN EFI_CPU_IO_PROTOCOL *CpuIo,\r
33 IN EFI_FLASH_SUBAREA_ENTRY *FlashEntry\r
34 );\r
35\r
36VOID\r
37BdsLockFv (\r
38 IN EFI_CPU_IO_PROTOCOL *CpuIo,\r
39 IN EFI_FLASH_SUBAREA_ENTRY *FlashEntry\r
40 )\r
41{\r
bc11b829 42}\r
43\r
44VOID\r
45BdsLockNonUpdatableFlash (\r
46 VOID\r
47 )\r
48{\r
bc11b829 49}\r
50\r
51EFI_STATUS\r
52ProcessCapsules (\r
53 EFI_BOOT_MODE BootMode\r
54 )\r
55/*++\r
56\r
57Routine Description:\r
58\r
59 This routine is called to see if there are any capsules we need to process.\r
60 If the boot mode is not UPDATE, then we do nothing. Otherwise find the\r
61 capsule HOBS and produce firmware volumes for them via the DXE service.\r
62 Then call the dispatcher to dispatch drivers from them. Finally, check\r
63 the status of the updates.\r
64\r
65Arguments:\r
66\r
67 BootMode - the current boot mode\r
68\r
69Returns:\r
70 \r
71 EFI_INVALID_PARAMETER - boot mode is not correct for an update\r
72\r
73Note:\r
74 \r
75 This function should be called by BDS in case we need to do some\r
76 sort of processing even if there is no capsule to process. We\r
77 need to do this if an earlier update went awry and we need to\r
78 clear the capsule variable so on the next reset PEI does not see it and \r
79 think there is a capsule available.\r
80\r
81--*/\r
82{\r
83 EFI_STATUS Status;\r
84 EFI_HOB_CAPSULE_VOLUME *CvHob;\r
85 EFI_PHYSICAL_ADDRESS BaseAddress;\r
86 UINT64 Length;\r
87 EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader;\r
88 EFI_HANDLE FvProtocolHandle;\r
89\r
90 //\r
91 // We don't do anything else if the boot mode is not flash-update\r
92 //\r
93 if (BootMode != BOOT_ON_FLASH_UPDATE) {\r
94 return EFI_INVALID_PARAMETER;\r
95 }\r
96 //\r
97 // Only one capsule HOB allowed.\r
98 //\r
99 CvHob = GetFirstHob (EFI_HOB_TYPE_CV);\r
100 if (CvHob == NULL) {\r
101 //\r
102 // We didn't find a hob, so had no errors.\r
103 //\r
104 BdsLockNonUpdatableFlash ();\r
105 return EFI_SUCCESS;\r
106 }\r
107 \r
108 BaseAddress = CvHob->BaseAddress;\r
109 Length = CvHob->Length;\r
110\r
111 Status = EFI_SUCCESS;\r
112 //\r
113 // Now walk the capsule and call the core to process each\r
114 // firmware volume in it.\r
115 //\r
116 while (Length != 0) {\r
117 //\r
118 // Point to the next firmware volume header, and then\r
119 // call the DXE service to process it.\r
120 //\r
121 FwVolHeader = (EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) BaseAddress;\r
122 if (FwVolHeader->FvLength > Length) {\r
123 //\r
124 // Notes: need to stuff this status somewhere so that the\r
125 // error can be detected at OS runtime\r
126 //\r
127 Status = EFI_VOLUME_CORRUPTED;\r
128 break;\r
129 }\r
130\r
131 Status = gDS->ProcessFirmwareVolume (\r
132 (VOID *) (UINTN) BaseAddress,\r
133 (UINTN) FwVolHeader->FvLength,\r
134 &FvProtocolHandle\r
135 );\r
136 if (EFI_ERROR (Status)) {\r
137 break;\r
138 }\r
139 //\r
140 // Call the dispatcher to dispatch any drivers from the produced firmware volume\r
141 //\r
142 gDS->Dispatch ();\r
143 //\r
144 // On to the next FV in the capsule\r
145 //\r
146 Length -= FwVolHeader->FvLength;\r
147 BaseAddress = (EFI_PHYSICAL_ADDRESS) ((UINTN) BaseAddress + FwVolHeader->FvLength);\r
148 //\r
149 // Notes: when capsule spec is finalized, if the requirement is made to\r
150 // have each FV in a capsule aligned, then we will need to align the\r
151 // BaseAddress and Length here.\r
152 //\r
153 }\r
154 \r
155\r
156 BdsLockNonUpdatableFlash ();\r
157\r
158 return Status;\r
159}\r
160\r