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