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