]>
Commit | Line | Data |
---|---|---|
5d73d92f | 1 | /** @file\r |
2 | Main file for LoadPciRom shell Debug1 function.\r | |
3 | \r | |
c011b6c9 | 4 | (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>\r |
20cfed16 | 5 | Copyright (c) 2005 - 2016, Intel Corporation. All rights reserved.<BR>\r |
5d73d92f | 6 | This program and the accompanying materials\r |
7 | are licensed and made available under the terms and conditions of the BSD License\r | |
8 | which accompanies this distribution. The full text of the license may be found at\r | |
9 | http://opensource.org/licenses/bsd-license.php\r | |
10 | \r | |
11 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
12 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
13 | \r | |
14 | **/\r | |
15 | \r | |
16 | #include "UefiShellDebug1CommandsLib.h"\r | |
17 | #include <IndustryStandard/Pci22.h>\r | |
18 | #include <IndustryStandard/Pci23.h>\r | |
19 | #include <IndustryStandard/PeImage.h>\r | |
20 | #include <Protocol/Decompress.h>\r | |
21 | \r | |
3737ac2b | 22 | /**\r |
23 | Connects all available drives and controllers.\r | |
24 | \r | |
25 | @retval EFI_SUCCESS The operation was successful.\r | |
26 | @retval EFI_ABORTED The abort mechanism was received.\r | |
27 | **/\r | |
5d73d92f | 28 | EFI_STATUS\r |
29 | EFIAPI\r | |
30 | LoadPciRomConnectAllDriversToAllControllers (\r | |
31 | VOID\r | |
32 | );\r | |
33 | \r | |
3737ac2b | 34 | /**\r |
35 | Command entry point.\r | |
5d73d92f | 36 | \r |
3737ac2b | 37 | @param[in] RomBar The Rom Base address.\r |
38 | @param[in] RomSize The Rom size.\r | |
39 | @param[in] FileName The file name.\r | |
40 | \r | |
41 | @retval EFI_SUCCESS The command completed successfully.\r | |
42 | @retval EFI_INVALID_PARAMETER Command usage error.\r | |
43 | @retval EFI_UNSUPPORTED Protocols unsupported.\r | |
44 | @retval EFI_OUT_OF_RESOURCES Out of memory.\r | |
45 | @retval Other value Unknown error.\r | |
46 | **/\r | |
5d73d92f | 47 | EFI_STATUS\r |
48 | EFIAPI\r | |
49 | LoadEfiDriversFromRomImage (\r | |
50 | VOID *RomBar,\r | |
51 | UINTN RomSize,\r | |
52 | CONST CHAR16 *FileName\r | |
53 | );\r | |
54 | \r | |
55 | STATIC CONST SHELL_PARAM_ITEM ParamList[] = {\r | |
56 | {L"-nc", TypeFlag},\r | |
57 | {NULL, TypeMax}\r | |
58 | };\r | |
59 | \r | |
3737ac2b | 60 | /**\r |
61 | Function for 'loadpcirom' command.\r | |
62 | \r | |
63 | @param[in] ImageHandle Handle to the Image (NULL if Internal).\r | |
64 | @param[in] SystemTable Pointer to the System Table (NULL if Internal).\r | |
65 | **/\r | |
5d73d92f | 66 | SHELL_STATUS\r |
67 | EFIAPI\r | |
68 | ShellCommandRunLoadPciRom (\r | |
69 | IN EFI_HANDLE ImageHandle,\r | |
70 | IN EFI_SYSTEM_TABLE *SystemTable\r | |
71 | )\r | |
72 | {\r | |
73 | EFI_SHELL_FILE_INFO *FileList;\r | |
74 | UINTN SourceSize;\r | |
75 | UINT8 *File1Buffer;\r | |
76 | EFI_STATUS Status;\r | |
77 | LIST_ENTRY *Package;\r | |
78 | CHAR16 *ProblemParam;\r | |
79 | SHELL_STATUS ShellStatus;\r | |
80 | BOOLEAN Connect;\r | |
81 | CONST CHAR16 *Param;\r | |
82 | UINTN ParamCount;\r | |
83 | EFI_SHELL_FILE_INFO *Node;\r | |
84 | //\r | |
85 | // Local variable initializations\r | |
86 | //\r | |
87 | File1Buffer = NULL;\r | |
88 | ShellStatus = SHELL_SUCCESS;\r | |
89 | FileList = NULL;\r | |
90 | \r | |
91 | \r | |
92 | //\r | |
93 | // verify number of arguments\r | |
94 | //\r | |
95 | Status = ShellCommandLineParse (ParamList, &Package, &ProblemParam, TRUE);\r | |
96 | if (EFI_ERROR(Status)) {\r | |
97 | if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {\r | |
4092a8f6 | 98 | ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, L"loadpcirom", ProblemParam); \r |
5d73d92f | 99 | FreePool(ProblemParam);\r |
100 | ShellStatus = SHELL_INVALID_PARAMETER;\r | |
101 | } else {\r | |
102 | ASSERT(FALSE);\r | |
103 | }\r | |
104 | } else {\r | |
3737ac2b | 105 | if (ShellCommandLineGetCount(Package) < 2) {\r |
4092a8f6 | 106 | ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellDebug1HiiHandle, L"loadpcirom"); \r |
5d73d92f | 107 | ShellStatus = SHELL_INVALID_PARAMETER;\r |
108 | } else {\r | |
3737ac2b | 109 | if (ShellCommandLineGetFlag(Package, L"-nc")) {\r |
5d73d92f | 110 | Connect = FALSE;\r |
111 | } else {\r | |
112 | Connect = TRUE;\r | |
113 | }\r | |
114 | \r | |
115 | //\r | |
116 | // get a list with each file specified by parameters\r | |
117 | // if parameter is a directory then add all the files below it to the list\r | |
118 | //\r | |
119 | for ( ParamCount = 1, Param = ShellCommandLineGetRawValue(Package, ParamCount)\r | |
120 | ; Param != NULL\r | |
121 | ; ParamCount++, Param = ShellCommandLineGetRawValue(Package, ParamCount)\r | |
122 | ){\r | |
123 | Status = ShellOpenFileMetaArg((CHAR16*)Param, EFI_FILE_MODE_WRITE|EFI_FILE_MODE_READ, &FileList);\r | |
124 | if (EFI_ERROR(Status)) {\r | |
4092a8f6 | 125 | ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL), gShellDebug1HiiHandle, L"loadpcirom", Param); \r |
5d73d92f | 126 | ShellStatus = SHELL_ACCESS_DENIED;\r |
127 | break;\r | |
128 | }\r | |
129 | }\r | |
3737ac2b | 130 | if (ShellStatus == SHELL_SUCCESS && FileList != NULL) {\r |
5d73d92f | 131 | //\r |
132 | // loop through the list and make sure we are not aborting...\r | |
133 | //\r | |
134 | for ( Node = (EFI_SHELL_FILE_INFO*)GetFirstNode(&FileList->Link)\r | |
135 | ; !IsNull(&FileList->Link, &Node->Link) && !ShellGetExecutionBreakFlag()\r | |
136 | ; Node = (EFI_SHELL_FILE_INFO*)GetNextNode(&FileList->Link, &Node->Link)\r | |
137 | ){\r | |
138 | if (EFI_ERROR(Node->Status)){\r | |
4092a8f6 | 139 | ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL), gShellDebug1HiiHandle, L"loadpcirom", Node->FullName); \r |
5d73d92f | 140 | ShellStatus = SHELL_INVALID_PARAMETER;\r |
141 | continue;\r | |
142 | }\r | |
143 | if (FileHandleIsDirectory(Node->Handle) == EFI_SUCCESS) {\r | |
4092a8f6 | 144 | ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_FILE_NOT_DIR), gShellDebug1HiiHandle, L"loadpcirom", Node->FullName); \r |
5d73d92f | 145 | ShellStatus = SHELL_INVALID_PARAMETER;\r |
146 | continue;\r | |
147 | }\r | |
148 | SourceSize = (UINTN) Node->Info->FileSize;\r | |
3737ac2b | 149 | File1Buffer = AllocateZeroPool (SourceSize);\r |
20cfed16 RN |
150 | if (File1Buffer == NULL) {\r |
151 | ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_OUT_MEM), gShellDebug1HiiHandle, L"loadpcirom");\r | |
152 | ShellStatus = SHELL_OUT_OF_RESOURCES;\r | |
153 | continue;\r | |
154 | }\r | |
5d73d92f | 155 | Status = gEfiShellProtocol->ReadFile(Node->Handle, &SourceSize, File1Buffer);\r |
156 | if (EFI_ERROR(Status)) {\r | |
4092a8f6 | 157 | ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_FILE_READ_FAIL), gShellDebug1HiiHandle, L"loadpcirom", Node->FullName); \r |
5d73d92f | 158 | ShellStatus = SHELL_INVALID_PARAMETER;\r |
159 | } else {\r | |
160 | Status = LoadEfiDriversFromRomImage (\r | |
161 | File1Buffer,\r | |
162 | SourceSize,\r | |
163 | Node->FullName\r | |
164 | );\r | |
165 | \r | |
166 | ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_LOAD_PCI_ROM_RES), gShellDebug1HiiHandle, Node->FullName, Status);\r | |
167 | }\r | |
168 | FreePool(File1Buffer);\r | |
169 | }\r | |
3737ac2b | 170 | } else if (ShellStatus == SHELL_SUCCESS) {\r |
4092a8f6 | 171 | ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_FILE_NOT_SPEC), gShellDebug1HiiHandle, "loadpcirom"); \r |
3737ac2b | 172 | ShellStatus = SHELL_NOT_FOUND;\r |
5d73d92f | 173 | }\r |
174 | if (FileList != NULL && !IsListEmpty(&FileList->Link)) {\r | |
175 | Status = ShellCloseFileMetaArg(&FileList);\r | |
176 | }\r | |
177 | FileList = NULL;\r | |
178 | \r | |
179 | if (Connect) {\r | |
180 | Status = LoadPciRomConnectAllDriversToAllControllers ();\r | |
181 | }\r | |
182 | }\r | |
183 | }\r | |
184 | \r | |
185 | return (ShellStatus);\r | |
186 | }\r | |
187 | \r | |
3737ac2b | 188 | /**\r |
189 | Command entry point.\r | |
190 | \r | |
191 | @param[in] RomBar The Rom Base address.\r | |
192 | @param[in] RomSize The Rom size.\r | |
193 | @param[in] FileName The file name.\r | |
194 | \r | |
195 | @retval EFI_SUCCESS The command completed successfully.\r | |
196 | @retval EFI_INVALID_PARAMETER Command usage error.\r | |
197 | @retval EFI_UNSUPPORTED Protocols unsupported.\r | |
198 | @retval EFI_OUT_OF_RESOURCES Out of memory.\r | |
199 | @retval Other value Unknown error.\r | |
200 | **/\r | |
5d73d92f | 201 | EFI_STATUS\r |
3737ac2b | 202 | EFIAPI\r |
5d73d92f | 203 | LoadEfiDriversFromRomImage (\r |
204 | VOID *RomBar,\r | |
205 | UINTN RomSize,\r | |
206 | CONST CHAR16 *FileName\r | |
207 | )\r | |
5d73d92f | 208 | \r |
5d73d92f | 209 | {\r |
210 | EFI_PCI_EXPANSION_ROM_HEADER *EfiRomHeader;\r | |
211 | PCI_DATA_STRUCTURE *Pcir;\r | |
212 | UINTN ImageIndex;\r | |
213 | UINTN RomBarOffset;\r | |
214 | UINT32 ImageSize;\r | |
215 | UINT16 ImageOffset;\r | |
216 | EFI_HANDLE ImageHandle;\r | |
217 | EFI_STATUS Status;\r | |
3737ac2b | 218 | EFI_STATUS ReturnStatus;\r |
5d73d92f | 219 | CHAR16 RomFileName[280];\r |
220 | EFI_DEVICE_PATH_PROTOCOL *FilePath;\r | |
221 | BOOLEAN SkipImage;\r | |
222 | UINT32 DestinationSize;\r | |
223 | UINT32 ScratchSize;\r | |
224 | UINT8 *Scratch;\r | |
225 | VOID *ImageBuffer;\r | |
226 | VOID *DecompressedImageBuffer;\r | |
227 | UINT32 ImageLength;\r | |
228 | EFI_DECOMPRESS_PROTOCOL *Decompress;\r | |
94020bb4 | 229 | UINT32 InitializationSize;\r |
5d73d92f | 230 | \r |
231 | ImageIndex = 0;\r | |
3737ac2b | 232 | ReturnStatus = EFI_NOT_FOUND;\r |
5d73d92f | 233 | RomBarOffset = (UINTN) RomBar;\r |
234 | \r | |
235 | do {\r | |
236 | \r | |
237 | EfiRomHeader = (EFI_PCI_EXPANSION_ROM_HEADER *) (UINTN) RomBarOffset;\r | |
238 | \r | |
94020bb4 | 239 | if (EfiRomHeader->Signature != PCI_EXPANSION_ROM_HEADER_SIGNATURE) {\r |
4092a8f6 | 240 | ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_LOADPCIROM_CORRUPT), gShellDebug1HiiHandle, L"loadpcirom", FileName, ImageIndex); \r |
5d73d92f | 241 | // PrintToken (STRING_TOKEN (STR_LOADPCIROM_IMAGE_CORRUPT), HiiHandle, ImageIndex);\r |
3737ac2b | 242 | return ReturnStatus;\r |
5d73d92f | 243 | }\r |
244 | \r | |
94020bb4 | 245 | //\r |
246 | // If the pointer to the PCI Data Structure is invalid, no further images can be located. \r | |
247 | // The PCI Data Structure must be DWORD aligned. \r | |
248 | //\r | |
249 | if (EfiRomHeader->PcirOffset == 0 ||\r | |
250 | (EfiRomHeader->PcirOffset & 3) != 0 ||\r | |
251 | RomBarOffset - (UINTN)RomBar + EfiRomHeader->PcirOffset + sizeof (PCI_DATA_STRUCTURE) > RomSize) {\r | |
252 | break;\r | |
253 | }\r | |
254 | \r | |
5d73d92f | 255 | Pcir = (PCI_DATA_STRUCTURE *) (UINTN) (RomBarOffset + EfiRomHeader->PcirOffset);\r |
94020bb4 | 256 | //\r |
257 | // If a valid signature is not present in the PCI Data Structure, no further images can be located.\r | |
258 | //\r | |
259 | if (Pcir->Signature != PCI_DATA_STRUCTURE_SIGNATURE) {\r | |
260 | break;\r | |
261 | }\r | |
5d73d92f | 262 | ImageSize = Pcir->ImageLength * 512;\r |
94020bb4 | 263 | if (RomBarOffset - (UINTN)RomBar + ImageSize > RomSize) {\r |
264 | break;\r | |
265 | }\r | |
5d73d92f | 266 | \r |
267 | if ((Pcir->CodeType == PCI_CODE_TYPE_EFI_IMAGE) &&\r | |
94020bb4 | 268 | (EfiRomHeader->EfiSignature == EFI_PCI_EXPANSION_ROM_HEADER_EFISIGNATURE) &&\r |
269 | ((EfiRomHeader->EfiSubsystem == EFI_IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER) ||\r | |
270 | (EfiRomHeader->EfiSubsystem == EFI_IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER))) {\r | |
271 | \r | |
272 | ImageOffset = EfiRomHeader->EfiImageHeaderOffset;\r | |
273 | InitializationSize = EfiRomHeader->InitializationSize * 512;\r | |
5d73d92f | 274 | \r |
94020bb4 | 275 | if (InitializationSize <= ImageSize && ImageOffset < InitializationSize) {\r |
5d73d92f | 276 | \r |
277 | ImageBuffer = (VOID *) (UINTN) (RomBarOffset + ImageOffset);\r | |
94020bb4 | 278 | ImageLength = InitializationSize - ImageOffset;\r |
5d73d92f | 279 | DecompressedImageBuffer = NULL;\r |
280 | \r | |
281 | //\r | |
282 | // decompress here if needed\r | |
283 | //\r | |
284 | SkipImage = FALSE;\r | |
285 | if (EfiRomHeader->CompressionType > EFI_PCI_EXPANSION_ROM_HEADER_COMPRESSED) {\r | |
286 | SkipImage = TRUE;\r | |
287 | }\r | |
288 | \r | |
289 | if (EfiRomHeader->CompressionType == EFI_PCI_EXPANSION_ROM_HEADER_COMPRESSED) {\r | |
290 | Status = gBS->LocateProtocol (&gEfiDecompressProtocolGuid, NULL, (VOID**)&Decompress);\r | |
291 | ASSERT_EFI_ERROR(Status);\r | |
292 | if (EFI_ERROR (Status)) {\r | |
293 | SkipImage = TRUE;\r | |
294 | } else {\r | |
295 | SkipImage = TRUE;\r | |
296 | Status = Decompress->GetInfo (\r | |
297 | Decompress,\r | |
298 | ImageBuffer,\r | |
299 | ImageLength,\r | |
300 | &DestinationSize,\r | |
301 | &ScratchSize\r | |
302 | );\r | |
303 | if (!EFI_ERROR (Status)) {\r | |
3737ac2b | 304 | DecompressedImageBuffer = AllocateZeroPool (DestinationSize);\r |
5d73d92f | 305 | if (ImageBuffer != NULL) {\r |
3737ac2b | 306 | Scratch = AllocateZeroPool (ScratchSize);\r |
5d73d92f | 307 | if (Scratch != NULL) {\r |
308 | Status = Decompress->Decompress (\r | |
309 | Decompress,\r | |
310 | ImageBuffer,\r | |
311 | ImageLength,\r | |
312 | DecompressedImageBuffer,\r | |
313 | DestinationSize,\r | |
314 | Scratch,\r | |
315 | ScratchSize\r | |
316 | );\r | |
317 | if (!EFI_ERROR (Status)) {\r | |
318 | ImageBuffer = DecompressedImageBuffer;\r | |
319 | ImageLength = DestinationSize;\r | |
320 | SkipImage = FALSE;\r | |
321 | }\r | |
322 | \r | |
323 | FreePool (Scratch);\r | |
324 | }\r | |
325 | }\r | |
326 | }\r | |
327 | }\r | |
328 | }\r | |
329 | \r | |
330 | if (!SkipImage) {\r | |
331 | //\r | |
332 | // load image and start image\r | |
333 | //\r | |
334 | UnicodeSPrint (RomFileName, sizeof (RomFileName), L"%s[%d]", FileName, ImageIndex);\r | |
335 | FilePath = FileDevicePath (NULL, RomFileName);\r | |
336 | \r | |
337 | Status = gBS->LoadImage (\r | |
338 | TRUE,\r | |
339 | gImageHandle,\r | |
340 | FilePath,\r | |
341 | ImageBuffer,\r | |
342 | ImageLength,\r | |
343 | &ImageHandle\r | |
344 | );\r | |
345 | if (EFI_ERROR (Status)) {\r | |
4092a8f6 | 346 | ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_LOADPCIROM_LOAD_FAIL), gShellDebug1HiiHandle, L"loadpcirom", FileName, ImageIndex); \r |
5d73d92f | 347 | // PrintToken (STRING_TOKEN (STR_LOADPCIROM_LOAD_IMAGE_ERROR), HiiHandle, ImageIndex, Status);\r |
348 | } else {\r | |
349 | Status = gBS->StartImage (ImageHandle, NULL, NULL);\r | |
350 | if (EFI_ERROR (Status)) {\r | |
4092a8f6 | 351 | ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_LOADPCIROM_START_FAIL), gShellDebug1HiiHandle, L"loadpcirom", FileName, ImageIndex); \r |
5d73d92f | 352 | // PrintToken (STRING_TOKEN (STR_LOADPCIROM_START_IMAGE), HiiHandle, ImageIndex, Status);\r |
353 | } else {\r | |
3737ac2b | 354 | ReturnStatus = Status;\r |
5d73d92f | 355 | }\r |
356 | }\r | |
357 | }\r | |
358 | \r | |
359 | if (DecompressedImageBuffer != NULL) {\r | |
360 | FreePool (DecompressedImageBuffer);\r | |
361 | }\r | |
362 | \r | |
363 | }\r | |
364 | }\r | |
365 | \r | |
366 | RomBarOffset = RomBarOffset + ImageSize;\r | |
367 | ImageIndex++;\r | |
368 | } while (((Pcir->Indicator & 0x80) == 0x00) && ((RomBarOffset - (UINTN) RomBar) < RomSize));\r | |
369 | \r | |
3737ac2b | 370 | return ReturnStatus;\r |
5d73d92f | 371 | }\r |
372 | \r | |
3737ac2b | 373 | /**\r |
374 | Connects all available drives and controllers.\r | |
375 | \r | |
376 | @retval EFI_SUCCESS The operation was successful.\r | |
377 | @retval EFI_ABORTED The abort mechanism was received.\r | |
378 | **/\r | |
5d73d92f | 379 | EFI_STATUS\r |
3737ac2b | 380 | EFIAPI\r |
5d73d92f | 381 | LoadPciRomConnectAllDriversToAllControllers (\r |
382 | VOID\r | |
383 | )\r | |
384 | \r | |
385 | {\r | |
386 | EFI_STATUS Status;\r | |
387 | UINTN AllHandleCount;\r | |
388 | EFI_HANDLE *AllHandleBuffer;\r | |
389 | UINTN Index;\r | |
390 | UINTN HandleCount;\r | |
391 | EFI_HANDLE *HandleBuffer;\r | |
392 | UINTN *HandleType;\r | |
393 | UINTN HandleIndex;\r | |
394 | BOOLEAN Parent;\r | |
395 | BOOLEAN Device;\r | |
396 | \r | |
397 | Status = gBS->LocateHandleBuffer(\r | |
398 | AllHandles,\r | |
399 | NULL,\r | |
400 | NULL,\r | |
401 | &AllHandleCount,\r | |
402 | &AllHandleBuffer\r | |
403 | );\r | |
404 | if (EFI_ERROR (Status)) {\r | |
405 | return Status;\r | |
406 | }\r | |
407 | \r | |
408 | for (Index = 0; Index < AllHandleCount; Index++) {\r | |
409 | if (ShellGetExecutionBreakFlag ()) {\r | |
410 | Status = EFI_ABORTED;\r | |
411 | goto Done;\r | |
412 | }\r | |
413 | //\r | |
414 | // Scan the handle database\r | |
415 | //\r | |
416 | Status = ParseHandleDatabaseByRelationshipWithType(\r | |
417 | NULL,\r | |
418 | AllHandleBuffer[Index],\r | |
419 | &HandleCount,\r | |
420 | &HandleBuffer,\r | |
421 | &HandleType\r | |
422 | );\r | |
423 | /*\r | |
424 | Status = LibScanHandleDatabase (\r | |
425 | NULL,\r | |
426 | NULL,\r | |
427 | AllHandleBuffer[Index],\r | |
428 | NULL,\r | |
429 | &HandleCount,\r | |
430 | &HandleBuffer,\r | |
431 | &HandleType\r | |
432 | );\r | |
433 | */\r | |
434 | if (EFI_ERROR (Status)) {\r | |
435 | goto Done;\r | |
436 | }\r | |
437 | \r | |
438 | Device = TRUE;\r | |
439 | if ((HandleType[Index] & HR_DRIVER_BINDING_HANDLE) != 0) {\r | |
440 | Device = FALSE;\r | |
441 | }\r | |
442 | \r | |
443 | if ((HandleType[Index] & HR_IMAGE_HANDLE) != 0) {\r | |
444 | Device = FALSE;\r | |
445 | }\r | |
446 | \r | |
447 | if (Device) {\r | |
448 | Parent = FALSE;\r | |
449 | for (HandleIndex = 0; HandleIndex < HandleCount; HandleIndex++) {\r | |
450 | if ((HandleType[HandleIndex] & HR_PARENT_HANDLE) != 0) {\r | |
451 | Parent = TRUE;\r | |
452 | }\r | |
453 | }\r | |
454 | \r | |
455 | if (!Parent) {\r | |
456 | if ((HandleType[Index] & HR_DEVICE_HANDLE) != 0) {\r | |
457 | Status = gBS->ConnectController (\r | |
458 | AllHandleBuffer[Index],\r | |
459 | NULL,\r | |
460 | NULL,\r | |
461 | TRUE\r | |
462 | );\r | |
463 | }\r | |
464 | }\r | |
465 | }\r | |
466 | \r | |
467 | FreePool (HandleBuffer);\r | |
468 | FreePool (HandleType);\r | |
469 | }\r | |
470 | \r | |
471 | Done:\r | |
472 | FreePool (AllHandleBuffer);\r | |
473 | return Status;\r | |
474 | }\r |