]> git.proxmox.com Git - mirror_edk2.git/blame - Nt32Pkg/PlatformBdsDxe/Generic/Capsules.c
Remove the old definition in FlashMapHob
[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
40f18da1 22#include "Bds.h"\r
bc11b829 23\r
24VOID\r
25BdsLockNonUpdatableFlash (\r
26 VOID\r
27 )\r
28{\r
bc11b829 29}\r
30\r
31EFI_STATUS\r
32ProcessCapsules (\r
33 EFI_BOOT_MODE BootMode\r
34 )\r
35/*++\r
36\r
37Routine Description:\r
38\r
39 This routine is called to see if there are any capsules we need to process.\r
40 If the boot mode is not UPDATE, then we do nothing. Otherwise find the\r
41 capsule HOBS and produce firmware volumes for them via the DXE service.\r
42 Then call the dispatcher to dispatch drivers from them. Finally, check\r
43 the status of the updates.\r
44\r
45Arguments:\r
46\r
47 BootMode - the current boot mode\r
48\r
49Returns:\r
50 \r
51 EFI_INVALID_PARAMETER - boot mode is not correct for an update\r
52\r
53Note:\r
54 \r
55 This function should be called by BDS in case we need to do some\r
56 sort of processing even if there is no capsule to process. We\r
57 need to do this if an earlier update went awry and we need to\r
58 clear the capsule variable so on the next reset PEI does not see it and \r
59 think there is a capsule available.\r
60\r
61--*/\r
62{\r
63 EFI_STATUS Status;\r
64 EFI_HOB_CAPSULE_VOLUME *CvHob;\r
65 EFI_PHYSICAL_ADDRESS BaseAddress;\r
66 UINT64 Length;\r
67 EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader;\r
68 EFI_HANDLE FvProtocolHandle;\r
69\r
70 //\r
71 // We don't do anything else if the boot mode is not flash-update\r
72 //\r
73 if (BootMode != BOOT_ON_FLASH_UPDATE) {\r
74 return EFI_INVALID_PARAMETER;\r
75 }\r
76 //\r
77 // Only one capsule HOB allowed.\r
78 //\r
79 CvHob = GetFirstHob (EFI_HOB_TYPE_CV);\r
80 if (CvHob == NULL) {\r
81 //\r
82 // We didn't find a hob, so had no errors.\r
83 //\r
84 BdsLockNonUpdatableFlash ();\r
85 return EFI_SUCCESS;\r
86 }\r
87 \r
88 BaseAddress = CvHob->BaseAddress;\r
89 Length = CvHob->Length;\r
90\r
91 Status = EFI_SUCCESS;\r
92 //\r
93 // Now walk the capsule and call the core to process each\r
94 // firmware volume in it.\r
95 //\r
96 while (Length != 0) {\r
97 //\r
98 // Point to the next firmware volume header, and then\r
99 // call the DXE service to process it.\r
100 //\r
101 FwVolHeader = (EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) BaseAddress;\r
102 if (FwVolHeader->FvLength > Length) {\r
103 //\r
104 // Notes: need to stuff this status somewhere so that the\r
105 // error can be detected at OS runtime\r
106 //\r
107 Status = EFI_VOLUME_CORRUPTED;\r
108 break;\r
109 }\r
110\r
111 Status = gDS->ProcessFirmwareVolume (\r
112 (VOID *) (UINTN) BaseAddress,\r
113 (UINTN) FwVolHeader->FvLength,\r
114 &FvProtocolHandle\r
115 );\r
116 if (EFI_ERROR (Status)) {\r
117 break;\r
118 }\r
119 //\r
120 // Call the dispatcher to dispatch any drivers from the produced firmware volume\r
121 //\r
122 gDS->Dispatch ();\r
123 //\r
124 // On to the next FV in the capsule\r
125 //\r
126 Length -= FwVolHeader->FvLength;\r
127 BaseAddress = (EFI_PHYSICAL_ADDRESS) ((UINTN) BaseAddress + FwVolHeader->FvLength);\r
128 //\r
129 // Notes: when capsule spec is finalized, if the requirement is made to\r
130 // have each FV in a capsule aligned, then we will need to align the\r
131 // BaseAddress and Length here.\r
132 //\r
133 }\r
134 \r
135\r
136 BdsLockNonUpdatableFlash ();\r
137\r
138 return Status;\r
139}\r
140\r