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