From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id F3DD2817CC for ; Sun, 8 Jan 2017 18:18:34 -0800 (PST) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga103.jf.intel.com with ESMTP; 08 Jan 2017 18:18:34 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,339,1477983600"; d="scan'208";a="211071831" Received: from ray-dev.ccr.corp.intel.com ([10.239.9.25]) by fmsmga004.fm.intel.com with ESMTP; 08 Jan 2017 18:18:33 -0800 From: Ruiyu Ni To: edk2-devel@lists.01.org Cc: Dandan Bi , Liming Gao Date: Mon, 9 Jan 2017 10:18:31 +0800 Message-Id: <20170109021831.116788-1-ruiyu.ni@intel.com> X-Mailer: git-send-email 2.9.0.windows.1 Subject: [PATCH] MdeModulePkg/BootMaintenanceManagerUiLib: Support NT32 terminals X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Jan 2017 02:18:35 -0000 The patch enhances Boot Maintenance Manager to recognize the terminal consoles in NT32 platform. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ruiyu Ni Cc: Dandan Bi Cc: Liming Gao --- .../BootMaintenanceManagerUiLib/ConsoleOption.c | 213 ++++++--------------- 1 file changed, 59 insertions(+), 154 deletions(-) diff --git a/MdeModulePkg/Library/BootMaintenanceManagerUiLib/ConsoleOption.c b/MdeModulePkg/Library/BootMaintenanceManagerUiLib/ConsoleOption.c index a145a77..11b77a6 100644 --- a/MdeModulePkg/Library/BootMaintenanceManagerUiLib/ConsoleOption.c +++ b/MdeModulePkg/Library/BootMaintenanceManagerUiLib/ConsoleOption.c @@ -1,7 +1,7 @@ /** @file handles console redirection from boot manager -Copyright (c) 2004 - 2015, Intel Corporation. All rights reserved.
+Copyright (c) 2004 - 2017, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -379,8 +379,6 @@ SortedUartHandle ( @param DevicePath DevicePath to be checked - @param Termi If DevicePath is valid Terminal, terminal type is returned. - @param Com If DevicePath is valid Terminal, Com Port type is returned. @retval TRUE If DevicePath point to a Terminal. @retval FALSE If DevicePath does not point to a Terminal. @@ -388,9 +386,7 @@ SortedUartHandle ( **/ BOOLEAN IsTerminalDevicePath ( - IN EFI_DEVICE_PATH_PROTOCOL *DevicePath, - OUT TYPE_OF_TERMINAL *Termi, - OUT UINTN *Com + IN EFI_DEVICE_PATH_PROTOCOL *DevicePath ); /** @@ -411,10 +407,8 @@ LocateSerialIo ( UINTN NoHandles; EFI_HANDLE *Handles; EFI_STATUS Status; - ACPI_HID_DEVICE_PATH *Acpi; EFI_DEVICE_PATH_PROTOCOL *DevicePath; EFI_SERIAL_IO_PROTOCOL *SerialIo; - EFI_DEVICE_PATH_PROTOCOL *Node; EFI_DEVICE_PATH_PROTOCOL *OutDevicePath; EFI_DEVICE_PATH_PROTOCOL *InpDevicePath; EFI_DEVICE_PATH_PROTOCOL *ErrDevicePath; @@ -458,76 +452,63 @@ LocateSerialIo ( (VOID **) &DevicePath ); - Acpi = NULL; - for (Node = DevicePath; !IsDevicePathEnd (Node); Node = NextDevicePathNode (Node)) { - if ((DevicePathType (Node) == MESSAGING_DEVICE_PATH) && (DevicePathSubType (Node) == MSG_UART_DP)) { - break; - } - // - // Acpi points to the node before Uart node - // - Acpi = (ACPI_HID_DEVICE_PATH *) Node; + NewMenuEntry = BOpt_CreateMenuEntry (BM_TERMINAL_CONTEXT_SELECT); + if (NewMenuEntry == NULL) { + FreePool (Handles); + return EFI_OUT_OF_RESOURCES; } - if ((Acpi != NULL) && IsIsaSerialNode (Acpi)) { - NewMenuEntry = BOpt_CreateMenuEntry (BM_TERMINAL_CONTEXT_SELECT); - if (NewMenuEntry == NULL) { - FreePool (Handles); - return EFI_OUT_OF_RESOURCES; - } + NewTerminalContext = (BM_TERMINAL_CONTEXT *) NewMenuEntry->VariableContext; + NewMenuEntry->OptionNumber = TerminalMenu.MenuNumber; + NewTerminalContext->DevicePath = DuplicateDevicePath (DevicePath); + // + // BugBug: I have no choice, calling EfiLibStrFromDatahub will hang the system! + // coz' the misc data for each platform is not correct, actually it's the device path stored in + // datahub which is not completed, so a searching for end of device path will enter a + // dead-loop. + // + NewMenuEntry->DisplayString = EfiLibStrFromDatahub (DevicePath); + if (NULL == NewMenuEntry->DisplayString) { + NewMenuEntry->DisplayString = UiDevicePathToStr (DevicePath); + } - NewTerminalContext = (BM_TERMINAL_CONTEXT *) NewMenuEntry->VariableContext; - CopyMem (&NewMenuEntry->OptionNumber, &Acpi->UID, sizeof (UINT32)); - NewTerminalContext->DevicePath = DuplicateDevicePath (DevicePath); - // - // BugBug: I have no choice, calling EfiLibStrFromDatahub will hang the system! - // coz' the misc data for each platform is not correct, actually it's the device path stored in - // datahub which is not completed, so a searching for end of device path will enter a - // dead-loop. - // - NewMenuEntry->DisplayString = EfiLibStrFromDatahub (DevicePath); - if (NULL == NewMenuEntry->DisplayString) { - NewMenuEntry->DisplayString = UiDevicePathToStr (DevicePath); - } + NewMenuEntry->HelpString = NULL; - NewMenuEntry->HelpString = NULL; + NewMenuEntry->DisplayStringToken = HiiSetString (mBmmCallbackInfo->BmmHiiHandle, 0, NewMenuEntry->DisplayString, NULL); - NewMenuEntry->DisplayStringToken = HiiSetString (mBmmCallbackInfo->BmmHiiHandle, 0, NewMenuEntry->DisplayString, NULL); + NewMenuEntry->HelpStringToken = NewMenuEntry->DisplayStringToken; - NewMenuEntry->HelpStringToken = NewMenuEntry->DisplayStringToken; - - gBS->HandleProtocol ( - Handles[Index], - &gEfiSerialIoProtocolGuid, - (VOID **) &SerialIo - ); + gBS->HandleProtocol ( + Handles[Index], + &gEfiSerialIoProtocolGuid, + (VOID **) &SerialIo + ); - CopyMem ( - &NewTerminalContext->BaudRate, - &SerialIo->Mode->BaudRate, - sizeof (UINT64) - ); + CopyMem ( + &NewTerminalContext->BaudRate, + &SerialIo->Mode->BaudRate, + sizeof (UINT64) + ); - CopyMem ( - &NewTerminalContext->DataBits, - &SerialIo->Mode->DataBits, - sizeof (UINT8) - ); + CopyMem ( + &NewTerminalContext->DataBits, + &SerialIo->Mode->DataBits, + sizeof (UINT8) + ); - CopyMem ( - &NewTerminalContext->Parity, - &SerialIo->Mode->Parity, - sizeof (UINT8) - ); + CopyMem ( + &NewTerminalContext->Parity, + &SerialIo->Mode->Parity, + sizeof (UINT8) + ); - CopyMem ( - &NewTerminalContext->StopBits, - &SerialIo->Mode->StopBits, - sizeof (UINT8) - ); - InsertTailList (&TerminalMenu.Head, &NewMenuEntry->Link); - TerminalMenu.MenuNumber++; - } + CopyMem ( + &NewTerminalContext->StopBits, + &SerialIo->Mode->StopBits, + sizeof (UINT8) + ); + InsertTailList (&TerminalMenu.Head, &NewMenuEntry->Link); + TerminalMenu.MenuNumber++; } if (Handles != NULL) { FreePool (Handles); @@ -753,8 +734,6 @@ GetConsoleMenu ( UINTN Index2; BM_MENU_ENTRY *NewMenuEntry; BM_CONSOLE_CONTEXT *NewConsoleContext; - TYPE_OF_TERMINAL Terminal; - UINTN Com; BM_MENU_OPTION *ConsoleMenu; DevicePath = NULL; @@ -822,11 +801,7 @@ GetConsoleMenu ( NewMenuEntry->HelpStringToken = HiiSetString (mBmmCallbackInfo->BmmHiiHandle, 0, NewMenuEntry->HelpString, NULL); } - NewConsoleContext->IsTerminal = IsTerminalDevicePath ( - NewConsoleContext->DevicePath, - &Terminal, - &Com - ); + NewConsoleContext->IsTerminal = IsTerminalDevicePath (NewConsoleContext->DevicePath); NewConsoleContext->IsActive = MatchDevicePaths ( DevicePath, @@ -884,8 +859,6 @@ FreeAllConsoles ( @param DevicePath DevicePath to be checked - @param Termi If DevicePath is valid Terminal, terminal type is returned. - @param Com If DevicePath is valid Terminal, Com Port type is returned. @retval TRUE If DevicePath point to a Terminal. @retval FALSE If DevicePath does not point to a Terminal. @@ -893,90 +866,22 @@ FreeAllConsoles ( **/ BOOLEAN IsTerminalDevicePath ( - IN EFI_DEVICE_PATH_PROTOCOL *DevicePath, - OUT TYPE_OF_TERMINAL *Termi, - OUT UINTN *Com + IN EFI_DEVICE_PATH_PROTOCOL *DevicePath ) { - BOOLEAN IsTerminal; + EFI_STATUS Status; EFI_DEVICE_PATH_PROTOCOL *Node; - VENDOR_DEVICE_PATH *Vendor; - UART_DEVICE_PATH *Uart; - ACPI_HID_DEVICE_PATH *Acpi; - - IsTerminal = FALSE; - - Uart = NULL; - Vendor = NULL; - Acpi = NULL; - for (Node = DevicePath; !IsDevicePathEnd (Node); Node = NextDevicePathNode (Node)) { - // - // Vendor points to the node before the End node - // - Vendor = (VENDOR_DEVICE_PATH *) Node; - - if ((DevicePathType (Node) == MESSAGING_DEVICE_PATH) && (DevicePathSubType (Node) == MSG_UART_DP)) { - Uart = (UART_DEVICE_PATH *) Node; - } - - if (Uart == NULL) { - // - // Acpi points to the node before the UART node - // - Acpi = (ACPI_HID_DEVICE_PATH *) Node; - } - } - - if (Vendor == NULL || - DevicePathType (Vendor) != MESSAGING_DEVICE_PATH || - DevicePathSubType (Vendor) != MSG_VENDOR_DP || - Uart == NULL) { - return FALSE; - } + EFI_HANDLE SerialHandle; - // - // There are four kinds of Terminal types - // check to see whether this devicepath - // is one of that type - // - if (CompareGuid (&Vendor->Guid, &TerminalTypeGuid[0])) { - *Termi = TerminalTypePcAnsi; - IsTerminal = TRUE; - } else { - if (CompareGuid (&Vendor->Guid, &TerminalTypeGuid[1])) { - *Termi = TerminalTypeVt100; - IsTerminal = TRUE; - } else { - if (CompareGuid (&Vendor->Guid, &TerminalTypeGuid[2])) { - *Termi = TerminalTypeVt100Plus; - IsTerminal = TRUE; - } else { - if (CompareGuid (&Vendor->Guid, &TerminalTypeGuid[3])) { - *Termi = TerminalTypeVtUtf8; - IsTerminal = TRUE; - } else { - if (CompareGuid (&Vendor->Guid, &TerminalTypeGuid[4])) { - *Termi = TerminalTypeTtyTerm; - IsTerminal = TRUE; - } else { - IsTerminal = FALSE; - } - } - } - } - } - - if (!IsTerminal) { - return FALSE; - } - - if ((Acpi != NULL) && IsIsaSerialNode (Acpi)) { - CopyMem (Com, &Acpi->UID, sizeof (UINT32)); - } else { + Node = DevicePath; + Status = gBS->LocateDevicePath (&gEfiSerialIoProtocolGuid, &Node, &SerialHandle); + if (EFI_ERROR (Status)) { return FALSE; } - return TRUE; + return (BOOLEAN) ( + (DevicePathType (Node) == MESSAGING_DEVICE_PATH) && + (DevicePathSubType (Node) == MSG_VENDOR_DP)); } /** -- 2.9.0.windows.1