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