]>
Commit | Line | Data |
---|---|---|
49ba9447 | 1 | /** @file\r |
2 | Platform BDS customizations.\r | |
3 | \r | |
94020bb4 | 4 | Copyright (c) 2004 - 2012, Intel Corporation. All rights reserved.<BR>\r |
56d7640a | 5 | This program and the accompanying materials\r |
49ba9447 | 6 | are licensed and made available under the terms and conditions of the BSD License\r |
7 | which accompanies this distribution. The full text of the license may be found at\r | |
8 | http://opensource.org/licenses/bsd-license.php\r | |
9 | \r | |
10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
11 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
12 | \r | |
13 | **/\r | |
14 | \r | |
15 | #include "BdsPlatform.h"\r | |
2cd086a6 | 16 | #include "QemuBootOrder.h"\r |
49ba9447 | 17 | \r |
18 | \r | |
40f2c454 | 19 | //\r |
20 | // Global data\r | |
21 | //\r | |
22 | \r | |
23 | VOID *mEfiDevPathNotifyReg;\r | |
24 | EFI_EVENT mEfiDevPathEvent;\r | |
9607962d | 25 | VOID *mEmuVariableEventReg;\r |
26 | EFI_EVENT mEmuVariableEvent;\r | |
e955462b | 27 | BOOLEAN mDetectVgaOnly;\r |
28 | \r | |
29 | \r | |
30 | //\r | |
31 | // Type definitions\r | |
32 | //\r | |
33 | \r | |
34 | typedef\r | |
35 | EFI_STATUS\r | |
36 | (EFIAPI *PROTOCOL_INSTANCE_CALLBACK)(\r | |
37 | IN EFI_HANDLE Handle,\r | |
38 | IN VOID *Instance,\r | |
39 | IN VOID *Context\r | |
40 | );\r | |
41 | \r | |
42 | /**\r | |
43 | @param[in] Handle - Handle of PCI device instance\r | |
44 | @param[in] PciIo - PCI IO protocol instance\r | |
45 | @param[in] Pci - PCI Header register block\r | |
46 | **/\r | |
47 | typedef\r | |
48 | EFI_STATUS\r | |
49 | (EFIAPI *VISIT_PCI_INSTANCE_CALLBACK)(\r | |
50 | IN EFI_HANDLE Handle,\r | |
51 | IN EFI_PCI_IO_PROTOCOL *PciIo,\r | |
52 | IN PCI_TYPE00 *Pci\r | |
53 | );\r | |
40f2c454 | 54 | \r |
55 | \r | |
56 | //\r | |
57 | // Function prototypes\r | |
58 | //\r | |
59 | \r | |
e955462b | 60 | EFI_STATUS\r |
61 | VisitAllInstancesOfProtocol (\r | |
62 | IN EFI_GUID *Id,\r | |
63 | IN PROTOCOL_INSTANCE_CALLBACK CallBackFunction,\r | |
64 | IN VOID *Context\r | |
65 | );\r | |
66 | \r | |
67 | EFI_STATUS\r | |
68 | VisitAllPciInstancesOfProtocol (\r | |
69 | IN VISIT_PCI_INSTANCE_CALLBACK CallBackFunction\r | |
70 | );\r | |
71 | \r | |
40f2c454 | 72 | VOID\r |
73 | InstallDevicePathCallback (\r | |
74 | VOID\r | |
75 | );\r | |
76 | \r | |
49ba9447 | 77 | //\r |
78 | // BDS Platform Functions\r | |
79 | //\r | |
80 | VOID\r | |
81 | EFIAPI\r | |
82 | PlatformBdsInit (\r | |
370ec7f1 | 83 | VOID\r |
49ba9447 | 84 | )\r |
85 | /*++\r | |
86 | \r | |
87 | Routine Description:\r | |
88 | \r | |
89 | Platform Bds init. Incude the platform firmware vendor, revision\r | |
90 | and so crc check.\r | |
91 | \r | |
92 | Arguments:\r | |
93 | \r | |
49ba9447 | 94 | Returns:\r |
95 | \r | |
96 | None.\r | |
97 | \r | |
98 | --*/\r | |
99 | {\r | |
100 | DEBUG ((EFI_D_INFO, "PlatformBdsInit\n"));\r | |
40f2c454 | 101 | InstallDevicePathCallback ();\r |
49ba9447 | 102 | }\r |
103 | \r | |
104 | \r | |
105 | EFI_STATUS\r | |
106 | ConnectRootBridge (\r | |
107 | VOID\r | |
108 | )\r | |
109 | /*++\r | |
110 | \r | |
111 | Routine Description:\r | |
112 | \r | |
113 | Connect RootBridge\r | |
114 | \r | |
115 | Arguments:\r | |
116 | \r | |
117 | None.\r | |
118 | \r | |
119 | Returns:\r | |
120 | \r | |
121 | EFI_SUCCESS - Connect RootBridge successfully.\r | |
122 | EFI_STATUS - Connect RootBridge fail.\r | |
123 | \r | |
124 | --*/\r | |
125 | {\r | |
126 | EFI_STATUS Status;\r | |
127 | EFI_HANDLE RootHandle;\r | |
128 | \r | |
129 | //\r | |
130 | // Make all the PCI_IO protocols on PCI Seg 0 show up\r | |
131 | //\r | |
132 | BdsLibConnectDevicePath (gPlatformRootBridges[0]);\r | |
133 | \r | |
134 | Status = gBS->LocateDevicePath (\r | |
135 | &gEfiDevicePathProtocolGuid,\r | |
136 | &gPlatformRootBridges[0],\r | |
137 | &RootHandle\r | |
138 | );\r | |
139 | if (EFI_ERROR (Status)) {\r | |
140 | return Status;\r | |
141 | }\r | |
142 | \r | |
143 | Status = gBS->ConnectController (RootHandle, NULL, NULL, FALSE);\r | |
144 | if (EFI_ERROR (Status)) {\r | |
145 | return Status;\r | |
146 | }\r | |
147 | \r | |
148 | return EFI_SUCCESS;\r | |
149 | }\r | |
150 | \r | |
151 | \r | |
152 | EFI_STATUS\r | |
153 | PrepareLpcBridgeDevicePath (\r | |
154 | IN EFI_HANDLE DeviceHandle\r | |
155 | )\r | |
156 | /*++\r | |
157 | \r | |
158 | Routine Description:\r | |
159 | \r | |
160 | Add IsaKeyboard to ConIn,\r | |
161 | add IsaSerial to ConOut, ConIn, ErrOut.\r | |
162 | LPC Bridge: 06 01 00\r | |
163 | \r | |
164 | Arguments:\r | |
165 | \r | |
166 | DeviceHandle - Handle of PCIIO protocol.\r | |
167 | \r | |
168 | Returns:\r | |
169 | \r | |
170 | EFI_SUCCESS - LPC bridge is added to ConOut, ConIn, and ErrOut.\r | |
171 | EFI_STATUS - No LPC bridge is added.\r | |
172 | \r | |
173 | --*/\r | |
174 | {\r | |
175 | EFI_STATUS Status;\r | |
176 | EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r | |
177 | EFI_DEVICE_PATH_PROTOCOL *TempDevicePath;\r | |
178 | CHAR16 *DevPathStr;\r | |
179 | \r | |
180 | DevicePath = NULL;\r | |
181 | Status = gBS->HandleProtocol (\r | |
182 | DeviceHandle,\r | |
183 | &gEfiDevicePathProtocolGuid,\r | |
184 | (VOID*)&DevicePath\r | |
185 | );\r | |
186 | if (EFI_ERROR (Status)) {\r | |
187 | return Status;\r | |
188 | }\r | |
189 | TempDevicePath = DevicePath;\r | |
190 | \r | |
191 | //\r | |
192 | // Register Keyboard\r | |
193 | //\r | |
194 | DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gPnpPs2KeyboardDeviceNode);\r | |
195 | \r | |
196 | BdsLibUpdateConsoleVariable (VarConsoleInp, DevicePath, NULL);\r | |
197 | \r | |
198 | //\r | |
199 | // Register COM1\r | |
200 | //\r | |
201 | DevicePath = TempDevicePath;\r | |
202 | gPnp16550ComPortDeviceNode.UID = 0;\r | |
203 | \r | |
204 | DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gPnp16550ComPortDeviceNode);\r | |
205 | DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gUartDeviceNode);\r | |
206 | DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gTerminalTypeDeviceNode);\r | |
207 | \r | |
208 | //\r | |
209 | // Print Device Path\r | |
210 | //\r | |
211 | DevPathStr = DevicePathToStr(DevicePath);\r | |
212 | DEBUG((\r | |
213 | EFI_D_INFO,\r | |
214 | "BdsPlatform.c+%d: COM%d DevPath: %s\n",\r | |
215 | __LINE__,\r | |
216 | gPnp16550ComPortDeviceNode.UID + 1,\r | |
217 | DevPathStr\r | |
218 | ));\r | |
219 | FreePool(DevPathStr);\r | |
220 | \r | |
221 | BdsLibUpdateConsoleVariable (VarConsoleOut, DevicePath, NULL);\r | |
222 | BdsLibUpdateConsoleVariable (VarConsoleInp, DevicePath, NULL);\r | |
223 | BdsLibUpdateConsoleVariable (VarErrorOut, DevicePath, NULL);\r | |
224 | \r | |
225 | //\r | |
226 | // Register COM2\r | |
227 | //\r | |
228 | DevicePath = TempDevicePath;\r | |
229 | gPnp16550ComPortDeviceNode.UID = 1;\r | |
230 | \r | |
231 | DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gPnp16550ComPortDeviceNode);\r | |
232 | DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gUartDeviceNode);\r | |
233 | DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gTerminalTypeDeviceNode);\r | |
234 | \r | |
235 | //\r | |
236 | // Print Device Path\r | |
237 | //\r | |
238 | DevPathStr = DevicePathToStr(DevicePath);\r | |
239 | DEBUG((\r | |
240 | EFI_D_INFO,\r | |
241 | "BdsPlatform.c+%d: COM%d DevPath: %s\n",\r | |
242 | __LINE__,\r | |
243 | gPnp16550ComPortDeviceNode.UID + 1,\r | |
244 | DevPathStr\r | |
245 | ));\r | |
246 | FreePool(DevPathStr);\r | |
247 | \r | |
248 | BdsLibUpdateConsoleVariable (VarConsoleOut, DevicePath, NULL);\r | |
249 | BdsLibUpdateConsoleVariable (VarConsoleInp, DevicePath, NULL);\r | |
250 | BdsLibUpdateConsoleVariable (VarErrorOut, DevicePath, NULL);\r | |
251 | \r | |
252 | return EFI_SUCCESS;\r | |
253 | }\r | |
254 | \r | |
255 | EFI_STATUS\r | |
256 | GetGopDevicePath (\r | |
257 | IN EFI_DEVICE_PATH_PROTOCOL *PciDevicePath,\r | |
258 | OUT EFI_DEVICE_PATH_PROTOCOL **GopDevicePath\r | |
259 | )\r | |
260 | {\r | |
261 | UINTN Index;\r | |
262 | EFI_STATUS Status;\r | |
263 | EFI_HANDLE PciDeviceHandle;\r | |
264 | EFI_DEVICE_PATH_PROTOCOL *TempDevicePath;\r | |
265 | EFI_DEVICE_PATH_PROTOCOL *TempPciDevicePath;\r | |
266 | UINTN GopHandleCount;\r | |
267 | EFI_HANDLE *GopHandleBuffer;\r | |
268 | \r | |
269 | if (PciDevicePath == NULL || GopDevicePath == NULL) {\r | |
270 | return EFI_INVALID_PARAMETER;\r | |
271 | }\r | |
272 | \r | |
273 | //\r | |
274 | // Initialize the GopDevicePath to be PciDevicePath\r | |
275 | //\r | |
276 | *GopDevicePath = PciDevicePath;\r | |
277 | TempPciDevicePath = PciDevicePath;\r | |
278 | \r | |
279 | Status = gBS->LocateDevicePath (\r | |
280 | &gEfiDevicePathProtocolGuid,\r | |
281 | &TempPciDevicePath,\r | |
282 | &PciDeviceHandle\r | |
283 | );\r | |
284 | if (EFI_ERROR (Status)) {\r | |
285 | return Status;\r | |
286 | }\r | |
287 | \r | |
288 | //\r | |
289 | // Try to connect this handle, so that GOP dirver could start on this\r | |
290 | // device and create child handles with GraphicsOutput Protocol installed\r | |
291 | // on them, then we get device paths of these child handles and select\r | |
292 | // them as possible console device.\r | |
293 | //\r | |
294 | gBS->ConnectController (PciDeviceHandle, NULL, NULL, FALSE);\r | |
295 | \r | |
296 | Status = gBS->LocateHandleBuffer (\r | |
297 | ByProtocol,\r | |
298 | &gEfiGraphicsOutputProtocolGuid,\r | |
299 | NULL,\r | |
300 | &GopHandleCount,\r | |
301 | &GopHandleBuffer\r | |
302 | );\r | |
303 | if (!EFI_ERROR (Status)) {\r | |
304 | //\r | |
305 | // Add all the child handles as possible Console Device\r | |
306 | //\r | |
307 | for (Index = 0; Index < GopHandleCount; Index++) {\r | |
308 | Status = gBS->HandleProtocol (GopHandleBuffer[Index], &gEfiDevicePathProtocolGuid, (VOID*)&TempDevicePath);\r | |
309 | if (EFI_ERROR (Status)) {\r | |
310 | continue;\r | |
311 | }\r | |
312 | if (CompareMem (\r | |
313 | PciDevicePath,\r | |
314 | TempDevicePath,\r | |
315 | GetDevicePathSize (PciDevicePath) - END_DEVICE_PATH_LENGTH\r | |
316 | ) == 0) {\r | |
317 | //\r | |
318 | // In current implementation, we only enable one of the child handles\r | |
319 | // as console device, i.e. sotre one of the child handle's device\r | |
320 | // path to variable "ConOut"\r | |
321 | // In futhure, we could select all child handles to be console device\r | |
322 | //\r | |
323 | \r | |
324 | *GopDevicePath = TempDevicePath;\r | |
325 | \r | |
326 | //\r | |
327 | // Delete the PCI device's path that added by GetPlugInPciVgaDevicePath()\r | |
328 | // Add the integrity GOP device path.\r | |
329 | //\r | |
330 | BdsLibUpdateConsoleVariable (VarConsoleOutDev, NULL, PciDevicePath);\r | |
331 | BdsLibUpdateConsoleVariable (VarConsoleOutDev, TempDevicePath, NULL);\r | |
332 | }\r | |
333 | }\r | |
334 | gBS->FreePool (GopHandleBuffer);\r | |
335 | }\r | |
336 | \r | |
337 | return EFI_SUCCESS;\r | |
338 | }\r | |
339 | \r | |
340 | EFI_STATUS\r | |
341 | PreparePciVgaDevicePath (\r | |
342 | IN EFI_HANDLE DeviceHandle\r | |
343 | )\r | |
344 | /*++\r | |
345 | \r | |
346 | Routine Description:\r | |
347 | \r | |
348 | Add PCI VGA to ConOut.\r | |
349 | PCI VGA: 03 00 00\r | |
350 | \r | |
351 | Arguments:\r | |
352 | \r | |
353 | DeviceHandle - Handle of PCIIO protocol.\r | |
354 | \r | |
355 | Returns:\r | |
356 | \r | |
357 | EFI_SUCCESS - PCI VGA is added to ConOut.\r | |
358 | EFI_STATUS - No PCI VGA device is added.\r | |
359 | \r | |
360 | --*/\r | |
361 | {\r | |
362 | EFI_STATUS Status;\r | |
363 | EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r | |
364 | EFI_DEVICE_PATH_PROTOCOL *GopDevicePath;\r | |
365 | \r | |
366 | DevicePath = NULL;\r | |
367 | Status = gBS->HandleProtocol (\r | |
368 | DeviceHandle,\r | |
369 | &gEfiDevicePathProtocolGuid,\r | |
370 | (VOID*)&DevicePath\r | |
371 | );\r | |
372 | if (EFI_ERROR (Status)) {\r | |
373 | return Status;\r | |
374 | }\r | |
375 | \r | |
376 | GetGopDevicePath (DevicePath, &GopDevicePath);\r | |
377 | DevicePath = GopDevicePath;\r | |
378 | \r | |
379 | BdsLibUpdateConsoleVariable (VarConsoleOut, DevicePath, NULL);\r | |
380 | \r | |
381 | return EFI_SUCCESS;\r | |
382 | }\r | |
383 | \r | |
384 | EFI_STATUS\r | |
385 | PreparePciSerialDevicePath (\r | |
386 | IN EFI_HANDLE DeviceHandle\r | |
387 | )\r | |
388 | /*++\r | |
389 | \r | |
390 | Routine Description:\r | |
391 | \r | |
392 | Add PCI Serial to ConOut, ConIn, ErrOut.\r | |
393 | PCI Serial: 07 00 02\r | |
394 | \r | |
395 | Arguments:\r | |
396 | \r | |
397 | DeviceHandle - Handle of PCIIO protocol.\r | |
398 | \r | |
399 | Returns:\r | |
400 | \r | |
401 | EFI_SUCCESS - PCI Serial is added to ConOut, ConIn, and ErrOut.\r | |
402 | EFI_STATUS - No PCI Serial device is added.\r | |
403 | \r | |
404 | --*/\r | |
405 | {\r | |
406 | EFI_STATUS Status;\r | |
407 | EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r | |
408 | \r | |
409 | DevicePath = NULL;\r | |
410 | Status = gBS->HandleProtocol (\r | |
411 | DeviceHandle,\r | |
412 | &gEfiDevicePathProtocolGuid,\r | |
413 | (VOID*)&DevicePath\r | |
414 | );\r | |
415 | if (EFI_ERROR (Status)) {\r | |
416 | return Status;\r | |
417 | }\r | |
418 | \r | |
419 | DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gUartDeviceNode);\r | |
420 | DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gTerminalTypeDeviceNode);\r | |
421 | \r | |
422 | BdsLibUpdateConsoleVariable (VarConsoleOut, DevicePath, NULL);\r | |
423 | BdsLibUpdateConsoleVariable (VarConsoleInp, DevicePath, NULL);\r | |
424 | BdsLibUpdateConsoleVariable (VarErrorOut, DevicePath, NULL);\r | |
425 | \r | |
426 | return EFI_SUCCESS;\r | |
427 | }\r | |
428 | \r | |
429 | EFI_STATUS\r | |
e955462b | 430 | VisitAllInstancesOfProtocol (\r |
431 | IN EFI_GUID *Id,\r | |
432 | IN PROTOCOL_INSTANCE_CALLBACK CallBackFunction,\r | |
433 | IN VOID *Context\r | |
49ba9447 | 434 | )\r |
49ba9447 | 435 | {\r |
436 | EFI_STATUS Status;\r | |
437 | UINTN HandleCount;\r | |
438 | EFI_HANDLE *HandleBuffer;\r | |
439 | UINTN Index;\r | |
e955462b | 440 | VOID *Instance;\r |
49ba9447 | 441 | \r |
442 | //\r | |
443 | // Start to check all the PciIo to find all possible device\r | |
444 | //\r | |
445 | HandleCount = 0;\r | |
446 | HandleBuffer = NULL;\r | |
447 | Status = gBS->LocateHandleBuffer (\r | |
448 | ByProtocol,\r | |
e955462b | 449 | Id,\r |
49ba9447 | 450 | NULL,\r |
451 | &HandleCount,\r | |
452 | &HandleBuffer\r | |
453 | );\r | |
454 | if (EFI_ERROR (Status)) {\r | |
455 | return Status;\r | |
456 | }\r | |
457 | \r | |
458 | for (Index = 0; Index < HandleCount; Index++) {\r | |
e955462b | 459 | Status = gBS->HandleProtocol (HandleBuffer[Index], Id, &Instance);\r |
49ba9447 | 460 | if (EFI_ERROR (Status)) {\r |
461 | continue;\r | |
462 | }\r | |
463 | \r | |
e955462b | 464 | Status = (*CallBackFunction) (\r |
465 | HandleBuffer[Index],\r | |
466 | Instance,\r | |
467 | Context\r | |
468 | );\r | |
469 | }\r | |
49ba9447 | 470 | \r |
e955462b | 471 | gBS->FreePool (HandleBuffer);\r |
607ca510 | 472 | \r |
e955462b | 473 | return EFI_SUCCESS;\r |
474 | }\r | |
475 | \r | |
476 | \r | |
477 | EFI_STATUS\r | |
478 | EFIAPI\r | |
479 | VisitingAPciInstance (\r | |
480 | IN EFI_HANDLE Handle,\r | |
481 | IN VOID *Instance,\r | |
482 | IN VOID *Context\r | |
483 | )\r | |
484 | {\r | |
485 | EFI_STATUS Status;\r | |
486 | EFI_PCI_IO_PROTOCOL *PciIo;\r | |
487 | PCI_TYPE00 Pci;\r | |
488 | \r | |
489 | PciIo = (EFI_PCI_IO_PROTOCOL*) Instance;\r | |
490 | \r | |
491 | //\r | |
492 | // Check for all PCI device\r | |
493 | //\r | |
494 | Status = PciIo->Pci.Read (\r | |
495 | PciIo,\r | |
496 | EfiPciIoWidthUint32,\r | |
497 | 0,\r | |
498 | sizeof (Pci) / sizeof (UINT32),\r | |
499 | &Pci\r | |
500 | );\r | |
501 | if (EFI_ERROR (Status)) {\r | |
502 | return Status;\r | |
503 | }\r | |
504 | \r | |
7d9cf3f2 | 505 | return (*(VISIT_PCI_INSTANCE_CALLBACK)(UINTN) Context) (\r |
e955462b | 506 | Handle,\r |
507 | PciIo,\r | |
508 | &Pci\r | |
509 | );\r | |
510 | \r | |
511 | }\r | |
512 | \r | |
513 | \r | |
514 | \r | |
515 | EFI_STATUS\r | |
516 | VisitAllPciInstances (\r | |
517 | IN VISIT_PCI_INSTANCE_CALLBACK CallBackFunction\r | |
518 | )\r | |
519 | {\r | |
520 | return VisitAllInstancesOfProtocol (\r | |
521 | &gEfiPciIoProtocolGuid,\r | |
522 | VisitingAPciInstance,\r | |
7d9cf3f2 | 523 | (VOID*)(UINTN) CallBackFunction\r |
e955462b | 524 | );\r |
525 | }\r | |
526 | \r | |
527 | \r | |
528 | /**\r | |
529 | Do platform specific PCI Device check and add them to\r | |
530 | ConOut, ConIn, ErrOut.\r | |
531 | \r | |
532 | @param[in] Handle - Handle of PCI device instance\r | |
533 | @param[in] PciIo - PCI IO protocol instance\r | |
534 | @param[in] Pci - PCI Header register block\r | |
535 | \r | |
536 | @retval EFI_SUCCESS - PCI Device check and Console variable update successfully.\r | |
537 | @retval EFI_STATUS - PCI Device check or Console variable update fail.\r | |
538 | \r | |
539 | **/\r | |
540 | EFI_STATUS\r | |
8861fc79 | 541 | EFIAPI\r |
e955462b | 542 | DetectAndPreparePlatformPciDevicePath (\r |
543 | IN EFI_HANDLE Handle,\r | |
544 | IN EFI_PCI_IO_PROTOCOL *PciIo,\r | |
545 | IN PCI_TYPE00 *Pci\r | |
546 | )\r | |
547 | {\r | |
548 | EFI_STATUS Status;\r | |
549 | \r | |
550 | Status = PciIo->Attributes (\r | |
551 | PciIo,\r | |
552 | EfiPciIoAttributeOperationEnable,\r | |
553 | EFI_PCI_DEVICE_ENABLE,\r | |
554 | NULL\r | |
555 | );\r | |
556 | ASSERT_EFI_ERROR (Status);\r | |
557 | \r | |
558 | if (!mDetectVgaOnly) {\r | |
559 | //\r | |
560 | // Here we decide whether it is LPC Bridge\r | |
561 | //\r | |
562 | if ((IS_PCI_LPC (Pci)) ||\r | |
563 | ((IS_PCI_ISA_PDECODE (Pci)) &&\r | |
564 | (Pci->Hdr.VendorId == 0x8086) &&\r | |
565 | (Pci->Hdr.DeviceId == 0x7000)\r | |
566 | )\r | |
567 | ) {\r | |
49ba9447 | 568 | //\r |
e955462b | 569 | // Add IsaKeyboard to ConIn,\r |
570 | // add IsaSerial to ConOut, ConIn, ErrOut\r | |
49ba9447 | 571 | //\r |
e955462b | 572 | DEBUG ((EFI_D_INFO, "Found LPC Bridge device\n"));\r |
573 | PrepareLpcBridgeDevicePath (Handle);\r | |
574 | return EFI_SUCCESS;\r | |
49ba9447 | 575 | }\r |
49ba9447 | 576 | //\r |
e955462b | 577 | // Here we decide which Serial device to enable in PCI bus\r |
49ba9447 | 578 | //\r |
e955462b | 579 | if (IS_PCI_16550SERIAL (Pci)) {\r |
49ba9447 | 580 | //\r |
e955462b | 581 | // Add them to ConOut, ConIn, ErrOut.\r |
49ba9447 | 582 | //\r |
e955462b | 583 | DEBUG ((EFI_D_INFO, "Found PCI 16550 SERIAL device\n"));\r |
584 | PreparePciSerialDevicePath (Handle);\r | |
585 | return EFI_SUCCESS;\r | |
49ba9447 | 586 | }\r |
587 | }\r | |
588 | \r | |
e955462b | 589 | //\r |
590 | // Here we decide which VGA device to enable in PCI bus\r | |
591 | //\r | |
592 | if (IS_PCI_VGA (Pci)) {\r | |
593 | //\r | |
594 | // Add them to ConOut.\r | |
595 | //\r | |
596 | DEBUG ((EFI_D_INFO, "Found PCI VGA device\n"));\r | |
597 | PreparePciVgaDevicePath (Handle);\r | |
598 | return EFI_SUCCESS;\r | |
599 | }\r | |
49ba9447 | 600 | \r |
e955462b | 601 | return Status;\r |
602 | }\r | |
603 | \r | |
604 | \r | |
605 | /**\r | |
606 | Do platform specific PCI Device check and add them to ConOut, ConIn, ErrOut\r | |
607 | \r | |
608 | @param[in] DetectVgaOnly - Only detect VGA device if it's TRUE.\r | |
609 | \r | |
610 | @retval EFI_SUCCESS - PCI Device check and Console variable update successfully.\r | |
611 | @retval EFI_STATUS - PCI Device check or Console variable update fail.\r | |
612 | \r | |
613 | **/\r | |
614 | EFI_STATUS\r | |
615 | DetectAndPreparePlatformPciDevicePaths (\r | |
616 | BOOLEAN DetectVgaOnly\r | |
617 | )\r | |
618 | {\r | |
619 | mDetectVgaOnly = DetectVgaOnly;\r | |
620 | return VisitAllPciInstances (DetectAndPreparePlatformPciDevicePath);\r | |
49ba9447 | 621 | }\r |
622 | \r | |
623 | \r | |
624 | EFI_STATUS\r | |
625 | PlatformBdsConnectConsole (\r | |
626 | IN BDS_CONSOLE_CONNECT_ENTRY *PlatformConsole\r | |
627 | )\r | |
628 | /*++\r | |
629 | \r | |
630 | Routine Description:\r | |
631 | \r | |
632 | Connect the predefined platform default console device. Always try to find\r | |
633 | and enable the vga device if have.\r | |
634 | \r | |
635 | Arguments:\r | |
636 | \r | |
637 | PlatformConsole - Predfined platform default console device array.\r | |
638 | \r | |
639 | Returns:\r | |
640 | \r | |
641 | EFI_SUCCESS - Success connect at least one ConIn and ConOut\r | |
642 | device, there must have one ConOut device is\r | |
643 | active vga device.\r | |
644 | \r | |
645 | EFI_STATUS - Return the status of\r | |
646 | BdsLibConnectAllDefaultConsoles ()\r | |
647 | \r | |
648 | --*/\r | |
649 | {\r | |
650 | EFI_STATUS Status;\r | |
651 | UINTN Index;\r | |
652 | EFI_DEVICE_PATH_PROTOCOL *VarConout;\r | |
653 | EFI_DEVICE_PATH_PROTOCOL *VarConin;\r | |
654 | UINTN DevicePathSize;\r | |
655 | \r | |
656 | //\r | |
657 | // Connect RootBridge\r | |
658 | //\r | |
49ba9447 | 659 | VarConout = BdsLibGetVariableAndSize (\r |
660 | VarConsoleOut,\r | |
661 | &gEfiGlobalVariableGuid,\r | |
662 | &DevicePathSize\r | |
663 | );\r | |
664 | VarConin = BdsLibGetVariableAndSize (\r | |
665 | VarConsoleInp,\r | |
666 | &gEfiGlobalVariableGuid,\r | |
667 | &DevicePathSize\r | |
668 | );\r | |
669 | \r | |
670 | if (VarConout == NULL || VarConin == NULL) {\r | |
671 | //\r | |
672 | // Do platform specific PCI Device check and add them to ConOut, ConIn, ErrOut\r | |
673 | //\r | |
e955462b | 674 | DetectAndPreparePlatformPciDevicePaths (FALSE);\r |
49ba9447 | 675 | \r |
676 | //\r | |
677 | // Have chance to connect the platform default console,\r | |
678 | // the platform default console is the minimue device group\r | |
679 | // the platform should support\r | |
680 | //\r | |
681 | for (Index = 0; PlatformConsole[Index].DevicePath != NULL; ++Index) {\r | |
682 | //\r | |
683 | // Update the console variable with the connect type\r | |
684 | //\r | |
685 | if ((PlatformConsole[Index].ConnectType & CONSOLE_IN) == CONSOLE_IN) {\r | |
686 | BdsLibUpdateConsoleVariable (VarConsoleInp, PlatformConsole[Index].DevicePath, NULL);\r | |
687 | }\r | |
688 | if ((PlatformConsole[Index].ConnectType & CONSOLE_OUT) == CONSOLE_OUT) {\r | |
689 | BdsLibUpdateConsoleVariable (VarConsoleOut, PlatformConsole[Index].DevicePath, NULL);\r | |
690 | }\r | |
691 | if ((PlatformConsole[Index].ConnectType & STD_ERROR) == STD_ERROR) {\r | |
692 | BdsLibUpdateConsoleVariable (VarErrorOut, PlatformConsole[Index].DevicePath, NULL);\r | |
693 | }\r | |
694 | }\r | |
695 | } else {\r | |
696 | //\r | |
697 | // Only detect VGA device and add them to ConOut\r | |
698 | //\r | |
e955462b | 699 | DetectAndPreparePlatformPciDevicePaths (TRUE);\r |
49ba9447 | 700 | }\r |
701 | \r | |
702 | //\r | |
703 | // Connect the all the default console with current cosole variable\r | |
704 | //\r | |
705 | Status = BdsLibConnectAllDefaultConsoles ();\r | |
706 | if (EFI_ERROR (Status)) {\r | |
707 | return Status;\r | |
708 | }\r | |
709 | \r | |
710 | return EFI_SUCCESS;\r | |
711 | }\r | |
712 | \r | |
713 | \r | |
714 | VOID\r | |
715 | PciInitialization (\r | |
716 | )\r | |
717 | {\r | |
718 | //\r | |
40f2c454 | 719 | // Bus 0, Device 0, Function 0 - Host to PCI Bridge\r |
720 | //\r | |
721 | PciWrite8 (PCI_LIB_ADDRESS (0, 0, 0, 0x3c), 0x00);\r | |
722 | \r | |
723 | //\r | |
724 | // Bus 0, Device 1, Function 0 - PCI to ISA Bridge\r | |
49ba9447 | 725 | //\r |
40f2c454 | 726 | PciWrite8 (PCI_LIB_ADDRESS (0, 1, 0, 0x3c), 0x00);\r |
05c89c7f | 727 | PciWrite8 (PCI_LIB_ADDRESS (0, 1, 0, 0x60), 0x0b); // LNKA routing target\r |
728 | PciWrite8 (PCI_LIB_ADDRESS (0, 1, 0, 0x61), 0x0b); // LNKB routing target\r | |
729 | PciWrite8 (PCI_LIB_ADDRESS (0, 1, 0, 0x62), 0x0a); // LNKC routing target\r | |
730 | PciWrite8 (PCI_LIB_ADDRESS (0, 1, 0, 0x63), 0x0a); // LNKD routing target\r | |
49ba9447 | 731 | \r |
732 | //\r | |
40f2c454 | 733 | // Bus 0, Device 1, Function 1 - IDE Controller\r |
49ba9447 | 734 | //\r |
40f2c454 | 735 | PciWrite8 (PCI_LIB_ADDRESS (0, 1, 1, 0x3c), 0x00);\r |
736 | PciWrite8 (PCI_LIB_ADDRESS (0, 1, 1, 0x0d), 0x40);\r | |
49ba9447 | 737 | \r |
738 | //\r | |
40f2c454 | 739 | // Bus 0, Device 1, Function 3 - Power Managment Controller\r |
49ba9447 | 740 | //\r |
05c89c7f | 741 | PciWrite8 (PCI_LIB_ADDRESS (0, 1, 3, 0x3c), 0x09);\r |
742 | PciWrite8 (PCI_LIB_ADDRESS (0, 1, 3, 0x3d), 0x01); // INTA\r | |
49ba9447 | 743 | \r |
744 | //\r | |
40f2c454 | 745 | // Bus 0, Device 2, Function 0 - Video Controller\r |
49ba9447 | 746 | //\r |
40f2c454 | 747 | PciWrite8 (PCI_LIB_ADDRESS (0, 2, 0, 0x3c), 0x00);\r |
49ba9447 | 748 | \r |
749 | //\r | |
40f2c454 | 750 | // Bus 0, Device 3, Function 0 - Network Controller\r |
49ba9447 | 751 | //\r |
05c89c7f | 752 | PciWrite8 (PCI_LIB_ADDRESS (0, 3, 0, 0x3c), 0x0a);\r |
753 | PciWrite8 (PCI_LIB_ADDRESS (0, 3, 0, 0x3d), 0x01); // INTA (-> LNKC)\r | |
49ba9447 | 754 | \r |
755 | //\r | |
a5595b1e | 756 | // Bus 0, Device 5, Function 0 - RAM Memory\r |
49ba9447 | 757 | //\r |
05c89c7f | 758 | PciWrite8 (PCI_LIB_ADDRESS (0, 5, 0, 0x3c), 0x0b);\r |
759 | PciWrite8 (PCI_LIB_ADDRESS (0, 5, 0, 0x3d), 0x01); // INTA (-> LNKA)\r | |
49ba9447 | 760 | }\r |
761 | \r | |
762 | \r | |
9b167857 | 763 | VOID\r |
764 | AcpiInitialization (\r | |
765 | VOID\r | |
766 | )\r | |
767 | {\r | |
768 | //\r | |
769 | // Set ACPI SCI_EN bit in PMCNTRL\r | |
770 | //\r | |
771 | IoOr16 ((PciRead32 (PCI_LIB_ADDRESS (0, 1, 3, 0x40)) & ~BIT0) + 4, BIT0);\r | |
772 | }\r | |
773 | \r | |
774 | \r | |
14b21de9 | 775 | EFI_STATUS\r |
776 | EFIAPI\r | |
777 | ConnectRecursivelyIfPciMassStorage (\r | |
778 | IN EFI_HANDLE Handle,\r | |
779 | IN EFI_PCI_IO_PROTOCOL *Instance,\r | |
780 | IN PCI_TYPE00 *PciHeader\r | |
781 | )\r | |
782 | {\r | |
783 | EFI_STATUS Status;\r | |
784 | EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r | |
785 | CHAR16 *DevPathStr;\r | |
786 | \r | |
787 | if (IS_CLASS1 (PciHeader, PCI_CLASS_MASS_STORAGE)) {\r | |
788 | DevicePath = NULL;\r | |
789 | Status = gBS->HandleProtocol (\r | |
790 | Handle,\r | |
791 | &gEfiDevicePathProtocolGuid,\r | |
792 | (VOID*)&DevicePath\r | |
793 | );\r | |
794 | if (EFI_ERROR (Status)) {\r | |
795 | return Status;\r | |
796 | }\r | |
797 | \r | |
798 | //\r | |
799 | // Print Device Path\r | |
800 | //\r | |
801 | DevPathStr = DevicePathToStr (DevicePath);\r | |
802 | DEBUG((\r | |
803 | EFI_D_INFO,\r | |
804 | "Found Mass Storage device: %s\n",\r | |
805 | DevPathStr\r | |
806 | ));\r | |
807 | FreePool(DevPathStr);\r | |
808 | \r | |
809 | Status = gBS->ConnectController (Handle, NULL, NULL, TRUE);\r | |
810 | if (EFI_ERROR (Status)) {\r | |
811 | return Status;\r | |
812 | }\r | |
813 | \r | |
814 | }\r | |
815 | \r | |
816 | return EFI_SUCCESS;\r | |
817 | }\r | |
818 | \r | |
819 | \r | |
9607962d | 820 | /**\r |
821 | This notification function is invoked when the\r | |
822 | EMU Variable FVB has been changed.\r | |
823 | \r | |
824 | @param Event The event that occured\r | |
825 | @param Context For EFI compatiblity. Not used.\r | |
826 | \r | |
827 | **/\r | |
828 | VOID\r | |
829 | EFIAPI\r | |
830 | EmuVariablesUpdatedCallback (\r | |
831 | IN EFI_EVENT Event,\r | |
832 | IN VOID *Context\r | |
833 | )\r | |
834 | {\r | |
835 | DEBUG ((EFI_D_INFO, "EmuVariablesUpdatedCallback\n"));\r | |
836 | UpdateNvVarsOnFileSystem ();\r | |
837 | }\r | |
838 | \r | |
839 | \r | |
14b21de9 | 840 | EFI_STATUS\r |
841 | EFIAPI\r | |
842 | VisitingFileSystemInstance (\r | |
843 | IN EFI_HANDLE Handle,\r | |
844 | IN VOID *Instance,\r | |
845 | IN VOID *Context\r | |
846 | )\r | |
847 | {\r | |
848 | EFI_STATUS Status;\r | |
849 | STATIC BOOLEAN ConnectedToFileSystem = FALSE;\r | |
850 | \r | |
851 | if (ConnectedToFileSystem) {\r | |
852 | return EFI_ALREADY_STARTED;\r | |
853 | }\r | |
854 | \r | |
855 | Status = ConnectNvVarsToFileSystem (Handle);\r | |
856 | if (EFI_ERROR (Status)) {\r | |
857 | return Status;\r | |
858 | }\r | |
859 | \r | |
860 | ConnectedToFileSystem = TRUE;\r | |
9607962d | 861 | mEmuVariableEvent =\r |
862 | EfiCreateProtocolNotifyEvent (\r | |
863 | &gEfiDevicePathProtocolGuid,\r | |
864 | TPL_CALLBACK,\r | |
865 | EmuVariablesUpdatedCallback,\r | |
866 | NULL,\r | |
867 | &mEmuVariableEventReg\r | |
868 | );\r | |
869 | PcdSet64 (PcdEmuVariableEvent, (UINT64)(UINTN) mEmuVariableEvent);\r | |
870 | \r | |
14b21de9 | 871 | return EFI_SUCCESS;\r |
872 | }\r | |
873 | \r | |
874 | \r | |
875 | VOID\r | |
876 | PlatformBdsRestoreNvVarsFromHardDisk (\r | |
877 | )\r | |
878 | {\r | |
879 | VisitAllPciInstances (ConnectRecursivelyIfPciMassStorage);\r | |
880 | VisitAllInstancesOfProtocol (\r | |
881 | &gEfiSimpleFileSystemProtocolGuid,\r | |
882 | VisitingFileSystemInstance,\r | |
883 | NULL\r | |
884 | );\r | |
3d131d1a | 885 | \r |
14b21de9 | 886 | }\r |
887 | \r | |
888 | \r | |
49ba9447 | 889 | VOID\r |
890 | PlatformBdsConnectSequence (\r | |
891 | VOID\r | |
892 | )\r | |
893 | /*++\r | |
894 | \r | |
895 | Routine Description:\r | |
896 | \r | |
897 | Connect with predeined platform connect sequence,\r | |
898 | the OEM/IBV can customize with their own connect sequence.\r | |
899 | \r | |
900 | Arguments:\r | |
901 | \r | |
902 | None.\r | |
903 | \r | |
904 | Returns:\r | |
905 | \r | |
906 | None.\r | |
907 | \r | |
908 | --*/\r | |
909 | {\r | |
910 | UINTN Index;\r | |
911 | \r | |
912 | DEBUG ((EFI_D_INFO, "PlatformBdsConnectSequence\n"));\r | |
913 | \r | |
914 | Index = 0;\r | |
915 | \r | |
916 | //\r | |
917 | // Here we can get the customized platform connect sequence\r | |
918 | // Notes: we can connect with new variable which record the\r | |
919 | // last time boots connect device path sequence\r | |
920 | //\r | |
921 | while (gPlatformConnectSequence[Index] != NULL) {\r | |
922 | //\r | |
923 | // Build the platform boot option\r | |
924 | //\r | |
925 | BdsLibConnectDevicePath (gPlatformConnectSequence[Index]);\r | |
926 | Index++;\r | |
927 | }\r | |
928 | \r | |
929 | //\r | |
930 | // Just use the simple policy to connect all devices\r | |
931 | //\r | |
932 | BdsLibConnectAll ();\r | |
933 | \r | |
934 | PciInitialization ();\r | |
9b167857 | 935 | AcpiInitialization ();\r |
40f2c454 | 936 | \r |
937 | //\r | |
938 | // Clear the logo after all devices are connected.\r | |
939 | //\r | |
940 | gST->ConOut->ClearScreen (gST->ConOut);\r | |
49ba9447 | 941 | }\r |
942 | \r | |
943 | VOID\r | |
944 | PlatformBdsGetDriverOption (\r | |
945 | IN OUT LIST_ENTRY *BdsDriverLists\r | |
946 | )\r | |
947 | /*++\r | |
948 | \r | |
949 | Routine Description:\r | |
950 | \r | |
951 | Load the predefined driver option, OEM/IBV can customize this\r | |
952 | to load their own drivers\r | |
953 | \r | |
954 | Arguments:\r | |
955 | \r | |
956 | BdsDriverLists - The header of the driver option link list.\r | |
957 | \r | |
958 | Returns:\r | |
959 | \r | |
960 | None.\r | |
961 | \r | |
962 | --*/\r | |
963 | {\r | |
964 | DEBUG ((EFI_D_INFO, "PlatformBdsGetDriverOption\n"));\r | |
965 | return;\r | |
966 | }\r | |
967 | \r | |
968 | VOID\r | |
969 | PlatformBdsDiagnostics (\r | |
970 | IN EXTENDMEM_COVERAGE_LEVEL MemoryTestLevel,\r | |
d18476d0 | 971 | IN BOOLEAN QuietBoot,\r |
972 | IN BASEM_MEMORY_TEST BaseMemoryTest\r | |
49ba9447 | 973 | )\r |
974 | /*++\r | |
975 | \r | |
976 | Routine Description:\r | |
977 | \r | |
978 | Perform the platform diagnostic, such like test memory. OEM/IBV also\r | |
979 | can customize this fuction to support specific platform diagnostic.\r | |
980 | \r | |
981 | Arguments:\r | |
982 | \r | |
983 | MemoryTestLevel - The memory test intensive level\r | |
984 | \r | |
985 | QuietBoot - Indicate if need to enable the quiet boot\r | |
986 | \r | |
d18476d0 | 987 | BaseMemoryTest - A pointer to BaseMemoryTest()\r |
988 | \r | |
49ba9447 | 989 | Returns:\r |
990 | \r | |
991 | None.\r | |
992 | \r | |
993 | --*/\r | |
994 | {\r | |
995 | EFI_STATUS Status;\r | |
996 | \r | |
997 | DEBUG ((EFI_D_INFO, "PlatformBdsDiagnostics\n"));\r | |
998 | \r | |
999 | //\r | |
1000 | // Here we can decide if we need to show\r | |
1001 | // the diagnostics screen\r | |
1002 | // Notes: this quiet boot code should be remove\r | |
1003 | // from the graphic lib\r | |
1004 | //\r | |
1005 | if (QuietBoot) {\r | |
d46f3632 | 1006 | EnableQuietBoot (PcdGetPtr(PcdLogoFile));\r |
49ba9447 | 1007 | //\r |
1008 | // Perform system diagnostic\r | |
1009 | //\r | |
d18476d0 | 1010 | Status = BaseMemoryTest (MemoryTestLevel);\r |
49ba9447 | 1011 | if (EFI_ERROR (Status)) {\r |
1012 | DisableQuietBoot ();\r | |
1013 | }\r | |
1014 | \r | |
1015 | return ;\r | |
1016 | }\r | |
1017 | //\r | |
1018 | // Perform system diagnostic\r | |
1019 | //\r | |
d18476d0 | 1020 | Status = BaseMemoryTest (MemoryTestLevel);\r |
49ba9447 | 1021 | }\r |
1022 | \r | |
1023 | \r | |
1024 | VOID\r | |
1025 | EFIAPI\r | |
1026 | PlatformBdsPolicyBehavior (\r | |
49ba9447 | 1027 | IN OUT LIST_ENTRY *DriverOptionList,\r |
d18476d0 | 1028 | IN OUT LIST_ENTRY *BootOptionList,\r |
1029 | IN PROCESS_CAPSULES ProcessCapsules,\r | |
1030 | IN BASEM_MEMORY_TEST BaseMemoryTest\r | |
49ba9447 | 1031 | )\r |
1032 | /*++\r | |
1033 | \r | |
1034 | Routine Description:\r | |
1035 | \r | |
1036 | The function will excute with as the platform policy, current policy\r | |
1037 | is driven by boot mode. IBV/OEM can customize this code for their specific\r | |
1038 | policy action.\r | |
1039 | \r | |
1040 | Arguments:\r | |
1041 | \r | |
49ba9447 | 1042 | DriverOptionList - The header of the driver option link list\r |
1043 | \r | |
1044 | BootOptionList - The header of the boot option link list\r | |
1045 | \r | |
d18476d0 | 1046 | ProcessCapsules - A pointer to ProcessCapsules()\r |
1047 | \r | |
1048 | BaseMemoryTest - A pointer to BaseMemoryTest()\r | |
1049 | \r | |
49ba9447 | 1050 | Returns:\r |
1051 | \r | |
1052 | None.\r | |
1053 | \r | |
1054 | --*/\r | |
1055 | {\r | |
1056 | EFI_STATUS Status;\r | |
1057 | UINT16 Timeout;\r | |
1058 | EFI_EVENT UserInputDurationTime;\r | |
1059 | LIST_ENTRY *Link;\r | |
1060 | BDS_COMMON_OPTION *BootOption;\r | |
1061 | UINTN Index;\r | |
1062 | EFI_INPUT_KEY Key;\r | |
1063 | EFI_TPL OldTpl;\r | |
370ec7f1 | 1064 | EFI_BOOT_MODE BootMode;\r |
49ba9447 | 1065 | \r |
1066 | DEBUG ((EFI_D_INFO, "PlatformBdsPolicyBehavior\n"));\r | |
1067 | \r | |
14b21de9 | 1068 | ConnectRootBridge ();\r |
1069 | \r | |
1070 | //\r | |
1071 | // Try to restore variables from the hard disk early so\r | |
1072 | // they can be used for the other BDS connect operations.\r | |
1073 | //\r | |
1074 | PlatformBdsRestoreNvVarsFromHardDisk ();\r | |
1075 | \r | |
49ba9447 | 1076 | //\r |
1077 | // Init the time out value\r | |
1078 | //\r | |
1079 | Timeout = PcdGet16 (PcdPlatformBootTimeOut);\r | |
1080 | \r | |
1081 | //\r | |
1082 | // Load the driver option as the driver option list\r | |
1083 | //\r | |
1084 | PlatformBdsGetDriverOption (DriverOptionList);\r | |
1085 | \r | |
1086 | //\r | |
1087 | // Get current Boot Mode\r | |
1088 | //\r | |
370ec7f1 | 1089 | Status = BdsLibGetBootMode (&BootMode);\r |
1090 | DEBUG ((EFI_D_ERROR, "Boot Mode:%x\n", BootMode));\r | |
49ba9447 | 1091 | \r |
1092 | //\r | |
1093 | // Go the different platform policy with different boot mode\r | |
1094 | // Notes: this part code can be change with the table policy\r | |
1095 | //\r | |
370ec7f1 | 1096 | ASSERT (BootMode == BOOT_WITH_FULL_CONFIGURATION);\r |
49ba9447 | 1097 | //\r |
1098 | // Connect platform console\r | |
1099 | //\r | |
1100 | Status = PlatformBdsConnectConsole (gPlatformConsole);\r | |
1101 | if (EFI_ERROR (Status)) {\r | |
1102 | //\r | |
1103 | // Here OEM/IBV can customize with defined action\r | |
1104 | //\r | |
1105 | PlatformBdsNoConsoleAction ();\r | |
1106 | }\r | |
1107 | //\r | |
1108 | // Create a 300ms duration event to ensure user has enough input time to enter Setup\r | |
1109 | //\r | |
1110 | Status = gBS->CreateEvent (\r | |
1111 | EVT_TIMER,\r | |
1112 | 0,\r | |
1113 | NULL,\r | |
1114 | NULL,\r | |
1115 | &UserInputDurationTime\r | |
1116 | );\r | |
1117 | ASSERT (Status == EFI_SUCCESS);\r | |
1118 | Status = gBS->SetTimer (UserInputDurationTime, TimerRelative, 3000000);\r | |
1119 | ASSERT (Status == EFI_SUCCESS);\r | |
1120 | //\r | |
1121 | // Memory test and Logo show\r | |
1122 | //\r | |
d18476d0 | 1123 | PlatformBdsDiagnostics (IGNORE, TRUE, BaseMemoryTest);\r |
49ba9447 | 1124 | \r |
1125 | //\r | |
1126 | // Perform some platform specific connect sequence\r | |
1127 | //\r | |
1128 | PlatformBdsConnectSequence ();\r | |
1129 | \r | |
1130 | //\r | |
1131 | // Give one chance to enter the setup if we\r | |
1132 | // have the time out\r | |
1133 | //\r | |
1134 | if (Timeout != 0) {\r | |
1135 | //PlatformBdsEnterFrontPage (Timeout, FALSE);\r | |
1136 | }\r | |
1137 | \r | |
1138 | DEBUG ((EFI_D_INFO, "BdsLibConnectAll\n"));\r | |
1139 | BdsLibConnectAll ();\r | |
1140 | BdsLibEnumerateAllBootOption (BootOptionList);\r | |
1141 | \r | |
2cd086a6 | 1142 | SetBootOrderFromQemu (BootOptionList);\r |
1143 | \r | |
49ba9447 | 1144 | //\r |
1145 | // Please uncomment above ConnectAll and EnumerateAll code and remove following first boot\r | |
1146 | // checking code in real production tip.\r | |
1147 | //\r | |
1148 | // In BOOT_WITH_FULL_CONFIGURATION boot mode, should always connect every device\r | |
1149 | // and do enumerate all the default boot options. But in development system board, the boot mode\r | |
1150 | // cannot be BOOT_ASSUMING_NO_CONFIGURATION_CHANGES because the machine box\r | |
1151 | // is always open. So the following code only do the ConnectAll and EnumerateAll at first boot.\r | |
1152 | //\r | |
1153 | Status = BdsLibBuildOptionFromVar (BootOptionList, L"BootOrder");\r | |
1154 | if (EFI_ERROR(Status)) {\r | |
1155 | //\r | |
1156 | // If cannot find "BootOrder" variable, it may be first boot.\r | |
1157 | // Try to connect all devices and enumerate all boot options here.\r | |
1158 | //\r | |
1159 | BdsLibConnectAll ();\r | |
1160 | BdsLibEnumerateAllBootOption (BootOptionList);\r | |
1161 | }\r | |
1162 | \r | |
1163 | //\r | |
1164 | // To give the User a chance to enter Setup here, if user set TimeOut is 0.\r | |
1165 | // BDS should still give user a chance to enter Setup\r | |
1166 | //\r | |
1167 | // Connect first boot option, and then check user input before exit\r | |
1168 | //\r | |
1169 | for (Link = BootOptionList->ForwardLink; Link != BootOptionList;Link = Link->ForwardLink) {\r | |
1170 | BootOption = CR (Link, BDS_COMMON_OPTION, Link, BDS_LOAD_OPTION_SIGNATURE);\r | |
1171 | if (!IS_LOAD_OPTION_TYPE (BootOption->Attribute, LOAD_OPTION_ACTIVE)) {\r | |
1172 | //\r | |
1173 | // skip the header of the link list, becuase it has no boot option\r | |
1174 | //\r | |
1175 | continue;\r | |
1176 | } else {\r | |
1177 | //\r | |
1178 | // Make sure the boot option device path connected, but ignore the BBS device path\r | |
1179 | //\r | |
1180 | if (DevicePathType (BootOption->DevicePath) != BBS_DEVICE_PATH) {\r | |
1181 | BdsLibConnectDevicePath (BootOption->DevicePath);\r | |
1182 | }\r | |
1183 | break;\r | |
1184 | }\r | |
1185 | }\r | |
1186 | \r | |
1187 | //\r | |
1188 | // Check whether the user input after the duration time has expired\r | |
1189 | //\r | |
1190 | OldTpl = EfiGetCurrentTpl();\r | |
1191 | gBS->RestoreTPL (TPL_APPLICATION);\r | |
1192 | gBS->WaitForEvent (1, &UserInputDurationTime, &Index);\r | |
1193 | gBS->CloseEvent (UserInputDurationTime);\r | |
1194 | Status = gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);\r | |
1195 | gBS->RaiseTPL (OldTpl);\r | |
1196 | \r | |
1197 | if (!EFI_ERROR (Status)) {\r | |
1198 | //\r | |
1199 | // Enter Setup if user input\r | |
1200 | //\r | |
1201 | Timeout = 0xffff;\r | |
1202 | PlatformBdsEnterFrontPage (Timeout, FALSE);\r | |
1203 | }\r | |
1204 | \r | |
1205 | return ;\r | |
1206 | }\r | |
1207 | \r | |
1208 | VOID\r | |
1209 | EFIAPI\r | |
1210 | PlatformBdsBootSuccess (\r | |
1211 | IN BDS_COMMON_OPTION *Option\r | |
1212 | )\r | |
1213 | /*++\r | |
1214 | \r | |
1215 | Routine Description:\r | |
1216 | \r | |
1217 | Hook point after a boot attempt succeeds. We don't expect a boot option to\r | |
1218 | return, so the EFI 1.0 specification defines that you will default to an\r | |
1219 | interactive mode and stop processing the BootOrder list in this case. This\r | |
1220 | is alos a platform implementation and can be customized by IBV/OEM.\r | |
1221 | \r | |
1222 | Arguments:\r | |
1223 | \r | |
1224 | Option - Pointer to Boot Option that succeeded to boot.\r | |
1225 | \r | |
1226 | Returns:\r | |
1227 | \r | |
1228 | None.\r | |
1229 | \r | |
1230 | --*/\r | |
1231 | {\r | |
1232 | CHAR16 *TmpStr;\r | |
1233 | \r | |
1234 | DEBUG ((EFI_D_INFO, "PlatformBdsBootSuccess\n"));\r | |
1235 | //\r | |
1236 | // If Boot returned with EFI_SUCCESS and there is not in the boot device\r | |
1237 | // select loop then we need to pop up a UI and wait for user input.\r | |
1238 | //\r | |
1239 | TmpStr = Option->StatusString;\r | |
1240 | if (TmpStr != NULL) {\r | |
1241 | BdsLibOutputStrings (gST->ConOut, TmpStr, Option->Description, L"\n\r", NULL);\r | |
1242 | FreePool (TmpStr);\r | |
1243 | }\r | |
1244 | }\r | |
1245 | \r | |
1246 | VOID\r | |
1247 | EFIAPI\r | |
1248 | PlatformBdsBootFail (\r | |
1249 | IN BDS_COMMON_OPTION *Option,\r | |
1250 | IN EFI_STATUS Status,\r | |
1251 | IN CHAR16 *ExitData,\r | |
1252 | IN UINTN ExitDataSize\r | |
1253 | )\r | |
1254 | /*++\r | |
1255 | \r | |
1256 | Routine Description:\r | |
1257 | \r | |
1258 | Hook point after a boot attempt fails.\r | |
1259 | \r | |
1260 | Arguments:\r | |
1261 | \r | |
1262 | Option - Pointer to Boot Option that failed to boot.\r | |
1263 | \r | |
1264 | Status - Status returned from failed boot.\r | |
1265 | \r | |
1266 | ExitData - Exit data returned from failed boot.\r | |
1267 | \r | |
1268 | ExitDataSize - Exit data size returned from failed boot.\r | |
1269 | \r | |
1270 | Returns:\r | |
1271 | \r | |
1272 | None.\r | |
1273 | \r | |
1274 | --*/\r | |
1275 | {\r | |
1276 | CHAR16 *TmpStr;\r | |
1277 | \r | |
1278 | DEBUG ((EFI_D_INFO, "PlatformBdsBootFail\n"));\r | |
1279 | \r | |
1280 | //\r | |
1281 | // If Boot returned with failed status then we need to pop up a UI and wait\r | |
1282 | // for user input.\r | |
1283 | //\r | |
1284 | TmpStr = Option->StatusString;\r | |
1285 | if (TmpStr != NULL) {\r | |
1286 | BdsLibOutputStrings (gST->ConOut, TmpStr, Option->Description, L"\n\r", NULL);\r | |
1287 | FreePool (TmpStr);\r | |
1288 | }\r | |
1289 | }\r | |
1290 | \r | |
1291 | EFI_STATUS\r | |
1292 | PlatformBdsNoConsoleAction (\r | |
1293 | VOID\r | |
1294 | )\r | |
1295 | /*++\r | |
1296 | \r | |
1297 | Routine Description:\r | |
1298 | \r | |
1299 | This function is remained for IBV/OEM to do some platform action,\r | |
1300 | if there no console device can be connected.\r | |
1301 | \r | |
1302 | Arguments:\r | |
1303 | \r | |
1304 | None.\r | |
1305 | \r | |
1306 | Returns:\r | |
1307 | \r | |
1308 | EFI_SUCCESS - Direct return success now.\r | |
1309 | \r | |
1310 | --*/\r | |
1311 | {\r | |
1312 | DEBUG ((EFI_D_INFO, "PlatformBdsNoConsoleAction\n"));\r | |
1313 | return EFI_SUCCESS;\r | |
1314 | }\r | |
1315 | \r | |
24cdd14e | 1316 | VOID\r |
49ba9447 | 1317 | EFIAPI\r |
1318 | PlatformBdsLockNonUpdatableFlash (\r | |
1319 | VOID\r | |
1320 | )\r | |
1321 | {\r | |
1322 | DEBUG ((EFI_D_INFO, "PlatformBdsLockNonUpdatableFlash\n"));\r | |
24cdd14e | 1323 | return;\r |
49ba9447 | 1324 | }\r |
40f2c454 | 1325 | \r |
1326 | \r | |
1327 | /**\r | |
1328 | This notification function is invoked when an instance of the\r | |
1329 | EFI_DEVICE_PATH_PROTOCOL is produced.\r | |
1330 | \r | |
1331 | @param Event The event that occured\r | |
1332 | @param Context For EFI compatiblity. Not used.\r | |
1333 | \r | |
1334 | **/\r | |
1335 | VOID\r | |
1336 | EFIAPI\r | |
1337 | NotifyDevPath (\r | |
1338 | IN EFI_EVENT Event,\r | |
1339 | IN VOID *Context\r | |
1340 | )\r | |
1341 | {\r | |
1342 | EFI_HANDLE Handle;\r | |
1343 | EFI_STATUS Status;\r | |
1344 | UINTN BufferSize;\r | |
1345 | EFI_DEVICE_PATH_PROTOCOL *DevPathNode;\r | |
1346 | ATAPI_DEVICE_PATH *Atapi;\r | |
1347 | \r | |
1348 | //\r | |
1349 | // Examine all new handles\r | |
1350 | //\r | |
1351 | for (;;) {\r | |
1352 | //\r | |
1353 | // Get the next handle\r | |
1354 | //\r | |
1355 | BufferSize = sizeof (Handle);\r | |
1356 | Status = gBS->LocateHandle (\r | |
1357 | ByRegisterNotify,\r | |
1358 | NULL,\r | |
1359 | mEfiDevPathNotifyReg,\r | |
1360 | &BufferSize,\r | |
1361 | &Handle\r | |
1362 | );\r | |
1363 | \r | |
1364 | //\r | |
1365 | // If not found, we're done\r | |
1366 | //\r | |
1367 | if (EFI_NOT_FOUND == Status) {\r | |
1368 | break;\r | |
1369 | }\r | |
1370 | \r | |
1371 | if (EFI_ERROR (Status)) {\r | |
1372 | continue;\r | |
1373 | }\r | |
1374 | \r | |
1375 | //\r | |
1376 | // Get the DevicePath protocol on that handle\r | |
1377 | //\r | |
1378 | Status = gBS->HandleProtocol (Handle, &gEfiDevicePathProtocolGuid, (VOID **)&DevPathNode);\r | |
1379 | ASSERT_EFI_ERROR (Status);\r | |
1380 | \r | |
1381 | while (!IsDevicePathEnd (DevPathNode)) {\r | |
1382 | //\r | |
1383 | // Find the handler to dump this device path node\r | |
1384 | //\r | |
1385 | if (\r | |
1386 | (DevicePathType(DevPathNode) == MESSAGING_DEVICE_PATH) &&\r | |
1387 | (DevicePathSubType(DevPathNode) == MSG_ATAPI_DP)\r | |
1388 | ) {\r | |
1389 | Atapi = (ATAPI_DEVICE_PATH*) DevPathNode;\r | |
1390 | PciOr16 (\r | |
1391 | PCI_LIB_ADDRESS (\r | |
1392 | 0,\r | |
1393 | 1,\r | |
1394 | 1,\r | |
1395 | (Atapi->PrimarySecondary == 1) ? 0x42: 0x40\r | |
1396 | ),\r | |
1397 | BIT15\r | |
1398 | );\r | |
1399 | }\r | |
1400 | \r | |
1401 | //\r | |
1402 | // Next device path node\r | |
1403 | //\r | |
1404 | DevPathNode = NextDevicePathNode (DevPathNode);\r | |
1405 | }\r | |
1406 | }\r | |
1407 | \r | |
1408 | return;\r | |
1409 | }\r | |
1410 | \r | |
1411 | \r | |
1412 | VOID\r | |
1413 | InstallDevicePathCallback (\r | |
1414 | VOID\r | |
1415 | )\r | |
1416 | {\r | |
1417 | DEBUG ((EFI_D_INFO, "Registered NotifyDevPath Event\n"));\r | |
1418 | mEfiDevPathEvent = EfiCreateProtocolNotifyEvent (\r | |
1419 | &gEfiDevicePathProtocolGuid,\r | |
1420 | TPL_CALLBACK,\r | |
1421 | NotifyDevPath,\r | |
1422 | NULL,\r | |
1423 | &mEfiDevPathNotifyReg\r | |
1424 | );\r | |
1425 | }\r | |
1426 | \r | |
24cdd14e LG |
1427 | /**\r |
1428 | Lock the ConsoleIn device in system table. All key\r | |
1429 | presses will be ignored until the Password is typed in. The only way to\r | |
1430 | disable the password is to type it in to a ConIn device.\r | |
1431 | \r | |
1432 | @param Password Password used to lock ConIn device.\r | |
1433 | \r | |
1434 | @retval EFI_SUCCESS lock the Console In Spliter virtual handle successfully.\r | |
1435 | @retval EFI_UNSUPPORTED Password not found\r | |
1436 | \r | |
1437 | **/\r | |
1438 | EFI_STATUS\r | |
1439 | EFIAPI\r | |
1440 | LockKeyboards (\r | |
1441 | IN CHAR16 *Password\r | |
1442 | )\r | |
1443 | {\r | |
1444 | return EFI_UNSUPPORTED;\r | |
1445 | }\r | |
5106d422 | 1446 | \r |