]> git.proxmox.com Git - mirror_edk2.git/commitdiff
NetworkPkg: Add URI configuration form to HTTP boot driver.
authorFu Siyuan <siyuan.fu@intel.com>
Mon, 15 Feb 2016 05:55:11 +0000 (13:55 +0800)
committerFu Siyuan <siyuan.fu@intel.com>
Mon, 7 Mar 2016 01:12:14 +0000 (09:12 +0800)
This patch updates the HTTP boot driver to produce a setup page for the boot
file URI configuration. A new boot option will be created for the manual
configured URI address. This change is made to support the HTTP boot usage
in home environment.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Fu Siyuan <siyuan.fu@intel.com>
Reviewed-by: Wu Jiaxin <jiaxin.wu@intel.com>
Reviewed-by: Ye Ting <ting.ye@intel.com>
17 files changed:
NetworkPkg/HttpBootDxe/HttpBootClient.c
NetworkPkg/HttpBootDxe/HttpBootConfig.c [new file with mode: 0644]
NetworkPkg/HttpBootDxe/HttpBootConfig.h [new file with mode: 0644]
NetworkPkg/HttpBootDxe/HttpBootConfigNVDataStruc.h [new file with mode: 0644]
NetworkPkg/HttpBootDxe/HttpBootConfigStrings.uni [new file with mode: 0644]
NetworkPkg/HttpBootDxe/HttpBootConfigVfr.vfr [new file with mode: 0644]
NetworkPkg/HttpBootDxe/HttpBootDhcp4.c
NetworkPkg/HttpBootDxe/HttpBootDhcp4.h
NetworkPkg/HttpBootDxe/HttpBootDhcp6.c
NetworkPkg/HttpBootDxe/HttpBootDxe.c
NetworkPkg/HttpBootDxe/HttpBootDxe.h
NetworkPkg/HttpBootDxe/HttpBootDxe.inf
NetworkPkg/HttpBootDxe/HttpBootImpl.c
NetworkPkg/HttpBootDxe/HttpBootSupport.c
NetworkPkg/HttpBootDxe/HttpBootSupport.h
NetworkPkg/Include/Guid/HttpBootConfigHii.h [new file with mode: 0644]
NetworkPkg/NetworkPkg.dec

index 2ccac8c842073e16c2697ce6dcf3759370e8e554..aae452729c8ebd4e0c27b7d3bbdc342221158817 100644 (file)
@@ -168,18 +168,35 @@ HttpBootDhcp4ExtractUriInfo (
   // HttpOffer contains the boot file URL.\r
   //\r
   SelectOffer = &Private->OfferBuffer[SelectIndex].Dhcp4;\r
-  if ((SelectOffer->OfferType == HttpOfferTypeDhcpIpUri) || (SelectOffer->OfferType == HttpOfferTypeDhcpNameUriDns)) {\r
-    HttpOffer = SelectOffer;\r
+  if (Private->FilePathUri == NULL) {\r
+    //\r
+    // In Corporate environment, we need a HttpOffer.\r
+    //\r
+    if ((SelectOffer->OfferType == HttpOfferTypeDhcpIpUri) || \r
+        (SelectOffer->OfferType == HttpOfferTypeDhcpIpUriDns) ||\r
+        (SelectOffer->OfferType == HttpOfferTypeDhcpNameUriDns)) {\r
+      HttpOffer = SelectOffer;\r
+    } else {\r
+      ASSERT (Private->SelectProxyType != HttpOfferTypeMax);\r
+      ProxyIndex = Private->OfferIndex[Private->SelectProxyType][0];\r
+      HttpOffer = &Private->OfferBuffer[ProxyIndex].Dhcp4;\r
+    }\r
+    Private->BootFileUriParser = HttpOffer->UriParser;\r
+    Private->BootFileUri = (CHAR8*) HttpOffer->OptList[HTTP_BOOT_DHCP4_TAG_INDEX_BOOTFILE]->Data;\r
   } else {\r
-    ASSERT (Private->SelectProxyType != HttpOfferTypeMax);\r
-    ProxyIndex = Private->OfferIndex[Private->SelectProxyType][0];\r
-    HttpOffer = &Private->OfferBuffer[ProxyIndex].Dhcp4;\r
+    //\r
+    // In Home environment the BootFileUri comes from the FilePath.\r
+    //\r
+    Private->BootFileUriParser = Private->FilePathUriParser;\r
+    Private->BootFileUri = Private->FilePathUri;\r
   }\r
 \r
   //\r
   // Configure the default DNS server if server assigned.\r
   //\r
-  if ((SelectOffer->OfferType == HttpOfferTypeDhcpNameUriDns) || (SelectOffer->OfferType == HttpOfferTypeDhcpDns)) {\r
+  if ((SelectOffer->OfferType == HttpOfferTypeDhcpNameUriDns) || \r
+      (SelectOffer->OfferType == HttpOfferTypeDhcpDns) ||\r
+      (SelectOffer->OfferType == HttpOfferTypeDhcpIpUriDns)) {\r
     Option = SelectOffer->OptList[HTTP_BOOT_DHCP4_TAG_INDEX_DNS_SERVER];\r
     ASSERT (Option != NULL);\r
     Status = HttpBootRegisterIp4Dns (\r
@@ -196,21 +213,14 @@ HttpBootDhcp4ExtractUriInfo (
   // Extract the port from URL, and use default HTTP port 80 if not provided.\r
   //\r
   Status = HttpUrlGetPort (\r
-             (CHAR8*) HttpOffer->OptList[HTTP_BOOT_DHCP4_TAG_INDEX_BOOTFILE]->Data,\r
-             HttpOffer->UriParser,\r
+             Private->BootFileUri,\r
+             Private->BootFileUriParser,\r
              &Private->Port\r
              );\r
   if (EFI_ERROR (Status) || Private->Port == 0) {\r
     Private->Port = 80;\r
   }\r
   \r
-  //\r
-  // Record the URI of boot file from the selected HTTP offer.\r
-  //\r
-  Private->BootFileUriParser = HttpOffer->UriParser;\r
-  Private->BootFileUri = (CHAR8*) HttpOffer->OptList[HTTP_BOOT_DHCP4_TAG_INDEX_BOOTFILE]->Data;\r
-\r
-  \r
   //\r
   // All boot informations are valid here.\r
   //\r
@@ -260,12 +270,27 @@ HttpBootDhcp6ExtractUriInfo (
   // HttpOffer contains the boot file URL.\r
   //\r
   SelectOffer = &Private->OfferBuffer[SelectIndex].Dhcp6;\r
-  if ((SelectOffer->OfferType == HttpOfferTypeDhcpIpUri) || (SelectOffer->OfferType == HttpOfferTypeDhcpNameUriDns)) {\r
-    HttpOffer = SelectOffer;\r
+  if (Private->FilePathUri == NULL) {\r
+    //\r
+    // In Corporate environment, we need a HttpOffer.\r
+    //\r
+    if ((SelectOffer->OfferType == HttpOfferTypeDhcpIpUri) ||\r
+        (SelectOffer->OfferType == HttpOfferTypeDhcpIpUriDns) ||\r
+        (SelectOffer->OfferType == HttpOfferTypeDhcpNameUriDns)) {\r
+      HttpOffer = SelectOffer;\r
+    } else {\r
+      ASSERT (Private->SelectProxyType != HttpOfferTypeMax);\r
+      ProxyIndex = Private->OfferIndex[Private->SelectProxyType][0];\r
+      HttpOffer = &Private->OfferBuffer[ProxyIndex].Dhcp6;\r
+    }\r
+    Private->BootFileUriParser = HttpOffer->UriParser;\r
+    Private->BootFileUri = (CHAR8*) HttpOffer->OptList[HTTP_BOOT_DHCP6_IDX_BOOT_FILE_URL]->Data;\r
   } else {\r
-    ASSERT (Private->SelectProxyType != HttpOfferTypeMax);\r
-    ProxyIndex = Private->OfferIndex[Private->SelectProxyType][0];\r
-    HttpOffer = &Private->OfferBuffer[ProxyIndex].Dhcp6;\r
+    //\r
+    // In Home environment the BootFileUri comes from the FilePath.\r
+    //\r
+    Private->BootFileUriParser = Private->FilePathUriParser;\r
+    Private->BootFileUri = Private->FilePathUri;\r
   }\r
 \r
   //\r
@@ -279,7 +304,9 @@ HttpBootDhcp6ExtractUriInfo (
   //\r
   // Configure the default DNS server if server assigned.\r
   //\r
-  if ((SelectOffer->OfferType == HttpOfferTypeDhcpNameUriDns) || (SelectOffer->OfferType == HttpOfferTypeDhcpDns)) {\r
+  if ((SelectOffer->OfferType == HttpOfferTypeDhcpNameUriDns) || \r
+      (SelectOffer->OfferType == HttpOfferTypeDhcpDns) ||\r
+      (SelectOffer->OfferType == HttpOfferTypeDhcpIpUriDns)) {\r
     Option = SelectOffer->OptList[HTTP_BOOT_DHCP6_IDX_DNS_SERVER];\r
     ASSERT (Option != NULL);\r
     Status = HttpBootSetIp6Dns (\r
@@ -297,8 +324,8 @@ HttpBootDhcp6ExtractUriInfo (
   // whether can send message to HTTP Server Ip through the GateWay.\r
   //\r
   Status = HttpUrlGetIp6 (\r
-             (CHAR8*) HttpOffer->OptList[HTTP_BOOT_DHCP6_IDX_BOOT_FILE_URL]->Data,\r
-             HttpOffer->UriParser,\r
+             Private->BootFileUri,\r
+             Private->BootFileUriParser,\r
              &IpAddr\r
              );\r
   \r
@@ -307,8 +334,8 @@ HttpBootDhcp6ExtractUriInfo (
     // The Http server address is expressed by Name Ip, so perform DNS resolution\r
     //\r
     Status = HttpUrlGetHostName (\r
-               (CHAR8*) HttpOffer->OptList[HTTP_BOOT_DHCP6_IDX_BOOT_FILE_URL]->Data,\r
-               HttpOffer->UriParser,\r
+               Private->BootFileUri,\r
+               Private->BootFileUriParser,\r
                &HostName\r
                );\r
     if (EFI_ERROR (Status)) {\r
@@ -343,21 +370,14 @@ HttpBootDhcp6ExtractUriInfo (
   // Extract the port from URL, and use default HTTP port 80 if not provided.\r
   //\r
   Status = HttpUrlGetPort (\r
-             (CHAR8*) HttpOffer->OptList[HTTP_BOOT_DHCP6_IDX_BOOT_FILE_URL]->Data,\r
-             HttpOffer->UriParser,\r
+             Private->BootFileUri,\r
+             Private->BootFileUriParser,\r
              &Private->Port\r
              );\r
   if (EFI_ERROR (Status) || Private->Port == 0) {\r
     Private->Port = 80;\r
   }\r
   \r
-  //\r
-  // Record the URI of boot file from the selected HTTP offer.\r
-  //\r
-  Private->BootFileUriParser = HttpOffer->UriParser;\r
-  Private->BootFileUri = (CHAR8*) HttpOffer->OptList[HTTP_BOOT_DHCP6_IDX_BOOT_FILE_URL]->Data;\r
-\r
-  \r
   //\r
   // All boot informations are valid here.\r
   //\r
@@ -570,10 +590,6 @@ HttpBootGetFileFromCache (
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
-  //\r
-  // Search file in the cache list, the cache entry will be released upon a successful\r
-  // match.\r
-  //\r
   NET_LIST_FOR_EACH (Entry, &Private->CacheList) {\r
     Cache = NET_LIST_USER_STRUCT (Entry, HTTP_BOOT_CACHE_CONTENT, Link);\r
     //\r
@@ -607,12 +623,6 @@ HttpBootGetFileFromCache (
         }\r
       }\r
       *BufferSize = CopyedSize;\r
-\r
-      //\r
-      // On success, free the cached data to release the memory resource.\r
-      //\r
-      RemoveEntryList (&Cache->Link);\r
-      HttpBootFreeCache (Cache);\r
       return EFI_SUCCESS;\r
     }\r
   }\r
@@ -1083,3 +1093,4 @@ ERROR_1:
 \r
   return Status;\r
 }\r
+\r
diff --git a/NetworkPkg/HttpBootDxe/HttpBootConfig.c b/NetworkPkg/HttpBootDxe/HttpBootConfig.c
new file mode 100644 (file)
index 0000000..db14da0
--- /dev/null
@@ -0,0 +1,723 @@
+/** @file\r
+  Helper functions for configuring or getting the parameters relating to HTTP Boot.\r
+\r
+Copyright (c) 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
+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
+\r
+**/\r
+\r
+#include "HttpBootDxe.h"\r
+\r
+CHAR16  mHttpBootConfigStorageName[]     = L"HTTP_BOOT_CONFIG_IFR_NVDATA";\r
+\r
+/**\r
+  Add new boot option for HTTP boot.\r
+\r
+  @param[in]  Private             Pointer to the driver private data.\r
+  @param[in]  UsingIpv6           Set to TRUE if creating boot option for IPv6.\r
+  @param[in]  Description         The description text of the boot option.\r
+  @param[in]  Uri                 The URI string of the boot file.\r
+  \r
+  @retval EFI_SUCCESS             The boot option is created successfully.\r
+  @retval Others                  Failed to create new boot option.\r
+\r
+**/\r
+EFI_STATUS\r
+HttpBootAddBootOption (\r
+  IN   HTTP_BOOT_PRIVATE_DATA   *Private,\r
+  IN   BOOLEAN                  UsingIpv6,\r
+  IN   CHAR16                   *Description,\r
+  IN   CHAR16                   *Uri\r
+  )\r
+{\r
+  EFI_DEV_PATH               *Node;\r
+  EFI_DEVICE_PATH_PROTOCOL   *TmpDevicePath;\r
+  EFI_DEVICE_PATH_PROTOCOL   *NewDevicePath;\r
+  UINTN                      Length;\r
+  CHAR8                      AsciiUri[URI_STR_MAX_SIZE];\r
+  CHAR16                     *CurrentOrder;\r
+  EFI_STATUS                 Status;\r
+  UINTN                      OrderCount;\r
+  UINTN                      TargetLocation;\r
+  BOOLEAN                    Found;\r
+  UINT8                      *TempByteBuffer;\r
+  UINT8                      *TempByteStart;\r
+  UINTN                      DescSize;\r
+  UINTN                      FilePathSize;\r
+  CHAR16                     OptionStr[10];\r
+  UINT16                     *NewOrder;\r
+  UINTN                      Index;\r
+\r
+  NewOrder      = NULL;\r
+  TempByteStart = NULL;\r
+  NewDevicePath = NULL;\r
+  NewOrder      = NULL;\r
+  Node          = NULL;\r
+  TmpDevicePath = NULL;\r
+  CurrentOrder  = NULL;\r
+\r
+  if (StrLen (Description) == 0) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  //\r
+  // Convert the scheme to all lower case.\r
+  //\r
+  for (Index = 0; Index < StrLen (Uri); Index++) {\r
+    if (Uri[Index] == L':') {\r
+      break;\r
+    }\r
+    if (Uri[Index] >= L'A' && Uri[Index] <= L'Z') {\r
+      Uri[Index] -= (CHAR16)(L'A' - L'a');\r
+    }\r
+  }\r
+\r
+  //\r
+  // Only accept http and https URI.\r
+  //\r
+  if ((StrnCmp (Uri, L"http://", 7) != 0) && (StrnCmp (Uri, L"https://", 7) != 0)) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+  \r
+  //\r
+  // Create a new device path by appending the IP node and URI node to\r
+  // the driver's parent device path\r
+  //\r
+  if (!UsingIpv6) {\r
+    Node = AllocateZeroPool (sizeof (IPv4_DEVICE_PATH));\r
+    if (Node == NULL) {\r
+      Status = EFI_OUT_OF_RESOURCES;\r
+      goto ON_EXIT;\r
+    }\r
+    Node->Ipv4.Header.Type    = MESSAGING_DEVICE_PATH;\r
+    Node->Ipv4.Header.SubType = MSG_IPv4_DP;\r
+    SetDevicePathNodeLength (Node, sizeof (IPv4_DEVICE_PATH));\r
+  } else {\r
+    Node = AllocateZeroPool (sizeof (IPv6_DEVICE_PATH));\r
+    if (Node == NULL) {\r
+      Status = EFI_OUT_OF_RESOURCES;\r
+      goto ON_EXIT;\r
+    }\r
+    Node->Ipv6.Header.Type     = MESSAGING_DEVICE_PATH;\r
+    Node->Ipv6.Header.SubType  = MSG_IPv6_DP;\r
+    SetDevicePathNodeLength (Node, sizeof (IPv6_DEVICE_PATH));\r
+  }\r
+  TmpDevicePath = AppendDevicePathNode (Private->ParentDevicePath, (EFI_DEVICE_PATH_PROTOCOL*) Node);\r
+  FreePool (Node);\r
+  if (TmpDevicePath == NULL) {\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
+  //\r
+  // Update the URI node with the input boot file URI.\r
+  //\r
+  UnicodeStrToAsciiStr (Uri, AsciiUri);\r
+  Length = sizeof (EFI_DEVICE_PATH_PROTOCOL) + AsciiStrSize (AsciiUri);\r
+  Node = AllocatePool (Length);\r
+  if (Node == NULL) {\r
+    Status = EFI_OUT_OF_RESOURCES;\r
+    FreePool (TmpDevicePath);\r
+    goto ON_EXIT;\r
+  }\r
+  Node->DevPath.Type    = MESSAGING_DEVICE_PATH;\r
+  Node->DevPath.SubType = MSG_URI_DP;\r
+  SetDevicePathNodeLength (Node, Length);\r
+  CopyMem ((UINT8*) Node + sizeof (EFI_DEVICE_PATH_PROTOCOL), AsciiUri, AsciiStrSize (AsciiUri));\r
+  NewDevicePath = AppendDevicePathNode (TmpDevicePath, (EFI_DEVICE_PATH_PROTOCOL*) Node);\r
+  FreePool (Node);\r
+  FreePool (TmpDevicePath);\r
+  if (NewDevicePath == NULL) {\r
+    Status = EFI_OUT_OF_RESOURCES;\r
+    goto ON_EXIT;\r
+  }\r
+\r
+  //\r
+  // Get current "BootOrder" variable and find a free target.\r
+  //\r
+  Length = 0;\r
+  Status = GetVariable2 (\r
+             L"BootOrder",\r
+             &gEfiGlobalVariableGuid,\r
+             &CurrentOrder,\r
+             &Length \r
+             );\r
+  if (EFI_ERROR (Status) && Status != EFI_NOT_FOUND) {\r
+    goto ON_EXIT;\r
+  }\r
+  OrderCount = Length / sizeof (UINT16);\r
+  Found = FALSE;\r
+  for (TargetLocation=0; TargetLocation < 0xFFFF; TargetLocation++) {\r
+    Found = TRUE;\r
+    for (Index = 0; Index < OrderCount; Index++) {\r
+      if (CurrentOrder[Index] == TargetLocation) {\r
+        Found = FALSE;\r
+        break;\r
+      }\r
+    }\r
+    if (Found) {\r
+      break;\r
+    }\r
+  }\r
+\r
+  if (TargetLocation == 0xFFFF) {\r
+    DEBUG ((EFI_D_ERROR, "Could not find unused target index.\n"));\r
+    Status = EFI_OUT_OF_RESOURCES;\r
+    goto ON_EXIT;\r
+  } else {\r
+    DEBUG ((EFI_D_INFO, "TargetIndex = %04x.\n", TargetLocation));\r
+  }\r
+  \r
+  //\r
+  // Construct and set the "Boot####" variable\r
+  //\r
+  DescSize = StrSize(Description);\r
+  FilePathSize = GetDevicePathSize (NewDevicePath);\r
+  TempByteBuffer = AllocateZeroPool(sizeof(EFI_LOAD_OPTION) + DescSize + FilePathSize);\r
+  if (TempByteBuffer == NULL) {\r
+    Status = EFI_OUT_OF_RESOURCES;\r
+    goto ON_EXIT;\r
+  }\r
+\r
+  TempByteStart = TempByteBuffer;\r
+  *((UINT32 *) TempByteBuffer) = LOAD_OPTION_ACTIVE;      // Attributes\r
+  TempByteBuffer += sizeof (UINT32);\r
+\r
+  *((UINT16 *) TempByteBuffer) = (UINT16)FilePathSize;    // FilePathListLength\r
+  TempByteBuffer += sizeof (UINT16);\r
+\r
+  CopyMem (TempByteBuffer, Description, DescSize);\r
+  TempByteBuffer += DescSize;\r
+  CopyMem (TempByteBuffer, NewDevicePath, FilePathSize);\r
+\r
+  UnicodeSPrint (OptionStr, sizeof(OptionStr), L"%s%04x", L"Boot", TargetLocation);\r
+  Status = gRT->SetVariable (\r
+                  OptionStr,\r
+                  &gEfiGlobalVariableGuid,\r
+                  EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r
+                  sizeof(UINT32) + sizeof(UINT16) + DescSize + FilePathSize,\r
+                  TempByteStart\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    goto ON_EXIT;\r
+  }\r
+\r
+  //\r
+  // Insert into the order list and set "BootOrder" variable\r
+  //\r
+  NewOrder = AllocateZeroPool ((OrderCount + 1) * sizeof (UINT16));\r
+  if (NewOrder == NULL) {\r
+    Status = EFI_OUT_OF_RESOURCES;\r
+    goto ON_EXIT;\r
+  }\r
+  CopyMem(NewOrder, CurrentOrder, OrderCount * sizeof(UINT16));\r
+  NewOrder[OrderCount] = (UINT16) TargetLocation;\r
+  Status = gRT->SetVariable (\r
+                  L"BootOrder",\r
+                  &gEfiGlobalVariableGuid,\r
+                  EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r
+                  ((OrderCount + 1) * sizeof (UINT16)),\r
+                  NewOrder\r
+                  );\r
+  \r
+\r
+ON_EXIT:\r
+\r
+  if (CurrentOrder != NULL) {\r
+    FreePool (CurrentOrder);\r
+  }\r
+  if (NewOrder != NULL) {\r
+    FreePool (NewOrder);\r
+  }\r
+  if (TempByteStart != NULL) {\r
+    FreePool (TempByteStart);\r
+  }\r
+  if (NewDevicePath != NULL) {\r
+    FreePool (NewDevicePath);\r
+  }\r
+\r
+  return Status;\r
+}\r
+\r
+/**\r
+   \r
+  This function allows the caller to request the current\r
+  configuration for one or more named elements. The resulting\r
+  string is in <ConfigAltResp> format. Also, any and all alternative\r
+  configuration strings shall be appended to the end of the\r
+  current configuration string. If they are, they must appear\r
+  after the current configuration. They must contain the same\r
+  routing (GUID, NAME, PATH) as the current configuration string.\r
+  They must have an additional description indicating the type of\r
+  alternative configuration the string represents,\r
+  "ALTCFG=<StringToken>". That <StringToken> (when\r
+  converted from Hex UNICODE to binary) is a reference to a\r
+  string in the associated string pack.\r
+\r
+  @param[in]  This       Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.\r
+\r
+  @param[in]  Request    A null-terminated Unicode string in\r
+                         <ConfigRequest> format. Note that this\r
+                         includes the routing information as well as\r
+                         the configurable name / value pairs. It is\r
+                         invalid for this string to be in\r
+                         <MultiConfigRequest> format.\r
+\r
+  @param[out] Progress   On return, points to a character in the\r
+                         Request string. Points to the string's null\r
+                         terminator if request was successful. Points\r
+                         to the most recent "&" before the first\r
+                         failing name / value pair (or the beginning\r
+                         of the string if the failure is in the first\r
+                         name / value pair) if the request was not successful.                        \r
+\r
+  @param[out] Results    A null-terminated Unicode string in\r
+                         <ConfigAltResp> format which has all values\r
+                         filled in for the names in the Request string.\r
+                         String to be allocated by the called function.\r
+\r
+  @retval EFI_SUCCESS             The Results string is filled with the\r
+                                  values corresponding to all requested\r
+                                  names.\r
+\r
+  @retval EFI_OUT_OF_RESOURCES    Not enough memory to store the\r
+                                  parts of the results that must be\r
+                                  stored awaiting possible future\r
+                                  protocols.\r
+\r
+  @retval EFI_INVALID_PARAMETER   For example, passing in a NULL\r
+                                  for the Request parameter\r
+                                  would result in this type of\r
+                                  error. In this case, the\r
+                                  Progress parameter would be\r
+                                  set to NULL. \r
+\r
+  @retval EFI_NOT_FOUND           Routing data doesn't match any\r
+                                  known driver. Progress set to the\r
+                                  first character in the routing header.\r
+                                  Note: There is no requirement that the\r
+                                  driver validate the routing data. It\r
+                                  must skip the <ConfigHdr> in order to\r
+                                  process the names.\r
+\r
+  @retval EFI_INVALID_PARAMETER   Illegal syntax. Progress set\r
+                                  to most recent "&" before the\r
+                                  error or the beginning of the\r
+                                  string.\r
+\r
+  @retval EFI_INVALID_PARAMETER   Unknown name. Progress points\r
+                                  to the & before the name in\r
+                                  question.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+HttpBootFormExtractConfig (\r
+  IN  CONST EFI_HII_CONFIG_ACCESS_PROTOCOL   *This,\r
+  IN  CONST EFI_STRING                       Request,\r
+  OUT EFI_STRING                             *Progress,\r
+  OUT EFI_STRING                             *Results\r
+  )\r
+{\r
+  EFI_STATUS                       Status;\r
+  UINTN                            BufferSize;\r
+  HTTP_BOOT_FORM_CALLBACK_INFO     *CallbackInfo;\r
+  EFI_STRING                       ConfigRequestHdr;\r
+  EFI_STRING                       ConfigRequest;\r
+  BOOLEAN                          AllocatedRequest;\r
+  UINTN                            Size;\r
+\r
+  if (Progress == NULL || Results == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  *Progress = Request;\r
+  if ((Request != NULL) && !HiiIsConfigHdrMatch (Request, &gHttpBootConfigGuid, mHttpBootConfigStorageName)) {\r
+    return EFI_NOT_FOUND;\r
+  }\r
+  \r
+  ConfigRequestHdr = NULL;\r
+  ConfigRequest    = NULL;\r
+  AllocatedRequest = FALSE;\r
+  Size             = 0;\r
+\r
+  CallbackInfo = HTTP_BOOT_FORM_CALLBACK_INFO_FROM_CONFIG_ACCESS (This);\r
+  //\r
+  // Convert buffer data to <ConfigResp> by helper function BlockToConfig()\r
+  //\r
+  BufferSize = sizeof (HTTP_BOOT_CONFIG_IFR_NVDATA);\r
+  ZeroMem (&CallbackInfo->HttpBootNvData, BufferSize);\r
+\r
+  ConfigRequest = Request;\r
+  if ((Request == NULL) || (StrStr (Request, L"OFFSET") == NULL)) {\r
+    //\r
+    // Request has no request element, construct full request string.\r
+    // Allocate and fill a buffer large enough to hold the <ConfigHdr> template\r
+    // followed by "&OFFSET=0&WIDTH=WWWWWWWWWWWWWWWW" followed by a Null-terminator\r
+    //\r
+    ConfigRequestHdr = HiiConstructConfigHdr (&gHttpBootConfigGuid, mHttpBootConfigStorageName, CallbackInfo->ChildHandle);\r
+    Size = (StrLen (ConfigRequestHdr) + 32 + 1) * sizeof (CHAR16);\r
+    ConfigRequest = AllocateZeroPool (Size);\r
+    ASSERT (ConfigRequest != NULL);\r
+    AllocatedRequest = TRUE;\r
+    UnicodeSPrint (ConfigRequest, Size, L"%s&OFFSET=0&WIDTH=%016LX", ConfigRequestHdr, (UINT64)BufferSize);\r
+    FreePool (ConfigRequestHdr);\r
+  }\r
+\r
+  Status = gHiiConfigRouting->BlockToConfig (\r
+                                gHiiConfigRouting,\r
+                                ConfigRequest,\r
+                                (UINT8 *) &CallbackInfo->HttpBootNvData,\r
+                                BufferSize,\r
+                                Results,\r
+                                Progress\r
+                                );\r
+  ASSERT_EFI_ERROR (Status);\r
+  \r
+  //\r
+  // Free the allocated config request string.\r
+  //\r
+  if (AllocatedRequest) {\r
+    FreePool (ConfigRequest);\r
+    ConfigRequest = NULL;\r
+  }\r
+  //\r
+  // Set Progress string to the original request string.\r
+  //\r
+  if (Request == NULL) {\r
+    *Progress = NULL;\r
+  } else if (StrStr (Request, L"OFFSET") == NULL) {\r
+    *Progress = Request + StrLen (Request);\r
+  }\r
+\r
+  return Status;\r
+}\r
+\r
+/**\r
+   \r
+  This function applies changes in a driver's configuration.\r
+  Input is a Configuration, which has the routing data for this\r
+  driver followed by name / value configuration pairs. The driver\r
+  must apply those pairs to its configurable storage. If the\r
+  driver's configuration is stored in a linear block of data\r
+  and the driver's name / value pairs are in <BlockConfig>\r
+  format, it may use the ConfigToBlock helper function (above) to\r
+  simplify the job.\r
+\r
+  @param[in]  This           Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.\r
+\r
+  @param[in]  Configuration  A null-terminated Unicode string in\r
+                             <ConfigString> format. \r
+  \r
+  @param[out] Progress       A pointer to a string filled in with the\r
+                             offset of the most recent '&' before the\r
+                             first failing name / value pair (or the\r
+                             beginning of the string if the failure\r
+                             is in the first name / value pair) or\r
+                             the terminating NULL if all was\r
+                             successful.\r
+\r
+  @retval EFI_SUCCESS             The results have been distributed or are\r
+                                  awaiting distribution.\r
+  \r
+  @retval EFI_OUT_OF_RESOURCES    Not enough memory to store the\r
+                                  parts of the results that must be\r
+                                  stored awaiting possible future\r
+                                  protocols.\r
+  \r
+  @retval EFI_INVALID_PARAMETERS  Passing in a NULL for the\r
+                                  Results parameter would result\r
+                                  in this type of error.\r
+  \r
+  @retval EFI_NOT_FOUND           Target for the specified routing data\r
+                                  was not found.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+HttpBootFormRouteConfig (\r
+  IN  CONST EFI_HII_CONFIG_ACCESS_PROTOCOL   *This,\r
+  IN  CONST EFI_STRING                       Configuration,\r
+  OUT EFI_STRING                             *Progress\r
+  )\r
+{\r
+  EFI_STATUS                       Status;\r
+  UINTN                            BufferSize;\r
+  HTTP_BOOT_FORM_CALLBACK_INFO     *CallbackInfo;\r
+  HTTP_BOOT_PRIVATE_DATA           *Private;\r
+\r
+  if (Progress == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+  *Progress = Configuration;\r
+\r
+  if (Configuration == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  //\r
+  // Check routing data in <ConfigHdr>.\r
+  // Note: there is no name for Name/Value storage, only GUID will be checked\r
+  //\r
+  if (!HiiIsConfigHdrMatch (Configuration, &gHttpBootConfigGuid, mHttpBootConfigStorageName)) {\r
+    return EFI_NOT_FOUND;\r
+  }\r
+\r
+  CallbackInfo = HTTP_BOOT_FORM_CALLBACK_INFO_FROM_CONFIG_ACCESS (This);\r
+  Private      = HTTP_BOOT_PRIVATE_DATA_FROM_CALLBACK_INFO (CallbackInfo);\r
+  \r
+  BufferSize = sizeof (HTTP_BOOT_CONFIG_IFR_NVDATA);\r
+  ZeroMem (&CallbackInfo->HttpBootNvData, BufferSize);\r
+\r
+  Status = gHiiConfigRouting->ConfigToBlock (\r
+                            gHiiConfigRouting,\r
+                            Configuration,\r
+                            (UINT8 *) &CallbackInfo->HttpBootNvData,\r
+                            &BufferSize,\r
+                            Progress\r
+                            );\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  //\r
+  // Create a new boot option according to the configuration data.\r
+  //\r
+  Status = HttpBootAddBootOption (\r
+             Private,\r
+             (CallbackInfo->HttpBootNvData.IpVersion == HTTP_BOOT_IP_VERSION_6) ? TRUE : FALSE,\r
+             CallbackInfo->HttpBootNvData.Description,\r
+             CallbackInfo->HttpBootNvData.Uri\r
+             );\r
+  \r
+  return Status;\r
+}\r
+\r
+/**\r
+   \r
+  This function is called to provide results data to the driver.\r
+  This data consists of a unique key that is used to identify\r
+  which data is either being passed back or being asked for.\r
+\r
+  @param[in]       This          Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.\r
+  @param[in]       Action        Specifies the type of action taken by the browser.\r
+  @param[in]       QuestionId    A unique value which is sent to the original\r
+                                 exporting driver so that it can identify the type\r
+                                 of data to expect. The format of the data tends to \r
+                                 vary based on the opcode that generated the callback.\r
+  @param[in]       Type          The type of value for the question.\r
+  @param[in, out]  Value         A pointer to the data being sent to the original\r
+                                 exporting driver.\r
+  @param[out]      ActionRequest On return, points to the action requested by the\r
+                                 callback function.\r
+\r
+  @retval EFI_SUCCESS            The callback successfully handled the action.\r
+  @retval EFI_OUT_OF_RESOURCES   Not enough storage is available to hold the\r
+                                 variable and its data.\r
+  @retval EFI_DEVICE_ERROR       The variable could not be saved.\r
+  @retval EFI_UNSUPPORTED        The specified Action is not supported by the\r
+                                 callback.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+HttpBootFormCallback (\r
+  IN CONST  EFI_HII_CONFIG_ACCESS_PROTOCOL   *This,\r
+  IN        EFI_BROWSER_ACTION               Action,\r
+  IN        EFI_QUESTION_ID                  QuestionId,\r
+  IN        UINT8                            Type,\r
+  IN OUT    EFI_IFR_TYPE_VALUE               *Value,\r
+  OUT       EFI_BROWSER_ACTION_REQUEST       *ActionRequest\r
+  )\r
+{\r
+  return EFI_UNSUPPORTED;\r
+}\r
+\r
+/**\r
+  Initialize the configuration form.\r
+\r
+  @param[in]  Private             Pointer to the driver private data.\r
+\r
+  @retval EFI_SUCCESS             The configuration form is initialized.\r
+  @retval EFI_OUT_OF_RESOURCES    Failed to allocate memory.\r
+\r
+**/\r
+EFI_STATUS\r
+HttpBootConfigFormInit (\r
+  IN HTTP_BOOT_PRIVATE_DATA     *Private\r
+  )\r
+{\r
+  EFI_STATUS                        Status;\r
+  HTTP_BOOT_FORM_CALLBACK_INFO      *CallbackInfo;\r
+  VENDOR_DEVICE_PATH                VendorDeviceNode;\r
+  EFI_SERVICE_BINDING_PROTOCOL      *HttpSb;\r
+  CHAR16                            *MacString;\r
+  CHAR16                            *OldMenuString;\r
+  CHAR16                            MenuString[128];\r
+\r
+  CallbackInfo = &Private->CallbackInfo;\r
+\r
+  if (CallbackInfo->Initilized) {\r
+    return EFI_SUCCESS;\r
+  }\r
+  \r
+  CallbackInfo->Signature = HTTP_BOOT_FORM_CALLBACK_INFO_SIGNATURE;\r
+\r
+  //\r
+  // Construct device path node for EFI HII Config Access protocol,\r
+  // which consists of controller physical device path and one hardware\r
+  // vendor guid node.\r
+  //\r
+  ZeroMem (&VendorDeviceNode, sizeof (VENDOR_DEVICE_PATH));\r
+  VendorDeviceNode.Header.Type    = HARDWARE_DEVICE_PATH;\r
+  VendorDeviceNode.Header.SubType = HW_VENDOR_DP;\r
+  CopyGuid (&VendorDeviceNode.Guid, &gEfiCallerIdGuid);\r
+  SetDevicePathNodeLength (&VendorDeviceNode.Header, sizeof (VENDOR_DEVICE_PATH));\r
+  CallbackInfo->HiiVendorDevicePath = AppendDevicePathNode (\r
+                                        Private->ParentDevicePath,\r
+                                        (EFI_DEVICE_PATH_PROTOCOL *) &VendorDeviceNode\r
+                                        );\r
+  if (CallbackInfo->HiiVendorDevicePath == NULL) {\r
+    Status = EFI_OUT_OF_RESOURCES;\r
+    goto Error;\r
+  }\r
+\r
+  CallbackInfo->ConfigAccess.ExtractConfig = HttpBootFormExtractConfig;\r
+  CallbackInfo->ConfigAccess.RouteConfig   = HttpBootFormRouteConfig;\r
+  CallbackInfo->ConfigAccess.Callback      = HttpBootFormCallback;\r
+  \r
+  //\r
+  // Install Device Path Protocol and Config Access protocol to driver handle.\r
+  //\r
+  Status = gBS->InstallMultipleProtocolInterfaces (\r
+                  &CallbackInfo->ChildHandle,\r
+                  &gEfiDevicePathProtocolGuid,\r
+                  CallbackInfo->HiiVendorDevicePath,\r
+                  &gEfiHiiConfigAccessProtocolGuid,\r
+                  &CallbackInfo->ConfigAccess,\r
+                  NULL\r
+                  );\r
+  if (!EFI_ERROR (Status)) {\r
+    //\r
+    // Open the Parent Handle for the child\r
+    //\r
+    Status = gBS->OpenProtocol (\r
+                    Private->Controller,\r
+                    &gEfiHttpServiceBindingProtocolGuid,\r
+                    (VOID **) &HttpSb,\r
+                    Private->Image,\r
+                    CallbackInfo->ChildHandle,\r
+                    EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER\r
+                    );\r
+  }\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    goto Error;\r
+  }\r
+\r
+  //\r
+  // Publish our HII data.\r
+  //\r
+  CallbackInfo->RegisteredHandle = HiiAddPackages (\r
+                                     &gHttpBootConfigGuid,\r
+                                     CallbackInfo->ChildHandle,\r
+                                     HttpBootDxeStrings,\r
+                                     HttpBootConfigVfrBin,\r
+                                     NULL\r
+                                     );\r
+  if (CallbackInfo->RegisteredHandle == NULL) {\r
+    Status = EFI_OUT_OF_RESOURCES;\r
+    goto Error;\r
+  }\r
+\r
+  //\r
+  // Append MAC string in the menu help string\r
+  //\r
+  Status = NetLibGetMacString (Private->Controller, Private->Image, &MacString);\r
+  if (!EFI_ERROR (Status)) {\r
+    OldMenuString = HiiGetString (\r
+                      CallbackInfo->RegisteredHandle, \r
+                      STRING_TOKEN (STR_HTTP_BOOT_CONFIG_FORM_HELP), \r
+                      NULL\r
+                      );\r
+    UnicodeSPrint (MenuString, 128, L"%s (MAC:%s)", OldMenuString, MacString);\r
+    HiiSetString (\r
+      CallbackInfo->RegisteredHandle, \r
+      STRING_TOKEN (STR_HTTP_BOOT_CONFIG_FORM_HELP), \r
+      MenuString, \r
+      NULL\r
+      );\r
+    \r
+    FreePool (MacString);\r
+    FreePool (OldMenuString);\r
+\r
+    return EFI_SUCCESS;\r
+  }\r
+  \r
+Error:\r
+\r
+  HttpBootConfigFormUnload (Private);\r
+  return Status;\r
+}\r
+\r
+/**\r
+  Unload the configuration form, this includes: delete all the configuration\r
+  entries, uninstall the form callback protocol, and free the resources used.\r
+\r
+  @param[in]  Private             Pointer to the driver private data.\r
+\r
+  @retval EFI_SUCCESS             The configuration form is unloaded.\r
+  @retval Others                  Failed to unload the form.\r
+\r
+**/\r
+EFI_STATUS\r
+HttpBootConfigFormUnload (\r
+  IN HTTP_BOOT_PRIVATE_DATA     *Private\r
+  )\r
+{\r
+  HTTP_BOOT_FORM_CALLBACK_INFO      *CallbackInfo;\r
+\r
+  CallbackInfo = &Private->CallbackInfo;\r
+  if (CallbackInfo->ChildHandle != NULL) {\r
+    //\r
+    // Close the child handle\r
+    //\r
+    gBS->CloseProtocol (\r
+           Private->Controller,\r
+           &gEfiHttpServiceBindingProtocolGuid,\r
+           Private->Image,\r
+           CallbackInfo->ChildHandle\r
+           );\r
+    \r
+    //\r
+    // Uninstall EFI_HII_CONFIG_ACCESS_PROTOCOL\r
+    //\r
+    gBS->UninstallMultipleProtocolInterfaces (\r
+           CallbackInfo->ChildHandle,\r
+           &gEfiDevicePathProtocolGuid,\r
+           CallbackInfo->HiiVendorDevicePath,\r
+           &gEfiHiiConfigAccessProtocolGuid,\r
+           &CallbackInfo->ConfigAccess,\r
+           NULL\r
+           );\r
+    CallbackInfo->ChildHandle = NULL;\r
+  }\r
+\r
+  if (CallbackInfo->HiiVendorDevicePath != NULL) {\r
+    FreePool (CallbackInfo->HiiVendorDevicePath);\r
+    CallbackInfo->HiiVendorDevicePath = NULL;\r
+  }\r
+\r
+  if (CallbackInfo->RegisteredHandle != NULL) {\r
+    //\r
+    // Remove HII package list\r
+    //\r
+    HiiRemovePackages (CallbackInfo->RegisteredHandle);\r
+    CallbackInfo->RegisteredHandle = NULL;\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
diff --git a/NetworkPkg/HttpBootDxe/HttpBootConfig.h b/NetworkPkg/HttpBootDxe/HttpBootConfig.h
new file mode 100644 (file)
index 0000000..a2afd18
--- /dev/null
@@ -0,0 +1,78 @@
+/** @file\r
+  The header file of functions for configuring or getting the parameters\r
+  relating to HTTP Boot.\r
+\r
+Copyright (c) 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
+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
+\r
+**/\r
+\r
+#ifndef _HTTP_BOOT_CONFIG_H_\r
+#define _HTTP_BOOT_CONFIG_H_\r
+\r
+\r
+#include "HttpBootConfigNVDataStruc.h"\r
+\r
+typedef struct _HTTP_BOOT_FORM_CALLBACK_INFO   HTTP_BOOT_FORM_CALLBACK_INFO;\r
+\r
+extern   UINT8                            HttpBootDxeStrings[];\r
+extern   UINT8                            HttpBootConfigVfrBin[];\r
+\r
+#pragma pack()\r
+\r
+#define HTTP_BOOT_FORM_CALLBACK_INFO_SIGNATURE  SIGNATURE_32 ('H', 'B', 'f', 'c')\r
+\r
+#define HTTP_BOOT_FORM_CALLBACK_INFO_FROM_CONFIG_ACCESS(Callback) \\r
+  CR ( \\r
+  Callback, \\r
+  HTTP_BOOT_FORM_CALLBACK_INFO, \\r
+  ConfigAccess, \\r
+  HTTP_BOOT_FORM_CALLBACK_INFO_SIGNATURE \\r
+  )\r
+\r
+struct _HTTP_BOOT_FORM_CALLBACK_INFO {\r
+  UINT32                           Signature;\r
+  BOOLEAN                          Initilized;\r
+  EFI_HANDLE                       ChildHandle;\r
+  EFI_DEVICE_PATH_PROTOCOL         *HiiVendorDevicePath;\r
+  EFI_HII_HANDLE                   RegisteredHandle;\r
+  EFI_HII_CONFIG_ACCESS_PROTOCOL   ConfigAccess;\r
+  HTTP_BOOT_CONFIG_IFR_NVDATA      HttpBootNvData;\r
+};\r
+\r
+/**\r
+  Initialize the configuration form.\r
+\r
+  @param[in]  Private             Pointer to the driver private data.\r
+\r
+  @retval EFI_SUCCESS             The configuration form is initialized.\r
+  @retval EFI_OUT_OF_RESOURCES    Failed to allocate memory.\r
+\r
+**/\r
+EFI_STATUS\r
+HttpBootConfigFormInit (\r
+  IN HTTP_BOOT_PRIVATE_DATA     *Private\r
+  );\r
+\r
+/**\r
+  Unload the configuration form, this includes: delete all the configuration\r
+  entries, uninstall the form callback protocol, and free the resources used.\r
+\r
+  @param[in]  Private             Pointer to the driver private data.\r
+\r
+  @retval EFI_SUCCESS             The configuration form is unloaded.\r
+  @retval Others                  Failed to unload the form.\r
+\r
+**/\r
+EFI_STATUS\r
+HttpBootConfigFormUnload (\r
+  IN HTTP_BOOT_PRIVATE_DATA     *Private\r
+  );\r
+\r
+#endif\r
diff --git a/NetworkPkg/HttpBootDxe/HttpBootConfigNVDataStruc.h b/NetworkPkg/HttpBootDxe/HttpBootConfigNVDataStruc.h
new file mode 100644 (file)
index 0000000..07043e7
--- /dev/null
@@ -0,0 +1,43 @@
+/** @file\r
+  Define NVData structures used by the HTTP Boot configuration component.\r
+\r
+Copyright (c) 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
+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
+\r
+**/\r
+\r
+#ifndef _HTTP_BOOT_NVDATA_STRUC_H_\r
+#define _HTTP_BOOT_NVDATA_STRUC_H_\r
+\r
+#include <Guid/HttpBootConfigHii.h>\r
+\r
+#define HTTP_BOOT_IP_VERSION_4         0\r
+#define HTTP_BOOT_IP_VERSION_6         1\r
+\r
+//\r
+// Macros used for an IPv4 or an IPv6 address.\r
+//\r
+#define URI_STR_MIN_SIZE           8\r
+#define URI_STR_MAX_SIZE           255\r
+\r
+#define CONFIGURATION_VARSTORE_ID    0x1234\r
+\r
+#define FORMID_MAIN_FORM    1\r
+\r
+#pragma pack(1)\r
+typedef struct _HTTP_BOOT_CONFIG_IFR_NVDATA {\r
+  UINT8     IpVersion;\r
+  UINT8     Padding;\r
+  CHAR16    Description[URI_STR_MAX_SIZE];\r
+  CHAR16    Uri[URI_STR_MAX_SIZE];\r
+} HTTP_BOOT_CONFIG_IFR_NVDATA;\r
+#pragma pack()\r
+\r
+\r
+#endif\r
diff --git a/NetworkPkg/HttpBootDxe/HttpBootConfigStrings.uni b/NetworkPkg/HttpBootDxe/HttpBootConfigStrings.uni
new file mode 100644 (file)
index 0000000..5001220
Binary files /dev/null and b/NetworkPkg/HttpBootDxe/HttpBootConfigStrings.uni differ
diff --git a/NetworkPkg/HttpBootDxe/HttpBootConfigVfr.vfr b/NetworkPkg/HttpBootDxe/HttpBootConfigVfr.vfr
new file mode 100644 (file)
index 0000000..e47c6af
--- /dev/null
@@ -0,0 +1,53 @@
+/** @file\r
+  VFR file used by the HTTP Boot configuration component.\r
+\r
+  Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>\r
+\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
+\r
+**/\r
+\r
+#include "HttpBootConfigNVDataStruc.h"\r
+\r
+\r
+formset\r
+  guid   = HTTP_BOOT_CONFIG_GUID,\r
+  title  = STRING_TOKEN(STR_HTTP_BOOT_CONFIG_FORM_TITLE),\r
+  help   = STRING_TOKEN(STR_HTTP_BOOT_CONFIG_FORM_HELP),\r
+\r
+  varstore HTTP_BOOT_CONFIG_IFR_NVDATA,\r
+    name = HTTP_BOOT_CONFIG_IFR_NVDATA,\r
+    guid = HTTP_BOOT_CONFIG_GUID;\r
+  \r
+  form formid = FORMID_MAIN_FORM,\r
+    title  = STRING_TOKEN(STR_HTTP_BOOT_CONFIG_FORM_TITLE);\r
+\r
+    string  varid   = HTTP_BOOT_CONFIG_IFR_NVDATA.Description,\r
+            prompt  = STRING_TOKEN(STR_BOOT_DESCRIPTION_PROMPT),\r
+            help    = STRING_TOKEN(STR_NULL_STRING),\r
+            minsize = 6,\r
+            maxsize = 75,\r
+    endstring;\r
+\r
+    oneof varid  = HTTP_BOOT_CONFIG_IFR_NVDATA.IpVersion,\r
+          prompt = STRING_TOKEN(STR_HTTP_BOOT_IP_VERSION_PROMPT),\r
+          help   = STRING_TOKEN(STR_HTTP_BOOT_IP_VERSION_HELP),\r
+          option text = STRING_TOKEN(STR_HTTP_BOOT_IP_VERSION_4),   value = HTTP_BOOT_IP_VERSION_4,   flags = DEFAULT;\r
+          option text = STRING_TOKEN(STR_HTTP_BOOT_IP_VERSION_6),   value = HTTP_BOOT_IP_VERSION_6,   flags = 0;\r
+    endoneof;\r
+\r
+    string  varid   = HTTP_BOOT_CONFIG_IFR_NVDATA.Uri,\r
+            prompt  = STRING_TOKEN(STR_BOOT_URI_PROMPT),\r
+            help    = STRING_TOKEN(STR_BOOT_URI_HELP),\r
+            minsize = URI_STR_MIN_SIZE,\r
+            maxsize = URI_STR_MAX_SIZE,\r
+    endstring;\r
+  endform;\r
+\r
+endformset;\r
index 9a947a6ea63ca1ac36aa671c8c47ee922e0da74f..b9c8084e11d792ee1fe43ac8ca83b34f6bfd0dc8 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Functions implementation related with DHCPv4 for HTTP boot driver.\r
 \r
-Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials are licensed and made available under \r
 the terms and conditions of the BSD License that accompanies this distribution.  \r
 The full text of the license may be found at\r
@@ -395,7 +395,11 @@ HttpBootParseDhcp4Packet (
   //\r
   if (IsHttpOffer) {\r
     if (IpExpressedUri) {\r
-      OfferType = IsProxyOffer ? HttpOfferTypeProxyIpUri : HttpOfferTypeDhcpIpUri;\r
+      if (IsProxyOffer) {\r
+        OfferType = HttpOfferTypeProxyIpUri;\r
+      } else {\r
+        OfferType = IsDnsOffer ? HttpOfferTypeDhcpIpUriDns : HttpOfferTypeDhcpIpUri;\r
+      }\r
     } else {\r
       if (!IsProxyOffer) {\r
         OfferType = IsDnsOffer ? HttpOfferTypeDhcpNameUriDns : HttpOfferTypeDhcpNameUri;\r
@@ -473,46 +477,81 @@ HttpBootSelectDhcpOffer (
 {\r
   Private->SelectIndex = 0;\r
   Private->SelectProxyType = HttpOfferTypeMax;\r
-  \r
-  //\r
-  // Priority1: HttpOfferTypeDhcpIpUri                           \r
-  // Priority2: HttpOfferTypeDhcpNameUriDns                      \r
-  // Priority3: HttpOfferTypeDhcpOnly + HttpOfferTypeProxyIpUri  \r
-  // Priority4: HttpOfferTypeDhcpDns  + HttpOfferTypeProxyIpUri  \r
-  // Priority5: HttpOfferTypeDhcpDns  + HttpOfferTypeProxyNameUri\r
-  // Priority6: HttpOfferTypeDhcpDns  + HttpOfferTypeDhcpNameUri \r
-  //    \r
-  if (Private->OfferCount[HttpOfferTypeDhcpIpUri] > 0) {\r
+\r
+  if (Private->FilePathUri != NULL) {\r
+    //\r
+    // We are in home environment, the URI is already specified.\r
+    // Just need to choose a DHCP offer.\r
+    // The offer with DNS server address takes priority here.\r
+    //\r
+    if (Private->OfferCount[HttpOfferTypeDhcpDns] > 0) {\r
+      \r
+      Private->SelectIndex = Private->OfferIndex[HttpOfferTypeDhcpDns][0] + 1;\r
+      \r
+    } else if (Private->OfferCount[HttpOfferTypeDhcpIpUriDns] > 0) {\r
     \r
-    Private->SelectIndex = Private->OfferIndex[HttpOfferTypeDhcpIpUri][0] + 1;\r
+      Private->SelectIndex = Private->OfferIndex[HttpOfferTypeDhcpIpUriDns][0] + 1;\r
+      \r
+    } else if (Private->OfferCount[HttpOfferTypeDhcpNameUriDns] > 0) {\r
     \r
-  } else if (Private->OfferCount[HttpOfferTypeDhcpNameUriDns] > 0) {\r
-  \r
-    Private->SelectIndex = Private->OfferIndex[HttpOfferTypeDhcpNameUriDns][0] + 1;\r
+      Private->SelectIndex = Private->OfferIndex[HttpOfferTypeDhcpNameUriDns][0] + 1;\r
+      \r
+    }  else if (Private->OfferCount[HttpOfferTypeDhcpOnly] > 0) {\r
     \r
-  } else if (Private->OfferCount[HttpOfferTypeDhcpOnly] > 0 &&\r
-             Private->OfferCount[HttpOfferTypeProxyIpUri] > 0) {\r
-             \r
-    Private->SelectIndex     = Private->OfferIndex[HttpOfferTypeDhcpOnly][0] + 1;\r
-    Private->SelectProxyType = HttpOfferTypeProxyIpUri;\r
+      Private->SelectIndex = Private->OfferIndex[HttpOfferTypeDhcpOnly][0] + 1;\r
+      \r
+    }  else if (Private->OfferCount[HttpOfferTypeDhcpIpUri] > 0) {\r
     \r
-  } else if (Private->OfferCount[HttpOfferTypeDhcpDns] > 0 &&\r
-             Private->OfferCount[HttpOfferTypeProxyIpUri] > 0) {\r
-             \r
-    Private->SelectIndex     = Private->OfferIndex[HttpOfferTypeDhcpDns][0] + 1;\r
-    Private->SelectProxyType = HttpOfferTypeProxyIpUri;\r
+      Private->SelectIndex = Private->OfferIndex[HttpOfferTypeDhcpIpUri][0] + 1;\r
+    }\r
     \r
-  } else if (Private->OfferCount[HttpOfferTypeDhcpDns] > 0 &&\r
-             Private->OfferCount[HttpOfferTypeProxyNameUri] > 0) {\r
-             \r
-    Private->SelectIndex     = Private->OfferIndex[HttpOfferTypeDhcpDns][0] + 1;\r
-    Private->SelectProxyType = HttpOfferTypeProxyNameUri;\r
+  } else {\r
+    //\r
+    // We are in corporate environment.\r
+    //\r
+    // Priority1: HttpOfferTypeDhcpIpUri or HttpOfferTypeDhcpIpUriDns\r
+    // Priority2: HttpOfferTypeDhcpNameUriDns                      \r
+    // Priority3: HttpOfferTypeDhcpOnly + HttpOfferTypeProxyIpUri  \r
+    // Priority4: HttpOfferTypeDhcpDns  + HttpOfferTypeProxyIpUri  \r
+    // Priority5: HttpOfferTypeDhcpDns  + HttpOfferTypeProxyNameUri\r
+    // Priority6: HttpOfferTypeDhcpDns  + HttpOfferTypeDhcpNameUri \r
+    //    \r
+    if (Private->OfferCount[HttpOfferTypeDhcpIpUri] > 0) {\r
+      \r
+      Private->SelectIndex = Private->OfferIndex[HttpOfferTypeDhcpIpUri][0] + 1;\r
+      \r
+    } else if (Private->OfferCount[HttpOfferTypeDhcpIpUriDns] > 0) {\r
+      \r
+      Private->SelectIndex = Private->OfferIndex[HttpOfferTypeDhcpIpUriDns][0] + 1;\r
+      \r
+    }else if (Private->OfferCount[HttpOfferTypeDhcpNameUriDns] > 0) {\r
     \r
-  } else if (Private->OfferCount[HttpOfferTypeDhcpDns] > 0 &&\r
-             Private->OfferCount[HttpOfferTypeDhcpNameUri] > 0) {\r
-             \r
-    Private->SelectIndex     = Private->OfferIndex[HttpOfferTypeDhcpDns][0] + 1;\r
-    Private->SelectProxyType = HttpOfferTypeDhcpNameUri;\r
+      Private->SelectIndex = Private->OfferIndex[HttpOfferTypeDhcpNameUriDns][0] + 1;\r
+      \r
+    } else if (Private->OfferCount[HttpOfferTypeDhcpOnly] > 0 &&\r
+               Private->OfferCount[HttpOfferTypeProxyIpUri] > 0) {\r
+               \r
+      Private->SelectIndex     = Private->OfferIndex[HttpOfferTypeDhcpOnly][0] + 1;\r
+      Private->SelectProxyType = HttpOfferTypeProxyIpUri;\r
+      \r
+    } else if (Private->OfferCount[HttpOfferTypeDhcpDns] > 0 &&\r
+               Private->OfferCount[HttpOfferTypeProxyIpUri] > 0) {\r
+               \r
+      Private->SelectIndex     = Private->OfferIndex[HttpOfferTypeDhcpDns][0] + 1;\r
+      Private->SelectProxyType = HttpOfferTypeProxyIpUri;\r
+      \r
+    } else if (Private->OfferCount[HttpOfferTypeDhcpDns] > 0 &&\r
+               Private->OfferCount[HttpOfferTypeProxyNameUri] > 0) {\r
+               \r
+      Private->SelectIndex     = Private->OfferIndex[HttpOfferTypeDhcpDns][0] + 1;\r
+      Private->SelectProxyType = HttpOfferTypeProxyNameUri;\r
+      \r
+    } else if (Private->OfferCount[HttpOfferTypeDhcpDns] > 0 &&\r
+               Private->OfferCount[HttpOfferTypeDhcpNameUri] > 0) {\r
+               \r
+      Private->SelectIndex     = Private->OfferIndex[HttpOfferTypeDhcpDns][0] + 1;\r
+      Private->SelectProxyType = HttpOfferTypeDhcpNameUri;\r
+    }\r
   }\r
 }\r
 \r
index 2bc46deafd41b2d3189e41ddb420d8f4aa9c720a..5ac7f7116536bc9a2770d4adb4cf966467a4cdce 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Functions declaration related with DHCPv4 for HTTP boot driver.\r
 \r
-Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials are licensed and made available under \r
 the terms and conditions of the BSD License that accompanies this distribution.  \r
 The full text of the license may be found at\r
@@ -96,11 +96,14 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 ///\r
 typedef enum {\r
   //\r
-  // <IP address, IP expressed URI> or\r
-  // <IP address, IP expressed URI, Name-server (will be ignored)>\r
+  // <IP address, IP expressed URI>\r
   //\r
   HttpOfferTypeDhcpIpUri,\r
   //\r
+  // <IP address, IP expressed URI, Name-server>\r
+  //\r
+  HttpOfferTypeDhcpIpUriDns,\r
+  //\r
   // <IP address, Domain-name expressed URI, Name-server>\r
   //\r
   HttpOfferTypeDhcpNameUriDns,\r
index 2538bd116ca42ddb47c2081c4fab3e03c0399766..d2960e4f6c14a15858f40d447d8a3e02eee88df7 100644 (file)
@@ -298,7 +298,11 @@ HttpBootParseDhcp6Packet (
   //\r
   if (IsHttpOffer) {\r
     if (IpExpressedUri) {\r
-      OfferType = IsProxyOffer ? HttpOfferTypeProxyIpUri : HttpOfferTypeDhcpIpUri;\r
+      if (IsProxyOffer) {\r
+        OfferType = HttpOfferTypeProxyIpUri;\r
+      } else {\r
+        OfferType = IsDnsOffer ? HttpOfferTypeDhcpIpUriDns : HttpOfferTypeDhcpIpUri;\r
+      }\r
     } else {\r
       if (!IsProxyOffer) {\r
         OfferType = IsDnsOffer ? HttpOfferTypeDhcpNameUriDns : HttpOfferTypeDhcpNameUri;\r
index 9fb33bbb53abf20e874f4ea240543577ab2870d1..6a3033db11a0ebeaecdc62c5bdd4903ab5b9a5b5 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Driver Binding functions implementation for UEFI HTTP boot.\r
 \r
-Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials are licensed and made available under \r
 the terms and conditions of the BSD License that accompanies this distribution.  \r
 The full text of the license may be found at\r
@@ -364,6 +364,14 @@ HttpBootIp4DxeDriverBindingStart (
       goto ON_ERROR;\r
     }\r
 \r
+    //\r
+    // Initialize the HII configuration form.\r
+    //\r
+    Status = HttpBootConfigFormInit (Private);\r
+    if (EFI_ERROR (Status)) {\r
+      goto ON_ERROR;\r
+    }\r
+\r
     //\r
     // Install a protocol with Caller Id Guid to the NIC, this is just to build the relationship between\r
     // NIC handle and the private data.\r
@@ -508,8 +516,9 @@ HttpBootIp4DxeDriverBindingStart (
 \r
     \r
 ON_ERROR:\r
-  \r
+\r
   HttpBootDestroyIp4Children (This, Private);\r
+  HttpBootConfigFormUnload (Private);\r
   FreePool (Private);\r
 \r
   return Status;\r
@@ -615,6 +624,11 @@ HttpBootIp4DxeDriverBindingStop (
     // Release the cached data.\r
     //\r
     HttpBootFreeCacheList (Private);\r
+\r
+    //\r
+    // Unload the config form.\r
+    //\r
+    HttpBootConfigFormUnload (Private);\r
     \r
     gBS->UninstallProtocolInterface (\r
            NicHandle,\r
@@ -822,6 +836,14 @@ HttpBootIp6DxeDriverBindingStart (
       goto ON_ERROR;\r
     }\r
 \r
+    //\r
+    // Initialize the HII configuration form.\r
+    //\r
+    Status = HttpBootConfigFormInit (Private);\r
+    if (EFI_ERROR (Status)) {\r
+      goto ON_ERROR;\r
+    }\r
+\r
     //\r
     // Install a protocol with Caller Id Guid to the NIC, this is just to build the relationship between\r
     // NIC handle and the private data.\r
@@ -989,12 +1011,12 @@ HttpBootIp6DxeDriverBindingStart (
   return EFI_SUCCESS;\r
    \r
 ON_ERROR:\r
-  \r
- HttpBootDestroyIp6Children(This, Private);\r
- FreePool (Private);\r
 \r
- return Status;\r
\r
+  HttpBootDestroyIp6Children(This, Private);\r
+  HttpBootConfigFormUnload (Private);\r
+  FreePool (Private);\r
+\r
+  return Status;\r
 }\r
 \r
 /**\r
@@ -1096,7 +1118,12 @@ HttpBootIp6DxeDriverBindingStop (
     // Release the cached data.\r
     //\r
     HttpBootFreeCacheList (Private);\r
-        \r
+\r
+    //\r
+    // Unload the config form.\r
+    //\r
+    HttpBootConfigFormUnload (Private);\r
+\r
     gBS->UninstallProtocolInterface (\r
            NicHandle,\r
            &gEfiCallerIdGuid,\r
@@ -1128,6 +1155,7 @@ HttpBootDxeDriverEntryPoint (
   )\r
 {\r
   EFI_STATUS   Status;\r
+\r
   //\r
   // Install UEFI Driver Model protocol(s).\r
   //\r
index 08f88c5606a008edbdd4eadf73428ad8c392e0ef..7cb4b2c55a14e40a58e9025065cfbcc965321ff5 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   UEFI HTTP boot driver's private data structure and interfaces declaration.\r
 \r
-Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.<BR>\r
 (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>\r
 This program and the accompanying materials are licensed and made available under \r
 the terms and conditions of the BSD License that accompanies this distribution.  \r
@@ -24,6 +24,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 // Libraries\r
 //\r
 #include <Library/UefiBootServicesTableLib.h>\r
+#include <Library/UefiHiiServicesLib.h>\r
+#include <Library/UefiRuntimeServicesTableLib.h>\r
 #include <Library/MemoryAllocationLib.h>\r
 #include <Library/BaseLib.h>\r
 #include <Library/UefiLib.h>\r
@@ -31,6 +33,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <Library/DebugLib.h>\r
 #include <Library/NetLib.h>\r
 #include <Library/HttpLib.h>\r
+#include <Library/HiiLib.h>\r
+#include <Library/PrintLib.h>\r
 \r
 //\r
 // UEFI Driver Model Protocols\r
@@ -42,6 +46,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 //\r
 // Consumed Protocols\r
 //\r
+#include <Protocol/ServiceBinding.h>\r
+#include <Protocol/HiiConfigAccess.h>\r
 #include <Protocol/NetworkInterfaceIdentifier.h>\r
 #include <Protocol/Dhcp4.h>\r
 #include <Protocol/Dhcp6.h>\r
@@ -54,6 +60,11 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 //\r
 #include <Protocol/LoadFile.h>\r
 \r
+//\r
+// Consumed Guids\r
+//\r
+#include <Guid/HttpBootConfigHii.h>\r
+\r
 //\r
 // Driver Version\r
 //\r
@@ -81,6 +92,7 @@ typedef struct _HTTP_BOOT_VIRTUAL_NIC       HTTP_BOOT_VIRTUAL_NIC;
 #include "HttpBootImpl.h"\r
 #include "HttpBootSupport.h"\r
 #include "HttpBootClient.h"\r
+#include "HttpBootConfig.h"\r
 \r
 typedef union {\r
   HTTP_BOOT_DHCP4_PACKET_CACHE              Dhcp4;\r
@@ -95,6 +107,14 @@ struct _HTTP_BOOT_VIRTUAL_NIC {
   HTTP_BOOT_PRIVATE_DATA                    *Private;\r
 };\r
 \r
+#define HTTP_BOOT_PRIVATE_DATA_FROM_CALLBACK_INFO(Callback) \\r
+  CR ( \\r
+  Callback, \\r
+  HTTP_BOOT_PRIVATE_DATA, \\r
+  CallbackInfo, \\r
+  HTTP_BOOT_PRIVATE_DATA_SIGNATURE \\r
+  )\r
+\r
 struct _HTTP_BOOT_PRIVATE_DATA {\r
   UINT32                                    Signature;\r
   EFI_HANDLE                                Controller;\r
@@ -131,6 +151,11 @@ struct _HTTP_BOOT_PRIVATE_DATA {
   EFI_DEVICE_PATH_PROTOCOL                  *DevicePath;\r
   UINT32                                    Id;\r
 \r
+  //\r
+  // HII callback info block\r
+  //\r
+  HTTP_BOOT_FORM_CALLBACK_INFO              CallbackInfo;\r
+\r
   //\r
   // Mode data\r
   //\r
@@ -146,6 +171,12 @@ struct _HTTP_BOOT_PRIVATE_DATA {
   UINTN                                     BootFileSize;\r
   BOOLEAN                                   NoGateway;\r
 \r
+  //\r
+  // URI string extracted from the input FilePath parameter.\r
+  //\r
+  CHAR8                                     *FilePathUri;\r
+  VOID                                      *FilePathUriParser;\r
+\r
   //\r
   // Cached HTTP data\r
   //\r
index e24b568ddc88756327ea64dfaebcd478c6bfc178..8b4219cb17117da51032e1b5be9ffae8df4062f3 100644 (file)
@@ -1,7 +1,7 @@
 ## @file\r
 #  This modules produce the Load File Protocol for UEFI HTTP boot.\r
 # \r
-#  Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>\r
+#  Copyright (c) 2015 - 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
 [Packages]\r
   MdePkg/MdePkg.dec\r
   MdeModulePkg/MdeModulePkg.dec\r
+  NetworkPkg/NetworkPkg.dec\r
 \r
 [Sources]\r
   HttpBootDxe.h\r
   HttpBootDxe.c\r
+  HttpBootConfig.c\r
   HttpBootComponentName.h\r
   HttpBootComponentName.c\r
   HttpBootImpl.h\r
@@ -41,6 +43,8 @@
   HttpBootSupport.c\r
   HttpBootClient.h\r
   HttpBootClient.c\r
+  HttpBootConfigVfr.vfr\r
+  HttpBootConfigStrings.uni\r
 \r
 [LibraryClasses]\r
   UefiDriverEntryPoint\r
@@ -52,6 +56,9 @@
   DebugLib\r
   NetLib\r
   HttpLib\r
+  HiiLib\r
+  PrintLib\r
+  UefiHiiServicesLib\r
 \r
 [Protocols]\r
   ## TO_START\r
   gEfiIp6ProtocolGuid                             ## TO_START\r
   gEfiIp6ConfigProtocolGuid                       ## TO_START\r
   gEfiNetworkInterfaceIdentifierProtocolGuid_31   ## SOMETIMES_CONSUMES\r
+  gEfiHiiConfigAccessProtocolGuid                 ## BY_START\r
+\r
+[Guids]\r
+  ## SOMETIMES_CONSUMES ## GUID # HiiIsConfigHdrMatch   mHttpBootConfigStorageName\r
+  ## SOMETIMES_PRODUCES ## GUID # HiiConstructConfigHdr mHttpBootConfigStorageName\r
+  ## SOMETIMES_PRODUCES ## GUID # HiiGetBrowserData     mHttpBootConfigStorageName\r
+  ## SOMETIMES_CONSUMES ## HII\r
+  gHttpBootConfigGuid\r
 \r
 [UserExtensions.TianoCore."ExtraFiles"]\r
   HttpBootDxeExtra.uni\r
index 9ea0d7f95f93eb26aa7bbd58e59196fe739b696f..3adb08d9f69c5460343b122c7602abe294cb3184 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   The implementation of EFI_LOAD_FILE_PROTOCOL for UEFI HTTP boot.\r
 \r
-Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials are licensed and made available under \r
 the terms and conditions of the BSD License that accompanies this distribution.  \r
 The full text of the license may be found at\r
@@ -21,22 +21,25 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
   @param[in]    UsingIpv6          Specifies the type of IP addresses that are to be\r
                                    used during the session that is being started.\r
                                    Set to TRUE for IPv6, and FALSE for IPv4.\r
+  @param[in]    FilePath           The device specific path of the file to load.\r
 \r
   @retval EFI_SUCCESS              HTTP boot was successfully enabled.\r
   @retval EFI_INVALID_PARAMETER    Private is NULL.\r
   @retval EFI_ALREADY_STARTED      The driver is already in started state.\r
+  @retval EFI_OUT_OF_RESOURCES     There are not enough resources.\r
   \r
 **/\r
 EFI_STATUS\r
 HttpBootStart (\r
   IN HTTP_BOOT_PRIVATE_DATA           *Private,\r
-  IN BOOLEAN                          UsingIpv6\r
+  IN BOOLEAN                          UsingIpv6,\r
+  IN EFI_DEVICE_PATH_PROTOCOL         *FilePath\r
   )\r
 {\r
   UINTN                Index;\r
   EFI_STATUS           Status;\r
 \r
-  if (Private == NULL) {\r
+  if (Private == NULL || FilePath == NULL) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
@@ -54,6 +57,26 @@ HttpBootStart (
   } else {\r
     return EFI_UNSUPPORTED;\r
   }\r
+\r
+  //\r
+  // Check whether the URI address is specified.\r
+  //\r
+  Status = HttpBootParseFilePath (FilePath, &Private->FilePathUri);\r
+  if (EFI_ERROR (Status)) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  if (Private->FilePathUri != NULL) {\r
+    Status = HttpParseUrl (\r
+               Private->FilePathUri,\r
+               (UINT32) AsciiStrLen (Private->FilePathUri),\r
+               FALSE,\r
+               &Private->FilePathUriParser\r
+               );\r
+    if (EFI_ERROR (Status)) {\r
+      return Status;\r
+    }\r
+  }\r
   \r
   //\r
   // Init the content of cached DHCP offer list.\r
@@ -301,12 +324,21 @@ HttpBootStop (
       }\r
     }\r
   }\r
+\r
+  if (Private->FilePathUri!= NULL) {\r
+    FreePool (Private->FilePathUri);\r
+    HttpUrlFreeParser (Private->FilePathUriParser);\r
+    Private->FilePathUri = NULL;\r
+    Private->FilePathUriParser = NULL;\r
+  }\r
   \r
   ZeroMem (Private->OfferBuffer, sizeof (Private->OfferBuffer));\r
   Private->OfferNum = 0;\r
   ZeroMem (Private->OfferCount, sizeof (Private->OfferCount));\r
   ZeroMem (Private->OfferIndex, sizeof (Private->OfferIndex));\r
-\r
+  \r
+  HttpBootFreeCacheList (Private);\r
+  \r
   return EFI_SUCCESS;\r
 }\r
 \r
@@ -357,7 +389,7 @@ HttpBootDxeLoadFile (
   BOOLEAN                       UsingIpv6;\r
   EFI_STATUS                    Status;\r
 \r
-  if (This == NULL || BufferSize == NULL) {\r
+  if (This == NULL || BufferSize == NULL || FilePath == NULL) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
@@ -370,7 +402,6 @@ HttpBootDxeLoadFile (
 \r
   VirtualNic = HTTP_BOOT_VIRTUAL_NIC_FROM_LOADFILE (This);\r
   Private = VirtualNic->Private;\r
-  UsingIpv6 = FALSE;\r
   \r
   //\r
   // Check media status before HTTP boot start\r
@@ -380,27 +411,37 @@ HttpBootDxeLoadFile (
   if (!MediaPresent) {\r
     return EFI_NO_MEDIA;\r
   }\r
-\r
+  \r
   //\r
   // Check whether the virtual nic is using IPv6 or not.\r
   //\r
+  UsingIpv6 = FALSE;\r
   if (VirtualNic == Private->Ip6Nic) {\r
     UsingIpv6 = TRUE;\r
   }\r
-  \r
+\r
   //\r
-  // Initialize HTTP boot and load the boot file.\r
+  // Initialize HTTP boot.\r
   //\r
-  Status = HttpBootStart (Private, UsingIpv6);\r
-  if (Status == EFI_ALREADY_STARTED && UsingIpv6 != Private->UsingIpv6) {\r
+  Status = HttpBootStart (Private, UsingIpv6, FilePath);\r
+  if (Status == EFI_ALREADY_STARTED) {\r
     //\r
-    // Http boot Driver has already been started but not on the required IP version, restart it.\r
+    // Restart the HTTP boot driver in 2 cases:\r
+    // 1. Http boot Driver has already been started but not on the required IP version.\r
+    // 2. The required boot FilePath is different with the one we produced in the device path\r
+    // protocol.\r
     //\r
-    Status = HttpBootStop (Private);\r
-    if (!EFI_ERROR (Status)) {\r
-      Status = HttpBootStart (Private, UsingIpv6);\r
+    if ((UsingIpv6 != Private->UsingIpv6) || !IsDevicePathEnd(FilePath)) {\r
+      Status = HttpBootStop (Private);\r
+      if (!EFI_ERROR (Status)) {\r
+        Status = HttpBootStart (Private, UsingIpv6, FilePath);\r
+      }\r
     }\r
   }\r
+\r
+  //\r
+  // Load the boot file.\r
+  //\r
   if (Status == EFI_SUCCESS || Status == EFI_ALREADY_STARTED) {\r
     Status = HttpBootLoadFile (Private, BufferSize, Buffer);\r
   }\r
index db2af780a10a6d00895f9b6acaa9ac3bce0321b4..f30d9f7fb0db7475f2293ac6cb4f4d48219dae94 100644 (file)
@@ -977,3 +977,66 @@ HttpIoRecvResponse (
 \r
   return Status;\r
 }\r
+\r
+/**\r
+  Get the URI address string from the input device path.\r
+\r
+  Caller need to free the buffer in the UriAddress pointer.\r
+  \r
+  @param[in]   FilePath         Pointer to the device path which contains a URI device path node.\r
+  @param[in]   UriAddress       The URI address string extract from the device path.\r
+  \r
+  @retval EFI_SUCCESS            The URI string is returned.\r
+  @retval EFI_OUT_OF_RESOURCES   Failed to allocate memory.\r
+\r
+**/\r
+EFI_STATUS\r
+HttpBootParseFilePath (\r
+  IN     EFI_DEVICE_PATH_PROTOCOL     *FilePath,\r
+     OUT CHAR8                        **UriAddress\r
+  )\r
+{\r
+  EFI_DEVICE_PATH_PROTOCOL  *TempDevicePath;\r
+  URI_DEVICE_PATH           *UriDevicePath;\r
+  CHAR8                     *Uri;\r
+  UINTN                     UriStrLength;\r
+\r
+  if (FilePath == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  *UriAddress = NULL;\r
+\r
+  //\r
+  // Extract the URI address from the FilePath\r
+  //\r
+  TempDevicePath = FilePath;\r
+  while (!IsDevicePathEnd (TempDevicePath)) {\r
+    if ((DevicePathType (TempDevicePath) == MESSAGING_DEVICE_PATH) &&\r
+        (DevicePathSubType (TempDevicePath) == MSG_URI_DP)) {\r
+      UriDevicePath = (URI_DEVICE_PATH*) TempDevicePath;\r
+      //\r
+      // UEFI Spec doesn't require the URI to be a NULL-terminated string\r
+      // So we allocate a new buffer and always append a '\0' to it.\r
+      //\r
+      UriStrLength = DevicePathNodeLength (UriDevicePath) - sizeof(EFI_DEVICE_PATH_PROTOCOL);\r
+      if (UriStrLength == 0) {\r
+        //\r
+        // return a NULL UriAddress if it's a empty URI device path node.\r
+        //\r
+        break;\r
+      }\r
+      Uri = AllocatePool (UriStrLength + 1);\r
+      if (Uri == NULL) {\r
+        return EFI_OUT_OF_RESOURCES;\r
+      }\r
+      CopyMem (Uri, UriDevicePath->Uri, DevicePathNodeLength (UriDevicePath) - sizeof(EFI_DEVICE_PATH_PROTOCOL));\r
+      Uri[DevicePathNodeLength (UriDevicePath) - sizeof(EFI_DEVICE_PATH_PROTOCOL)] = '\0';\r
+\r
+      *UriAddress = Uri;\r
+    }\r
+    TempDevicePath = NextDevicePathNode (TempDevicePath);\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
index 8e0fc37fdd8fe5b8cccb615db64f5471bb8def50..3edea615af290851170c4e206d6b0fdb1b62f3ee 100644 (file)
@@ -329,4 +329,22 @@ HttpIoRecvResponse (
      OUT  HTTP_IO_RESPONSE_DATA    *ResponseData\r
   );\r
 \r
+/**\r
+  Get the URI address string from the input device path.\r
+\r
+  Caller need to free the buffer in the UriAddress pointer.\r
+  \r
+  @param[in]   FilePath         Pointer to the device path which contains a URI device path node.\r
+  @param[in]   UriAddress       The URI address string extract from the device path.\r
+  \r
+  @retval EFI_SUCCESS            The URI string is returned.\r
+  @retval EFI_OUT_OF_RESOURCES   Failed to allocate memory.\r
+\r
+**/\r
+EFI_STATUS\r
+HttpBootParseFilePath (\r
+  IN     EFI_DEVICE_PATH_PROTOCOL     *FilePath,\r
+     OUT CHAR8                        **UriAddress\r
+  );\r
+\r
 #endif\r
diff --git a/NetworkPkg/Include/Guid/HttpBootConfigHii.h b/NetworkPkg/Include/Guid/HttpBootConfigHii.h
new file mode 100644 (file)
index 0000000..7e44436
--- /dev/null
@@ -0,0 +1,25 @@
+/** @file\r
+  GUIDs used as HII FormSet and HII Package list GUID in HTTP boot driver.\r
+  \r
+Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials are licensed and made available under \r
+the terms and conditions of the BSD License that accompanies this distribution.  \r
+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
+\r
+**/\r
+\r
+#ifndef __HTTP_BOOT_HII_GUID_H__\r
+#define __HTTP_BOOT_HII_GUID_H__\r
+\r
+#define HTTP_BOOT_CONFIG_GUID \\r
+  { \\r
+    0x4d20583a, 0x7765, 0x4e7a, { 0x8a, 0x67, 0xdc, 0xde, 0x74, 0xee, 0x3e, 0xc5 } \\r
+  }\r
+\r
+extern EFI_GUID gHttpBootConfigGuid;\r
+\r
+#endif\r
index 288d1aad2ba102acaf4ca9fb138be7d83190cbb4..268188a3d8ebf1dacb42d9b25006e39fba3198f5 100644 (file)
@@ -4,7 +4,7 @@
 # This package provides network modules that conform to UEFI 2.4 specification.\r
 #\r
 # (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>\r
-# Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR>\r
 #\r
 # This program and the accompanying materials are licensed and made available under\r
 # the terms and conditions of the BSD License which accompanies this distribution.\r
@@ -37,6 +37,9 @@
   # Include/Guid/IscsiConfigHii.h\r
   gIScsiConfigGuid              = { 0x4b47d616, 0xa8d6, 0x4552, { 0x9d, 0x44, 0xcc, 0xad, 0x2e, 0xf, 0x4c, 0xf9}}\r
 \r
+  # Include/Guid/HttpBootConfigHii.h\r
+  gHttpBootConfigGuid           = { 0x4d20583a, 0x7765, 0x4e7a, { 0x8a, 0x67, 0xdc, 0xde, 0x74, 0xee, 0x3e, 0xc5 }}\r
+\r
 [PcdsFeatureFlag]\r
   ## Indicates if the IPsec IKEv2 Certificate Authentication feature is enabled or not.<BR><BR>\r
   #   TRUE  - Certificate Authentication feature is enabled.<BR>\r