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