]>
Commit | Line | Data |
---|---|---|
4af04335 DB |
1 | /** @file\r |
2 | handles console redirection from boot manager\r | |
3 | \r | |
4 | Copyright (c) 2004 - 2015, Intel Corporation. All rights reserved.<BR>\r | |
5 | 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 "BootMaintenanceManager.h"\r | |
16 | \r | |
17 | /**\r | |
18 | Function compares a device path data structure to that of all the nodes of a\r | |
19 | second device path instance.\r | |
20 | \r | |
21 | @param Multi A pointer to a multi-instance device path data\r | |
22 | structure.\r | |
23 | @param Single A pointer to a single-instance device path data\r | |
24 | structure.\r | |
25 | \r | |
26 | @retval TRUE If the Single device path is contained within Multi device path.\r | |
27 | @retval FALSE The Single device path is not match within Multi device path.\r | |
28 | \r | |
29 | **/\r | |
30 | BOOLEAN\r | |
31 | MatchDevicePaths (\r | |
32 | IN EFI_DEVICE_PATH_PROTOCOL *Multi,\r | |
33 | IN EFI_DEVICE_PATH_PROTOCOL *Single\r | |
34 | )\r | |
35 | {\r | |
36 | EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r | |
37 | EFI_DEVICE_PATH_PROTOCOL *DevicePathInst;\r | |
38 | UINTN Size;\r | |
39 | \r | |
40 | if (Multi == NULL || Single == NULL) {\r | |
41 | return FALSE;\r | |
42 | }\r | |
43 | \r | |
44 | DevicePath = Multi;\r | |
45 | DevicePathInst = GetNextDevicePathInstance (&DevicePath, &Size);\r | |
46 | \r | |
47 | //\r | |
48 | // Search for the match of 'Single' in 'Multi'\r | |
49 | //\r | |
50 | while (DevicePathInst != NULL) {\r | |
51 | //\r | |
52 | // If the single device path is found in multiple device paths,\r | |
53 | // return success\r | |
54 | //\r | |
55 | if (CompareMem (Single, DevicePathInst, Size) == 0) {\r | |
56 | FreePool (DevicePathInst);\r | |
57 | return TRUE;\r | |
58 | }\r | |
59 | \r | |
60 | FreePool (DevicePathInst);\r | |
61 | DevicePathInst = GetNextDevicePathInstance (&DevicePath, &Size);\r | |
62 | }\r | |
63 | \r | |
64 | return FALSE;\r | |
65 | }\r | |
66 | \r | |
67 | /**\r | |
68 | Check whether the device path node is ISA Serial Node.\r | |
69 | \r | |
70 | @param Acpi Device path node to be checked\r | |
71 | \r | |
72 | @retval TRUE It's ISA Serial Node.\r | |
73 | @retval FALSE It's NOT ISA Serial Node.\r | |
74 | \r | |
75 | **/\r | |
76 | BOOLEAN\r | |
77 | IsIsaSerialNode (\r | |
78 | IN ACPI_HID_DEVICE_PATH *Acpi\r | |
79 | )\r | |
80 | {\r | |
81 | return (BOOLEAN) (\r | |
82 | (DevicePathType (Acpi) == ACPI_DEVICE_PATH) &&\r | |
83 | (DevicePathSubType (Acpi) == ACPI_DP) &&\r | |
84 | (ReadUnaligned32 (&Acpi->HID) == EISA_PNP_ID (0x0501))\r | |
85 | );\r | |
86 | }\r | |
87 | \r | |
88 | /**\r | |
89 | Update Com Ports attributes from DevicePath\r | |
90 | \r | |
91 | @param DevicePath DevicePath that contains Com ports\r | |
92 | \r | |
93 | @retval EFI_SUCCESS The update is successful.\r | |
94 | \r | |
95 | **/\r | |
96 | EFI_STATUS\r | |
97 | UpdateComAttributeFromVariable (\r | |
98 | EFI_DEVICE_PATH_PROTOCOL *DevicePath\r | |
99 | );\r | |
100 | \r | |
101 | /**\r | |
102 | Update the multi-instance device path of Terminal Device based on\r | |
103 | the global TerminalMenu. If ChangeTernimal is TRUE, the terminal \r | |
104 | device path in the Terminal Device in TerminalMenu is also updated.\r | |
105 | \r | |
106 | @param DevicePath The multi-instance device path.\r | |
107 | @param ChangeTerminal TRUE, then device path in the Terminal Device \r | |
108 | in TerminalMenu is also updated; FALSE, no update.\r | |
109 | \r | |
110 | @return EFI_SUCCESS The function completes successfully.\r | |
111 | \r | |
112 | **/\r | |
113 | EFI_STATUS\r | |
114 | ChangeTerminalDevicePath (\r | |
115 | IN OUT EFI_DEVICE_PATH_PROTOCOL *DevicePath,\r | |
116 | IN BOOLEAN ChangeTerminal\r | |
117 | )\r | |
118 | {\r | |
119 | EFI_DEVICE_PATH_PROTOCOL *Node;\r | |
120 | EFI_DEVICE_PATH_PROTOCOL *Node1;\r | |
121 | ACPI_HID_DEVICE_PATH *Acpi;\r | |
122 | UART_DEVICE_PATH *Uart;\r | |
123 | UART_DEVICE_PATH *Uart1;\r | |
124 | UINTN Com;\r | |
125 | BM_TERMINAL_CONTEXT *NewTerminalContext;\r | |
126 | BM_MENU_ENTRY *NewMenuEntry;\r | |
127 | \r | |
128 | Node = DevicePath;\r | |
129 | Node = NextDevicePathNode (Node);\r | |
130 | Com = 0;\r | |
131 | while (!IsDevicePathEnd (Node)) {\r | |
132 | Acpi = (ACPI_HID_DEVICE_PATH *) Node;\r | |
133 | if (IsIsaSerialNode (Acpi)) {\r | |
134 | CopyMem (&Com, &Acpi->UID, sizeof (UINT32));\r | |
135 | }\r | |
136 | \r | |
137 | NewMenuEntry = BOpt_GetMenuEntry (&TerminalMenu, Com);\r | |
138 | \r | |
139 | NewTerminalContext = (BM_TERMINAL_CONTEXT *) NewMenuEntry->VariableContext;\r | |
140 | if ((DevicePathType (Node) == MESSAGING_DEVICE_PATH) && (DevicePathSubType (Node) == MSG_UART_DP)) {\r | |
141 | Uart = (UART_DEVICE_PATH *) Node;\r | |
142 | CopyMem (\r | |
143 | &Uart->BaudRate,\r | |
144 | &NewTerminalContext->BaudRate,\r | |
145 | sizeof (UINT64)\r | |
146 | );\r | |
147 | \r | |
148 | CopyMem (\r | |
149 | &Uart->DataBits,\r | |
150 | &NewTerminalContext->DataBits,\r | |
151 | sizeof (UINT8)\r | |
152 | );\r | |
153 | \r | |
154 | CopyMem (\r | |
155 | &Uart->Parity,\r | |
156 | &NewTerminalContext->Parity,\r | |
157 | sizeof (UINT8)\r | |
158 | );\r | |
159 | \r | |
160 | CopyMem (\r | |
161 | &Uart->StopBits,\r | |
162 | &NewTerminalContext->StopBits,\r | |
163 | sizeof (UINT8)\r | |
164 | );\r | |
165 | //\r | |
166 | // Change the device path in the ComPort\r | |
167 | //\r | |
168 | if (ChangeTerminal) {\r | |
169 | Node1 = NewTerminalContext->DevicePath;\r | |
170 | Node1 = NextDevicePathNode (Node1);\r | |
171 | while (!IsDevicePathEnd (Node1)) {\r | |
172 | if ((DevicePathType (Node1) == MESSAGING_DEVICE_PATH) && (DevicePathSubType (Node1) == MSG_UART_DP)) {\r | |
173 | Uart1 = (UART_DEVICE_PATH *) Node1;\r | |
174 | CopyMem (\r | |
175 | &Uart1->BaudRate,\r | |
176 | &NewTerminalContext->BaudRate,\r | |
177 | sizeof (UINT64)\r | |
178 | );\r | |
179 | \r | |
180 | CopyMem (\r | |
181 | &Uart1->DataBits,\r | |
182 | &NewTerminalContext->DataBits,\r | |
183 | sizeof (UINT8)\r | |
184 | );\r | |
185 | \r | |
186 | CopyMem (\r | |
187 | &Uart1->Parity,\r | |
188 | &NewTerminalContext->Parity,\r | |
189 | sizeof (UINT8)\r | |
190 | );\r | |
191 | \r | |
192 | CopyMem (\r | |
193 | &Uart1->StopBits,\r | |
194 | &NewTerminalContext->StopBits,\r | |
195 | sizeof (UINT8)\r | |
196 | );\r | |
197 | break;\r | |
198 | }\r | |
199 | //\r | |
200 | // end if\r | |
201 | //\r | |
202 | Node1 = NextDevicePathNode (Node1);\r | |
203 | }\r | |
204 | //\r | |
205 | // end while\r | |
206 | //\r | |
207 | break;\r | |
208 | }\r | |
209 | }\r | |
210 | \r | |
211 | Node = NextDevicePathNode (Node);\r | |
212 | }\r | |
213 | \r | |
214 | return EFI_SUCCESS;\r | |
215 | \r | |
216 | }\r | |
217 | \r | |
218 | /**\r | |
219 | Update the device path that describing a terminal device\r | |
220 | based on the new BaudRate, Data Bits, parity and Stop Bits\r | |
221 | set.\r | |
222 | \r | |
223 | @param DevicePath terminal device's path\r | |
224 | \r | |
225 | **/\r | |
226 | VOID\r | |
227 | ChangeVariableDevicePath (\r | |
228 | IN OUT EFI_DEVICE_PATH_PROTOCOL *DevicePath\r | |
229 | )\r | |
230 | {\r | |
231 | EFI_DEVICE_PATH_PROTOCOL *Node;\r | |
232 | ACPI_HID_DEVICE_PATH *Acpi;\r | |
233 | UART_DEVICE_PATH *Uart;\r | |
234 | UINTN Com;\r | |
235 | BM_TERMINAL_CONTEXT *NewTerminalContext;\r | |
236 | BM_MENU_ENTRY *NewMenuEntry;\r | |
237 | \r | |
238 | Node = DevicePath;\r | |
239 | Node = NextDevicePathNode (Node);\r | |
240 | Com = 0;\r | |
241 | while (!IsDevicePathEnd (Node)) {\r | |
242 | Acpi = (ACPI_HID_DEVICE_PATH *) Node;\r | |
243 | if (IsIsaSerialNode (Acpi)) {\r | |
244 | CopyMem (&Com, &Acpi->UID, sizeof (UINT32));\r | |
245 | }\r | |
246 | \r | |
247 | if ((DevicePathType (Node) == MESSAGING_DEVICE_PATH) && (DevicePathSubType (Node) == MSG_UART_DP)) {\r | |
248 | NewMenuEntry = BOpt_GetMenuEntry (\r | |
249 | &TerminalMenu,\r | |
250 | Com\r | |
251 | );\r | |
252 | ASSERT (NewMenuEntry != NULL);\r | |
253 | NewTerminalContext = (BM_TERMINAL_CONTEXT *) NewMenuEntry->VariableContext;\r | |
254 | Uart = (UART_DEVICE_PATH *) Node;\r | |
255 | CopyMem (\r | |
256 | &Uart->BaudRate,\r | |
257 | &NewTerminalContext->BaudRate,\r | |
258 | sizeof (UINT64)\r | |
259 | );\r | |
260 | \r | |
261 | CopyMem (\r | |
262 | &Uart->DataBits,\r | |
263 | &NewTerminalContext->DataBits,\r | |
264 | sizeof (UINT8)\r | |
265 | );\r | |
266 | \r | |
267 | CopyMem (\r | |
268 | &Uart->Parity,\r | |
269 | &NewTerminalContext->Parity,\r | |
270 | sizeof (UINT8)\r | |
271 | );\r | |
272 | \r | |
273 | CopyMem (\r | |
274 | &Uart->StopBits,\r | |
275 | &NewTerminalContext->StopBits,\r | |
276 | sizeof (UINT8)\r | |
277 | );\r | |
278 | }\r | |
279 | \r | |
280 | Node = NextDevicePathNode (Node);\r | |
281 | }\r | |
282 | }\r | |
283 | \r | |
284 | /**\r | |
285 | Retrieve ACPI UID of UART from device path\r | |
286 | \r | |
287 | @param Handle The handle for the UART device.\r | |
288 | @param AcpiUid The ACPI UID on output.\r | |
289 | \r | |
290 | @retval TRUE Find valid UID from device path\r | |
291 | @retval FALSE Can't find\r | |
292 | \r | |
293 | **/\r | |
294 | BOOLEAN\r | |
295 | RetrieveUartUid (\r | |
296 | IN EFI_HANDLE Handle,\r | |
297 | IN OUT UINT32 *AcpiUid\r | |
298 | )\r | |
299 | {\r | |
300 | EFI_STATUS Status;\r | |
301 | ACPI_HID_DEVICE_PATH *Acpi;\r | |
302 | EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r | |
303 | \r | |
304 | Status = gBS->HandleProtocol (\r | |
305 | Handle,\r | |
306 | &gEfiDevicePathProtocolGuid,\r | |
307 | (VOID **) &DevicePath\r | |
308 | );\r | |
309 | if (EFI_ERROR (Status)) {\r | |
310 | return FALSE;\r | |
311 | }\r | |
312 | \r | |
313 | Acpi = NULL;\r | |
314 | for (; !IsDevicePathEnd (DevicePath); DevicePath = NextDevicePathNode (DevicePath)) {\r | |
315 | if ((DevicePathType (DevicePath) == MESSAGING_DEVICE_PATH) && (DevicePathSubType (DevicePath) == MSG_UART_DP)) {\r | |
316 | break;\r | |
317 | }\r | |
318 | //\r | |
319 | // Acpi points to the node before the Uart node\r | |
320 | //\r | |
321 | Acpi = (ACPI_HID_DEVICE_PATH *) DevicePath;\r | |
322 | }\r | |
323 | \r | |
324 | if ((Acpi != NULL) && IsIsaSerialNode (Acpi)) {\r | |
325 | if (AcpiUid != NULL) {\r | |
326 | CopyMem (AcpiUid, &Acpi->UID, sizeof (UINT32));\r | |
327 | }\r | |
328 | return TRUE;\r | |
329 | } else {\r | |
330 | return FALSE;\r | |
331 | }\r | |
332 | }\r | |
333 | \r | |
334 | /**\r | |
335 | Sort Uart handles array with Acpi->UID from low to high.\r | |
336 | \r | |
337 | @param Handles EFI_SERIAL_IO_PROTOCOL handle buffer\r | |
338 | @param NoHandles EFI_SERIAL_IO_PROTOCOL handle count\r | |
339 | **/\r | |
340 | VOID\r | |
341 | SortedUartHandle (\r | |
342 | IN EFI_HANDLE *Handles,\r | |
343 | IN UINTN NoHandles\r | |
344 | )\r | |
345 | {\r | |
346 | UINTN Index1;\r | |
347 | UINTN Index2;\r | |
348 | UINTN Position;\r | |
349 | UINT32 AcpiUid1;\r | |
350 | UINT32 AcpiUid2;\r | |
351 | UINT32 TempAcpiUid;\r | |
352 | EFI_HANDLE TempHandle;\r | |
353 | \r | |
354 | for (Index1 = 0; Index1 < NoHandles-1; Index1++) {\r | |
355 | if (!RetrieveUartUid (Handles[Index1], &AcpiUid1)) {\r | |
356 | continue;\r | |
357 | }\r | |
358 | TempHandle = Handles[Index1];\r | |
359 | Position = Index1;\r | |
360 | TempAcpiUid = AcpiUid1;\r | |
361 | \r | |
362 | for (Index2 = Index1+1; Index2 < NoHandles; Index2++) {\r | |
363 | if (!RetrieveUartUid (Handles[Index2], &AcpiUid2)) {\r | |
364 | continue;\r | |
365 | }\r | |
366 | if (AcpiUid2 < TempAcpiUid) {\r | |
367 | TempAcpiUid = AcpiUid2;\r | |
368 | TempHandle = Handles[Index2];\r | |
369 | Position = Index2;\r | |
370 | }\r | |
371 | }\r | |
372 | Handles[Position] = Handles[Index1];\r | |
373 | Handles[Index1] = TempHandle;\r | |
374 | }\r | |
375 | }\r | |
376 | \r | |
377 | /**\r | |
378 | Test whether DevicePath is a valid Terminal\r | |
379 | \r | |
380 | \r | |
381 | @param DevicePath DevicePath to be checked\r | |
382 | @param Termi If DevicePath is valid Terminal, terminal type is returned.\r | |
383 | @param Com If DevicePath is valid Terminal, Com Port type is returned.\r | |
384 | \r | |
385 | @retval TRUE If DevicePath point to a Terminal.\r | |
386 | @retval FALSE If DevicePath does not point to a Terminal.\r | |
387 | \r | |
388 | **/\r | |
389 | BOOLEAN\r | |
390 | IsTerminalDevicePath (\r | |
391 | IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,\r | |
392 | OUT TYPE_OF_TERMINAL *Termi,\r | |
393 | OUT UINTN *Com\r | |
394 | );\r | |
395 | \r | |
396 | /**\r | |
397 | Build a list containing all serial devices.\r | |
398 | \r | |
399 | \r | |
400 | @retval EFI_SUCCESS The function complete successfully.\r | |
401 | @retval EFI_UNSUPPORTED No serial ports present.\r | |
402 | \r | |
403 | **/\r | |
404 | EFI_STATUS\r | |
405 | LocateSerialIo (\r | |
406 | VOID\r | |
407 | )\r | |
408 | {\r | |
409 | UINTN Index;\r | |
410 | UINTN Index2;\r | |
411 | UINTN NoHandles;\r | |
412 | EFI_HANDLE *Handles;\r | |
413 | EFI_STATUS Status;\r | |
414 | ACPI_HID_DEVICE_PATH *Acpi;\r | |
415 | EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r | |
416 | EFI_SERIAL_IO_PROTOCOL *SerialIo;\r | |
417 | EFI_DEVICE_PATH_PROTOCOL *Node;\r | |
418 | EFI_DEVICE_PATH_PROTOCOL *OutDevicePath;\r | |
419 | EFI_DEVICE_PATH_PROTOCOL *InpDevicePath;\r | |
420 | EFI_DEVICE_PATH_PROTOCOL *ErrDevicePath;\r | |
421 | BM_MENU_ENTRY *NewMenuEntry;\r | |
422 | BM_TERMINAL_CONTEXT *NewTerminalContext;\r | |
423 | EFI_DEVICE_PATH_PROTOCOL *NewDevicePath;\r | |
424 | VENDOR_DEVICE_PATH Vendor;\r | |
425 | \r | |
426 | //\r | |
427 | // Get all handles that have SerialIo protocol installed\r | |
428 | //\r | |
429 | InitializeListHead (&TerminalMenu.Head);\r | |
430 | TerminalMenu.MenuNumber = 0;\r | |
431 | Status = gBS->LocateHandleBuffer (\r | |
432 | ByProtocol,\r | |
433 | &gEfiSerialIoProtocolGuid,\r | |
434 | NULL,\r | |
435 | &NoHandles,\r | |
436 | &Handles\r | |
437 | );\r | |
438 | if (EFI_ERROR (Status)) {\r | |
439 | //\r | |
440 | // No serial ports present\r | |
441 | //\r | |
442 | return EFI_UNSUPPORTED;\r | |
443 | }\r | |
444 | \r | |
445 | //\r | |
446 | // Sort Uart handles array with Acpi->UID from low to high\r | |
447 | // then Terminal menu can be built from low Acpi->UID to high Acpi->UID\r | |
448 | //\r | |
449 | SortedUartHandle (Handles, NoHandles);\r | |
450 | \r | |
451 | for (Index = 0; Index < NoHandles; Index++) {\r | |
452 | //\r | |
453 | // Check to see whether the handle has DevicePath Protocol installed\r | |
454 | //\r | |
455 | gBS->HandleProtocol (\r | |
456 | Handles[Index],\r | |
457 | &gEfiDevicePathProtocolGuid,\r | |
458 | (VOID **) &DevicePath\r | |
459 | );\r | |
460 | \r | |
461 | Acpi = NULL;\r | |
462 | for (Node = DevicePath; !IsDevicePathEnd (Node); Node = NextDevicePathNode (Node)) {\r | |
463 | if ((DevicePathType (Node) == MESSAGING_DEVICE_PATH) && (DevicePathSubType (Node) == MSG_UART_DP)) {\r | |
464 | break;\r | |
465 | }\r | |
466 | //\r | |
467 | // Acpi points to the node before Uart node\r | |
468 | //\r | |
469 | Acpi = (ACPI_HID_DEVICE_PATH *) Node;\r | |
470 | }\r | |
471 | \r | |
472 | if ((Acpi != NULL) && IsIsaSerialNode (Acpi)) {\r | |
473 | NewMenuEntry = BOpt_CreateMenuEntry (BM_TERMINAL_CONTEXT_SELECT);\r | |
474 | if (NewMenuEntry == NULL) {\r | |
475 | FreePool (Handles);\r | |
476 | return EFI_OUT_OF_RESOURCES;\r | |
477 | }\r | |
478 | \r | |
479 | NewTerminalContext = (BM_TERMINAL_CONTEXT *) NewMenuEntry->VariableContext;\r | |
480 | CopyMem (&NewMenuEntry->OptionNumber, &Acpi->UID, sizeof (UINT32));\r | |
481 | NewTerminalContext->DevicePath = DuplicateDevicePath (DevicePath);\r | |
482 | //\r | |
483 | // BugBug: I have no choice, calling EfiLibStrFromDatahub will hang the system!\r | |
484 | // coz' the misc data for each platform is not correct, actually it's the device path stored in\r | |
485 | // datahub which is not completed, so a searching for end of device path will enter a\r | |
486 | // dead-loop.\r | |
487 | //\r | |
488 | NewMenuEntry->DisplayString = EfiLibStrFromDatahub (DevicePath);\r | |
489 | if (NULL == NewMenuEntry->DisplayString) {\r | |
490 | NewMenuEntry->DisplayString = UiDevicePathToStr (DevicePath);\r | |
491 | }\r | |
492 | \r | |
493 | NewMenuEntry->HelpString = NULL;\r | |
494 | \r | |
495 | NewMenuEntry->DisplayStringToken = HiiSetString (mBmmCallbackInfo->BmmHiiHandle, 0, NewMenuEntry->DisplayString, NULL);\r | |
496 | \r | |
497 | NewMenuEntry->HelpStringToken = NewMenuEntry->DisplayStringToken;\r | |
498 | \r | |
499 | gBS->HandleProtocol (\r | |
500 | Handles[Index],\r | |
501 | &gEfiSerialIoProtocolGuid,\r | |
502 | (VOID **) &SerialIo\r | |
503 | );\r | |
504 | \r | |
505 | CopyMem (\r | |
506 | &NewTerminalContext->BaudRate,\r | |
507 | &SerialIo->Mode->BaudRate,\r | |
508 | sizeof (UINT64)\r | |
509 | );\r | |
510 | \r | |
511 | CopyMem (\r | |
512 | &NewTerminalContext->DataBits,\r | |
513 | &SerialIo->Mode->DataBits,\r | |
514 | sizeof (UINT8)\r | |
515 | );\r | |
516 | \r | |
517 | CopyMem (\r | |
518 | &NewTerminalContext->Parity,\r | |
519 | &SerialIo->Mode->Parity,\r | |
520 | sizeof (UINT8)\r | |
521 | );\r | |
522 | \r | |
523 | CopyMem (\r | |
524 | &NewTerminalContext->StopBits,\r | |
525 | &SerialIo->Mode->StopBits,\r | |
526 | sizeof (UINT8)\r | |
527 | );\r | |
528 | InsertTailList (&TerminalMenu.Head, &NewMenuEntry->Link);\r | |
529 | TerminalMenu.MenuNumber++;\r | |
530 | }\r | |
531 | }\r | |
532 | if (Handles != NULL) {\r | |
533 | FreePool (Handles);\r | |
534 | }\r | |
535 | \r | |
536 | //\r | |
537 | // Get L"ConOut", L"ConIn" and L"ErrOut" from the Var\r | |
538 | //\r | |
539 | GetEfiGlobalVariable2 (L"ConOut", (VOID**)&OutDevicePath, NULL);\r | |
540 | GetEfiGlobalVariable2 (L"ConIn", (VOID**)&InpDevicePath, NULL);\r | |
541 | GetEfiGlobalVariable2 (L"ErrOut", (VOID**)&ErrDevicePath, NULL);\r | |
542 | if (OutDevicePath != NULL) {\r | |
543 | UpdateComAttributeFromVariable (OutDevicePath);\r | |
544 | }\r | |
545 | \r | |
546 | if (InpDevicePath != NULL) {\r | |
547 | UpdateComAttributeFromVariable (InpDevicePath);\r | |
548 | }\r | |
549 | \r | |
550 | if (ErrDevicePath != NULL) {\r | |
551 | UpdateComAttributeFromVariable (ErrDevicePath);\r | |
552 | }\r | |
553 | \r | |
554 | for (Index = 0; Index < TerminalMenu.MenuNumber; Index++) {\r | |
555 | NewMenuEntry = BOpt_GetMenuEntry (&TerminalMenu, Index);\r | |
556 | if (NULL == NewMenuEntry) {\r | |
557 | return EFI_NOT_FOUND;\r | |
558 | }\r | |
559 | \r | |
560 | NewTerminalContext = (BM_TERMINAL_CONTEXT *) NewMenuEntry->VariableContext;\r | |
561 | \r | |
562 | NewTerminalContext->TerminalType = 0;\r | |
563 | NewTerminalContext->IsConIn = FALSE;\r | |
564 | NewTerminalContext->IsConOut = FALSE;\r | |
565 | NewTerminalContext->IsStdErr = FALSE;\r | |
566 | \r | |
567 | Vendor.Header.Type = MESSAGING_DEVICE_PATH;\r | |
568 | Vendor.Header.SubType = MSG_VENDOR_DP;\r | |
569 | \r | |
570 | for (Index2 = 0; Index2 < (sizeof (TerminalTypeGuid) / sizeof (TerminalTypeGuid[0])); Index2++) {\r | |
571 | CopyMem (&Vendor.Guid, &TerminalTypeGuid[Index2], sizeof (EFI_GUID));\r | |
572 | SetDevicePathNodeLength (&Vendor.Header, sizeof (VENDOR_DEVICE_PATH));\r | |
573 | NewDevicePath = AppendDevicePathNode (\r | |
574 | NewTerminalContext->DevicePath,\r | |
575 | (EFI_DEVICE_PATH_PROTOCOL *) &Vendor\r | |
576 | );\r | |
577 | if (NewMenuEntry->HelpString != NULL) {\r | |
578 | FreePool (NewMenuEntry->HelpString);\r | |
579 | }\r | |
580 | //\r | |
581 | // NewMenuEntry->HelpString = UiDevicePathToStr (NewDevicePath);\r | |
582 | // NewMenuEntry->DisplayString = NewMenuEntry->HelpString;\r | |
583 | //\r | |
584 | NewMenuEntry->HelpString = NULL;\r | |
585 | \r | |
586 | NewMenuEntry->DisplayStringToken = HiiSetString (mBmmCallbackInfo->BmmHiiHandle, 0, NewMenuEntry->DisplayString, NULL);\r | |
587 | \r | |
588 | NewMenuEntry->HelpStringToken = NewMenuEntry->DisplayStringToken;\r | |
589 | \r | |
590 | if (MatchDevicePaths (OutDevicePath, NewDevicePath)) {\r | |
591 | NewTerminalContext->IsConOut = TRUE;\r | |
592 | NewTerminalContext->TerminalType = (UINT8) Index2;\r | |
593 | }\r | |
594 | \r | |
595 | if (MatchDevicePaths (InpDevicePath, NewDevicePath)) {\r | |
596 | NewTerminalContext->IsConIn = TRUE;\r | |
597 | NewTerminalContext->TerminalType = (UINT8) Index2;\r | |
598 | }\r | |
599 | \r | |
600 | if (MatchDevicePaths (ErrDevicePath, NewDevicePath)) {\r | |
601 | NewTerminalContext->IsStdErr = TRUE;\r | |
602 | NewTerminalContext->TerminalType = (UINT8) Index2;\r | |
603 | }\r | |
604 | }\r | |
605 | }\r | |
606 | \r | |
607 | return EFI_SUCCESS;\r | |
608 | }\r | |
609 | \r | |
610 | /**\r | |
611 | Update Com Ports attributes from DevicePath\r | |
612 | \r | |
613 | @param DevicePath DevicePath that contains Com ports\r | |
614 | \r | |
615 | @retval EFI_SUCCESS The update is successful.\r | |
616 | @retval EFI_NOT_FOUND Can not find specific menu entry\r | |
617 | **/\r | |
618 | EFI_STATUS\r | |
619 | UpdateComAttributeFromVariable (\r | |
620 | EFI_DEVICE_PATH_PROTOCOL *DevicePath\r | |
621 | )\r | |
622 | {\r | |
623 | EFI_DEVICE_PATH_PROTOCOL *Node;\r | |
624 | EFI_DEVICE_PATH_PROTOCOL *SerialNode;\r | |
625 | ACPI_HID_DEVICE_PATH *Acpi;\r | |
626 | UART_DEVICE_PATH *Uart;\r | |
627 | UART_DEVICE_PATH *Uart1;\r | |
628 | UINTN TerminalNumber;\r | |
629 | BM_MENU_ENTRY *NewMenuEntry;\r | |
630 | BM_TERMINAL_CONTEXT *NewTerminalContext;\r | |
631 | UINTN Index;\r | |
632 | \r | |
633 | Node = DevicePath;\r | |
634 | Node = NextDevicePathNode (Node);\r | |
635 | TerminalNumber = 0;\r | |
636 | for (Index = 0; Index < TerminalMenu.MenuNumber; Index++) {\r | |
637 | while (!IsDevicePathEnd (Node)) {\r | |
638 | Acpi = (ACPI_HID_DEVICE_PATH *) Node;\r | |
639 | if (IsIsaSerialNode (Acpi)) {\r | |
640 | CopyMem (&TerminalNumber, &Acpi->UID, sizeof (UINT32));\r | |
641 | }\r | |
642 | \r | |
643 | if ((DevicePathType (Node) == MESSAGING_DEVICE_PATH) && (DevicePathSubType (Node) == MSG_UART_DP)) {\r | |
644 | Uart = (UART_DEVICE_PATH *) Node;\r | |
645 | NewMenuEntry = BOpt_GetMenuEntry (&TerminalMenu, TerminalNumber);\r | |
646 | if (NULL == NewMenuEntry) {\r | |
647 | return EFI_NOT_FOUND;\r | |
648 | }\r | |
649 | \r | |
650 | NewTerminalContext = (BM_TERMINAL_CONTEXT *) NewMenuEntry->VariableContext;\r | |
651 | CopyMem (\r | |
652 | &NewTerminalContext->BaudRate,\r | |
653 | &Uart->BaudRate,\r | |
654 | sizeof (UINT64)\r | |
655 | );\r | |
656 | \r | |
657 | CopyMem (\r | |
658 | &NewTerminalContext->DataBits,\r | |
659 | &Uart->DataBits,\r | |
660 | sizeof (UINT8)\r | |
661 | );\r | |
662 | \r | |
663 | CopyMem (\r | |
664 | &NewTerminalContext->Parity,\r | |
665 | &Uart->Parity,\r | |
666 | sizeof (UINT8)\r | |
667 | );\r | |
668 | \r | |
669 | CopyMem (\r | |
670 | &NewTerminalContext->StopBits,\r | |
671 | &Uart->StopBits,\r | |
672 | sizeof (UINT8)\r | |
673 | );\r | |
674 | \r | |
675 | SerialNode = NewTerminalContext->DevicePath;\r | |
676 | SerialNode = NextDevicePathNode (SerialNode);\r | |
677 | while (!IsDevicePathEnd (SerialNode)) {\r | |
678 | if ((DevicePathType (SerialNode) == MESSAGING_DEVICE_PATH) && (DevicePathSubType (SerialNode) == MSG_UART_DP)) {\r | |
679 | //\r | |
680 | // Update following device paths according to\r | |
681 | // previous acquired uart attributes\r | |
682 | //\r | |
683 | Uart1 = (UART_DEVICE_PATH *) SerialNode;\r | |
684 | CopyMem (\r | |
685 | &Uart1->BaudRate,\r | |
686 | &NewTerminalContext->BaudRate,\r | |
687 | sizeof (UINT64)\r | |
688 | );\r | |
689 | \r | |
690 | CopyMem (\r | |
691 | &Uart1->DataBits,\r | |
692 | &NewTerminalContext->DataBits,\r | |
693 | sizeof (UINT8)\r | |
694 | );\r | |
695 | CopyMem (\r | |
696 | &Uart1->Parity,\r | |
697 | &NewTerminalContext->Parity,\r | |
698 | sizeof (UINT8)\r | |
699 | );\r | |
700 | CopyMem (\r | |
701 | &Uart1->StopBits,\r | |
702 | &NewTerminalContext->StopBits,\r | |
703 | sizeof (UINT8)\r | |
704 | );\r | |
705 | \r | |
706 | break;\r | |
707 | }\r | |
708 | \r | |
709 | SerialNode = NextDevicePathNode (SerialNode);\r | |
710 | }\r | |
711 | //\r | |
712 | // end while\r | |
713 | //\r | |
714 | }\r | |
715 | \r | |
716 | Node = NextDevicePathNode (Node);\r | |
717 | }\r | |
718 | //\r | |
719 | // end while\r | |
720 | //\r | |
721 | }\r | |
722 | \r | |
723 | return EFI_SUCCESS;\r | |
724 | }\r | |
725 | \r | |
726 | /**\r | |
727 | Build up Console Menu based on types passed in. The type can\r | |
728 | be BM_CONSOLE_IN_CONTEXT_SELECT, BM_CONSOLE_OUT_CONTEXT_SELECT\r | |
729 | and BM_CONSOLE_ERR_CONTEXT_SELECT.\r | |
730 | \r | |
731 | @param ConsoleMenuType Can be BM_CONSOLE_IN_CONTEXT_SELECT, BM_CONSOLE_OUT_CONTEXT_SELECT\r | |
732 | and BM_CONSOLE_ERR_CONTEXT_SELECT.\r | |
733 | \r | |
734 | @retval EFI_UNSUPPORTED The type passed in is not in the 3 types defined.\r | |
735 | @retval EFI_NOT_FOUND If the EFI Variable defined in UEFI spec with name "ConOutDev", \r | |
736 | "ConInDev" or "ConErrDev" doesn't exists.\r | |
737 | @retval EFI_OUT_OF_RESOURCES Not enough resource to complete the operations.\r | |
738 | @retval EFI_SUCCESS Function completes successfully.\r | |
739 | \r | |
740 | **/\r | |
741 | EFI_STATUS\r | |
742 | GetConsoleMenu (\r | |
743 | IN UINTN ConsoleMenuType\r | |
744 | )\r | |
745 | {\r | |
746 | EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r | |
747 | EFI_DEVICE_PATH_PROTOCOL *AllDevicePath;\r | |
748 | EFI_DEVICE_PATH_PROTOCOL *MultiDevicePath;\r | |
749 | EFI_DEVICE_PATH_PROTOCOL *DevicePathInst;\r | |
750 | UINTN Size;\r | |
751 | UINTN AllCount;\r | |
752 | UINTN Index;\r | |
753 | UINTN Index2;\r | |
754 | BM_MENU_ENTRY *NewMenuEntry;\r | |
755 | BM_CONSOLE_CONTEXT *NewConsoleContext;\r | |
756 | TYPE_OF_TERMINAL Terminal;\r | |
757 | UINTN Com;\r | |
758 | BM_MENU_OPTION *ConsoleMenu;\r | |
759 | \r | |
760 | DevicePath = NULL;\r | |
761 | AllDevicePath = NULL;\r | |
762 | AllCount = 0;\r | |
763 | switch (ConsoleMenuType) {\r | |
764 | case BM_CONSOLE_IN_CONTEXT_SELECT:\r | |
765 | ConsoleMenu = &ConsoleInpMenu;\r | |
766 | GetEfiGlobalVariable2 (L"ConIn", (VOID**)&DevicePath, NULL);\r | |
767 | GetEfiGlobalVariable2 (L"ConInDev", (VOID**)&AllDevicePath, NULL);\r | |
768 | break;\r | |
769 | \r | |
770 | case BM_CONSOLE_OUT_CONTEXT_SELECT:\r | |
771 | ConsoleMenu = &ConsoleOutMenu;\r | |
772 | GetEfiGlobalVariable2 (L"ConOut", (VOID**)&DevicePath, NULL);\r | |
773 | GetEfiGlobalVariable2 (L"ConOutDev", (VOID**)&AllDevicePath, NULL);\r | |
774 | break;\r | |
775 | \r | |
776 | case BM_CONSOLE_ERR_CONTEXT_SELECT:\r | |
777 | ConsoleMenu = &ConsoleErrMenu;\r | |
778 | GetEfiGlobalVariable2 (L"ErrOut", (VOID**)&DevicePath, NULL);\r | |
779 | GetEfiGlobalVariable2 (L"ErrOutDev", (VOID**)&AllDevicePath, NULL);\r | |
780 | break;\r | |
781 | \r | |
782 | default:\r | |
783 | return EFI_UNSUPPORTED;\r | |
784 | }\r | |
785 | \r | |
786 | if (NULL == AllDevicePath) {\r | |
787 | return EFI_NOT_FOUND;\r | |
788 | }\r | |
789 | \r | |
790 | InitializeListHead (&ConsoleMenu->Head);\r | |
791 | \r | |
792 | AllCount = EfiDevicePathInstanceCount (AllDevicePath);\r | |
793 | ConsoleMenu->MenuNumber = 0;\r | |
794 | //\r | |
795 | // Following is menu building up for Console Devices selected.\r | |
796 | //\r | |
797 | MultiDevicePath = AllDevicePath;\r | |
798 | Index2 = 0;\r | |
799 | for (Index = 0; Index < AllCount; Index++) {\r | |
800 | DevicePathInst = GetNextDevicePathInstance (&MultiDevicePath, &Size);\r | |
801 | \r | |
802 | NewMenuEntry = BOpt_CreateMenuEntry (BM_CONSOLE_CONTEXT_SELECT);\r | |
803 | if (NULL == NewMenuEntry) {\r | |
804 | return EFI_OUT_OF_RESOURCES;\r | |
805 | }\r | |
806 | \r | |
807 | NewConsoleContext = (BM_CONSOLE_CONTEXT *) NewMenuEntry->VariableContext;\r | |
808 | NewMenuEntry->OptionNumber = Index2;\r | |
809 | \r | |
810 | NewConsoleContext->DevicePath = DuplicateDevicePath (DevicePathInst);\r | |
811 | ASSERT (NewConsoleContext->DevicePath != NULL);\r | |
812 | NewMenuEntry->DisplayString = EfiLibStrFromDatahub (NewConsoleContext->DevicePath);\r | |
813 | if (NULL == NewMenuEntry->DisplayString) {\r | |
814 | NewMenuEntry->DisplayString = UiDevicePathToStr (NewConsoleContext->DevicePath);\r | |
815 | }\r | |
816 | \r | |
817 | NewMenuEntry->DisplayStringToken = HiiSetString (mBmmCallbackInfo->BmmHiiHandle, 0, NewMenuEntry->DisplayString, NULL);\r | |
818 | \r | |
819 | if (NULL == NewMenuEntry->HelpString) {\r | |
820 | NewMenuEntry->HelpStringToken = NewMenuEntry->DisplayStringToken;\r | |
821 | } else {\r | |
822 | NewMenuEntry->HelpStringToken = HiiSetString (mBmmCallbackInfo->BmmHiiHandle, 0, NewMenuEntry->HelpString, NULL);\r | |
823 | }\r | |
824 | \r | |
825 | NewConsoleContext->IsTerminal = IsTerminalDevicePath (\r | |
826 | NewConsoleContext->DevicePath,\r | |
827 | &Terminal,\r | |
828 | &Com\r | |
829 | );\r | |
830 | \r | |
831 | NewConsoleContext->IsActive = MatchDevicePaths (\r | |
832 | DevicePath,\r | |
833 | NewConsoleContext->DevicePath\r | |
834 | );\r | |
835 | \r | |
836 | if (NewConsoleContext->IsTerminal) {\r | |
837 | BOpt_DestroyMenuEntry (NewMenuEntry);\r | |
838 | } else {\r | |
839 | Index2++;\r | |
840 | ConsoleMenu->MenuNumber++;\r | |
841 | InsertTailList (&ConsoleMenu->Head, &NewMenuEntry->Link);\r | |
842 | }\r | |
843 | }\r | |
844 | \r | |
845 | return EFI_SUCCESS;\r | |
846 | }\r | |
847 | \r | |
848 | /**\r | |
849 | Build up ConsoleOutMenu, ConsoleInpMenu and ConsoleErrMenu\r | |
850 | \r | |
851 | @retval EFI_SUCCESS The function always complete successfully.\r | |
852 | \r | |
853 | **/\r | |
854 | EFI_STATUS\r | |
855 | GetAllConsoles (\r | |
856 | VOID\r | |
857 | )\r | |
858 | {\r | |
859 | GetConsoleMenu (BM_CONSOLE_IN_CONTEXT_SELECT);\r | |
860 | GetConsoleMenu (BM_CONSOLE_OUT_CONTEXT_SELECT);\r | |
861 | GetConsoleMenu (BM_CONSOLE_ERR_CONTEXT_SELECT);\r | |
862 | return EFI_SUCCESS;\r | |
863 | }\r | |
864 | \r | |
865 | /**\r | |
866 | Free ConsoleOutMenu, ConsoleInpMenu and ConsoleErrMenu\r | |
867 | \r | |
868 | @retval EFI_SUCCESS The function always complete successfully.\r | |
869 | **/\r | |
870 | EFI_STATUS\r | |
871 | FreeAllConsoles (\r | |
872 | VOID\r | |
873 | )\r | |
874 | {\r | |
875 | BOpt_FreeMenu (&ConsoleOutMenu);\r | |
876 | BOpt_FreeMenu (&ConsoleInpMenu);\r | |
877 | BOpt_FreeMenu (&ConsoleErrMenu);\r | |
878 | BOpt_FreeMenu (&TerminalMenu);\r | |
879 | return EFI_SUCCESS;\r | |
880 | }\r | |
881 | \r | |
882 | /**\r | |
883 | Test whether DevicePath is a valid Terminal\r | |
884 | \r | |
885 | \r | |
886 | @param DevicePath DevicePath to be checked\r | |
887 | @param Termi If DevicePath is valid Terminal, terminal type is returned.\r | |
888 | @param Com If DevicePath is valid Terminal, Com Port type is returned.\r | |
889 | \r | |
890 | @retval TRUE If DevicePath point to a Terminal.\r | |
891 | @retval FALSE If DevicePath does not point to a Terminal.\r | |
892 | \r | |
893 | **/\r | |
894 | BOOLEAN\r | |
895 | IsTerminalDevicePath (\r | |
896 | IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,\r | |
897 | OUT TYPE_OF_TERMINAL *Termi,\r | |
898 | OUT UINTN *Com\r | |
899 | )\r | |
900 | {\r | |
901 | BOOLEAN IsTerminal;\r | |
902 | EFI_DEVICE_PATH_PROTOCOL *Node;\r | |
903 | VENDOR_DEVICE_PATH *Vendor;\r | |
904 | UART_DEVICE_PATH *Uart;\r | |
905 | ACPI_HID_DEVICE_PATH *Acpi;\r | |
906 | \r | |
907 | IsTerminal = FALSE;\r | |
908 | \r | |
909 | Uart = NULL;\r | |
910 | Vendor = NULL;\r | |
911 | Acpi = NULL;\r | |
912 | for (Node = DevicePath; !IsDevicePathEnd (Node); Node = NextDevicePathNode (Node)) {\r | |
913 | //\r | |
914 | // Vendor points to the node before the End node\r | |
915 | //\r | |
916 | Vendor = (VENDOR_DEVICE_PATH *) Node;\r | |
917 | \r | |
918 | if ((DevicePathType (Node) == MESSAGING_DEVICE_PATH) && (DevicePathSubType (Node) == MSG_UART_DP)) {\r | |
919 | Uart = (UART_DEVICE_PATH *) Node;\r | |
920 | }\r | |
921 | \r | |
922 | if (Uart == NULL) {\r | |
923 | //\r | |
924 | // Acpi points to the node before the UART node\r | |
925 | //\r | |
926 | Acpi = (ACPI_HID_DEVICE_PATH *) Node;\r | |
927 | }\r | |
928 | }\r | |
929 | \r | |
930 | if (Vendor == NULL ||\r | |
931 | DevicePathType (Vendor) != MESSAGING_DEVICE_PATH ||\r | |
932 | DevicePathSubType (Vendor) != MSG_VENDOR_DP ||\r | |
933 | Uart == NULL) {\r | |
934 | return FALSE;\r | |
935 | }\r | |
936 | \r | |
937 | //\r | |
938 | // There are four kinds of Terminal types\r | |
939 | // check to see whether this devicepath\r | |
940 | // is one of that type\r | |
941 | //\r | |
942 | if (CompareGuid (&Vendor->Guid, &TerminalTypeGuid[0])) {\r | |
943 | *Termi = TerminalTypePcAnsi;\r | |
944 | IsTerminal = TRUE;\r | |
945 | } else {\r | |
946 | if (CompareGuid (&Vendor->Guid, &TerminalTypeGuid[1])) {\r | |
947 | *Termi = TerminalTypeVt100;\r | |
948 | IsTerminal = TRUE;\r | |
949 | } else {\r | |
950 | if (CompareGuid (&Vendor->Guid, &TerminalTypeGuid[2])) {\r | |
951 | *Termi = TerminalTypeVt100Plus;\r | |
952 | IsTerminal = TRUE;\r | |
953 | } else {\r | |
954 | if (CompareGuid (&Vendor->Guid, &TerminalTypeGuid[3])) {\r | |
955 | *Termi = TerminalTypeVtUtf8;\r | |
956 | IsTerminal = TRUE;\r | |
957 | } else {\r | |
958 | if (CompareGuid (&Vendor->Guid, &TerminalTypeGuid[4])) {\r | |
959 | *Termi = TerminalTypeTtyTerm;\r | |
960 | IsTerminal = TRUE;\r | |
961 | } else {\r | |
962 | IsTerminal = FALSE;\r | |
963 | }\r | |
964 | }\r | |
965 | }\r | |
966 | }\r | |
967 | }\r | |
968 | \r | |
969 | if (!IsTerminal) {\r | |
970 | return FALSE;\r | |
971 | }\r | |
972 | \r | |
973 | if ((Acpi != NULL) && IsIsaSerialNode (Acpi)) {\r | |
974 | CopyMem (Com, &Acpi->UID, sizeof (UINT32));\r | |
975 | } else {\r | |
976 | return FALSE;\r | |
977 | }\r | |
978 | \r | |
979 | return TRUE;\r | |
980 | }\r | |
981 | \r | |
982 | /**\r | |
983 | Get mode number according to column and row\r | |
984 | \r | |
985 | @param CallbackData The BMM context data.\r | |
986 | **/\r | |
987 | VOID\r | |
988 | GetConsoleOutMode (\r | |
989 | IN BMM_CALLBACK_DATA *CallbackData\r | |
990 | )\r | |
991 | {\r | |
992 | UINTN Col;\r | |
993 | UINTN Row;\r | |
994 | UINTN CurrentCol;\r | |
995 | UINTN CurrentRow;\r | |
996 | UINTN Mode;\r | |
997 | UINTN MaxMode;\r | |
998 | EFI_STATUS Status;\r | |
999 | EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *ConOut;\r | |
1000 | \r | |
1001 | ConOut = gST->ConOut;\r | |
1002 | MaxMode = (UINTN) (ConOut->Mode->MaxMode);\r | |
1003 | \r | |
1004 | CurrentCol = PcdGet32 (PcdSetupConOutColumn);\r | |
1005 | CurrentRow = PcdGet32 (PcdSetupConOutRow);\r | |
1006 | for (Mode = 0; Mode < MaxMode; Mode++) {\r | |
1007 | Status = ConOut->QueryMode (ConOut, Mode, &Col, &Row);\r | |
1008 | if (!EFI_ERROR(Status)) {\r | |
1009 | if (CurrentCol == Col && CurrentRow == Row) {\r | |
1010 | CallbackData->BmmFakeNvData.ConsoleOutMode = (UINT16) Mode;\r | |
1011 | break;\r | |
1012 | }\r | |
1013 | }\r | |
1014 | }\r | |
1015 | }\r | |
1016 | \r | |
1017 | /**\r | |
1018 | \r | |
1019 | Initialize console input device check box to ConsoleInCheck[MAX_MENU_NUMBER]\r | |
1020 | in BMM_FAKE_NV_DATA structure.\r | |
1021 | \r | |
1022 | @param CallbackData The BMM context data.\r | |
1023 | \r | |
1024 | **/ \r | |
1025 | VOID \r | |
1026 | GetConsoleInCheck (\r | |
1027 | IN BMM_CALLBACK_DATA *CallbackData\r | |
1028 | )\r | |
1029 | {\r | |
1030 | UINT16 Index;\r | |
1031 | BM_MENU_ENTRY *NewMenuEntry; \r | |
1032 | UINT8 *ConInCheck;\r | |
1033 | BM_CONSOLE_CONTEXT *NewConsoleContext;\r | |
1034 | \r | |
1035 | ASSERT (CallbackData != NULL);\r | |
1036 | \r | |
1037 | ConInCheck = &CallbackData->BmmFakeNvData.ConsoleInCheck[0];\r | |
1038 | for (Index = 0; ((Index < ConsoleInpMenu.MenuNumber) && \\r | |
1039 | (Index < MAX_MENU_NUMBER)) ; Index++) { \r | |
1040 | NewMenuEntry = BOpt_GetMenuEntry (&ConsoleInpMenu, Index);\r | |
1041 | NewConsoleContext = (BM_CONSOLE_CONTEXT *) NewMenuEntry->VariableContext; \r | |
1042 | ConInCheck[Index] = NewConsoleContext->IsActive;\r | |
1043 | }\r | |
1044 | }\r | |
1045 | \r | |
1046 | /**\r | |
1047 | \r | |
1048 | Initialize console output device check box to ConsoleOutCheck[MAX_MENU_NUMBER]\r | |
1049 | in BMM_FAKE_NV_DATA structure.\r | |
1050 | \r | |
1051 | @param CallbackData The BMM context data.\r | |
1052 | \r | |
1053 | **/ \r | |
1054 | VOID \r | |
1055 | GetConsoleOutCheck (\r | |
1056 | IN BMM_CALLBACK_DATA *CallbackData\r | |
1057 | )\r | |
1058 | {\r | |
1059 | UINT16 Index;\r | |
1060 | BM_MENU_ENTRY *NewMenuEntry; \r | |
1061 | UINT8 *ConOutCheck;\r | |
1062 | BM_CONSOLE_CONTEXT *NewConsoleContext;\r | |
1063 | \r | |
1064 | ASSERT (CallbackData != NULL);\r | |
1065 | ConOutCheck = &CallbackData->BmmFakeNvData.ConsoleOutCheck[0];\r | |
1066 | for (Index = 0; ((Index < ConsoleOutMenu.MenuNumber) && \\r | |
1067 | (Index < MAX_MENU_NUMBER)) ; Index++) { \r | |
1068 | NewMenuEntry = BOpt_GetMenuEntry (&ConsoleOutMenu, Index);\r | |
1069 | NewConsoleContext = (BM_CONSOLE_CONTEXT *) NewMenuEntry->VariableContext; \r | |
1070 | ConOutCheck[Index] = NewConsoleContext->IsActive;\r | |
1071 | }\r | |
1072 | }\r | |
1073 | \r | |
1074 | /**\r | |
1075 | \r | |
1076 | Initialize standard error output device check box to ConsoleErrCheck[MAX_MENU_NUMBER]\r | |
1077 | in BMM_FAKE_NV_DATA structure.\r | |
1078 | \r | |
1079 | @param CallbackData The BMM context data.\r | |
1080 | \r | |
1081 | **/ \r | |
1082 | VOID \r | |
1083 | GetConsoleErrCheck (\r | |
1084 | IN BMM_CALLBACK_DATA *CallbackData\r | |
1085 | )\r | |
1086 | {\r | |
1087 | UINT16 Index;\r | |
1088 | BM_MENU_ENTRY *NewMenuEntry; \r | |
1089 | UINT8 *ConErrCheck;\r | |
1090 | BM_CONSOLE_CONTEXT *NewConsoleContext;\r | |
1091 | \r | |
1092 | ASSERT (CallbackData != NULL);\r | |
1093 | ConErrCheck = &CallbackData->BmmFakeNvData.ConsoleErrCheck[0];\r | |
1094 | for (Index = 0; ((Index < ConsoleErrMenu.MenuNumber) && \\r | |
1095 | (Index < MAX_MENU_NUMBER)) ; Index++) { \r | |
1096 | NewMenuEntry = BOpt_GetMenuEntry (&ConsoleErrMenu, Index);\r | |
1097 | NewConsoleContext = (BM_CONSOLE_CONTEXT *) NewMenuEntry->VariableContext; \r | |
1098 | ConErrCheck[Index] = NewConsoleContext->IsActive;\r | |
1099 | }\r | |
1100 | }\r | |
1101 | \r | |
1102 | /**\r | |
1103 | \r | |
1104 | Initialize terminal attributes (baudrate, data rate, stop bits, parity and terminal type)\r | |
1105 | to BMM_FAKE_NV_DATA structure.\r | |
1106 | \r | |
1107 | @param CallbackData The BMM context data.\r | |
1108 | \r | |
1109 | **/\r | |
1110 | VOID \r | |
1111 | GetTerminalAttribute (\r | |
1112 | IN BMM_CALLBACK_DATA *CallbackData\r | |
1113 | )\r | |
1114 | {\r | |
1115 | BMM_FAKE_NV_DATA *CurrentFakeNVMap;\r | |
1116 | BM_MENU_ENTRY *NewMenuEntry;\r | |
1117 | BM_TERMINAL_CONTEXT *NewTerminalContext; \r | |
1118 | UINT16 TerminalIndex; \r | |
1119 | UINT8 AttributeIndex;\r | |
1120 | \r | |
1121 | ASSERT (CallbackData != NULL);\r | |
1122 | \r | |
1123 | CurrentFakeNVMap = &CallbackData->BmmFakeNvData; \r | |
1124 | for (TerminalIndex = 0; ((TerminalIndex < TerminalMenu.MenuNumber) && \\r | |
1125 | (TerminalIndex < MAX_MENU_NUMBER)); TerminalIndex++) { \r | |
1126 | NewMenuEntry = BOpt_GetMenuEntry (&TerminalMenu, TerminalIndex);\r | |
1127 | NewTerminalContext = (BM_TERMINAL_CONTEXT *) NewMenuEntry->VariableContext;\r | |
1128 | for (AttributeIndex = 0; AttributeIndex < sizeof (BaudRateList) / sizeof (BaudRateList [0]); AttributeIndex++) {\r | |
1129 | if (NewTerminalContext->BaudRate == (UINT64) (BaudRateList[AttributeIndex].Value)) {\r | |
1130 | NewTerminalContext->BaudRateIndex = AttributeIndex;\r | |
1131 | break;\r | |
1132 | }\r | |
1133 | }\r | |
1134 | for (AttributeIndex = 0; AttributeIndex < sizeof (DataBitsList) / sizeof (DataBitsList[0]); AttributeIndex++) {\r | |
1135 | if (NewTerminalContext->DataBits == (UINT64) (DataBitsList[AttributeIndex].Value)) {\r | |
1136 | NewTerminalContext->DataBitsIndex = AttributeIndex;\r | |
1137 | break;\r | |
1138 | }\r | |
1139 | } \r | |
1140 | \r | |
1141 | for (AttributeIndex = 0; AttributeIndex < sizeof (ParityList) / sizeof (ParityList[0]); AttributeIndex++) {\r | |
1142 | if (NewTerminalContext->Parity == (UINT64) (ParityList[AttributeIndex].Value)) {\r | |
1143 | NewTerminalContext->ParityIndex = AttributeIndex;\r | |
1144 | break;\r | |
1145 | }\r | |
1146 | }\r | |
1147 | \r | |
1148 | for (AttributeIndex = 0; AttributeIndex < sizeof (StopBitsList) / sizeof (StopBitsList[0]); AttributeIndex++) {\r | |
1149 | if (NewTerminalContext->StopBits == (UINT64) (StopBitsList[AttributeIndex].Value)) {\r | |
1150 | NewTerminalContext->StopBitsIndex = AttributeIndex;\r | |
1151 | break;\r | |
1152 | }\r | |
1153 | }\r | |
1154 | CurrentFakeNVMap->COMBaudRate[TerminalIndex] = NewTerminalContext->BaudRateIndex;\r | |
1155 | CurrentFakeNVMap->COMDataRate[TerminalIndex] = NewTerminalContext->DataBitsIndex;\r | |
1156 | CurrentFakeNVMap->COMStopBits[TerminalIndex] = NewTerminalContext->StopBitsIndex;\r | |
1157 | CurrentFakeNVMap->COMParity[TerminalIndex] = NewTerminalContext->ParityIndex; \r | |
1158 | CurrentFakeNVMap->COMTerminalType[TerminalIndex] = NewTerminalContext->TerminalType;\r | |
1159 | CurrentFakeNVMap->COMFlowControl[TerminalIndex] = NewTerminalContext->FlowControl;\r | |
1160 | }\r | |
1161 | }\r | |
1162 | \r |