]>
Commit | Line | Data |
---|---|---|
1 | /** @file\r | |
2 | Platform BDS customizations.\r | |
3 | \r | |
4 | Copyright (c) 2004 - 2008, Intel Corporation. <BR>\r | |
5 | All rights reserved. This program and the accompanying materials\r | |
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 | |
18 | //\r | |
19 | // BDS Platform Functions\r | |
20 | //\r | |
21 | VOID\r | |
22 | EFIAPI\r | |
23 | PlatformBdsInit (\r | |
24 | VOID\r | |
25 | )\r | |
26 | /*++\r | |
27 | \r | |
28 | Routine Description:\r | |
29 | \r | |
30 | Platform Bds init. Incude the platform firmware vendor, revision\r | |
31 | and so crc check.\r | |
32 | \r | |
33 | Arguments:\r | |
34 | \r | |
35 | Returns:\r | |
36 | \r | |
37 | None.\r | |
38 | \r | |
39 | --*/\r | |
40 | {\r | |
41 | DEBUG ((EFI_D_INFO, "PlatformBdsInit\n"));\r | |
42 | }\r | |
43 | \r | |
44 | \r | |
45 | EFI_STATUS\r | |
46 | ConnectRootBridge (\r | |
47 | VOID\r | |
48 | )\r | |
49 | /*++\r | |
50 | \r | |
51 | Routine Description:\r | |
52 | \r | |
53 | Connect RootBridge\r | |
54 | \r | |
55 | Arguments:\r | |
56 | \r | |
57 | None.\r | |
58 | \r | |
59 | Returns:\r | |
60 | \r | |
61 | EFI_SUCCESS - Connect RootBridge successfully.\r | |
62 | EFI_STATUS - Connect RootBridge fail.\r | |
63 | \r | |
64 | --*/\r | |
65 | {\r | |
66 | EFI_STATUS Status;\r | |
67 | EFI_HANDLE RootHandle;\r | |
68 | \r | |
69 | //\r | |
70 | // Make all the PCI_IO protocols on PCI Seg 0 show up\r | |
71 | //\r | |
72 | BdsLibConnectDevicePath (gPlatformRootBridges[0]);\r | |
73 | \r | |
74 | Status = gBS->LocateDevicePath (\r | |
75 | &gEfiDevicePathProtocolGuid,\r | |
76 | &gPlatformRootBridges[0],\r | |
77 | &RootHandle\r | |
78 | );\r | |
79 | if (EFI_ERROR (Status)) {\r | |
80 | return Status;\r | |
81 | }\r | |
82 | \r | |
83 | Status = gBS->ConnectController (RootHandle, NULL, NULL, FALSE);\r | |
84 | if (EFI_ERROR (Status)) {\r | |
85 | return Status;\r | |
86 | }\r | |
87 | \r | |
88 | return EFI_SUCCESS;\r | |
89 | }\r | |
90 | \r | |
91 | \r | |
92 | EFI_STATUS\r | |
93 | PrepareLpcBridgeDevicePath (\r | |
94 | IN EFI_HANDLE DeviceHandle\r | |
95 | )\r | |
96 | /*++\r | |
97 | \r | |
98 | Routine Description:\r | |
99 | \r | |
100 | Add IsaKeyboard to ConIn,\r | |
101 | add IsaSerial to ConOut, ConIn, ErrOut.\r | |
102 | LPC Bridge: 06 01 00\r | |
103 | \r | |
104 | Arguments:\r | |
105 | \r | |
106 | DeviceHandle - Handle of PCIIO protocol.\r | |
107 | \r | |
108 | Returns:\r | |
109 | \r | |
110 | EFI_SUCCESS - LPC bridge is added to ConOut, ConIn, and ErrOut.\r | |
111 | EFI_STATUS - No LPC bridge is added.\r | |
112 | \r | |
113 | --*/\r | |
114 | {\r | |
115 | EFI_STATUS Status;\r | |
116 | EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r | |
117 | EFI_DEVICE_PATH_PROTOCOL *TempDevicePath;\r | |
118 | CHAR16 *DevPathStr;\r | |
119 | \r | |
120 | DevicePath = NULL;\r | |
121 | Status = gBS->HandleProtocol (\r | |
122 | DeviceHandle,\r | |
123 | &gEfiDevicePathProtocolGuid,\r | |
124 | (VOID*)&DevicePath\r | |
125 | );\r | |
126 | if (EFI_ERROR (Status)) {\r | |
127 | return Status;\r | |
128 | }\r | |
129 | TempDevicePath = DevicePath;\r | |
130 | \r | |
131 | //\r | |
132 | // Register Keyboard\r | |
133 | //\r | |
134 | DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gPnpPs2KeyboardDeviceNode);\r | |
135 | \r | |
136 | BdsLibUpdateConsoleVariable (VarConsoleInp, DevicePath, NULL);\r | |
137 | \r | |
138 | //\r | |
139 | // Register COM1\r | |
140 | //\r | |
141 | DevicePath = TempDevicePath;\r | |
142 | gPnp16550ComPortDeviceNode.UID = 0;\r | |
143 | \r | |
144 | DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gPnp16550ComPortDeviceNode);\r | |
145 | DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gUartDeviceNode);\r | |
146 | DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gTerminalTypeDeviceNode);\r | |
147 | \r | |
148 | //\r | |
149 | // Print Device Path\r | |
150 | //\r | |
151 | DevPathStr = DevicePathToStr(DevicePath);\r | |
152 | DEBUG((\r | |
153 | EFI_D_INFO,\r | |
154 | "BdsPlatform.c+%d: COM%d DevPath: %s\n",\r | |
155 | __LINE__,\r | |
156 | gPnp16550ComPortDeviceNode.UID + 1,\r | |
157 | DevPathStr\r | |
158 | ));\r | |
159 | FreePool(DevPathStr);\r | |
160 | \r | |
161 | BdsLibUpdateConsoleVariable (VarConsoleOut, DevicePath, NULL);\r | |
162 | BdsLibUpdateConsoleVariable (VarConsoleInp, DevicePath, NULL);\r | |
163 | BdsLibUpdateConsoleVariable (VarErrorOut, DevicePath, NULL);\r | |
164 | \r | |
165 | //\r | |
166 | // Register COM2\r | |
167 | //\r | |
168 | DevicePath = TempDevicePath;\r | |
169 | gPnp16550ComPortDeviceNode.UID = 1;\r | |
170 | \r | |
171 | DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gPnp16550ComPortDeviceNode);\r | |
172 | DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gUartDeviceNode);\r | |
173 | DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gTerminalTypeDeviceNode);\r | |
174 | \r | |
175 | //\r | |
176 | // Print Device Path\r | |
177 | //\r | |
178 | DevPathStr = DevicePathToStr(DevicePath);\r | |
179 | DEBUG((\r | |
180 | EFI_D_INFO,\r | |
181 | "BdsPlatform.c+%d: COM%d DevPath: %s\n",\r | |
182 | __LINE__,\r | |
183 | gPnp16550ComPortDeviceNode.UID + 1,\r | |
184 | DevPathStr\r | |
185 | ));\r | |
186 | FreePool(DevPathStr);\r | |
187 | \r | |
188 | BdsLibUpdateConsoleVariable (VarConsoleOut, DevicePath, NULL);\r | |
189 | BdsLibUpdateConsoleVariable (VarConsoleInp, DevicePath, NULL);\r | |
190 | BdsLibUpdateConsoleVariable (VarErrorOut, DevicePath, NULL);\r | |
191 | \r | |
192 | return EFI_SUCCESS;\r | |
193 | }\r | |
194 | \r | |
195 | EFI_STATUS\r | |
196 | GetGopDevicePath (\r | |
197 | IN EFI_DEVICE_PATH_PROTOCOL *PciDevicePath,\r | |
198 | OUT EFI_DEVICE_PATH_PROTOCOL **GopDevicePath\r | |
199 | )\r | |
200 | {\r | |
201 | UINTN Index;\r | |
202 | EFI_STATUS Status;\r | |
203 | EFI_HANDLE PciDeviceHandle;\r | |
204 | EFI_DEVICE_PATH_PROTOCOL *TempDevicePath;\r | |
205 | EFI_DEVICE_PATH_PROTOCOL *TempPciDevicePath;\r | |
206 | UINTN GopHandleCount;\r | |
207 | EFI_HANDLE *GopHandleBuffer;\r | |
208 | \r | |
209 | if (PciDevicePath == NULL || GopDevicePath == NULL) {\r | |
210 | return EFI_INVALID_PARAMETER;\r | |
211 | }\r | |
212 | \r | |
213 | //\r | |
214 | // Initialize the GopDevicePath to be PciDevicePath\r | |
215 | //\r | |
216 | *GopDevicePath = PciDevicePath;\r | |
217 | TempPciDevicePath = PciDevicePath;\r | |
218 | \r | |
219 | Status = gBS->LocateDevicePath (\r | |
220 | &gEfiDevicePathProtocolGuid,\r | |
221 | &TempPciDevicePath,\r | |
222 | &PciDeviceHandle\r | |
223 | );\r | |
224 | if (EFI_ERROR (Status)) {\r | |
225 | return Status;\r | |
226 | }\r | |
227 | \r | |
228 | //\r | |
229 | // Try to connect this handle, so that GOP dirver could start on this\r | |
230 | // device and create child handles with GraphicsOutput Protocol installed\r | |
231 | // on them, then we get device paths of these child handles and select\r | |
232 | // them as possible console device.\r | |
233 | //\r | |
234 | gBS->ConnectController (PciDeviceHandle, NULL, NULL, FALSE);\r | |
235 | \r | |
236 | Status = gBS->LocateHandleBuffer (\r | |
237 | ByProtocol,\r | |
238 | &gEfiGraphicsOutputProtocolGuid,\r | |
239 | NULL,\r | |
240 | &GopHandleCount,\r | |
241 | &GopHandleBuffer\r | |
242 | );\r | |
243 | if (!EFI_ERROR (Status)) {\r | |
244 | //\r | |
245 | // Add all the child handles as possible Console Device\r | |
246 | //\r | |
247 | for (Index = 0; Index < GopHandleCount; Index++) {\r | |
248 | Status = gBS->HandleProtocol (GopHandleBuffer[Index], &gEfiDevicePathProtocolGuid, (VOID*)&TempDevicePath);\r | |
249 | if (EFI_ERROR (Status)) {\r | |
250 | continue;\r | |
251 | }\r | |
252 | if (CompareMem (\r | |
253 | PciDevicePath,\r | |
254 | TempDevicePath,\r | |
255 | GetDevicePathSize (PciDevicePath) - END_DEVICE_PATH_LENGTH\r | |
256 | ) == 0) {\r | |
257 | //\r | |
258 | // In current implementation, we only enable one of the child handles\r | |
259 | // as console device, i.e. sotre one of the child handle's device\r | |
260 | // path to variable "ConOut"\r | |
261 | // In futhure, we could select all child handles to be console device\r | |
262 | //\r | |
263 | \r | |
264 | *GopDevicePath = TempDevicePath;\r | |
265 | \r | |
266 | //\r | |
267 | // Delete the PCI device's path that added by GetPlugInPciVgaDevicePath()\r | |
268 | // Add the integrity GOP device path.\r | |
269 | //\r | |
270 | BdsLibUpdateConsoleVariable (VarConsoleOutDev, NULL, PciDevicePath);\r | |
271 | BdsLibUpdateConsoleVariable (VarConsoleOutDev, TempDevicePath, NULL);\r | |
272 | }\r | |
273 | }\r | |
274 | gBS->FreePool (GopHandleBuffer);\r | |
275 | }\r | |
276 | \r | |
277 | return EFI_SUCCESS;\r | |
278 | }\r | |
279 | \r | |
280 | EFI_STATUS\r | |
281 | PreparePciVgaDevicePath (\r | |
282 | IN EFI_HANDLE DeviceHandle\r | |
283 | )\r | |
284 | /*++\r | |
285 | \r | |
286 | Routine Description:\r | |
287 | \r | |
288 | Add PCI VGA to ConOut.\r | |
289 | PCI VGA: 03 00 00\r | |
290 | \r | |
291 | Arguments:\r | |
292 | \r | |
293 | DeviceHandle - Handle of PCIIO protocol.\r | |
294 | \r | |
295 | Returns:\r | |
296 | \r | |
297 | EFI_SUCCESS - PCI VGA is added to ConOut.\r | |
298 | EFI_STATUS - No PCI VGA device is added.\r | |
299 | \r | |
300 | --*/\r | |
301 | {\r | |
302 | EFI_STATUS Status;\r | |
303 | EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r | |
304 | EFI_DEVICE_PATH_PROTOCOL *GopDevicePath;\r | |
305 | \r | |
306 | DevicePath = NULL;\r | |
307 | Status = gBS->HandleProtocol (\r | |
308 | DeviceHandle,\r | |
309 | &gEfiDevicePathProtocolGuid,\r | |
310 | (VOID*)&DevicePath\r | |
311 | );\r | |
312 | if (EFI_ERROR (Status)) {\r | |
313 | return Status;\r | |
314 | }\r | |
315 | \r | |
316 | GetGopDevicePath (DevicePath, &GopDevicePath);\r | |
317 | DevicePath = GopDevicePath;\r | |
318 | \r | |
319 | BdsLibUpdateConsoleVariable (VarConsoleOut, DevicePath, NULL);\r | |
320 | \r | |
321 | return EFI_SUCCESS;\r | |
322 | }\r | |
323 | \r | |
324 | EFI_STATUS\r | |
325 | PreparePciSerialDevicePath (\r | |
326 | IN EFI_HANDLE DeviceHandle\r | |
327 | )\r | |
328 | /*++\r | |
329 | \r | |
330 | Routine Description:\r | |
331 | \r | |
332 | Add PCI Serial to ConOut, ConIn, ErrOut.\r | |
333 | PCI Serial: 07 00 02\r | |
334 | \r | |
335 | Arguments:\r | |
336 | \r | |
337 | DeviceHandle - Handle of PCIIO protocol.\r | |
338 | \r | |
339 | Returns:\r | |
340 | \r | |
341 | EFI_SUCCESS - PCI Serial is added to ConOut, ConIn, and ErrOut.\r | |
342 | EFI_STATUS - No PCI Serial device is added.\r | |
343 | \r | |
344 | --*/\r | |
345 | {\r | |
346 | EFI_STATUS Status;\r | |
347 | EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r | |
348 | \r | |
349 | DevicePath = NULL;\r | |
350 | Status = gBS->HandleProtocol (\r | |
351 | DeviceHandle,\r | |
352 | &gEfiDevicePathProtocolGuid,\r | |
353 | (VOID*)&DevicePath\r | |
354 | );\r | |
355 | if (EFI_ERROR (Status)) {\r | |
356 | return Status;\r | |
357 | }\r | |
358 | \r | |
359 | DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gUartDeviceNode);\r | |
360 | DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gTerminalTypeDeviceNode);\r | |
361 | \r | |
362 | BdsLibUpdateConsoleVariable (VarConsoleOut, DevicePath, NULL);\r | |
363 | BdsLibUpdateConsoleVariable (VarConsoleInp, DevicePath, NULL);\r | |
364 | BdsLibUpdateConsoleVariable (VarErrorOut, DevicePath, NULL);\r | |
365 | \r | |
366 | return EFI_SUCCESS;\r | |
367 | }\r | |
368 | \r | |
369 | EFI_STATUS\r | |
370 | DetectAndPreparePlatformPciDevicePath (\r | |
371 | BOOLEAN DetectVgaOnly\r | |
372 | )\r | |
373 | /*++\r | |
374 | \r | |
375 | Routine Description:\r | |
376 | \r | |
377 | Do platform specific PCI Device check and add them to ConOut, ConIn, ErrOut\r | |
378 | \r | |
379 | Arguments:\r | |
380 | \r | |
381 | DetectVgaOnly - Only detect VGA device if it's TRUE.\r | |
382 | \r | |
383 | Returns:\r | |
384 | \r | |
385 | EFI_SUCCESS - PCI Device check and Console variable update successfully.\r | |
386 | EFI_STATUS - PCI Device check or Console variable update fail.\r | |
387 | \r | |
388 | --*/\r | |
389 | {\r | |
390 | EFI_STATUS Status;\r | |
391 | UINTN HandleCount;\r | |
392 | EFI_HANDLE *HandleBuffer;\r | |
393 | UINTN Index;\r | |
394 | EFI_PCI_IO_PROTOCOL *PciIo;\r | |
395 | PCI_TYPE00 Pci;\r | |
396 | \r | |
397 | //\r | |
398 | // Start to check all the PciIo to find all possible device\r | |
399 | //\r | |
400 | HandleCount = 0;\r | |
401 | HandleBuffer = NULL;\r | |
402 | Status = gBS->LocateHandleBuffer (\r | |
403 | ByProtocol,\r | |
404 | &gEfiPciIoProtocolGuid,\r | |
405 | NULL,\r | |
406 | &HandleCount,\r | |
407 | &HandleBuffer\r | |
408 | );\r | |
409 | if (EFI_ERROR (Status)) {\r | |
410 | return Status;\r | |
411 | }\r | |
412 | \r | |
413 | for (Index = 0; Index < HandleCount; Index++) {\r | |
414 | Status = gBS->HandleProtocol (HandleBuffer[Index], &gEfiPciIoProtocolGuid, (VOID*)&PciIo);\r | |
415 | if (EFI_ERROR (Status)) {\r | |
416 | continue;\r | |
417 | }\r | |
418 | \r | |
419 | //\r | |
420 | // Check for all PCI device\r | |
421 | //\r | |
422 | Status = PciIo->Pci.Read (\r | |
423 | PciIo,\r | |
424 | EfiPciIoWidthUint32,\r | |
425 | 0,\r | |
426 | sizeof (Pci) / sizeof (UINT32),\r | |
427 | &Pci\r | |
428 | );\r | |
429 | if (EFI_ERROR (Status)) {\r | |
430 | continue;\r | |
431 | }\r | |
432 | \r | |
433 | if (!DetectVgaOnly) {\r | |
434 | //\r | |
435 | // Here we decide whether it is LPC Bridge\r | |
436 | //\r | |
437 | if ((IS_PCI_LPC (&Pci)) ||\r | |
438 | ((IS_PCI_ISA_PDECODE (&Pci)) &&\r | |
439 | (Pci.Hdr.VendorId == 0x8086) &&\r | |
440 | (Pci.Hdr.DeviceId == 0x7000)\r | |
441 | )\r | |
442 | ) {\r | |
443 | Status = PciIo->Attributes (\r | |
444 | PciIo,\r | |
445 | EfiPciIoAttributeOperationEnable,\r | |
446 | EFI_PCI_DEVICE_ENABLE,\r | |
447 | NULL\r | |
448 | );\r | |
449 | //\r | |
450 | // Add IsaKeyboard to ConIn,\r | |
451 | // add IsaSerial to ConOut, ConIn, ErrOut\r | |
452 | //\r | |
453 | DEBUG ((EFI_D_INFO, "Find the LPC Bridge device\n"));\r | |
454 | PrepareLpcBridgeDevicePath (HandleBuffer[Index]);\r | |
455 | continue;\r | |
456 | }\r | |
457 | //\r | |
458 | // Here we decide which Serial device to enable in PCI bus\r | |
459 | //\r | |
460 | if (IS_PCI_16550SERIAL (&Pci)) {\r | |
461 | //\r | |
462 | // Add them to ConOut, ConIn, ErrOut.\r | |
463 | //\r | |
464 | DEBUG ((EFI_D_INFO, "Find the 16550 SERIAL device\n"));\r | |
465 | PreparePciSerialDevicePath (HandleBuffer[Index]);\r | |
466 | continue;\r | |
467 | }\r | |
468 | }\r | |
469 | \r | |
470 | if ((Pci.Hdr.VendorId == 0x8086) &&\r | |
471 | (Pci.Hdr.DeviceId == 0x7010)\r | |
472 | ) {\r | |
473 | Status = PciIo->Attributes (\r | |
474 | PciIo,\r | |
475 | EfiPciIoAttributeOperationEnable,\r | |
476 | EFI_PCI_DEVICE_ENABLE,\r | |
477 | NULL\r | |
478 | );\r | |
479 | }\r | |
480 | \r | |
481 | //\r | |
482 | // Here we decide which VGA device to enable in PCI bus\r | |
483 | //\r | |
484 | if (IS_PCI_VGA (&Pci)) {\r | |
485 | //\r | |
486 | // Add them to ConOut.\r | |
487 | //\r | |
488 | DEBUG ((EFI_D_INFO, "Find the VGA device\n"));\r | |
489 | PreparePciVgaDevicePath (HandleBuffer[Index]);\r | |
490 | continue;\r | |
491 | }\r | |
492 | }\r | |
493 | \r | |
494 | gBS->FreePool (HandleBuffer);\r | |
495 | \r | |
496 | return EFI_SUCCESS;\r | |
497 | }\r | |
498 | \r | |
499 | \r | |
500 | EFI_STATUS\r | |
501 | PlatformBdsConnectConsole (\r | |
502 | IN BDS_CONSOLE_CONNECT_ENTRY *PlatformConsole\r | |
503 | )\r | |
504 | /*++\r | |
505 | \r | |
506 | Routine Description:\r | |
507 | \r | |
508 | Connect the predefined platform default console device. Always try to find\r | |
509 | and enable the vga device if have.\r | |
510 | \r | |
511 | Arguments:\r | |
512 | \r | |
513 | PlatformConsole - Predfined platform default console device array.\r | |
514 | \r | |
515 | Returns:\r | |
516 | \r | |
517 | EFI_SUCCESS - Success connect at least one ConIn and ConOut\r | |
518 | device, there must have one ConOut device is\r | |
519 | active vga device.\r | |
520 | \r | |
521 | EFI_STATUS - Return the status of\r | |
522 | BdsLibConnectAllDefaultConsoles ()\r | |
523 | \r | |
524 | --*/\r | |
525 | {\r | |
526 | EFI_STATUS Status;\r | |
527 | UINTN Index;\r | |
528 | EFI_DEVICE_PATH_PROTOCOL *VarConout;\r | |
529 | EFI_DEVICE_PATH_PROTOCOL *VarConin;\r | |
530 | UINTN DevicePathSize;\r | |
531 | \r | |
532 | //\r | |
533 | // Connect RootBridge\r | |
534 | //\r | |
535 | ConnectRootBridge ();\r | |
536 | \r | |
537 | VarConout = BdsLibGetVariableAndSize (\r | |
538 | VarConsoleOut,\r | |
539 | &gEfiGlobalVariableGuid,\r | |
540 | &DevicePathSize\r | |
541 | );\r | |
542 | VarConin = BdsLibGetVariableAndSize (\r | |
543 | VarConsoleInp,\r | |
544 | &gEfiGlobalVariableGuid,\r | |
545 | &DevicePathSize\r | |
546 | );\r | |
547 | \r | |
548 | if (VarConout == NULL || VarConin == NULL) {\r | |
549 | //\r | |
550 | // Do platform specific PCI Device check and add them to ConOut, ConIn, ErrOut\r | |
551 | //\r | |
552 | DetectAndPreparePlatformPciDevicePath (FALSE);\r | |
553 | \r | |
554 | //\r | |
555 | // Have chance to connect the platform default console,\r | |
556 | // the platform default console is the minimue device group\r | |
557 | // the platform should support\r | |
558 | //\r | |
559 | for (Index = 0; PlatformConsole[Index].DevicePath != NULL; ++Index) {\r | |
560 | //\r | |
561 | // Update the console variable with the connect type\r | |
562 | //\r | |
563 | if ((PlatformConsole[Index].ConnectType & CONSOLE_IN) == CONSOLE_IN) {\r | |
564 | BdsLibUpdateConsoleVariable (VarConsoleInp, PlatformConsole[Index].DevicePath, NULL);\r | |
565 | }\r | |
566 | if ((PlatformConsole[Index].ConnectType & CONSOLE_OUT) == CONSOLE_OUT) {\r | |
567 | BdsLibUpdateConsoleVariable (VarConsoleOut, PlatformConsole[Index].DevicePath, NULL);\r | |
568 | }\r | |
569 | if ((PlatformConsole[Index].ConnectType & STD_ERROR) == STD_ERROR) {\r | |
570 | BdsLibUpdateConsoleVariable (VarErrorOut, PlatformConsole[Index].DevicePath, NULL);\r | |
571 | }\r | |
572 | }\r | |
573 | } else {\r | |
574 | //\r | |
575 | // Only detect VGA device and add them to ConOut\r | |
576 | //\r | |
577 | DetectAndPreparePlatformPciDevicePath (TRUE);\r | |
578 | }\r | |
579 | \r | |
580 | //\r | |
581 | // Connect the all the default console with current cosole variable\r | |
582 | //\r | |
583 | Status = BdsLibConnectAllDefaultConsoles ();\r | |
584 | if (EFI_ERROR (Status)) {\r | |
585 | return Status;\r | |
586 | }\r | |
587 | \r | |
588 | return EFI_SUCCESS;\r | |
589 | }\r | |
590 | \r | |
591 | \r | |
592 | VOID\r | |
593 | PciInitialization (\r | |
594 | )\r | |
595 | {\r | |
596 | //\r | |
597 | // Device 0 Function 0\r | |
598 | //\r | |
599 | PciWrite8 (PCI_LIB_ADDRESS (0,0,0,0x3c), 0x00);\r | |
600 | \r | |
601 | //\r | |
602 | // Device 1 Function 0\r | |
603 | //\r | |
604 | PciWrite8 (PCI_LIB_ADDRESS (0,1,0,0x3c), 0x00);\r | |
605 | PciWrite8 (PCI_LIB_ADDRESS (0,1,0,0x60), 0x8b);\r | |
606 | PciWrite8 (PCI_LIB_ADDRESS (0,1,0,0x61), 0x89);\r | |
607 | PciWrite8 (PCI_LIB_ADDRESS (0,1,0,0x62), 0x0a);\r | |
608 | PciWrite8 (PCI_LIB_ADDRESS (0,1,0,0x63), 0x89);\r | |
609 | //PciWrite8 (PCI_LIB_ADDRESS (0,1,0,0x82), 0x02);\r | |
610 | \r | |
611 | //\r | |
612 | // Device 1 Function 1\r | |
613 | //\r | |
614 | PciWrite8 (PCI_LIB_ADDRESS (0,1,1,0x3c), 0x00);\r | |
615 | \r | |
616 | //\r | |
617 | // Device 1 Function 3\r | |
618 | //\r | |
619 | PciWrite8 (PCI_LIB_ADDRESS (0,1,3,0x3c), 0x0b);\r | |
620 | PciWrite8 (PCI_LIB_ADDRESS (0,1,3,0x3d), 0x01);\r | |
621 | PciWrite8 (PCI_LIB_ADDRESS (0,1,3,0x5f), 0x90);\r | |
622 | \r | |
623 | //\r | |
624 | // Device 2 Function 0\r | |
625 | //\r | |
626 | PciWrite8 (PCI_LIB_ADDRESS (0,2,0,0x3c), 0x00);\r | |
627 | \r | |
628 | //\r | |
629 | // Device 3 Function 0\r | |
630 | //\r | |
631 | PciWrite8 (PCI_LIB_ADDRESS (0,3,0,0x3c), 0x0b);\r | |
632 | PciWrite8 (PCI_LIB_ADDRESS (0,3,0,0x3d), 0x01);\r | |
633 | }\r | |
634 | \r | |
635 | \r | |
636 | VOID\r | |
637 | PlatformBdsConnectSequence (\r | |
638 | VOID\r | |
639 | )\r | |
640 | /*++\r | |
641 | \r | |
642 | Routine Description:\r | |
643 | \r | |
644 | Connect with predeined platform connect sequence,\r | |
645 | the OEM/IBV can customize with their own connect sequence.\r | |
646 | \r | |
647 | Arguments:\r | |
648 | \r | |
649 | None.\r | |
650 | \r | |
651 | Returns:\r | |
652 | \r | |
653 | None.\r | |
654 | \r | |
655 | --*/\r | |
656 | {\r | |
657 | UINTN Index;\r | |
658 | \r | |
659 | DEBUG ((EFI_D_INFO, "PlatformBdsConnectSequence\n"));\r | |
660 | \r | |
661 | Index = 0;\r | |
662 | \r | |
663 | //\r | |
664 | // Here we can get the customized platform connect sequence\r | |
665 | // Notes: we can connect with new variable which record the\r | |
666 | // last time boots connect device path sequence\r | |
667 | //\r | |
668 | while (gPlatformConnectSequence[Index] != NULL) {\r | |
669 | //\r | |
670 | // Build the platform boot option\r | |
671 | //\r | |
672 | BdsLibConnectDevicePath (gPlatformConnectSequence[Index]);\r | |
673 | Index++;\r | |
674 | }\r | |
675 | \r | |
676 | //\r | |
677 | // Just use the simple policy to connect all devices\r | |
678 | //\r | |
679 | BdsLibConnectAll ();\r | |
680 | \r | |
681 | PciInitialization ();\r | |
682 | }\r | |
683 | \r | |
684 | VOID\r | |
685 | PlatformBdsGetDriverOption (\r | |
686 | IN OUT LIST_ENTRY *BdsDriverLists\r | |
687 | )\r | |
688 | /*++\r | |
689 | \r | |
690 | Routine Description:\r | |
691 | \r | |
692 | Load the predefined driver option, OEM/IBV can customize this\r | |
693 | to load their own drivers\r | |
694 | \r | |
695 | Arguments:\r | |
696 | \r | |
697 | BdsDriverLists - The header of the driver option link list.\r | |
698 | \r | |
699 | Returns:\r | |
700 | \r | |
701 | None.\r | |
702 | \r | |
703 | --*/\r | |
704 | {\r | |
705 | DEBUG ((EFI_D_INFO, "PlatformBdsGetDriverOption\n"));\r | |
706 | return;\r | |
707 | }\r | |
708 | \r | |
709 | VOID\r | |
710 | PlatformBdsDiagnostics (\r | |
711 | IN EXTENDMEM_COVERAGE_LEVEL MemoryTestLevel,\r | |
712 | IN BOOLEAN QuietBoot\r | |
713 | )\r | |
714 | /*++\r | |
715 | \r | |
716 | Routine Description:\r | |
717 | \r | |
718 | Perform the platform diagnostic, such like test memory. OEM/IBV also\r | |
719 | can customize this fuction to support specific platform diagnostic.\r | |
720 | \r | |
721 | Arguments:\r | |
722 | \r | |
723 | MemoryTestLevel - The memory test intensive level\r | |
724 | \r | |
725 | QuietBoot - Indicate if need to enable the quiet boot\r | |
726 | \r | |
727 | Returns:\r | |
728 | \r | |
729 | None.\r | |
730 | \r | |
731 | --*/\r | |
732 | {\r | |
733 | EFI_STATUS Status;\r | |
734 | \r | |
735 | DEBUG ((EFI_D_INFO, "PlatformBdsDiagnostics\n"));\r | |
736 | \r | |
737 | //\r | |
738 | // Here we can decide if we need to show\r | |
739 | // the diagnostics screen\r | |
740 | // Notes: this quiet boot code should be remove\r | |
741 | // from the graphic lib\r | |
742 | //\r | |
743 | if (QuietBoot) {\r | |
744 | EnableQuietBoot (&gEfiDefaultBmpLogoGuid);\r | |
745 | //\r | |
746 | // Perform system diagnostic\r | |
747 | //\r | |
748 | Status = BdsMemoryTest (MemoryTestLevel);\r | |
749 | if (EFI_ERROR (Status)) {\r | |
750 | DisableQuietBoot ();\r | |
751 | }\r | |
752 | \r | |
753 | return ;\r | |
754 | }\r | |
755 | //\r | |
756 | // Perform system diagnostic\r | |
757 | //\r | |
758 | Status = BdsMemoryTest (MemoryTestLevel);\r | |
759 | }\r | |
760 | \r | |
761 | \r | |
762 | VOID\r | |
763 | EFIAPI\r | |
764 | PlatformBdsPolicyBehavior (\r | |
765 | IN OUT LIST_ENTRY *DriverOptionList,\r | |
766 | IN OUT LIST_ENTRY *BootOptionList\r | |
767 | )\r | |
768 | /*++\r | |
769 | \r | |
770 | Routine Description:\r | |
771 | \r | |
772 | The function will excute with as the platform policy, current policy\r | |
773 | is driven by boot mode. IBV/OEM can customize this code for their specific\r | |
774 | policy action.\r | |
775 | \r | |
776 | Arguments:\r | |
777 | \r | |
778 | DriverOptionList - The header of the driver option link list\r | |
779 | \r | |
780 | BootOptionList - The header of the boot option link list\r | |
781 | \r | |
782 | Returns:\r | |
783 | \r | |
784 | None.\r | |
785 | \r | |
786 | --*/\r | |
787 | {\r | |
788 | EFI_STATUS Status;\r | |
789 | UINT16 Timeout;\r | |
790 | EFI_EVENT UserInputDurationTime;\r | |
791 | LIST_ENTRY *Link;\r | |
792 | BDS_COMMON_OPTION *BootOption;\r | |
793 | UINTN Index;\r | |
794 | EFI_INPUT_KEY Key;\r | |
795 | EFI_TPL OldTpl;\r | |
796 | EFI_BOOT_MODE BootMode;\r | |
797 | \r | |
798 | DEBUG ((EFI_D_INFO, "PlatformBdsPolicyBehavior\n"));\r | |
799 | \r | |
800 | //\r | |
801 | // Init the time out value\r | |
802 | //\r | |
803 | Timeout = PcdGet16 (PcdPlatformBootTimeOut);\r | |
804 | \r | |
805 | //\r | |
806 | // Load the driver option as the driver option list\r | |
807 | //\r | |
808 | PlatformBdsGetDriverOption (DriverOptionList);\r | |
809 | \r | |
810 | //\r | |
811 | // Get current Boot Mode\r | |
812 | //\r | |
813 | Status = BdsLibGetBootMode (&BootMode);\r | |
814 | DEBUG ((EFI_D_ERROR, "Boot Mode:%x\n", BootMode));\r | |
815 | \r | |
816 | //\r | |
817 | // Go the different platform policy with different boot mode\r | |
818 | // Notes: this part code can be change with the table policy\r | |
819 | //\r | |
820 | ASSERT (BootMode == BOOT_WITH_FULL_CONFIGURATION);\r | |
821 | //\r | |
822 | // Connect platform console\r | |
823 | //\r | |
824 | Status = PlatformBdsConnectConsole (gPlatformConsole);\r | |
825 | if (EFI_ERROR (Status)) {\r | |
826 | //\r | |
827 | // Here OEM/IBV can customize with defined action\r | |
828 | //\r | |
829 | PlatformBdsNoConsoleAction ();\r | |
830 | }\r | |
831 | //\r | |
832 | // Create a 300ms duration event to ensure user has enough input time to enter Setup\r | |
833 | //\r | |
834 | Status = gBS->CreateEvent (\r | |
835 | EVT_TIMER,\r | |
836 | 0,\r | |
837 | NULL,\r | |
838 | NULL,\r | |
839 | &UserInputDurationTime\r | |
840 | );\r | |
841 | ASSERT (Status == EFI_SUCCESS);\r | |
842 | Status = gBS->SetTimer (UserInputDurationTime, TimerRelative, 3000000);\r | |
843 | ASSERT (Status == EFI_SUCCESS);\r | |
844 | //\r | |
845 | // Memory test and Logo show\r | |
846 | //\r | |
847 | PlatformBdsDiagnostics (IGNORE, TRUE);\r | |
848 | \r | |
849 | //\r | |
850 | // Perform some platform specific connect sequence\r | |
851 | //\r | |
852 | PlatformBdsConnectSequence ();\r | |
853 | \r | |
854 | //\r | |
855 | // Give one chance to enter the setup if we\r | |
856 | // have the time out\r | |
857 | //\r | |
858 | if (Timeout != 0) {\r | |
859 | //PlatformBdsEnterFrontPage (Timeout, FALSE);\r | |
860 | }\r | |
861 | \r | |
862 | DEBUG ((EFI_D_INFO, "BdsLibConnectAll\n"));\r | |
863 | BdsLibConnectAll ();\r | |
864 | BdsLibEnumerateAllBootOption (BootOptionList);\r | |
865 | \r | |
866 | //\r | |
867 | // Please uncomment above ConnectAll and EnumerateAll code and remove following first boot\r | |
868 | // checking code in real production tip.\r | |
869 | //\r | |
870 | // In BOOT_WITH_FULL_CONFIGURATION boot mode, should always connect every device\r | |
871 | // and do enumerate all the default boot options. But in development system board, the boot mode\r | |
872 | // cannot be BOOT_ASSUMING_NO_CONFIGURATION_CHANGES because the machine box\r | |
873 | // is always open. So the following code only do the ConnectAll and EnumerateAll at first boot.\r | |
874 | //\r | |
875 | Status = BdsLibBuildOptionFromVar (BootOptionList, L"BootOrder");\r | |
876 | if (EFI_ERROR(Status)) {\r | |
877 | //\r | |
878 | // If cannot find "BootOrder" variable, it may be first boot.\r | |
879 | // Try to connect all devices and enumerate all boot options here.\r | |
880 | //\r | |
881 | BdsLibConnectAll ();\r | |
882 | BdsLibEnumerateAllBootOption (BootOptionList);\r | |
883 | }\r | |
884 | \r | |
885 | //\r | |
886 | // To give the User a chance to enter Setup here, if user set TimeOut is 0.\r | |
887 | // BDS should still give user a chance to enter Setup\r | |
888 | //\r | |
889 | // Connect first boot option, and then check user input before exit\r | |
890 | //\r | |
891 | for (Link = BootOptionList->ForwardLink; Link != BootOptionList;Link = Link->ForwardLink) {\r | |
892 | BootOption = CR (Link, BDS_COMMON_OPTION, Link, BDS_LOAD_OPTION_SIGNATURE);\r | |
893 | if (!IS_LOAD_OPTION_TYPE (BootOption->Attribute, LOAD_OPTION_ACTIVE)) {\r | |
894 | //\r | |
895 | // skip the header of the link list, becuase it has no boot option\r | |
896 | //\r | |
897 | continue;\r | |
898 | } else {\r | |
899 | //\r | |
900 | // Make sure the boot option device path connected, but ignore the BBS device path\r | |
901 | //\r | |
902 | if (DevicePathType (BootOption->DevicePath) != BBS_DEVICE_PATH) {\r | |
903 | BdsLibConnectDevicePath (BootOption->DevicePath);\r | |
904 | }\r | |
905 | break;\r | |
906 | }\r | |
907 | }\r | |
908 | \r | |
909 | //\r | |
910 | // Check whether the user input after the duration time has expired\r | |
911 | //\r | |
912 | OldTpl = EfiGetCurrentTpl();\r | |
913 | gBS->RestoreTPL (TPL_APPLICATION);\r | |
914 | gBS->WaitForEvent (1, &UserInputDurationTime, &Index);\r | |
915 | gBS->CloseEvent (UserInputDurationTime);\r | |
916 | Status = gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);\r | |
917 | gBS->RaiseTPL (OldTpl);\r | |
918 | \r | |
919 | if (!EFI_ERROR (Status)) {\r | |
920 | //\r | |
921 | // Enter Setup if user input\r | |
922 | //\r | |
923 | Timeout = 0xffff;\r | |
924 | PlatformBdsEnterFrontPage (Timeout, FALSE);\r | |
925 | }\r | |
926 | \r | |
927 | return ;\r | |
928 | }\r | |
929 | \r | |
930 | VOID\r | |
931 | EFIAPI\r | |
932 | PlatformBdsBootSuccess (\r | |
933 | IN BDS_COMMON_OPTION *Option\r | |
934 | )\r | |
935 | /*++\r | |
936 | \r | |
937 | Routine Description:\r | |
938 | \r | |
939 | Hook point after a boot attempt succeeds. We don't expect a boot option to\r | |
940 | return, so the EFI 1.0 specification defines that you will default to an\r | |
941 | interactive mode and stop processing the BootOrder list in this case. This\r | |
942 | is alos a platform implementation and can be customized by IBV/OEM.\r | |
943 | \r | |
944 | Arguments:\r | |
945 | \r | |
946 | Option - Pointer to Boot Option that succeeded to boot.\r | |
947 | \r | |
948 | Returns:\r | |
949 | \r | |
950 | None.\r | |
951 | \r | |
952 | --*/\r | |
953 | {\r | |
954 | CHAR16 *TmpStr;\r | |
955 | \r | |
956 | DEBUG ((EFI_D_INFO, "PlatformBdsBootSuccess\n"));\r | |
957 | //\r | |
958 | // If Boot returned with EFI_SUCCESS and there is not in the boot device\r | |
959 | // select loop then we need to pop up a UI and wait for user input.\r | |
960 | //\r | |
961 | TmpStr = Option->StatusString;\r | |
962 | if (TmpStr != NULL) {\r | |
963 | BdsLibOutputStrings (gST->ConOut, TmpStr, Option->Description, L"\n\r", NULL);\r | |
964 | FreePool (TmpStr);\r | |
965 | }\r | |
966 | }\r | |
967 | \r | |
968 | VOID\r | |
969 | EFIAPI\r | |
970 | PlatformBdsBootFail (\r | |
971 | IN BDS_COMMON_OPTION *Option,\r | |
972 | IN EFI_STATUS Status,\r | |
973 | IN CHAR16 *ExitData,\r | |
974 | IN UINTN ExitDataSize\r | |
975 | )\r | |
976 | /*++\r | |
977 | \r | |
978 | Routine Description:\r | |
979 | \r | |
980 | Hook point after a boot attempt fails.\r | |
981 | \r | |
982 | Arguments:\r | |
983 | \r | |
984 | Option - Pointer to Boot Option that failed to boot.\r | |
985 | \r | |
986 | Status - Status returned from failed boot.\r | |
987 | \r | |
988 | ExitData - Exit data returned from failed boot.\r | |
989 | \r | |
990 | ExitDataSize - Exit data size returned from failed boot.\r | |
991 | \r | |
992 | Returns:\r | |
993 | \r | |
994 | None.\r | |
995 | \r | |
996 | --*/\r | |
997 | {\r | |
998 | CHAR16 *TmpStr;\r | |
999 | \r | |
1000 | DEBUG ((EFI_D_INFO, "PlatformBdsBootFail\n"));\r | |
1001 | \r | |
1002 | //\r | |
1003 | // If Boot returned with failed status then we need to pop up a UI and wait\r | |
1004 | // for user input.\r | |
1005 | //\r | |
1006 | TmpStr = Option->StatusString;\r | |
1007 | if (TmpStr != NULL) {\r | |
1008 | BdsLibOutputStrings (gST->ConOut, TmpStr, Option->Description, L"\n\r", NULL);\r | |
1009 | FreePool (TmpStr);\r | |
1010 | }\r | |
1011 | }\r | |
1012 | \r | |
1013 | EFI_STATUS\r | |
1014 | PlatformBdsNoConsoleAction (\r | |
1015 | VOID\r | |
1016 | )\r | |
1017 | /*++\r | |
1018 | \r | |
1019 | Routine Description:\r | |
1020 | \r | |
1021 | This function is remained for IBV/OEM to do some platform action,\r | |
1022 | if there no console device can be connected.\r | |
1023 | \r | |
1024 | Arguments:\r | |
1025 | \r | |
1026 | None.\r | |
1027 | \r | |
1028 | Returns:\r | |
1029 | \r | |
1030 | EFI_SUCCESS - Direct return success now.\r | |
1031 | \r | |
1032 | --*/\r | |
1033 | {\r | |
1034 | DEBUG ((EFI_D_INFO, "PlatformBdsNoConsoleAction\n"));\r | |
1035 | return EFI_SUCCESS;\r | |
1036 | }\r | |
1037 | \r | |
1038 | EFI_STATUS\r | |
1039 | EFIAPI\r | |
1040 | PlatformBdsLockNonUpdatableFlash (\r | |
1041 | VOID\r | |
1042 | )\r | |
1043 | {\r | |
1044 | DEBUG ((EFI_D_INFO, "PlatformBdsLockNonUpdatableFlash\n"));\r | |
1045 | return EFI_SUCCESS;\r | |
1046 | }\r |