From fca04738c94394277725a3ede6da9e887d6fae12 Mon Sep 17 00:00:00 2001 From: Fu Siyuan Date: Mon, 13 Nov 2017 15:20:37 +0800 Subject: NetworkPkg: Print error message to screen if error occurs during HTTP boot. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Fu Siyuan Reviewed-by: Wu Jiaxin Reviewed-by: Ye Ting --- NetworkPkg/HttpBootDxe/HttpBootImpl.c | 21 +++++++++++++++++++++ NetworkPkg/HttpBootDxe/HttpBootSupport.c | 2 ++ 2 files changed, 23 insertions(+) (limited to 'NetworkPkg/HttpBootDxe') diff --git a/NetworkPkg/HttpBootDxe/HttpBootImpl.c b/NetworkPkg/HttpBootDxe/HttpBootImpl.c index 06a8a6a386..d591db5bd4 100644 --- a/NetworkPkg/HttpBootDxe/HttpBootImpl.c +++ b/NetworkPkg/HttpBootDxe/HttpBootImpl.c @@ -327,6 +327,7 @@ HttpBootLoadFile ( // Status = HttpBootDiscoverBootInfo (Private); if (EFI_ERROR (Status)) { + AsciiPrint ("\n Error: Could not discover the boot information for DHCP server.\n"); goto ON_EXIT; } } @@ -369,6 +370,7 @@ HttpBootLoadFile ( &Private->ImageType ); if (EFI_ERROR (Status) && Status != EFI_BUFFER_TOO_SMALL) { + AsciiPrint ("\n Error: Could not retrieve NBP file size from HTTP server.\n"); goto ON_EXIT; } } @@ -394,6 +396,22 @@ HttpBootLoadFile ( ON_EXIT: HttpBootUninstallCallback (Private); + + if (Status == EFI_ACCESS_DENIED) { + AsciiPrint ("\n Error: Could not establish connection with HTTP server.\n"); + } else if (Status == EFI_BUFFER_TOO_SMALL && Buffer != NULL) { + AsciiPrint ("\n Error: Buffer size is smaller than the requested file.\n"); + } else if (Status == EFI_OUT_OF_RESOURCES) { + AsciiPrint ("\n Error: Could not allocate I/O buffers.\n"); + } else if (Status == EFI_DEVICE_ERROR) { + AsciiPrint ("\n Error: Network device error.\n"); + } else if (Status == EFI_TIMEOUT) { + AsciiPrint ("\n Error: Server response timeout.\n"); + } else if (Status == EFI_ABORTED) { + AsciiPrint ("\n Error: Remote boot cancelled.\n"); + } else if (Status != EFI_BUFFER_TOO_SMALL) { + AsciiPrint ("\n Error: Unexpected network error.\n"); + } return Status; } @@ -555,6 +573,7 @@ HttpBootDxeLoadFile ( MediaPresent = TRUE; NetLibDetectMedia (Private->Controller, &MediaPresent); if (!MediaPresent) { + AsciiPrint ("\n Error: Could not detect network connection.\n"); return EFI_NO_MEDIA; } @@ -595,6 +614,8 @@ HttpBootDxeLoadFile ( Status = HttpBootRegisterRamDisk (Private, *BufferSize, Buffer, ImageType); if (!EFI_ERROR (Status)) { Status = EFI_WARN_FILE_SYSTEM; + } else { + AsciiPrint ("\n Error: Could not register RAM disk to the system.\n"); } } diff --git a/NetworkPkg/HttpBootDxe/HttpBootSupport.c b/NetworkPkg/HttpBootDxe/HttpBootSupport.c index d508e2c1a9..7ca48f33d7 100644 --- a/NetworkPkg/HttpBootDxe/HttpBootSupport.c +++ b/NetworkPkg/HttpBootDxe/HttpBootSupport.c @@ -1093,6 +1093,7 @@ HttpBootCheckUriScheme ( // Return EFI_INVALID_PARAMETER if the URI is not HTTP or HTTPS. // if ((AsciiStrnCmp (Uri, "http://", 7) != 0) && (AsciiStrnCmp (Uri, "https://", 8) != 0)) { + AsciiPrint ("\n Error: Invalid URI address.\n"); DEBUG ((EFI_D_ERROR, "HttpBootCheckUriScheme: Invalid Uri.\n")); return EFI_INVALID_PARAMETER; } @@ -1101,6 +1102,7 @@ HttpBootCheckUriScheme ( // HTTP is disabled, return EFI_ACCESS_DENIED if the URI is HTTP. // if (!PcdGetBool (PcdAllowHttpConnections) && (AsciiStrnCmp (Uri, "http://", 7) == 0)) { + AsciiPrint ("\n Error: Access forbidden, only HTTPS connection is allowed.\n"); DEBUG ((EFI_D_ERROR, "HttpBootCheckUriScheme: HTTP is disabled.\n")); return EFI_ACCESS_DENIED; } -- cgit v1.2.3