]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ShellPkg/Library/UefiShellDebug1CommandsLib/EditMenuBar.c
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / ShellPkg / Library / UefiShellDebug1CommandsLib / EditMenuBar.c
index 58e90ac5b2eb466e4df321783ab4b9f0864d7cff..3284f0c1e214a215495f6edd76c042932be81ed8 100644 (file)
@@ -2,13 +2,7 @@
   implements menubar interface functions.\r
 \r
   Copyright (c) 2005 - 2018, Intel Corporation. All rights reserved. <BR>\r
-  This program and the accompanying materials\r
-  are licensed and made available under the terms and conditions of the BSD License\r
-  which accompanies this distribution.  The full text of the license may be found at\r
-  http://opensource.org/licenses/bsd-license.php\r
-\r
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+  SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
 \r
@@ -16,9 +10,9 @@
 #include "UefiShellDebug1CommandsLib.h"\r
 #include "EditStatusBar.h"\r
 \r
-EDITOR_MENU_ITEM   *MenuItems;\r
-MENU_ITEM_FUNCTION *ControlBasedMenuFunctions;\r
-UINTN                 NumItems;\r
+EDITOR_MENU_ITEM    *MenuItems;\r
+MENU_ITEM_FUNCTION  *ControlBasedMenuFunctions;\r
+UINTN               NumItems;\r
 \r
 /**\r
   Cleanup function for a menu bar.  frees all allocated memory.\r
@@ -28,7 +22,7 @@ MenuBarCleanup (
   VOID\r
   )\r
 {\r
-  SHELL_FREE_NON_NULL(MenuItems);\r
+  SHELL_FREE_NON_NULL (MenuItems);\r
 }\r
 \r
 /**\r
@@ -46,13 +40,15 @@ MenuBarInit (
 {\r
   CONST EDITOR_MENU_ITEM  *ItemsWalker;\r
 \r
-  for (NumItems = 0, ItemsWalker = Items ; ItemsWalker != NULL && ItemsWalker->Function != NULL ; ItemsWalker++,NumItems++);\r
-  \r
-  MenuItems = AllocateZeroPool((NumItems+1) * sizeof(EDITOR_MENU_ITEM));\r
+  for (NumItems = 0, ItemsWalker = Items; ItemsWalker != NULL && ItemsWalker->Function != NULL; ItemsWalker++, NumItems++) {\r
+  }\r
+\r
+  MenuItems = AllocateZeroPool ((NumItems+1) * sizeof (EDITOR_MENU_ITEM));\r
   if (MenuItems == NULL) {\r
     return EFI_OUT_OF_RESOURCES;\r
   }\r
-  CopyMem(MenuItems, Items, (NumItems+1) * sizeof(EDITOR_MENU_ITEM));\r
+\r
+  CopyMem (MenuItems, Items, (NumItems+1) * sizeof (EDITOR_MENU_ITEM));\r
   return EFI_SUCCESS;\r
 }\r
 \r
@@ -69,8 +65,9 @@ ControlHotKeyInit (
   )\r
 {\r
   ControlBasedMenuFunctions = Items;\r
-  return EFI_SUCCESS; \r
+  return EFI_SUCCESS;\r
 }\r
+\r
 /**\r
   Refresh function for the menu bar.\r
 \r
@@ -81,16 +78,16 @@ ControlHotKeyInit (
 **/\r
 EFI_STATUS\r
 MenuBarRefresh (\r
-  IN CONST UINTN LastRow,\r
-  IN CONST UINTN LastCol\r
+  IN CONST UINTN  LastRow,\r
+  IN CONST UINTN  LastCol\r
   )\r
 {\r
   EDITOR_MENU_ITEM  *Item;\r
-  UINTN                 Col;\r
-  UINTN                 Row;\r
-  UINTN                 Width;\r
-  CHAR16                *NameString;\r
-  CHAR16                *FunctionKeyString;\r
+  UINTN             Col;\r
+  UINTN             Row;\r
+  UINTN             Width;\r
+  CHAR16            *NameString;\r
+  CHAR16            *FunctionKeyString;\r
 \r
   //\r
   // variable initialization\r
@@ -103,25 +100,21 @@ MenuBarRefresh (
   //\r
   EditorClearLine (LastRow - 2, LastCol, LastRow);\r
   EditorClearLine (LastRow - 1, LastCol, LastRow);\r
-  EditorClearLine (LastRow    , LastCol, LastRow);\r
-\r
+  EditorClearLine (LastRow, LastCol, LastRow);\r
 \r
   //\r
   // print out the menu items\r
   //\r
   for (Item = MenuItems; Item != NULL && Item->Function != NULL; Item++) {\r
+    NameString = HiiGetString (gShellDebug1HiiHandle, Item->NameToken, NULL);\r
 \r
-\r
-    NameString = HiiGetString(gShellDebug1HiiHandle, Item->NameToken, NULL);\r
-\r
-\r
-    Width             = MAX ((StrLen (NameString) + 6), 20);\r
+    Width = MAX ((StrLen (NameString) + 6), 20);\r
     if (((Col + Width) > LastCol)) {\r
       Row++;\r
       Col = 1;\r
     }\r
 \r
-    FunctionKeyString = HiiGetString(gShellDebug1HiiHandle, Item->FunctionKeyToken, NULL);\r
+    FunctionKeyString = HiiGetString (gShellDebug1HiiHandle, Item->FunctionKeyToken, NULL);\r
 \r
     ShellPrintEx ((INT32)(Col) - 1, (INT32)(Row) - 1, L"%E%s%N  %H%s%N  ", FunctionKeyString, NameString);\r
 \r
@@ -138,18 +131,18 @@ MenuBarRefresh (
 \r
   @param[in] Key                The pressed key.\r
 \r
-  @retval EFI_NOT_FOUND         The key was not a valid function key \r
+  @retval EFI_NOT_FOUND         The key was not a valid function key\r
                                 (an error was sent to the status bar).\r
   @return The return value from the called dispatch function.\r
 **/\r
 EFI_STATUS\r
 MenuBarDispatchFunctionKey (\r
-  IN CONST EFI_INPUT_KEY   *Key\r
+  IN CONST EFI_INPUT_KEY  *Key\r
   )\r
 {\r
-  UINTN                 Index;\r
+  UINTN  Index;\r
 \r
-  Index     = Key->ScanCode - SCAN_F1;\r
+  Index = Key->ScanCode - SCAN_F1;\r
 \r
   //\r
   // check whether in range\r
@@ -167,16 +160,16 @@ MenuBarDispatchFunctionKey (
 \r
   @param[in] KeyData                The pressed key.\r
 \r
-  @retval EFI_NOT_FOUND         The key was not a valid control-based key \r
+  @retval EFI_NOT_FOUND         The key was not a valid control-based key\r
                                 (an error was sent to the status bar).\r
   @return EFI_SUCCESS.\r
 **/\r
 EFI_STATUS\r
 MenuBarDispatchControlHotKey (\r
-  IN CONST EFI_KEY_DATA   *KeyData\r
+  IN CONST EFI_KEY_DATA  *KeyData\r
   )\r
 {\r
-  UINT16                  ControlIndex;\r
+  UINT16  ControlIndex;\r
 \r
   //\r
   // Set to invalid value first.\r
@@ -184,7 +177,8 @@ MenuBarDispatchControlHotKey (
   ControlIndex = MAX_UINT16;\r
 \r
   if (((KeyData->KeyState.KeyShiftState & EFI_SHIFT_STATE_VALID) == 0) ||\r
-      (KeyData->KeyState.KeyShiftState == EFI_SHIFT_STATE_VALID)) {\r
+      (KeyData->KeyState.KeyShiftState == EFI_SHIFT_STATE_VALID))\r
+  {\r
     //\r
     // For consoles that don't support/report shift state,\r
     // Ctrl+A is translated to 1 (UnicodeChar).\r
@@ -192,7 +186,8 @@ MenuBarDispatchControlHotKey (
     ControlIndex = KeyData->Key.UnicodeChar;\r
   } else if (((KeyData->KeyState.KeyShiftState & EFI_SHIFT_STATE_VALID) != 0) &&\r
              ((KeyData->KeyState.KeyShiftState & (EFI_RIGHT_CONTROL_PRESSED | EFI_LEFT_CONTROL_PRESSED)) != 0) &&\r
-             ((KeyData->KeyState.KeyShiftState & ~(EFI_SHIFT_STATE_VALID | EFI_RIGHT_CONTROL_PRESSED | EFI_LEFT_CONTROL_PRESSED)) == 0)) {\r
+             ((KeyData->KeyState.KeyShiftState & ~(EFI_SHIFT_STATE_VALID | EFI_RIGHT_CONTROL_PRESSED | EFI_LEFT_CONTROL_PRESSED)) == 0))\r
+  {\r
     //\r
     // For consoles that supports/reports shift state,\r
     // make sure only CONTROL is pressed.\r
@@ -203,14 +198,13 @@ MenuBarDispatchControlHotKey (
       ControlIndex = KeyData->Key.UnicodeChar - L'a' + 1;\r
     }\r
   }\r
-  if ((SCAN_CONTROL_Z < ControlIndex)\r
-    ||(NULL == ControlBasedMenuFunctions[ControlIndex]))\r
+\r
+  if (  (SCAN_CONTROL_Z < ControlIndex)\r
+     || (NULL == ControlBasedMenuFunctions[ControlIndex]))\r
   {\r
-      return EFI_NOT_FOUND;\r
+    return EFI_NOT_FOUND;\r
   }\r
 \r
   ControlBasedMenuFunctions[ControlIndex]();\r
   return EFI_SUCCESS;\r
 }\r
-\r
-\r