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