]> git.proxmox.com Git - mirror_edk2.git/commitdiff
SecurityPkg: Use FileExplorerLib in SecureBootConfigDxe
authorDandan Bi <dandan.bi@intel.com>
Thu, 28 Jan 2016 01:36:43 +0000 (09:36 +0800)
committerStar Zeng <star.zeng@intel.com>
Fri, 26 Feb 2016 08:52:51 +0000 (16:52 +0800)
Using existing library FileExplorerLib to replace the same
logic in SecureBootConfigDxe to make the code clear. After using
FileExplorerLib, the UI behavior for enroll PK will change,
previously when select one PK file, commit/discard changes will
return to Device Manager,press ESC will return to FileExplorer.
Now using FileExplorerLib the behavior will keep same with
enroll KEK/DB/..., commit/discard changes will return to Custom
Secure Boot Options form and ESC will return to PK options form.

Cc: Chao Zhang <chao.b.zhang@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Dandan Bi <dandan.bi@intel.com>
Acked-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
Reviewed-by: Chao Zhang <chao.b.zhang@intel.com>
SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfig.vfr
SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigDxe.inf
SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigFileExplorer.c
SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigImpl.c
SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigImpl.h
SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigNvData.h

index e53630c833f06a9982e26e7f3e92cf6dab82244d..484da2c0cabdf84f9ec3435afcce788e672b3e89 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   VFR file used by the SecureBoot configuration component.\r
 \r
-Copyright (c) 2011 - 2015, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2011 - 2016, 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
@@ -202,11 +202,29 @@ formset
 \r
     subtitle text = STRING_TOKEN(STR_NULL);\r
 \r
-    goto FORM_FILE_EXPLORER_ID_PK,\r
+    goto FORMID_ENROLL_PK_FORM,\r
          prompt = STRING_TOKEN(STR_SECURE_BOOT_ENROLL_PK_FILE),\r
          help = STRING_TOKEN(STR_SECURE_BOOT_ENROLL_PK_FILE),\r
          flags = INTERACTIVE,\r
-         key = SECUREBOOT_ADD_PK_FILE_FORM_ID;\r
+         key = FORMID_ENROLL_PK_FORM;\r
+\r
+    subtitle text = STRING_TOKEN(STR_NULL);\r
+    label FORMID_ENROLL_PK_FORM;\r
+    label LABEL_END;\r
+    subtitle text = STRING_TOKEN(STR_NULL);\r
+\r
+    goto FORMID_SECURE_BOOT_OPTION_FORM,\r
+      prompt = STRING_TOKEN(STR_SAVE_AND_EXIT),\r
+      help   = STRING_TOKEN(STR_SAVE_AND_EXIT),\r
+      flags  = INTERACTIVE| RESET_REQUIRED,\r
+      key    = KEY_VALUE_SAVE_AND_EXIT_PK;\r
+\r
+    goto FORMID_SECURE_BOOT_OPTION_FORM,\r
+      prompt = STRING_TOKEN(STR_NO_SAVE_AND_EXIT),\r
+      help   = STRING_TOKEN(STR_NO_SAVE_AND_EXIT),\r
+      flags  = INTERACTIVE,\r
+      key    = KEY_VALUE_NO_SAVE_AND_EXIT_PK;\r
+\r
   endform;\r
 \r
   //\r
@@ -245,7 +263,7 @@ formset
 \r
     subtitle text = STRING_TOKEN(STR_NULL);\r
 \r
-    goto FORM_FILE_EXPLORER_ID_KEK,\r
+    goto FORMID_ENROLL_KEK_FORM,\r
          prompt = STRING_TOKEN(STR_FORM_ENROLL_KEK_FROM_FILE_TITLE),\r
          help   = STRING_TOKEN(STR_FORM_ENROLL_KEK_FROM_FILE_TITLE_HELP),\r
          flags  = INTERACTIVE,\r
@@ -408,7 +426,7 @@ formset
 \r
     subtitle text = STRING_TOKEN(STR_NULL);\r
 \r
-    goto FORM_FILE_EXPLORER_ID_DB,\r
+    goto SECUREBOOT_ENROLL_SIGNATURE_TO_DB,\r
          prompt = STRING_TOKEN(STR_SECURE_BOOT_ADD_SIGNATURE_FILE),\r
          help = STRING_TOKEN(STR_SECURE_BOOT_ADD_SIGNATURE_FILE),\r
          flags = INTERACTIVE,\r
@@ -453,7 +471,7 @@ formset
 \r
     subtitle text = STRING_TOKEN(STR_NULL);\r
 \r
-    goto FORM_FILE_EXPLORER_ID_DBX,\r
+    goto SECUREBOOT_ENROLL_SIGNATURE_TO_DBX,\r
          prompt = STRING_TOKEN(STR_SECURE_BOOT_ADD_SIGNATURE_FILE),\r
          help = STRING_TOKEN(STR_SECURE_BOOT_ADD_SIGNATURE_FILE),\r
          flags = INTERACTIVE,\r
@@ -529,7 +547,7 @@ formset
 \r
     subtitle text = STRING_TOKEN(STR_NULL);\r
 \r
-    goto FORM_FILE_EXPLORER_ID_DBT,\r
+    goto SECUREBOOT_ENROLL_SIGNATURE_TO_DBT,\r
          prompt = STRING_TOKEN(STR_SECURE_BOOT_ADD_SIGNATURE_FILE),\r
          help = STRING_TOKEN(STR_SECURE_BOOT_ADD_SIGNATURE_FILE),\r
          flags = INTERACTIVE,\r
@@ -566,81 +584,4 @@ formset
 \r
   endform;\r
 \r
-  //\r
-  // File Explorer for PK\r
-  //\r
-  form formid = FORM_FILE_EXPLORER_ID_PK,\r
-       title = STRING_TOKEN(STR_FILE_EXPLORER_TITLE);\r
-\r
-       label FORM_FILE_EXPLORER_ID;\r
-       label LABEL_END;\r
-  endform;\r
-\r
-  //\r
-  // File Explorer for KEK\r
-  //\r
-  form formid = FORM_FILE_EXPLORER_ID_KEK,\r
-       title = STRING_TOKEN(STR_FILE_EXPLORER_TITLE);\r
-\r
-       label FORM_FILE_EXPLORER_ID;\r
-       label LABEL_END;\r
-  endform;\r
-\r
-  //\r
-  // File Explorer for DB\r
-  //\r
-  form formid = FORM_FILE_EXPLORER_ID_DB,\r
-       title = STRING_TOKEN(STR_FILE_EXPLORER_TITLE);\r
-\r
-       label FORM_FILE_EXPLORER_ID;\r
-       label LABEL_END;\r
-  endform;\r
-\r
-  //\r
-  // File Explorer for DBX\r
-  //\r
-  form formid = FORM_FILE_EXPLORER_ID_DBX,\r
-       title = STRING_TOKEN(STR_FILE_EXPLORER_TITLE);\r
-\r
-       label FORM_FILE_EXPLORER_ID;\r
-       label LABEL_END;\r
-  endform;\r
-\r
-  //\r
-  // File Explorer for DBT\r
-  //\r
-  form formid = FORM_FILE_EXPLORER_ID_DBT,\r
-       title = STRING_TOKEN(STR_FILE_EXPLORER_TITLE);\r
-\r
-       label FORM_FILE_EXPLORER_ID;\r
-       label LABEL_END;\r
-  endform;\r
-\r
-  //\r
-  // Enroll Pk from File Commit Form\r
-  //\r
-  form formid = SECUREBOOT_ADD_PK_FILE_FORM_ID,\r
-    title = STRING_TOKEN(STR_SAVE_PK_FILE);\r
-\r
-    label SECUREBOOT_ADD_PK_FILE_FORM_ID;\r
-    label LABEL_END;\r
-\r
-    subtitle text = STRING_TOKEN(STR_NULL);\r
-\r
-     text\r
-       help   = STRING_TOKEN(STR_SAVE_AND_EXIT),\r
-       text   = STRING_TOKEN(STR_SAVE_AND_EXIT),\r
-       text   = STRING_TOKEN(STR_NULL),\r
-       flags  = INTERACTIVE,\r
-       key    = KEY_VALUE_SAVE_AND_EXIT_PK;\r
-\r
-     text\r
-       help   = STRING_TOKEN(STR_NO_SAVE_AND_EXIT),\r
-       text   = STRING_TOKEN(STR_NO_SAVE_AND_EXIT),\r
-       text   = STRING_TOKEN(STR_NULL),\r
-       flags  = INTERACTIVE,\r
-       key    = KEY_VALUE_NO_SAVE_AND_EXIT_PK;\r
-\r
-  endform;\r
-\r
 endformset;
\ No newline at end of file
index ef400c47b9dc07154faea6d54c207bfee9172284..6b143f5e0196151910e5b059df11205fa7feb72f 100644 (file)
@@ -2,7 +2,7 @@
 #  Provides the capbility to configure secure boot in a setup browser\r
 #  By this module, user may change the content of DB, DBX, PK and KEK.\r
 #\r
-# Copyright (c) 2011 - 2014, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2011 - 2016, 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
@@ -57,6 +57,7 @@
   HiiLib\r
   PlatformSecureLib\r
   DevicePathLib\r
+  FileExplorerLib\r
 \r
 [Guids]\r
   ## SOMETIMES_CONSUMES      ## Variable:L"CustomMode"\r
index e1fd78db4eeba714451fde7412ea953761049ad5..2adb85ce90a5f60c6160e518adb11f3c89aafd64 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Internal file explorer functions for SecureBoot configuration module.\r
 \r
-Copyright (c) 2012 - 2015, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2012 - 2016, 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
@@ -14,446 +14,70 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \r
 #include "SecureBootConfigImpl.h"\r
 \r
-///\r
-/// File system selection menu\r
-///\r
-SECUREBOOT_MENU_OPTION      FsOptionMenu = {\r
-  SECUREBOOT_MENU_OPTION_SIGNATURE,\r
-  {NULL},\r
-  0\r
-};\r
-\r
-///\r
-/// Files and sub-directories in current directory menu\r
-///\r
-SECUREBOOT_MENU_OPTION      DirectoryMenu = {\r
-  SECUREBOOT_MENU_OPTION_SIGNATURE,\r
-  {NULL},\r
-  0\r
-};\r
-\r
 VOID                  *mStartOpCodeHandle = NULL;\r
 VOID                  *mEndOpCodeHandle = NULL;\r
 EFI_IFR_GUID_LABEL    *mStartLabel = NULL;\r
 EFI_IFR_GUID_LABEL    *mEndLabel = NULL;\r
 \r
 /**\r
-  Duplicate a string.\r
-\r
-  @param[in]    Src             The source string.\r
-\r
-  @return      A new string which is duplicated copy of the source,\r
-               or NULL if there is not enough memory.\r
-\r
-**/\r
-CHAR16 *\r
-StrDuplicate (\r
-  IN CHAR16   *Src\r
-  )\r
-{\r
-  CHAR16  *Dest;\r
-  UINTN   Size;\r
-\r
-  Size  = StrSize (Src);\r
-  Dest  = AllocateZeroPool (Size);\r
-  ASSERT (Dest != NULL);\r
-  if (Dest != NULL) {\r
-    CopyMem (Dest, Src, Size);\r
-  }\r
-\r
-  return Dest;\r
-}\r
-\r
-/**\r
-  Helper function called as part of the code needed to allocate\r
-  the proper sized buffer for various EFI interfaces.\r
-\r
-  @param[in, out]   Status          Current status\r
-  @param[in, out]   Buffer          Current allocated buffer, or NULL\r
-  @param[in]        BufferSize      Current buffer size needed\r
-\r
-  @retval  TRUE         If the buffer was reallocated and the caller\r
-                        should try the API again.\r
-  @retval  FALSE        The caller should not call this function again.\r
+  Refresh the global UpdateData structure.\r
 \r
 **/\r
-BOOLEAN\r
-GrowBuffer (\r
-  IN OUT EFI_STATUS   *Status,\r
-  IN OUT VOID         **Buffer,\r
-  IN UINTN            BufferSize\r
+VOID\r
+RefreshUpdateData (\r
+  VOID\r
   )\r
 {\r
-  BOOLEAN TryAgain;\r
-\r
   //\r
-  // If this is an initial request, buffer will be null with a new buffer size\r
+  // Free current updated date\r
   //\r
-  if ((*Buffer == NULL) && (BufferSize != 0)) {\r
-    *Status = EFI_BUFFER_TOO_SMALL;\r
+  if (mStartOpCodeHandle != NULL) {\r
+    HiiFreeOpCodeHandle (mStartOpCodeHandle);\r
   }\r
-  //\r
-  // If the status code is "buffer too small", resize the buffer\r
-  //\r
-  TryAgain = FALSE;\r
-  if (*Status == EFI_BUFFER_TOO_SMALL) {\r
-\r
-    if (*Buffer != NULL) {\r
-      FreePool (*Buffer);\r
-    }\r
 \r
-    *Buffer = AllocateZeroPool (BufferSize);\r
-\r
-    if (*Buffer != NULL) {\r
-      TryAgain = TRUE;\r
-    } else {\r
-      *Status = EFI_OUT_OF_RESOURCES;\r
-    }\r
-  }\r
   //\r
-  // If there's an error, free the buffer\r
+  // Create new OpCode Handle\r
   //\r
-  if (!TryAgain && EFI_ERROR (*Status) && (*Buffer != NULL)) {\r
-    FreePool (*Buffer);\r
-    *Buffer = NULL;\r
-  }\r
-\r
-  return TryAgain;\r
-}\r
-\r
-/**\r
-  Append file name to existing file name, and allocate a new buffer\r
-  to hold the appended result.\r
-\r
-  @param[in]  Str1  The existing file name\r
-  @param[in]  Str2  The file name to be appended\r
-\r
-  @return      A new string with appended result.\r
-\r
-**/\r
-CHAR16 *\r
-AppendFileName (\r
-  IN  CHAR16  *Str1,\r
-  IN  CHAR16  *Str2\r
-  )\r
-{\r
-  UINTN   Size1;\r
-  UINTN   Size2;\r
-  UINTN   BufferSize;\r
-  CHAR16  *Str;\r
-  CHAR16  *TmpStr;\r
-  CHAR16  *Ptr;\r
-  CHAR16  *LastSlash;\r
-\r
-  Size1 = StrSize (Str1);\r
-  Size2 = StrSize (Str2);\r
-  BufferSize = Size1 + Size2 + sizeof (CHAR16);\r
-  Str   = AllocateZeroPool (BufferSize);\r
-  ASSERT (Str != NULL);\r
-\r
-  TmpStr = AllocateZeroPool (BufferSize);\r
-  ASSERT (TmpStr != NULL);\r
-\r
-  StrCatS (Str, BufferSize / sizeof (CHAR16), Str1);\r
-\r
-  if (!((*Str == '\\') && (*(Str + 1) == 0))) {\r
-    StrCatS (Str, BufferSize / sizeof (CHAR16), L"\\");\r
-  }\r
-\r
-  StrCatS (Str, BufferSize / sizeof (CHAR16), Str2);\r
-\r
-  Ptr       = Str;\r
-  LastSlash = Str;\r
-  while (*Ptr != 0) {\r
-    if (*Ptr == '\\' && *(Ptr + 1) == '.' && *(Ptr + 2) == '.' && *(Ptr + 3) == L'\\') {\r
-      //\r
-      // Convert "\Name\..\" to "\"\r
-      // DO NOT convert the .. if it is at the end of the string. This will\r
-      // break the .. behavior in changing directories.\r
-      //\r
-\r
-      //\r
-      // Use TmpStr as a backup, as StrCpyS in BaseLib does not handle copy of two strings\r
-      // that overlap.\r
-      //\r
-      StrCpyS (TmpStr, BufferSize / sizeof (CHAR16), Ptr + 3);\r
-      StrCpyS (LastSlash, BufferSize / sizeof (CHAR16), TmpStr);\r
-      Ptr = LastSlash;\r
-    } else if (*Ptr == '\\' && *(Ptr + 1) == '.' && *(Ptr + 2) == '\\') {\r
-      //\r
-      // Convert a "\.\" to a "\"\r
-      //\r
-\r
-      //\r
-      // Use TmpStr as a backup, as StrCpyS in BaseLib does not handle copy of two strings\r
-      // that overlap.\r
-      //\r
-      StrCpyS (TmpStr, BufferSize / sizeof (CHAR16), Ptr + 2);\r
-      StrCpyS (Ptr, BufferSize / sizeof (CHAR16), TmpStr);\r
-      Ptr = LastSlash;\r
-    } else if (*Ptr == '\\') {\r
-      LastSlash = Ptr;\r
-    }\r
-\r
-    Ptr++;\r
-  }\r
-\r
-  FreePool (TmpStr);\r
-\r
-  return Str;\r
-}\r
-\r
-/**\r
-  Create a SECUREBOOT_MENU_ENTRY, and stores it in a buffer allocated from the pool.\r
-\r
-  @return           The new menu entry or NULL of error happens.\r
-\r
-**/\r
-SECUREBOOT_MENU_ENTRY *\r
-CreateMenuEntry (\r
-  VOID\r
-  )\r
-{\r
-  SECUREBOOT_MENU_ENTRY *MenuEntry;\r
-  UINTN                 ContextSize;\r
+  mStartOpCodeHandle = HiiAllocateOpCodeHandle ();\r
 \r
   //\r
-  // Create new menu entry\r
+  // Create Hii Extend Label OpCode as the start opcode\r
   //\r
-  MenuEntry = AllocateZeroPool (sizeof (SECUREBOOT_MENU_ENTRY));\r
-  if (MenuEntry == NULL) {\r
-    return NULL;\r
-  }\r
-\r
-  ContextSize = sizeof (SECUREBOOT_FILE_CONTEXT);\r
-  MenuEntry->FileContext = AllocateZeroPool (ContextSize);\r
-  if (MenuEntry->FileContext == NULL) {\r
-    FreePool (MenuEntry);\r
-    return NULL;\r
-  }\r
-\r
-  MenuEntry->Signature = SECUREBOOT_MENU_ENTRY_SIGNATURE;\r
-\r
-  return MenuEntry;\r
-}\r
-\r
-/**\r
-  Get Menu Entry from the Menu Entry List by MenuNumber.\r
-\r
-  If MenuNumber is great or equal to the number of Menu\r
-  Entry in the list, then ASSERT.\r
-\r
-  @param[in]  MenuOption      The Menu Entry List to read the menu entry.\r
-  @param[in]  MenuNumber      The index of Menu Entry.\r
-\r
-  @return     The Menu Entry.\r
-\r
-**/\r
-SECUREBOOT_MENU_ENTRY *\r
-GetMenuEntry (\r
-  IN  SECUREBOOT_MENU_OPTION      *MenuOption,\r
-  IN  UINTN                       MenuNumber\r
-  )\r
-{\r
-  SECUREBOOT_MENU_ENTRY       *NewMenuEntry;\r
-  UINTN                       Index;\r
-  LIST_ENTRY                  *List;\r
-\r
-  ASSERT (MenuNumber < MenuOption->MenuNumber);\r
-\r
-  List = MenuOption->Head.ForwardLink;\r
-  for (Index = 0; Index < MenuNumber; Index++) {\r
-    List = List->ForwardLink;\r
-  }\r
-\r
-  NewMenuEntry = CR (List, SECUREBOOT_MENU_ENTRY, Link, SECUREBOOT_MENU_ENTRY_SIGNATURE);\r
-\r
-  return NewMenuEntry;\r
-}\r
-\r
-/**\r
-  Create string tokens for a menu from its help strings and display strings.\r
-\r
-  @param[in] HiiHandle          Hii Handle of the package to be updated.\r
-  @param[in] MenuOption         The Menu whose string tokens need to be created.\r
-\r
-**/\r
-VOID\r
-CreateMenuStringToken (\r
-  IN EFI_HII_HANDLE                          HiiHandle,\r
-  IN SECUREBOOT_MENU_OPTION                  *MenuOption\r
-  )\r
-{\r
-  SECUREBOOT_MENU_ENTRY *NewMenuEntry;\r
-  UINTN         Index;\r
-\r
-  for (Index = 0; Index < MenuOption->MenuNumber; Index++) {\r
-    NewMenuEntry = GetMenuEntry (MenuOption, Index);\r
-\r
-    NewMenuEntry->DisplayStringToken = HiiSetString (\r
-                                         HiiHandle,\r
-                                         0,\r
-                                         NewMenuEntry->DisplayString,\r
-                                         NULL\r
+  mStartLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (\r
+                                         mStartOpCodeHandle,\r
+                                         &gEfiIfrTianoGuid,\r
+                                         NULL,\r
+                                         sizeof (EFI_IFR_GUID_LABEL)\r
                                          );\r
-\r
-    if (NewMenuEntry->HelpString == NULL) {\r
-      NewMenuEntry->HelpStringToken = NewMenuEntry->DisplayStringToken;\r
-    } else {\r
-      NewMenuEntry->HelpStringToken = HiiSetString (\r
-                                        HiiHandle,\r
-                                        0,\r
-                                        NewMenuEntry->HelpString,\r
-                                        NULL\r
-                                        );\r
-    }\r
-  }\r
-}\r
-\r
-/**\r
-  Free up all resources allocated for a SECUREBOOT_MENU_ENTRY.\r
-\r
-  @param[in, out]  MenuEntry   A pointer to SECUREBOOT_MENU_ENTRY.\r
-\r
-**/\r
-VOID\r
-DestroyMenuEntry (\r
-  IN OUT SECUREBOOT_MENU_ENTRY         *MenuEntry\r
-  )\r
-{\r
-  SECUREBOOT_FILE_CONTEXT           *FileContext;\r
-\r
-\r
-  FileContext = (SECUREBOOT_FILE_CONTEXT *) MenuEntry->FileContext;\r
-\r
-  if (!FileContext->IsRoot && FileContext->DevicePath != NULL) {\r
-    FreePool (FileContext->DevicePath);\r
-  } else {\r
-    if (FileContext->FHandle != NULL) {\r
-      FileContext->FHandle->Close (FileContext->FHandle);\r
-    }\r
-  }\r
-\r
-  if (FileContext->FileName != NULL) {\r
-    FreePool (FileContext->FileName);\r
-  }\r
-  if (FileContext->Info != NULL) {\r
-    FreePool (FileContext->Info);\r
-  }\r
-\r
-  FreePool (FileContext);\r
-\r
-  if (MenuEntry->DisplayString != NULL) {\r
-    FreePool (MenuEntry->DisplayString);\r
-  }\r
-  if (MenuEntry->HelpString != NULL) {\r
-    FreePool (MenuEntry->HelpString);\r
-  }\r
-\r
-  FreePool (MenuEntry);\r
+  mStartLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;\r
 }\r
 \r
 /**\r
-  Free resources allocated in Allocate Rountine.\r
+  Clean up the dynamic opcode at label and form specified by both LabelId.\r
 \r
-  @param[in, out]  MenuOption        Menu to be freed\r
+  @param[in] LabelId         It is both the Form ID and Label ID for opcode deletion.\r
+  @param[in] PrivateData     Module private data.\r
 \r
 **/\r
 VOID\r
-FreeMenu (\r
-  IN OUT SECUREBOOT_MENU_OPTION        *MenuOption\r
-  )\r
-{\r
-  SECUREBOOT_MENU_ENTRY      *MenuEntry;\r
-  while (!IsListEmpty (&MenuOption->Head)) {\r
-    MenuEntry = CR (\r
-                  MenuOption->Head.ForwardLink,\r
-                  SECUREBOOT_MENU_ENTRY,\r
-                  Link,\r
-                  SECUREBOOT_MENU_ENTRY_SIGNATURE\r
-                  );\r
-    RemoveEntryList (&MenuEntry->Link);\r
-    DestroyMenuEntry (MenuEntry);\r
-  }\r
-  MenuOption->MenuNumber = 0;\r
-}\r
-\r
-/**\r
-  This function gets the file information from an open file descriptor, and stores it\r
-  in a buffer allocated from pool.\r
-\r
-  @param[in]  FHand           File Handle.\r
-\r
-  @return    A pointer to a buffer with file information or NULL is returned\r
-\r
-**/\r
-EFI_FILE_INFO *\r
-FileInfo (\r
-  IN EFI_FILE_HANDLE      FHand\r
-  )\r
-{\r
-  EFI_STATUS    Status;\r
-  EFI_FILE_INFO *Buffer;\r
-  UINTN         BufferSize;\r
-\r
-  //\r
-  // Initialize for GrowBuffer loop\r
-  //\r
-  Buffer      = NULL;\r
-  BufferSize  = SIZE_OF_EFI_FILE_INFO + 200;\r
-\r
-  //\r
-  // Call the real function\r
-  //\r
-  while (GrowBuffer (&Status, (VOID **) &Buffer, BufferSize)) {\r
-    Status = FHand->GetInfo (\r
-                      FHand,\r
-                      &gEfiFileInfoGuid,\r
-                      &BufferSize,\r
-                      Buffer\r
-                      );\r
-  }\r
-\r
-  return Buffer;\r
-}\r
-\r
-/**\r
-  This function gets the file system information from an open file descriptor,\r
-  and stores it in a buffer allocated from pool.\r
-\r
-  @param[in] FHand       The file handle.\r
-\r
-  @return                A pointer to a buffer with file information.\r
-  @retval                NULL is returned if failed to get Vaolume Label Info.\r
-\r
-**/\r
-EFI_FILE_SYSTEM_VOLUME_LABEL *\r
-FileSystemVolumeLabelInfo (\r
-  IN EFI_FILE_HANDLE      FHand\r
+CleanUpPage (\r
+  IN UINT16                           LabelId,\r
+  IN SECUREBOOT_CONFIG_PRIVATE_DATA   *PrivateData\r
   )\r
 {\r
-  EFI_STATUS                        Status;\r
-  EFI_FILE_SYSTEM_VOLUME_LABEL      *Buffer;\r
-  UINTN                             BufferSize;\r
-  //\r
-  // Initialize for GrowBuffer loop\r
-  //\r
-  Buffer      = NULL;\r
-  BufferSize  = SIZE_OF_EFI_FILE_SYSTEM_VOLUME_LABEL + 200;\r
+  RefreshUpdateData ();\r
 \r
   //\r
-  // Call the real function\r
+  // Remove all op-codes from dynamic page\r
   //\r
-  while (GrowBuffer (&Status, (VOID **) &Buffer, BufferSize)) {\r
-    Status = FHand->GetInfo (\r
-                      FHand,\r
-                      &gEfiFileSystemVolumeLabelInfoIdGuid,\r
-                      &BufferSize,\r
-                      Buffer\r
-                      );\r
-  }\r
-\r
-  return Buffer;\r
+  mStartLabel->Number = LabelId;\r
+  HiiUpdateForm (\r
+    PrivateData->HiiHandle,\r
+    &gSecureBootConfigFormSetGuid,\r
+    LabelId,\r
+    mStartOpCodeHandle, // Label LabelId\r
+    mEndOpCodeHandle    // LABEL_END\r
+    );\r
 }\r
 \r
 /**\r
@@ -595,640 +219,187 @@ OpenFileByDevicePath(
   return EFI_SUCCESS;\r
 }\r
 \r
+\r
 /**\r
-  Function opens and returns a file handle to the root directory of a volume.\r
+  Extract filename from device path. The returned buffer is allocated using AllocateCopyPool.\r
+  The caller is responsible for freeing the allocated buffer using FreePool().\r
 \r
-  @param[in]   DeviceHandle    A handle for a device\r
+  @param DevicePath       Device path.\r
 \r
-  @return      A valid file handle or NULL if error happens.\r
+  @return                 A new allocated string that represents the file name.\r
 \r
 **/\r
-EFI_FILE_HANDLE\r
-OpenRoot (\r
-  IN EFI_HANDLE                   DeviceHandle\r
+CHAR16 *\r
+ExtractFileNameFromDevicePath (\r
+  IN   EFI_DEVICE_PATH_PROTOCOL *DevicePath\r
   )\r
 {\r
-  EFI_STATUS                      Status;\r
-  EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *Volume;\r
-  EFI_FILE_HANDLE                 File;\r
-\r
-  File = NULL;\r
-\r
-  //\r
-  // File the file system interface to the device\r
-  //\r
-  Status = gBS->HandleProtocol (\r
-                  DeviceHandle,\r
-                  &gEfiSimpleFileSystemProtocolGuid,\r
-                  (VOID *) &Volume\r
-                  );\r
-\r
-  //\r
-  // Open the root directory of the volume\r
-  //\r
-  if (!EFI_ERROR (Status)) {\r
-    Status = Volume->OpenVolume (\r
-                      Volume,\r
-                      &File\r
-                      );\r
-  }\r
-  //\r
-  // Done\r
-  //\r
-  return EFI_ERROR (Status) ? NULL : File;\r
-}\r
+  CHAR16          *String;\r
+  CHAR16          *MatchString;\r
+  CHAR16          *LastMatch;\r
+  CHAR16          *FileName;\r
+  UINTN           Length;\r
 \r
-/**\r
-  This function builds the FsOptionMenu list which records all\r
-  available file system in the system. They include all instances\r
-  of EFI_SIMPLE_FILE_SYSTEM_PROTOCOL, all instances of EFI_LOAD_FILE_SYSTEM\r
-  and all type of legacy boot device.\r
-\r
-  @retval  EFI_SUCCESS             Success find the file system\r
-  @retval  EFI_OUT_OF_RESOURCES    Can not create menu entry\r
+  ASSERT(DevicePath != NULL);\r
 \r
-**/\r
-EFI_STATUS\r
-FindFileSystem (\r
-  VOID\r
-  )\r
-{\r
-  UINTN                     NoBlkIoHandles;\r
-  UINTN                     NoSimpleFsHandles;\r
-  EFI_HANDLE                *BlkIoHandle;\r
-  EFI_HANDLE                *SimpleFsHandle;\r
-  UINT16                    *VolumeLabel;\r
-  EFI_BLOCK_IO_PROTOCOL     *BlkIo;\r
-  UINTN                     Index;\r
-  EFI_STATUS                Status;\r
-  SECUREBOOT_MENU_ENTRY     *MenuEntry;\r
-  SECUREBOOT_FILE_CONTEXT   *FileContext;\r
-  UINT16                    *TempStr;\r
-  UINTN                     OptionNumber;\r
-  VOID                      *Buffer;\r
-\r
-  BOOLEAN                   RemovableMedia;\r
-\r
-\r
-  NoSimpleFsHandles = 0;\r
-  OptionNumber      = 0;\r
-  InitializeListHead (&FsOptionMenu.Head);\r
+  String = DevicePathToStr(DevicePath);\r
+  MatchString = String;\r
+  LastMatch   = String;\r
 \r
-  //\r
-  // Locate Handles that support BlockIo protocol\r
-  //\r
-  Status = gBS->LocateHandleBuffer (\r
-                  ByProtocol,\r
-                  &gEfiBlockIoProtocolGuid,\r
-                  NULL,\r
-                  &NoBlkIoHandles,\r
-                  &BlkIoHandle\r
-                  );\r
-  if (!EFI_ERROR (Status)) {\r
-\r
-    for (Index = 0; Index < NoBlkIoHandles; Index++) {\r
-      Status = gBS->HandleProtocol (\r
-                      BlkIoHandle[Index],\r
-                      &gEfiBlockIoProtocolGuid,\r
-                      (VOID **) &BlkIo\r
-                      );\r
-\r
-      if (EFI_ERROR (Status)) {\r
-        continue;\r
-      }\r
-\r
-      //\r
-      // Issue a dummy read to trigger reinstall of BlockIo protocol for removable media\r
-      //\r
-      if (BlkIo->Media->RemovableMedia) {\r
-        Buffer = AllocateZeroPool (BlkIo->Media->BlockSize);\r
-        if (NULL == Buffer) {\r
-          FreePool (BlkIoHandle);\r
-          return EFI_OUT_OF_RESOURCES;\r
-        }\r
-\r
-        BlkIo->ReadBlocks (\r
-                BlkIo,\r
-                BlkIo->Media->MediaId,\r
-                0,\r
-                BlkIo->Media->BlockSize,\r
-                Buffer\r
-                );\r
-        FreePool (Buffer);\r
-      }\r
-    }\r
-    FreePool (BlkIoHandle);\r
+  while(MatchString != NULL){\r
+    LastMatch   = MatchString + 1;\r
+    MatchString = StrStr(LastMatch,L"\\");\r
   }\r
 \r
-  //\r
-  // Locate Handles that support Simple File System protocol\r
-  //\r
-  Status = gBS->LocateHandleBuffer (\r
-                  ByProtocol,\r
-                  &gEfiSimpleFileSystemProtocolGuid,\r
-                  NULL,\r
-                  &NoSimpleFsHandles,\r
-                  &SimpleFsHandle\r
-                  );\r
-  if (!EFI_ERROR (Status)) {\r
-    //\r
-    // Find all the instances of the File System prototocol\r
-    //\r
-    for (Index = 0; Index < NoSimpleFsHandles; Index++) {\r
-      Status = gBS->HandleProtocol (\r
-                      SimpleFsHandle[Index],\r
-                      &gEfiBlockIoProtocolGuid,\r
-                      (VOID **) &BlkIo\r
-                      );\r
-      if (EFI_ERROR (Status)) {\r
-        //\r
-        // If no block IO exists assume it's NOT a removable media\r
-        //\r
-        RemovableMedia = FALSE;\r
-      } else {\r
-        //\r
-        // If block IO exists check to see if it's remobable media\r
-        //\r
-        RemovableMedia = BlkIo->Media->RemovableMedia;\r
-      }\r
-\r
-      //\r
-      // Allocate pool for this instance.\r
-      //\r
-      MenuEntry = CreateMenuEntry ();\r
-      if (NULL == MenuEntry) {\r
-        FreePool (SimpleFsHandle);\r
-        return EFI_OUT_OF_RESOURCES;\r
-      }\r
-\r
-      FileContext = (SECUREBOOT_FILE_CONTEXT *) MenuEntry->FileContext;\r
-\r
-      FileContext->Handle     = SimpleFsHandle[Index];\r
-      MenuEntry->OptionNumber = Index;\r
-      FileContext->FHandle    = OpenRoot (FileContext->Handle);\r
-      if (FileContext->FHandle == NULL) {\r
-        DestroyMenuEntry (MenuEntry);\r
-        continue;\r
-      }\r
-\r
-      MenuEntry->HelpString = DevicePathToStr (DevicePathFromHandle (FileContext->Handle));\r
-      FileContext->Info = FileSystemVolumeLabelInfo (FileContext->FHandle);\r
-      FileContext->FileName = StrDuplicate (L"\\");\r
-      FileContext->DevicePath = FileDevicePath (\r
-                                  FileContext->Handle,\r
-                                  FileContext->FileName\r
-                                  );\r
-      FileContext->IsDir            = TRUE;\r
-      FileContext->IsRoot           = TRUE;\r
-      FileContext->IsRemovableMedia = RemovableMedia;\r
-      FileContext->IsLoadFile       = FALSE;\r
-\r
-      //\r
-      // Get current file system's Volume Label\r
-      //\r
-      if (FileContext->Info == NULL) {\r
-        VolumeLabel = L"NO FILE SYSTEM INFO";\r
-      } else {\r
-        if (FileContext->Info->VolumeLabel == NULL) {\r
-          VolumeLabel = L"NULL VOLUME LABEL";\r
-        } else {\r
-          VolumeLabel = FileContext->Info->VolumeLabel;\r
-          if (*VolumeLabel == 0x0000) {\r
-            VolumeLabel = L"NO VOLUME LABEL";\r
-          }\r
-        }\r
-      }\r
-\r
-      TempStr                   = MenuEntry->HelpString;\r
-      MenuEntry->DisplayString  = AllocateZeroPool (MAX_CHAR);\r
-      ASSERT (MenuEntry->DisplayString != NULL);\r
-      UnicodeSPrint (\r
-        MenuEntry->DisplayString,\r
-        MAX_CHAR,\r
-        L"%s, [%s]",\r
-        VolumeLabel,\r
-        TempStr\r
-        );\r
-      OptionNumber++;\r
-      InsertTailList (&FsOptionMenu.Head, &MenuEntry->Link);\r
-    }\r
-  }\r
+  Length = StrLen(LastMatch);\r
+  FileName = AllocateCopyPool ((Length + 1) * sizeof(CHAR16), LastMatch);\r
+  *(FileName + Length) = 0;\r
 \r
-  if (NoSimpleFsHandles != 0) {\r
-    FreePool (SimpleFsHandle);\r
-  }\r
+  FreePool(String);\r
 \r
-  //\r
-  // Remember how many file system options are here\r
-  //\r
-  FsOptionMenu.MenuNumber = OptionNumber;\r
-  return EFI_SUCCESS;\r
+  return FileName;\r
 }\r
 \r
 \r
 /**\r
-  Find files under the current directory. All files and sub-directories\r
-  in current directory will be stored in DirectoryMenu for future use.\r
+  Update  the form base on the selected file.\r
 \r
-  @param[in] MenuEntry     The Menu Entry.\r
+  @param FilePath   Point to the file path.\r
+  @param FormId     The form need to display.\r
 \r
-  @retval EFI_SUCCESS      Get files from current dir successfully.\r
-  @return Other            Can't get files from current dir.\r
+  @retval TRUE   Exit caller function.\r
+  @retval FALSE  Not exit caller function.\r
 \r
 **/\r
-EFI_STATUS\r
-FindFiles (\r
-  IN SECUREBOOT_MENU_ENTRY              *MenuEntry\r
+BOOLEAN\r
+UpdatePage(\r
+  IN  EFI_DEVICE_PATH_PROTOCOL  *FilePath,\r
+  IN  EFI_FORM_ID               FormId\r
   )\r
 {\r
-  EFI_FILE_HANDLE           NewDir;\r
-  EFI_FILE_HANDLE           Dir;\r
-  EFI_FILE_INFO             *DirInfo;\r
-  UINTN                     BufferSize;\r
-  UINTN                     DirBufferSize;\r
-  SECUREBOOT_MENU_ENTRY     *NewMenuEntry;\r
-  SECUREBOOT_FILE_CONTEXT   *FileContext;\r
-  SECUREBOOT_FILE_CONTEXT   *NewFileContext;\r
-  UINTN                     Pass;\r
-  EFI_STATUS                Status;\r
-  UINTN                     OptionNumber;\r
-\r
-  FileContext   = (SECUREBOOT_FILE_CONTEXT *) MenuEntry->FileContext;\r
-  Dir           = FileContext->FHandle;\r
-  OptionNumber  = 0;\r
-  //\r
-  // Open current directory to get files from it\r
-  //\r
-  Status = Dir->Open (\r
-                  Dir,\r
-                  &NewDir,\r
-                  FileContext->FileName,\r
-                  EFI_FILE_READ_ONLY,\r
-                  0\r
-                  );\r
-  if (!FileContext->IsRoot) {\r
-    Dir->Close (Dir);\r
-  }\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
+  CHAR16                *FileName;\r
+  EFI_STRING_ID         StringToken;\r
 \r
-  DirInfo = FileInfo (NewDir);\r
-  if (DirInfo == NULL) {\r
-    return EFI_NOT_FOUND;\r
-  }\r
-\r
-  if ((DirInfo->Attribute & EFI_FILE_DIRECTORY) == 0) {\r
-    return EFI_INVALID_PARAMETER;\r
+  if (FilePath != NULL){\r
+    FileName = ExtractFileNameFromDevicePath(FilePath);\r
+    StringToken = HiiSetString (gSecureBootPrivateData->HiiHandle, 0, FileName, NULL);\r
+  } else {\r
+    FileName = HiiGetString (gSecureBootPrivateData->HiiHandle, STRING_TOKEN (STR_NULL), NULL);\r
+    ASSERT (FileName != NULL);\r
+    StringToken =  HiiSetString (gSecureBootPrivateData->HiiHandle, 0, FileName, NULL);\r
   }\r
 \r
-  FileContext->DevicePath = FileDevicePath (\r
-                              FileContext->Handle,\r
-                              FileContext->FileName\r
-                              );\r
-\r
-  DirBufferSize = sizeof (EFI_FILE_INFO) + 1024;\r
-  DirInfo       = AllocateZeroPool (DirBufferSize);\r
-  if (DirInfo == NULL) {\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
+  gSecureBootPrivateData->FileContext->FileName = FileName;\r
 \r
+  OpenFileByDevicePath(\r
+    &FilePath,\r
+    &gSecureBootPrivateData->FileContext->FHandle,\r
+    EFI_FILE_MODE_READ,\r
+    0\r
+    );\r
   //\r
-  // Get all files in current directory\r
-  // Pass 1 to get Directories\r
-  // Pass 2 to get files that are EFI images\r
+  // Create Subtitle op-code for the display string of the option.\r
   //\r
-  for (Pass = 1; Pass <= 2; Pass++) {\r
-    NewDir->SetPosition (NewDir, 0);\r
-    for (;;) {\r
-      BufferSize  = DirBufferSize;\r
-      Status      = NewDir->Read (NewDir, &BufferSize, DirInfo);\r
-      if (EFI_ERROR (Status) || BufferSize == 0) {\r
-        break;\r
-      }\r
-\r
-      if (((DirInfo->Attribute & EFI_FILE_DIRECTORY) != 0 && Pass == 2) ||\r
-          ((DirInfo->Attribute & EFI_FILE_DIRECTORY) == 0 && Pass == 1)\r
-          ) {\r
-        //\r
-        // Pass 1 is for Directories\r
-        // Pass 2 is for file names\r
-        //\r
-        continue;\r
-      }\r
-\r
-      NewMenuEntry = CreateMenuEntry ();\r
-      if (NULL == NewMenuEntry) {\r
-        return EFI_OUT_OF_RESOURCES;\r
-      }\r
-\r
-      NewFileContext          = (SECUREBOOT_FILE_CONTEXT *) NewMenuEntry->FileContext;\r
-      NewFileContext->Handle  = FileContext->Handle;\r
-      NewFileContext->FileName = AppendFileName (\r
-                                  FileContext->FileName,\r
-                                  DirInfo->FileName\r
-                                  );\r
-      NewFileContext->FHandle = NewDir;\r
-      NewFileContext->DevicePath = FileDevicePath (\r
-                                    NewFileContext->Handle,\r
-                                    NewFileContext->FileName\r
-                                    );\r
-      NewMenuEntry->HelpString = NULL;\r
-\r
-      NewFileContext->IsDir = (BOOLEAN) ((DirInfo->Attribute & EFI_FILE_DIRECTORY) == EFI_FILE_DIRECTORY);\r
-      if (NewFileContext->IsDir) {\r
-        BufferSize = StrLen (DirInfo->FileName) * 2 + 6;\r
-        NewMenuEntry->DisplayString = AllocateZeroPool (BufferSize);\r
-\r
-        UnicodeSPrint (\r
-          NewMenuEntry->DisplayString,\r
-          BufferSize,\r
-          L"<%s>",\r
-          DirInfo->FileName\r
-          );\r
-\r
-      } else {\r
-        NewMenuEntry->DisplayString = StrDuplicate (DirInfo->FileName);\r
-      }\r
-\r
-      NewFileContext->IsRoot            = FALSE;\r
-      NewFileContext->IsLoadFile        = FALSE;\r
-      NewFileContext->IsRemovableMedia  = FALSE;\r
-\r
-      NewMenuEntry->OptionNumber        = OptionNumber;\r
-      OptionNumber++;\r
-      InsertTailList (&DirectoryMenu.Head, &NewMenuEntry->Link);\r
-    }\r
-  }\r
+  RefreshUpdateData ();\r
+  mStartLabel->Number = FormId;\r
 \r
-  DirectoryMenu.MenuNumber = OptionNumber;\r
-  FreePool (DirInfo);\r
-  return EFI_SUCCESS;\r
+  HiiCreateSubTitleOpCode (\r
+    mStartOpCodeHandle,\r
+    StringToken,\r
+    0,\r
+    0,\r
+    0\r
+   );\r
+\r
+  HiiUpdateForm (\r
+    gSecureBootPrivateData->HiiHandle,\r
+    &gSecureBootConfigFormSetGuid,\r
+    FormId,\r
+    mStartOpCodeHandle, // Label FormId\r
+    mEndOpCodeHandle    // LABEL_END\r
+    );\r
+\r
+  return TRUE;\r
 }\r
 \r
 /**\r
-  Refresh the global UpdateData structure.\r
+  Update the PK form base on the input file path info.\r
 \r
+  @param FilePath    Point to the file path.\r
+\r
+  @retval TRUE   Exit caller function.\r
+  @retval FALSE  Not exit caller function.\r
 **/\r
-VOID\r
-RefreshUpdateData (\r
-  VOID\r
+BOOLEAN\r
+UpdatePKFromFile (\r
+  IN EFI_DEVICE_PATH_PROTOCOL    *FilePath\r
   )\r
 {\r
-  //\r
-  // Free current updated date\r
-  //\r
-  if (mStartOpCodeHandle != NULL) {\r
-    HiiFreeOpCodeHandle (mStartOpCodeHandle);\r
-  }\r
-\r
-  //\r
-  // Create new OpCode Handle\r
-  //\r
-  mStartOpCodeHandle = HiiAllocateOpCodeHandle ();\r
+  return UpdatePage(FilePath, FORMID_ENROLL_PK_FORM);\r
 \r
-  //\r
-  // Create Hii Extend Label OpCode as the start opcode\r
-  //\r
-  mStartLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (\r
-                                         mStartOpCodeHandle,\r
-                                         &gEfiIfrTianoGuid,\r
-                                         NULL,\r
-                                         sizeof (EFI_IFR_GUID_LABEL)\r
-                                         );\r
-  mStartLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;\r
 }\r
 \r
 /**\r
-  Update the File Explore page.\r
+  Update the KEK form base on the input file path info.\r
 \r
-  @param[in] HiiHandle          Hii Handle of the package to be updated.\r
-  @param[in] MenuOption         The Menu whose string tokens need to be updated.\r
-  @param[in] FeCurrentState     Current file explorer state.\r
+  @param FilePath    Point to the file path.\r
 \r
+  @retval TRUE   Exit caller function.\r
+  @retval FALSE  Not exit caller function.\r
 **/\r
-VOID\r
-UpdateFileExplorePage (\r
-  IN EFI_HII_HANDLE               HiiHandle,\r
-  IN SECUREBOOT_MENU_OPTION       *MenuOption,\r
-  IN FILE_EXPLORER_STATE          FeCurrentState\r
+BOOLEAN\r
+UpdateKEKFromFile (\r
+  IN EFI_DEVICE_PATH_PROTOCOL    *FilePath\r
   )\r
 {\r
-  UINTN                   Index;\r
-  SECUREBOOT_MENU_ENTRY   *NewMenuEntry;\r
-  SECUREBOOT_FILE_CONTEXT *NewFileContext;\r
-  EFI_FORM_ID             FormId;\r
-  EFI_FORM_ID             FileFormId;\r
-\r
-  if (FeCurrentState == FileExplorerStateEnrollPkFile) {\r
-    FormId     = SECUREBOOT_ADD_PK_FILE_FORM_ID;\r
-    FileFormId = FORM_FILE_EXPLORER_ID_PK;\r
-  } else if (FeCurrentState == FileExplorerStateEnrollKekFile) {\r
-    FormId     = FORMID_ENROLL_KEK_FORM;\r
-    FileFormId = FORM_FILE_EXPLORER_ID_KEK;\r
-  } else if (FeCurrentState == FileExplorerStateEnrollSignatureFileToDb) {\r
-    FormId     = SECUREBOOT_ENROLL_SIGNATURE_TO_DB;\r
-    FileFormId = FORM_FILE_EXPLORER_ID_DB;\r
-  } else if (FeCurrentState == FileExplorerStateEnrollSignatureFileToDbx) {\r
-    FormId     = SECUREBOOT_ENROLL_SIGNATURE_TO_DBX;\r
-    FileFormId = FORM_FILE_EXPLORER_ID_DBX;\r
-  } else if (FeCurrentState == FileExplorerStateEnrollSignatureFileToDbt) {\r
-    FormId     = SECUREBOOT_ENROLL_SIGNATURE_TO_DBT;\r
-    FileFormId = FORM_FILE_EXPLORER_ID_DBT;\r
-  } else {\r
-    return;\r
-  }\r
-\r
-  NewMenuEntry    = NULL;\r
-  NewFileContext  = NULL;\r
-\r
-  RefreshUpdateData ();\r
-  mStartLabel->Number = FORM_FILE_EXPLORER_ID;\r
-\r
-  for (Index = 0; Index < MenuOption->MenuNumber; Index++) {\r
-    NewMenuEntry    = GetMenuEntry (MenuOption, Index);\r
-    NewFileContext  = (SECUREBOOT_FILE_CONTEXT *) NewMenuEntry->FileContext;\r
-\r
-    if (NewFileContext->IsDir) {\r
-      //\r
-      // Create Text opcode for directory.\r
-      //\r
-      HiiCreateActionOpCode (\r
-        mStartOpCodeHandle,\r
-        (UINT16) (FILE_OPTION_OFFSET + Index),\r
-        NewMenuEntry->DisplayStringToken,\r
-        STRING_TOKEN (STR_NULL),\r
-        EFI_IFR_FLAG_CALLBACK,\r
-        0\r
-        );\r
-    } else {\r
-\r
-      //\r
-      // Create Goto opcode for file.\r
-      //\r
-      HiiCreateGotoOpCode (\r
-        mStartOpCodeHandle,\r
-        FormId,\r
-        NewMenuEntry->DisplayStringToken,\r
-        STRING_TOKEN (STR_NULL),\r
-        EFI_IFR_FLAG_CALLBACK,\r
-        (UINT16) (FILE_OPTION_GOTO_OFFSET + Index)\r
-        );\r
-    }\r
-  }\r
-\r
-  HiiUpdateForm (\r
-    HiiHandle,\r
-    &gSecureBootConfigFormSetGuid,\r
-    FileFormId,\r
-    mStartOpCodeHandle, // Label FORM_FILE_EXPLORER_ID\r
-    mEndOpCodeHandle    // LABEL_END\r
-    );\r
+  return UpdatePage(FilePath, FORMID_ENROLL_KEK_FORM);\r
 }\r
 \r
 /**\r
-  Update the file explorer page with the refreshed file system.\r
-\r
-  @param[in] PrivateData     Module private data.\r
-  @param[in] KeyValue        Key value to identify the type of data to expect.\r
+  Update the DB form base on the input file path info.\r
 \r
-  @retval  TRUE           Inform the caller to create a callback packet to exit file explorer.\r
-  @retval  FALSE          Indicate that there is no need to exit file explorer.\r
+  @param FilePath    Point to the file path.\r
 \r
+  @retval TRUE   Exit caller function.\r
+  @retval FALSE  Not exit caller function.\r
 **/\r
 BOOLEAN\r
-UpdateFileExplorer (\r
-  IN SECUREBOOT_CONFIG_PRIVATE_DATA   *PrivateData,\r
-  IN UINT16                           KeyValue\r
+UpdateDBFromFile (\r
+  IN EFI_DEVICE_PATH_PROTOCOL    *FilePath\r
   )\r
 {\r
-  UINT16                              FileOptionMask;\r
-  SECUREBOOT_MENU_ENTRY               *NewMenuEntry;\r
-  SECUREBOOT_FILE_CONTEXT             *NewFileContext;\r
-  EFI_FORM_ID                         FormId;\r
-  BOOLEAN                             ExitFileExplorer;\r
-  EFI_STATUS                          Status;\r
-  EFI_DEVICE_PATH_PROTOCOL            *TmpDevicePath;\r
-\r
-  NewMenuEntry      = NULL;\r
-  NewFileContext    = NULL;\r
-  ExitFileExplorer  = FALSE;\r
-  FileOptionMask    = (UINT16) (FILE_OPTION_MASK & KeyValue);\r
-\r
-  if (PrivateData->FeDisplayContext == FileExplorerDisplayUnknown) {\r
-    //\r
-    // First in, display file system.\r
-    //\r
-    FreeMenu (&FsOptionMenu);\r
-    FindFileSystem ();\r
-\r
-    CreateMenuStringToken (PrivateData->HiiHandle, &FsOptionMenu);\r
-    UpdateFileExplorePage (PrivateData->HiiHandle, &FsOptionMenu, PrivateData->FeCurrentState);\r
+  return UpdatePage(FilePath, SECUREBOOT_ENROLL_SIGNATURE_TO_DB);\r
+}\r
 \r
-    PrivateData->FeDisplayContext = FileExplorerDisplayFileSystem;\r
-  } else {\r
-    if (PrivateData->FeDisplayContext == FileExplorerDisplayFileSystem) {\r
-      NewMenuEntry = GetMenuEntry (&FsOptionMenu, FileOptionMask);\r
-    } else if (PrivateData->FeDisplayContext == FileExplorerDisplayDirectory) {\r
-      NewMenuEntry = GetMenuEntry (&DirectoryMenu, FileOptionMask);\r
-    }\r
+/**\r
+  Update the DBX form base on the input file path info.\r
 \r
-    NewFileContext = (SECUREBOOT_FILE_CONTEXT *) NewMenuEntry->FileContext;\r
-\r
-    if (NewFileContext->IsDir ) {\r
-      PrivateData->FeDisplayContext = FileExplorerDisplayDirectory;\r
-\r
-      RemoveEntryList (&NewMenuEntry->Link);\r
-      FreeMenu (&DirectoryMenu);\r
-      Status = FindFiles (NewMenuEntry);\r
-       if (EFI_ERROR (Status)) {\r
-         ExitFileExplorer = TRUE;\r
-         goto OnExit;\r
-       }\r
-      CreateMenuStringToken (PrivateData->HiiHandle, &DirectoryMenu);\r
-      DestroyMenuEntry (NewMenuEntry);\r
-\r
-      UpdateFileExplorePage (PrivateData->HiiHandle, &DirectoryMenu, PrivateData->FeCurrentState);\r
-\r
-    } else {\r
-      if (PrivateData->FeCurrentState == FileExplorerStateEnrollPkFile) {\r
-        FormId = SECUREBOOT_ADD_PK_FILE_FORM_ID;\r
-      } else if (PrivateData->FeCurrentState == FileExplorerStateEnrollKekFile) {\r
-        FormId = FORMID_ENROLL_KEK_FORM;\r
-      } else if (PrivateData->FeCurrentState == FileExplorerStateEnrollSignatureFileToDb) {\r
-        FormId = SECUREBOOT_ENROLL_SIGNATURE_TO_DB;\r
-      } else if (PrivateData->FeCurrentState == FileExplorerStateEnrollSignatureFileToDbx) {\r
-        FormId = SECUREBOOT_ENROLL_SIGNATURE_TO_DBX;\r
-      } else if (PrivateData->FeCurrentState == FileExplorerStateEnrollSignatureFileToDbt) {\r
-        FormId = SECUREBOOT_ENROLL_SIGNATURE_TO_DBT;\r
-      } else {\r
-        return FALSE;\r
-      }\r
-\r
-      PrivateData->MenuEntry = NewMenuEntry;\r
-      PrivateData->FileContext->FileName = NewFileContext->FileName;\r
-\r
-      TmpDevicePath = NewFileContext->DevicePath;\r
-      OpenFileByDevicePath (\r
-        &TmpDevicePath,\r
-        &PrivateData->FileContext->FHandle,\r
-        EFI_FILE_MODE_READ,\r
-        0\r
-        );\r
-\r
-      //\r
-      // Create Subtitle op-code for the display string of the option.\r
-      //\r
-      RefreshUpdateData ();\r
-      mStartLabel->Number = FormId;\r
-\r
-      HiiCreateSubTitleOpCode (\r
-        mStartOpCodeHandle,\r
-        NewMenuEntry->DisplayStringToken,\r
-        0,\r
-        0,\r
-        0\r
-        );\r
-\r
-      HiiUpdateForm (\r
-        PrivateData->HiiHandle,\r
-        &gSecureBootConfigFormSetGuid,\r
-        FormId,\r
-        mStartOpCodeHandle, // Label FormId\r
-        mEndOpCodeHandle    // LABEL_END\r
-        );\r
-    }\r
-  }\r
+  @param FilePath    Point to the file path.\r
 \r
-OnExit:\r
-  return ExitFileExplorer;\r
+  @retval TRUE   Exit caller function.\r
+  @retval FALSE  Not exit caller function.\r
+**/\r
+BOOLEAN\r
+UpdateDBXFromFile (\r
+  IN EFI_DEVICE_PATH_PROTOCOL    *FilePath\r
+  )\r
+{\r
+  return UpdatePage(FilePath, SECUREBOOT_ENROLL_SIGNATURE_TO_DBX);\r
 }\r
 \r
 /**\r
-  Clean up the dynamic opcode at label and form specified by both LabelId.\r
+  Update the DBT form base on the input file path info.\r
 \r
-  @param[in] LabelId         It is both the Form ID and Label ID for opcode deletion.\r
-  @param[in] PrivateData     Module private data.\r
+  @param FilePath    Point to the file path.\r
 \r
+  @retval TRUE   Exit caller function.\r
+  @retval FALSE  Not exit caller function.\r
 **/\r
-VOID\r
-CleanUpPage (\r
-  IN UINT16                           LabelId,\r
-  IN SECUREBOOT_CONFIG_PRIVATE_DATA   *PrivateData\r
+BOOLEAN\r
+UpdateDBTFromFile (\r
+  IN EFI_DEVICE_PATH_PROTOCOL    *FilePath\r
   )\r
 {\r
-  RefreshUpdateData ();\r
-\r
-  //\r
-  // Remove all op-codes from dynamic page\r
-  //\r
-  mStartLabel->Number = LabelId;\r
-  HiiUpdateForm (\r
-    PrivateData->HiiHandle,\r
-    &gSecureBootConfigFormSetGuid,\r
-    LabelId,\r
-    mStartOpCodeHandle, // Label LabelId\r
-    mEndOpCodeHandle    // LABEL_END\r
-    );\r
+  return UpdatePage(FilePath, SECUREBOOT_ENROLL_SIGNATURE_TO_DBT);\r
 }\r
+\r
index e2340e63023d9ebf1a32110bb4acec2eb698cdcc..bbd2f334137064de2a0d408b72b250e8875451b9 100644 (file)
@@ -97,6 +97,8 @@ CHAR16* mDerEncodedSuffix[] = {
 };\r
 CHAR16* mSupportX509Suffix = L"*.cer/der/crt";\r
 \r
+SECUREBOOT_CONFIG_PRIVATE_DATA  *gSecureBootPrivateData = NULL;\r
+\r
 /**\r
   This code checks if the FileSuffix is one of the possible DER-encoded certificate suffix.\r
 \r
@@ -657,7 +659,11 @@ ON_EXIT:
 \r
   CloseFile (Private->FileContext->FHandle);\r
   Private->FileContext->FHandle = NULL;\r
-  Private->FileContext->FileName = NULL;\r
+\r
+  if (Private->FileContext->FileName != NULL){\r
+    FreePool(Private->FileContext->FileName);\r
+    Private->FileContext->FileName = NULL;\r
+  }\r
 \r
   if (Private->SignatureGUID != NULL) {\r
     FreePool (Private->SignatureGUID);\r
@@ -779,7 +785,11 @@ EnrollX509ToKek (
 ON_EXIT:\r
 \r
   CloseFile (Private->FileContext->FHandle);\r
-  Private->FileContext->FileName = NULL;\r
+  if (Private->FileContext->FileName != NULL){\r
+    FreePool(Private->FileContext->FileName);\r
+    Private->FileContext->FileName = NULL;\r
+  }\r
+\r
   Private->FileContext->FHandle = NULL;\r
 \r
   if (Private->SignatureGUID != NULL) {\r
@@ -949,7 +959,11 @@ EnrollX509toSigDB (
 ON_EXIT:\r
 \r
   CloseFile (Private->FileContext->FHandle);\r
-  Private->FileContext->FileName = NULL;\r
+  if (Private->FileContext->FileName != NULL){\r
+    FreePool(Private->FileContext->FileName);\r
+    Private->FileContext->FileName = NULL;\r
+  }\r
+\r
   Private->FileContext->FHandle = NULL;\r
 \r
   if (Private->SignatureGUID != NULL) {\r
@@ -1509,7 +1523,11 @@ EnrollX509HashtoSigDB (
 \r
 ON_EXIT:\r
   CloseFile (Private->FileContext->FHandle);\r
-  Private->FileContext->FileName = NULL;\r
+  if (Private->FileContext->FileName != NULL){\r
+    FreePool(Private->FileContext->FileName);\r
+    Private->FileContext->FileName = NULL;\r
+  }\r
+\r
   Private->FileContext->FHandle = NULL;\r
 \r
   if (Private->SignatureGUID != NULL) {\r
@@ -2157,7 +2175,11 @@ ON_EXIT:
 \r
   CloseFile (Private->FileContext->FHandle);\r
   Private->FileContext->FHandle = NULL;\r
-  Private->FileContext->FileName = NULL;\r
+\r
+  if (Private->FileContext->FileName != NULL){\r
+    FreePool(Private->FileContext->FileName);\r
+    Private->FileContext->FileName = NULL;\r
+  }\r
 \r
   if (Private->SignatureGUID != NULL) {\r
     FreePool (Private->SignatureGUID);\r
@@ -3434,16 +3456,20 @@ SecureBootCallback (
   UINT8                           *SecureBootMode;\r
   CHAR16                          PromptString[100];\r
   UINT8                           CurSecureBootMode;\r
+  EFI_DEVICE_PATH_PROTOCOL        *File;\r
 \r
   Status           = EFI_SUCCESS;\r
   SecureBootEnable = NULL;\r
   SecureBootMode   = NULL;\r
+  File             = NULL;\r
 \r
   if ((This == NULL) || (Value == NULL) || (ActionRequest == NULL)) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
   Private = SECUREBOOT_CONFIG_PRIVATE_FROM_THIS (This);\r
 \r
+  gSecureBootPrivateData = Private;\r
+\r
   //\r
   // Retrieve uncommitted data from Browser\r
   //\r
@@ -3461,6 +3487,7 @@ SecureBootCallback (
       // Update secure boot strings when opening this form\r
       //\r
       Status = UpdateSecureBootString(Private);\r
+      SecureBootExtractConfigFromVariable (IfrNvData);\r
       mIsEnterSecureBootForm = TRUE;\r
     } else if (QuestionId == KEY_TRANS_SECURE_BOOT_MODE){\r
       //\r
@@ -3523,11 +3550,6 @@ SecureBootCallback (
       }\r
       break;\r
 \r
-    case KEY_SECURE_BOOT_OPTION:\r
-      FreeMenu (&DirectoryMenu);\r
-      FreeMenu (&FsOptionMenu);\r
-      break;\r
-\r
     case KEY_SECURE_BOOT_KEK_OPTION:\r
     case KEY_SECURE_BOOT_DB_OPTION:\r
     case KEY_SECURE_BOOT_DBX_OPTION:\r
@@ -3558,28 +3580,32 @@ SecureBootCallback (
       //\r
       CleanUpPage (LabelId, Private);\r
       break;\r
+    case KEY_SECURE_BOOT_PK_OPTION:\r
+      LabelId = FORMID_ENROLL_PK_FORM;\r
+      //\r
+      // Refresh selected file.\r
+      //\r
+      CleanUpPage (LabelId, Private);\r
+      break;\r
+\r
+    case FORMID_ENROLL_PK_FORM:\r
+      ChooseFile( NULL, NULL, (CHOOSE_HANDLER) UpdatePKFromFile, &File);\r
+      break;\r
 \r
-    case SECUREBOOT_ADD_PK_FILE_FORM_ID:\r
     case FORMID_ENROLL_KEK_FORM:\r
+      ChooseFile( NULL, NULL, (CHOOSE_HANDLER) UpdateKEKFromFile, &File);\r
+      break;\r
+\r
     case SECUREBOOT_ENROLL_SIGNATURE_TO_DB:\r
+      ChooseFile( NULL, NULL, (CHOOSE_HANDLER) UpdateDBFromFile, &File);\r
+      break;\r
+\r
     case SECUREBOOT_ENROLL_SIGNATURE_TO_DBX:\r
-    case SECUREBOOT_ENROLL_SIGNATURE_TO_DBT:\r
-      if (QuestionId == SECUREBOOT_ADD_PK_FILE_FORM_ID) {\r
-        Private->FeCurrentState = FileExplorerStateEnrollPkFile;\r
-      } else if (QuestionId == FORMID_ENROLL_KEK_FORM) {\r
-        Private->FeCurrentState = FileExplorerStateEnrollKekFile;\r
-      } else if (QuestionId == SECUREBOOT_ENROLL_SIGNATURE_TO_DB) {\r
-        Private->FeCurrentState = FileExplorerStateEnrollSignatureFileToDb;\r
-      } else if (QuestionId == SECUREBOOT_ENROLL_SIGNATURE_TO_DBX) {\r
-        Private->FeCurrentState = FileExplorerStateEnrollSignatureFileToDbx;\r
-        IfrNvData->CertificateFormat = HASHALG_SHA256;\r
-      } else {\r
-        Private->FeCurrentState = FileExplorerStateEnrollSignatureFileToDbt;\r
-      }\r
+      ChooseFile( NULL, NULL, (CHOOSE_HANDLER) UpdateDBXFromFile, &File);\r
+      break;\r
 \r
-      Private->FeDisplayContext = FileExplorerDisplayUnknown;\r
-      CleanUpPage (FORM_FILE_EXPLORER_ID, Private);\r
-      UpdateFileExplorer (Private, 0);\r
+    case SECUREBOOT_ENROLL_SIGNATURE_TO_DBT:\r
+      ChooseFile( NULL, NULL, (CHOOSE_HANDLER) UpdateDBTFromFile, &File);\r
       break;\r
 \r
     case KEY_SECURE_BOOT_DELETE_PK:\r
@@ -3722,6 +3748,24 @@ SecureBootCallback (
           );\r
       }\r
       break;\r
+    case KEY_VALUE_SAVE_AND_EXIT_PK:\r
+      Status = EnrollPlatformKey (Private);\r
+      if (EFI_ERROR (Status)) {\r
+        UnicodeSPrint (\r
+          PromptString,\r
+          sizeof (PromptString),\r
+          L"Only DER encoded certificate file (%s) is supported.",\r
+          mSupportX509Suffix\r
+          );\r
+        CreatePopUp (\r
+          EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,\r
+          &Key,\r
+          L"ERROR: Unsupported file type!",\r
+          PromptString,\r
+          NULL\r
+          );\r
+      }\r
+      break;\r
     case KEY_TRANS_SECURE_BOOT_MODE:\r
       //\r
       // Pop up to alert user want to change secure boot mode \r
@@ -3774,9 +3818,7 @@ SecureBootCallback (
       break;\r
 \r
     default:\r
-      if (QuestionId >= FILE_OPTION_GOTO_OFFSET) {\r
-        UpdateFileExplorer (Private, QuestionId);\r
-      } else if ((QuestionId >= OPTION_DEL_KEK_QUESTION_ID) &&\r
+      if ((QuestionId >= OPTION_DEL_KEK_QUESTION_ID) &&\r
                  (QuestionId < (OPTION_DEL_KEK_QUESTION_ID + OPTION_CONFIG_RANGE))) {\r
         DeleteKeyExchangeKey (Private, QuestionId);\r
       } else if ((QuestionId >= OPTION_DEL_DB_QUESTION_ID) &&\r
@@ -3814,32 +3856,6 @@ SecureBootCallback (
           );\r
       }\r
       break;\r
-    }\r
-  } else if (Action == EFI_BROWSER_ACTION_CHANGED) {\r
-    switch (QuestionId) {\r
-    case KEY_SECURE_BOOT_ENABLE:\r
-      *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_APPLY;\r
-      break;\r
-    case KEY_VALUE_SAVE_AND_EXIT_PK:\r
-      Status = EnrollPlatformKey (Private);\r
-      if (EFI_ERROR (Status)) {\r
-        UnicodeSPrint (\r
-          PromptString,\r
-          sizeof (PromptString),\r
-          L"Only DER encoded certificate file (%s) is supported.",\r
-          mSupportX509Suffix\r
-          );\r
-        CreatePopUp (\r
-          EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,\r
-          &Key,\r
-          L"ERROR: Unsupported file type!",\r
-          PromptString,\r
-          NULL\r
-          );\r
-      } else {\r
-        *ActionRequest = EFI_BROWSER_ACTION_REQUEST_RESET;\r
-      }\r
-      break;\r
 \r
     case KEY_VALUE_NO_SAVE_AND_EXIT_PK:\r
     case KEY_VALUE_NO_SAVE_AND_EXIT_KEK:\r
@@ -3849,16 +3865,23 @@ SecureBootCallback (
       if (Private->FileContext->FHandle != NULL) {\r
         CloseFile (Private->FileContext->FHandle);\r
         Private->FileContext->FHandle = NULL;\r
-        Private->FileContext->FileName = NULL;\r
+        if (Private->FileContext->FileName!= NULL){\r
+          FreePool(Private->FileContext->FileName);\r
+          Private->FileContext->FileName = NULL;\r
+        }\r
       }\r
 \r
       if (Private->SignatureGUID != NULL) {\r
         FreePool (Private->SignatureGUID);\r
         Private->SignatureGUID = NULL;\r
       }\r
-      *ActionRequest = EFI_BROWSER_ACTION_REQUEST_EXIT;\r
       break;\r
-\r
+    }\r
+  } else if (Action == EFI_BROWSER_ACTION_CHANGED) {\r
+    switch (QuestionId) {\r
+    case KEY_SECURE_BOOT_ENABLE:\r
+      *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_APPLY;\r
+      break;\r
     case KEY_SECURE_BOOT_MODE:\r
       mIsEnterSecureBootForm = FALSE;\r
       break;\r
@@ -3898,11 +3921,6 @@ SecureBootCallback (
       }\r
       break;\r
     default:\r
-      if (QuestionId >= FILE_OPTION_OFFSET && QuestionId < FILE_OPTION_GOTO_OFFSET) {\r
-        if (UpdateFileExplorer (Private, QuestionId)) {\r
-          *ActionRequest = EFI_BROWSER_ACTION_REQUEST_EXIT;\r
-        }\r
-      }\r
       break;\r
     }\r
   } else if (Action == EFI_BROWSER_ACTION_DEFAULT_STANDARD) {\r
@@ -3939,6 +3957,11 @@ EXIT:
 \r
   FreePool (IfrNvData);\r
 \r
+  if (File != NULL){\r
+    FreePool(File);\r
+    File = NULL;\r
+  }\r
+\r
   return EFI_SUCCESS;\r
 }\r
 \r
@@ -4003,19 +4026,12 @@ InstallSecureBootConfigForm (
   PrivateData->HiiHandle = HiiHandle;\r
 \r
   PrivateData->FileContext = AllocateZeroPool (sizeof (SECUREBOOT_FILE_CONTEXT));\r
-  PrivateData->MenuEntry   = AllocateZeroPool (sizeof (SECUREBOOT_MENU_ENTRY));\r
 \r
-  if (PrivateData->FileContext == NULL || PrivateData->MenuEntry == NULL) {\r
+  if (PrivateData->FileContext == NULL) {\r
     UninstallSecureBootConfigForm (PrivateData);\r
     return EFI_OUT_OF_RESOURCES;\r
   }\r
 \r
-  PrivateData->FeCurrentState = FileExplorerStateInActive;\r
-  PrivateData->FeDisplayContext = FileExplorerDisplayUnknown;\r
-\r
-  InitializeListHead (&FsOptionMenu.Head);\r
-  InitializeListHead (&DirectoryMenu.Head);\r
-\r
   //\r
   // Init OpCode Handle and Allocate space for creation of Buffer\r
   //\r
@@ -4095,19 +4111,12 @@ UninstallSecureBootConfigForm (
     FreePool (PrivateData->SignatureGUID);\r
   }\r
 \r
-  if (PrivateData->MenuEntry != NULL) {\r
-    FreePool (PrivateData->MenuEntry);\r
-  }\r
-\r
   if (PrivateData->FileContext != NULL) {\r
     FreePool (PrivateData->FileContext);\r
   }\r
 \r
   FreePool (PrivateData);\r
 \r
-  FreeMenu (&DirectoryMenu);\r
-  FreeMenu (&FsOptionMenu);\r
-\r
   if (mStartOpCodeHandle != NULL) {\r
     HiiFreeOpCodeHandle (mStartOpCodeHandle);\r
   }\r
index bcb1c12e23142d193d3c93be0209891c0c783541..a8dbd92ee436b1dc158875db6cdc355930ff1ec5 100644 (file)
@@ -2,7 +2,7 @@
   The header file of HII Config Access protocol implementation of SecureBoot\r
   configuration module.\r
 \r
-Copyright (c) 2011 - 2014, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2011 - 2016, 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
@@ -39,6 +39,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <Library/PrintLib.h>\r
 #include <Library/PlatformSecureLib.h>\r
 #include <Library/BaseCryptLib.h>\r
+#include <Library/FileExplorerLib.h>\r
+\r
 #include <Guid/MdeModuleHii.h>\r
 #include <Guid/AuthenticatedVariableFormat.h>\r
 #include <Guid/FileSystemVolumeLabelInfo.h>\r
@@ -118,22 +120,6 @@ typedef struct {
   CHAR16                    TargetName[1];\r
 } ISCSI_DEVICE_PATH_WITH_NAME;\r
 \r
-typedef enum _FILE_EXPLORER_DISPLAY_CONTEXT {\r
-  FileExplorerDisplayFileSystem,\r
-  FileExplorerDisplayDirectory,\r
-  FileExplorerDisplayUnknown\r
-} FILE_EXPLORER_DISPLAY_CONTEXT;\r
-\r
-typedef enum _FILE_EXPLORER_STATE {\r
-  FileExplorerStateInActive                      = 0,\r
-  FileExplorerStateEnrollPkFile,\r
-  FileExplorerStateEnrollKekFile,\r
-  FileExplorerStateEnrollSignatureFileToDb,\r
-  FileExplorerStateEnrollSignatureFileToDbx,\r
-  FileExplorerStateEnrollSignatureFileToDbt,\r
-  FileExplorerStateUnknown\r
-} FILE_EXPLORER_STATE;\r
-\r
 typedef struct {\r
   CHAR16  *Str;\r
   UINTN   Len;\r
@@ -159,32 +145,9 @@ typedef struct {
   UINTN             MenuNumber;\r
 } SECUREBOOT_MENU_OPTION;\r
 \r
-extern  SECUREBOOT_MENU_OPTION     FsOptionMenu;\r
-extern  SECUREBOOT_MENU_OPTION     DirectoryMenu;\r
-\r
-typedef struct {\r
-  UINTN             Signature;\r
-  LIST_ENTRY        Link;\r
-  UINTN             OptionNumber;\r
-  UINT16            *DisplayString;\r
-  UINT16            *HelpString;\r
-  EFI_STRING_ID     DisplayStringToken;\r
-  EFI_STRING_ID     HelpStringToken;\r
-  VOID              *FileContext;\r
-} SECUREBOOT_MENU_ENTRY;\r
-\r
 typedef struct {\r
-  EFI_HANDLE                        Handle;\r
-  EFI_DEVICE_PATH_PROTOCOL          *DevicePath;\r
   EFI_FILE_HANDLE                   FHandle;\r
   UINT16                            *FileName;\r
-  EFI_FILE_SYSTEM_VOLUME_LABEL      *Info;\r
-\r
-  BOOLEAN                           IsRoot;\r
-  BOOLEAN                           IsDir;\r
-  BOOLEAN                           IsRemovableMedia;\r
-  BOOLEAN                           IsLoadFile;\r
-  BOOLEAN                           IsBootLegacy;\r
 } SECUREBOOT_FILE_CONTEXT;\r
 \r
 \r
@@ -216,16 +179,13 @@ typedef struct {
   EFI_HII_HANDLE                    HiiHandle;\r
   EFI_HANDLE                        DriverHandle;\r
 \r
-  FILE_EXPLORER_STATE               FeCurrentState;\r
-  FILE_EXPLORER_DISPLAY_CONTEXT     FeDisplayContext;\r
-\r
-  SECUREBOOT_MENU_ENTRY             *MenuEntry;\r
   SECUREBOOT_FILE_CONTEXT           *FileContext;\r
 \r
   EFI_GUID                          *SignatureGUID;\r
 } SECUREBOOT_CONFIG_PRIVATE_DATA;\r
 \r
 extern SECUREBOOT_CONFIG_PRIVATE_DATA      mSecureBootConfigPrivateDateTemplate;\r
+extern SECUREBOOT_CONFIG_PRIVATE_DATA      *gSecureBootPrivateData;\r
 \r
 #define SECUREBOOT_CONFIG_PRIVATE_DATA_SIGNATURE     SIGNATURE_32 ('S', 'E', 'C', 'B')\r
 #define SECUREBOOT_CONFIG_PRIVATE_FROM_THIS(a)  CR (a, SECUREBOOT_CONFIG_PRIVATE_DATA, ConfigAccess, SECUREBOOT_CONFIG_PRIVATE_DATA_SIGNATURE)\r
@@ -495,35 +455,6 @@ CleanUpPage (
   );\r
 \r
 \r
-/**\r
-  Update the file explorer page with the refreshed file system.\r
-\r
-  @param[in] PrivateData     Module private data.\r
-  @param[in] KeyValue        Key value to identify the type of data to expect.\r
-\r
-  @retval  TRUE           Inform the caller to create a callback packet to exit file explorer.\r
-  @retval  FALSE          Indicate that there is no need to exit file explorer.\r
-\r
-**/\r
-BOOLEAN\r
-UpdateFileExplorer (\r
-  IN SECUREBOOT_CONFIG_PRIVATE_DATA   *PrivateData,\r
-  IN UINT16                           KeyValue\r
-  );\r
-\r
-\r
-/**\r
-  Free resources allocated in Allocate Rountine.\r
-\r
-  @param[in, out]  MenuOption        Menu to be freed\r
-\r
-**/\r
-VOID\r
-FreeMenu (\r
-  IN OUT SECUREBOOT_MENU_OPTION        *MenuOption\r
-  );\r
-\r
-\r
 /**\r
   Read file content into BufferPtr, the size of the allocate buffer\r
   is *FileSize plus AddtionAllocateSize.\r
@@ -621,4 +552,69 @@ GuidToString (
   IN  UINTN     BufferSize\r
   );\r
 \r
+/**\r
+  Update the PK form base on the input file path info.\r
+\r
+  @param FilePath    Point to the file path.\r
+\r
+  @retval TRUE   Exit caller function.\r
+  @retval FALSE  Not exit caller function.\r
+**/\r
+BOOLEAN\r
+UpdatePKFromFile (\r
+  IN EFI_DEVICE_PATH_PROTOCOL    *FilePath\r
+  );\r
+\r
+/**\r
+  Update the KEK form base on the input file path info.\r
+\r
+  @param FilePath    Point to the file path.\r
+\r
+  @retval TRUE   Exit caller function.\r
+  @retval FALSE  Not exit caller function.\r
+**/\r
+BOOLEAN\r
+UpdateKEKFromFile (\r
+  IN EFI_DEVICE_PATH_PROTOCOL    *FilePath\r
+  );\r
+\r
+/**\r
+  Update the DB form base on the input file path info.\r
+\r
+  @param FilePath    Point to the file path.\r
+\r
+  @retval TRUE   Exit caller function.\r
+  @retval FALSE  Not exit caller function.\r
+**/\r
+BOOLEAN\r
+UpdateDBFromFile (\r
+  IN EFI_DEVICE_PATH_PROTOCOL    *FilePath\r
+  );\r
+\r
+/**\r
+  Update the DBX form base on the input file path info.\r
+\r
+  @param FilePath    Point to the file path.\r
+\r
+  @retval TRUE   Exit caller function.\r
+  @retval FALSE  Not exit caller function.\r
+**/\r
+BOOLEAN\r
+UpdateDBXFromFile (\r
+  IN EFI_DEVICE_PATH_PROTOCOL    *FilePath\r
+  );\r
+\r
+/**\r
+  Update the DBT form base on the input file path info.\r
+\r
+  @param FilePath    Point to the file path.\r
+\r
+  @retval TRUE   Exit caller function.\r
+  @retval FALSE  Not exit caller function.\r
+**/\r
+BOOLEAN\r
+UpdateDBTFromFile (\r
+  IN EFI_DEVICE_PATH_PROTOCOL    *FilePath\r
+  );\r
+\r
 #endif\r
index 101b605e2c7c62c700b9a9ba83b56c55ceb99318..cf8dc885dedbe05586915c9bf38e85bba3a89bcd 100644 (file)
@@ -36,15 +36,9 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #define SECUREBOOT_DELETE_SIGNATURE_FROM_DB   0x0c\r
 #define SECUREBOOT_ENROLL_SIGNATURE_TO_DBX    0x0d\r
 #define SECUREBOOT_DELETE_SIGNATURE_FROM_DBX  0x0e\r
-#define FORM_FILE_EXPLORER_ID                 0x0f\r
-#define FORM_FILE_EXPLORER_ID_PK              0x10\r
-#define FORM_FILE_EXPLORER_ID_KEK             0x11\r
-#define FORM_FILE_EXPLORER_ID_DB              0x12\r
-#define FORM_FILE_EXPLORER_ID_DBX             0x13\r
 #define FORMID_SECURE_BOOT_DBT_OPTION_FORM    0x14\r
 #define SECUREBOOT_ENROLL_SIGNATURE_TO_DBT    0x15\r
 #define SECUREBOOT_DELETE_SIGNATURE_FROM_DBT  0x16\r
-#define FORM_FILE_EXPLORER_ID_DBT             0x17\r
 \r
 #define SECURE_BOOT_MODE_CUSTOM               0x01\r
 #define SECURE_BOOT_MODE_STANDARD             0x00\r
@@ -111,10 +105,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 //\r
 #define OPTION_DEL_DBT_QUESTION_ID            0x5000\r
 \r
-#define FILE_OPTION_GOTO_OFFSET               0xC000\r
-#define FILE_OPTION_OFFSET                    0x8000\r
-#define FILE_OPTION_MASK                      0x3FFF\r
-\r
 #define SECURE_BOOT_GUID_SIZE                 36\r
 #define SECURE_BOOT_GUID_STORAGE_SIZE         37\r
 \r