summaryrefslogtreecommitdiffstats
path: root/NetworkPkg/HttpBootDxe/HttpBootSupport.c
diff options
context:
space:
mode:
authorFu Siyuan <siyuan.fu@intel.com>2016-02-15 13:55:11 +0800
committerFu Siyuan <siyuan.fu@intel.com>2016-03-07 09:12:14 +0800
commitfa848a4048943251fc057fe8d6c5a82e01d2ffb6 (patch)
tree0ffe9aa44385b2bd9e49c974f3ed52345579e61e /NetworkPkg/HttpBootDxe/HttpBootSupport.c
parent9353c60cea6eeedbbe4b336aea02646e2bf25f47 (diff)
downloadedk2-fa848a4048943251fc057fe8d6c5a82e01d2ffb6.tar.gz
edk2-fa848a4048943251fc057fe8d6c5a82e01d2ffb6.tar.bz2
edk2-fa848a4048943251fc057fe8d6c5a82e01d2ffb6.zip
NetworkPkg: Add URI configuration form to HTTP boot driver.
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>
Diffstat (limited to 'NetworkPkg/HttpBootDxe/HttpBootSupport.c')
-rw-r--r--NetworkPkg/HttpBootDxe/HttpBootSupport.c63
1 files changed, 63 insertions, 0 deletions
diff --git a/NetworkPkg/HttpBootDxe/HttpBootSupport.c b/NetworkPkg/HttpBootDxe/HttpBootSupport.c
index db2af780a1..f30d9f7fb0 100644
--- a/NetworkPkg/HttpBootDxe/HttpBootSupport.c
+++ b/NetworkPkg/HttpBootDxe/HttpBootSupport.c
@@ -977,3 +977,66 @@ HttpIoRecvResponse (
return Status;
}
+
+/**
+ Get the URI address string from the input device path.
+
+ Caller need to free the buffer in the UriAddress pointer.
+
+ @param[in] FilePath Pointer to the device path which contains a URI device path node.
+ @param[in] UriAddress The URI address string extract from the device path.
+
+ @retval EFI_SUCCESS The URI string is returned.
+ @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.
+
+**/
+EFI_STATUS
+HttpBootParseFilePath (
+ IN EFI_DEVICE_PATH_PROTOCOL *FilePath,
+ OUT CHAR8 **UriAddress
+ )
+{
+ EFI_DEVICE_PATH_PROTOCOL *TempDevicePath;
+ URI_DEVICE_PATH *UriDevicePath;
+ CHAR8 *Uri;
+ UINTN UriStrLength;
+
+ if (FilePath == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ *UriAddress = NULL;
+
+ //
+ // Extract the URI address from the FilePath
+ //
+ TempDevicePath = FilePath;
+ while (!IsDevicePathEnd (TempDevicePath)) {
+ if ((DevicePathType (TempDevicePath) == MESSAGING_DEVICE_PATH) &&
+ (DevicePathSubType (TempDevicePath) == MSG_URI_DP)) {
+ UriDevicePath = (URI_DEVICE_PATH*) TempDevicePath;
+ //
+ // UEFI Spec doesn't require the URI to be a NULL-terminated string
+ // So we allocate a new buffer and always append a '\0' to it.
+ //
+ UriStrLength = DevicePathNodeLength (UriDevicePath) - sizeof(EFI_DEVICE_PATH_PROTOCOL);
+ if (UriStrLength == 0) {
+ //
+ // return a NULL UriAddress if it's a empty URI device path node.
+ //
+ break;
+ }
+ Uri = AllocatePool (UriStrLength + 1);
+ if (Uri == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+ CopyMem (Uri, UriDevicePath->Uri, DevicePathNodeLength (UriDevicePath) - sizeof(EFI_DEVICE_PATH_PROTOCOL));
+ Uri[DevicePathNodeLength (UriDevicePath) - sizeof(EFI_DEVICE_PATH_PROTOCOL)] = '\0';
+
+ *UriAddress = Uri;
+ }
+ TempDevicePath = NextDevicePathNode (TempDevicePath);
+ }
+
+ return EFI_SUCCESS;
+}