summaryrefslogtreecommitdiffstats
path: root/NetworkPkg/HttpBootDxe/HttpBootClient.c
diff options
context:
space:
mode:
authorFu Siyuan <siyuan.fu@intel.com>2016-03-22 13:30:58 +0800
committerFu Siyuan <siyuan.fu@intel.com>2016-04-11 09:49:05 +0800
commit587d204ccda4b507be4f9f42e8c9d226fd755be0 (patch)
tree56f5d7668645348a3f4ec16055df3e84db72452f /NetworkPkg/HttpBootDxe/HttpBootClient.c
parent64ee6ed72ad5c1e4b7c9a96f419c3592e93314ad (diff)
downloadedk2-587d204ccda4b507be4f9f42e8c9d226fd755be0.tar.gz
edk2-587d204ccda4b507be4f9f42e8c9d226fd755be0.tar.bz2
edk2-587d204ccda4b507be4f9f42e8c9d226fd755be0.zip
NetworkPkg: Add RAM disk boot support to HTTP Boot driver.
This patch updates the HTTP Boot driver to support the download and boot a RAM disk image from HTTP server. The HTTP RAM disk boot is described in section 23.7 "HTTP Boot" in UEFI 2.6. HTTP server could provide either an UEFI image or a RAM disk image for the HTTP boot client to use. The RAM disk image must contain a UEFI compliant file system in it. HTTP boot driver will identify the image type either by the "Content-Type" entity header filed or by the file name extension as below: "application/efi" or *.efi -> EFI Image *.iso -> CD/DVD Image *.img -> Virtual Disk Image Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Fu Siyuan <siyuan.fu@intel.com> Reviewed-by: Ye Ting <ting.ye@intel.com> Reviewed-by: El-Haj-Mahmoud Samer <samer.el-haj-mahmoud@hpe.com>
Diffstat (limited to 'NetworkPkg/HttpBootDxe/HttpBootClient.c')
-rw-r--r--NetworkPkg/HttpBootDxe/HttpBootClient.c37
1 files changed, 31 insertions, 6 deletions
diff --git a/NetworkPkg/HttpBootDxe/HttpBootClient.c b/NetworkPkg/HttpBootDxe/HttpBootClient.c
index 0c472938a0..9d445e3c8e 100644
--- a/NetworkPkg/HttpBootDxe/HttpBootClient.c
+++ b/NetworkPkg/HttpBootDxe/HttpBootClient.c
@@ -570,6 +570,7 @@ HttpBootFreeCacheList (
@param[out] Buffer The memory buffer to transfer the file to. IF Buffer is NULL,
then the size of the requested file is returned in
BufferSize.
+ @param[out] ImageType The image type of the downloaded file.
@retval EFI_SUCCESS Successfully created.
@retval Others Failed to create HttpIo.
@@ -580,7 +581,8 @@ HttpBootGetFileFromCache (
IN HTTP_BOOT_PRIVATE_DATA *Private,
IN CHAR16 *Uri,
IN OUT UINTN *BufferSize,
- OUT UINT8 *Buffer
+ OUT UINT8 *Buffer,
+ OUT HTTP_BOOT_IMAGE_TYPE *ImageType
)
{
LIST_ENTRY *Entry;
@@ -589,7 +591,7 @@ HttpBootGetFileFromCache (
HTTP_BOOT_ENTITY_DATA *EntityData;
UINTN CopyedSize;
- if (Uri == NULL || BufferSize == 0 || Buffer == NULL) {
+ if (Uri == NULL || BufferSize == 0 || Buffer == NULL || ImageType == NULL) {
return EFI_INVALID_PARAMETER;
}
@@ -603,7 +605,12 @@ HttpBootGetFileFromCache (
(StrCmp (Uri, Cache->RequestData->Url) == 0))
{
//
- // Hit cache, check buffer size.
+ // Hit in cache, record image type.
+ //
+ *ImageType = Cache->ImageType;
+
+ //
+ // Check buffer size.
//
if (*BufferSize < Cache->EntityLength) {
*BufferSize = Cache->EntityLength;
@@ -712,6 +719,7 @@ HttpBootGetBootFileCallback (
@param[out] Buffer The memory buffer to transfer the file to. IF Buffer is NULL,
then the size of the requested file is returned in
BufferSize.
+ @param[out] ImageType The image type of the downloaded file.
@retval EFI_SUCCESS The file was loaded.
@retval EFI_INVALID_PARAMETER BufferSize is NULL or Buffer Size is not NULL but Buffer is NULL.
@@ -727,7 +735,8 @@ HttpBootGetBootFile (
IN HTTP_BOOT_PRIVATE_DATA *Private,
IN BOOLEAN HeaderOnly,
IN OUT UINTN *BufferSize,
- OUT UINT8 *Buffer
+ OUT UINT8 *Buffer,
+ OUT HTTP_BOOT_IMAGE_TYPE *ImageType
)
{
EFI_STATUS Status;
@@ -750,7 +759,7 @@ HttpBootGetBootFile (
ASSERT (Private != NULL);
ASSERT (Private->HttpCreated);
- if (BufferSize == NULL) {
+ if (BufferSize == NULL || ImageType == NULL) {
return EFI_INVALID_PARAMETER;
}
@@ -767,7 +776,7 @@ HttpBootGetBootFile (
}
AsciiStrToUnicodeStr (Private->BootFileUri, Url);
if (!HeaderOnly) {
- Status = HttpBootGetFileFromCache (Private, Url, BufferSize, Buffer);
+ Status = HttpBootGetFileFromCache (Private, Url, BufferSize, Buffer, ImageType);
if (Status != EFI_NOT_FOUND) {
FreePool (Url);
return Status;
@@ -788,6 +797,7 @@ HttpBootGetBootFile (
Status = EFI_OUT_OF_RESOURCES;
goto ERROR_1;
}
+ Cache->ImageType = ImageTypeMax;
InitializeListHead (&Cache->EntityDataList);
}
@@ -919,10 +929,25 @@ HttpBootGetBootFile (
}
//
+ // Check the image type according to server's response.
+ //
+ Status = HttpBootCheckImageType (
+ Private->BootFileUri,
+ Private->BootFileUriParser,
+ ResponseData->HeaderCount,
+ ResponseData->Headers,
+ ImageType
+ );
+ if (EFI_ERROR (Status)) {
+ goto ERROR_5;
+ }
+
+ //
// 3.2 Cache the response header.
//
if (Cache != NULL) {
Cache->ResponseData = ResponseData;
+ Cache->ImageType = *ImageType;
}
//