Re: [edk2] [Patch V3] NetworkPkg/HttpBootDxe: Add HTTP Boot Callback protocol support.
Hi, On 06/20/17 03:23, Fu Siyuan wrote: > V3 update: > Fix X64 build error. > > V2 update: > Correct the file size print for IA32. > > This patch updates the HTTP Boot driver to install a default HTTP Callback > protocol > if the platform doesn't provide one. This callback implementation will print > the > boot file download progress in percentage format. This patch breaks the GCC build, because: > diff --git a/NetworkPkg/HttpBootDxe/HttpBootImpl.c > b/NetworkPkg/HttpBootDxe/HttpBootImpl.c > index cf6de80..56f5bab 100644 > --- a/NetworkPkg/HttpBootDxe/HttpBootImpl.c > +++ b/NetworkPkg/HttpBootDxe/HttpBootImpl.c > +**/ > +EFI_STATUS > +HttpBootCallback ( > + IN EFI_HTTP_BOOT_CALLBACK_PROTOCOL *This, > + IN EFI_HTTP_BOOT_CALLBACK_DATA_TYPEDataType, > + IN BOOLEAN Received, > + IN UINT32 DataLength, > + IN VOID*Data OPTIONAL > + ) the EFIAPI calling convention wasn't specified here, but > +/// > +/// HTTP Boot Callback Protocol instance > +/// > +GLOBAL_REMOVE_IF_UNREFERENCED > +EFI_HTTP_BOOT_CALLBACK_PROTOCOL gHttpBootDxeHttpBootCallback = { > + HttpBootCallback > +}; it is required here, for the EFI_HTTP_BOOT_CALLBACK function pointer type. (Reported by Gerd's Jenkins CI.) Thanks, Laszlo ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
Re: [edk2] [Patch V3] NetworkPkg/HttpBootDxe: Add HTTP Boot Callback protocol support.
Reviewed-by: Ye Ting -Original Message- From: Fu, Siyuan Sent: Tuesday, June 20, 2017 9:23 AM To: edk2-devel@lists.01.org Cc: Ye, Ting ; Wu, Jiaxin Subject: [Patch V3] NetworkPkg/HttpBootDxe: Add HTTP Boot Callback protocol support. V3 update: Fix X64 build error. V2 update: Correct the file size print for IA32. This patch updates the HTTP Boot driver to install a default HTTP Callback protocol if the platform doesn't provide one. This callback implementation will print the boot file download progress in percentage format. Cc: Ye Ting Cc: Wu Jiaxin Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Fu Siyuan --- NetworkPkg/HttpBootDxe/HttpBootClient.c | 67 +- NetworkPkg/HttpBootDxe/HttpBootClient.h | 4 +- NetworkPkg/HttpBootDxe/HttpBootDhcp4.c | 26 +++- NetworkPkg/HttpBootDxe/HttpBootDhcp6.c | 106 +-- NetworkPkg/HttpBootDxe/HttpBootDxe.h | 14 ++ NetworkPkg/HttpBootDxe/HttpBootDxe.inf | 3 +- NetworkPkg/HttpBootDxe/HttpBootImpl.c| 221 +-- NetworkPkg/HttpBootDxe/HttpBootImpl.h| 2 + NetworkPkg/HttpBootDxe/HttpBootSupport.c | 29 NetworkPkg/HttpBootDxe/HttpBootSupport.h | 34 + 10 files changed, 446 insertions(+), 60 deletions(-) diff --git a/NetworkPkg/HttpBootDxe/HttpBootClient.c b/NetworkPkg/HttpBootDxe/HttpBootClient.c index 99db3d5..68f5a49 100644 --- a/NetworkPkg/HttpBootDxe/HttpBootClient.c +++ b/NetworkPkg/HttpBootDxe/HttpBootClient.c @@ -233,7 +233,6 @@ HttpBootDhcp4ExtractUriInfo ( // // All boot informations are valid here. // - AsciiPrint ("\n URI: %a", Private->BootFileUri); // // Update the device path to include the IP and boot URI information. @@ -401,7 +400,7 @@ HttpBootDhcp6ExtractUriInfo ( // // All boot informations are valid here. // - AsciiPrint ("\n URI: %a", Private->BootFileUri); + // // Update the device path to include the IP and boot URI information. // @@ -452,6 +451,40 @@ HttpBootDiscoverBootInfo ( } /** + HttpIo Callback function which will be invoked when specified HTTP_IO_CALLBACK_EVENT happened. + + @param[in]EventType Indicate the Event type that occurs in the current callback. + @param[in]MessageHTTP message which will be send to, or just received from HTTP server. + @param[in]ContextThe Callback Context pointer. + + @retval EFI_SUCCESS Tells the HttpIo to continue the HTTP process. + @retval Others Tells the HttpIo to abort the current HTTP process. +**/ +EFI_STATUS +EFIAPI +HttpBootHttpIoCallback ( + IN HTTP_IO_CALLBACK_EVENTEventType, + IN EFI_HTTP_MESSAGE *Message, + IN VOID *Context + ) +{ + HTTP_BOOT_PRIVATE_DATA *Private; + EFI_STATUS Status; + Private = (HTTP_BOOT_PRIVATE_DATA *) Context; + if (Private->HttpBootCallback != NULL) { +Status = Private->HttpBootCallback->Callback ( + Private->HttpBootCallback, + EventType == HttpIoRequest ? HttpBootHttpRequest : HttpBootHttpResponse, + EventType == HttpIoRequest ? FALSE : TRUE, + sizeof (EFI_HTTP_MESSAGE), + (VOID *) Message + ); +return Status; + } + return EFI_SUCCESS; +} + +/** Create a HttpIo instance for the file download. @param[in]PrivateThe pointer to the driver's private data. @@ -490,6 +523,8 @@ HttpBootCreateHttpIo ( Private->Controller, Private->UsingIpv6 ? IP_VERSION_6 : IP_VERSION_4, &ConfigData, + HttpBootHttpIoCallback, + (VOID *) Private, &Private->HttpIo ); if (EFI_ERROR (Status)) { @@ -686,6 +721,8 @@ HttpBootGetBootFileCallback ( { HTTP_BOOT_CALLBACK_DATA *CallbackData; HTTP_BOOT_ENTITY_DATA*NewEntityData; + EFI_STATUS Status; + EFI_HTTP_BOOT_CALLBACK_PROTOCOL *HttpBootCallback; // // We only care about the entity data. @@ -695,6 +732,19 @@ HttpBootGetBootFileCallback ( } CallbackData = (HTTP_BOOT_CALLBACK_DATA *) Context; + HttpBootCallback = CallbackData->Private->HttpBootCallback; + if (HttpBootCallback != NULL) { +Status = HttpBootCallback->Callback ( + HttpBootCallback, + HttpBootHttpEntityBody, + TRUE, + (UINT32)Length, + Data + ); +if (EFI_ERROR (Status)) { + return Status; +} + } // // Copy data if caller has provided a buffer. // @@ -977,6 +1027,7 @@ HttpBootGetBootFile ( Context.Buffer = Buffer; Context.BufferSize = *BufferSize; Context.Cache = Cache; + Context.Private= Private; Status = HttpInitMsgParser ( HeaderOnly? HttpMethodHead : HttpMethodGet, ResponseData->Response.StatusCode, @@ -1032,6 +1083,18 @@ HttpBootGetBootFile ( goto ER
Re: [edk2] [Patch V3] NetworkPkg/HttpBootDxe: Add HTTP Boot Callback protocol support.
Reviewed-by: Wu Jiaxin > -Original Message- > From: Fu, Siyuan > Sent: Tuesday, June 20, 2017 9:23 AM > To: edk2-devel@lists.01.org > Cc: Ye, Ting ; Wu, Jiaxin > Subject: [Patch V3] NetworkPkg/HttpBootDxe: Add HTTP Boot Callback > protocol support. > > V3 update: > Fix X64 build error. > > V2 update: > Correct the file size print for IA32. > > This patch updates the HTTP Boot driver to install a default HTTP Callback > protocol > if the platform doesn't provide one. This callback implementation will print > the > boot file download progress in percentage format. > > Cc: Ye Ting > Cc: Wu Jiaxin > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Fu Siyuan > --- > NetworkPkg/HttpBootDxe/HttpBootClient.c | 67 +- > NetworkPkg/HttpBootDxe/HttpBootClient.h | 4 +- > NetworkPkg/HttpBootDxe/HttpBootDhcp4.c | 26 +++- > NetworkPkg/HttpBootDxe/HttpBootDhcp6.c | 106 +-- > NetworkPkg/HttpBootDxe/HttpBootDxe.h | 14 ++ > NetworkPkg/HttpBootDxe/HttpBootDxe.inf | 3 +- > NetworkPkg/HttpBootDxe/HttpBootImpl.c| 221 > +-- > NetworkPkg/HttpBootDxe/HttpBootImpl.h| 2 + > NetworkPkg/HttpBootDxe/HttpBootSupport.c | 29 > NetworkPkg/HttpBootDxe/HttpBootSupport.h | 34 + > 10 files changed, 446 insertions(+), 60 deletions(-) > > diff --git a/NetworkPkg/HttpBootDxe/HttpBootClient.c > b/NetworkPkg/HttpBootDxe/HttpBootClient.c > index 99db3d5..68f5a49 100644 > --- a/NetworkPkg/HttpBootDxe/HttpBootClient.c > +++ b/NetworkPkg/HttpBootDxe/HttpBootClient.c > @@ -233,7 +233,6 @@ HttpBootDhcp4ExtractUriInfo ( >// >// All boot informations are valid here. >// > - AsciiPrint ("\n URI: %a", Private->BootFileUri); > >// >// Update the device path to include the IP and boot URI information. > @@ -401,7 +400,7 @@ HttpBootDhcp6ExtractUriInfo ( >// >// All boot informations are valid here. >// > - AsciiPrint ("\n URI: %a", Private->BootFileUri); > + >// >// Update the device path to include the IP and boot URI information. >// > @@ -452,6 +451,40 @@ HttpBootDiscoverBootInfo ( > } > > /** > + HttpIo Callback function which will be invoked when specified > HTTP_IO_CALLBACK_EVENT happened. > + > + @param[in]EventType Indicate the Event type that occurs in the > current callback. > + @param[in]MessageHTTP message which will be send to, or just > received from HTTP server. > + @param[in]ContextThe Callback Context pointer. > + > + @retval EFI_SUCCESS Tells the HttpIo to continue the HTTP process. > + @retval Others Tells the HttpIo to abort the current HTTP > process. > +**/ > +EFI_STATUS > +EFIAPI > +HttpBootHttpIoCallback ( > + IN HTTP_IO_CALLBACK_EVENTEventType, > + IN EFI_HTTP_MESSAGE *Message, > + IN VOID *Context > + ) > +{ > + HTTP_BOOT_PRIVATE_DATA *Private; > + EFI_STATUS Status; > + Private = (HTTP_BOOT_PRIVATE_DATA *) Context; > + if (Private->HttpBootCallback != NULL) { > +Status = Private->HttpBootCallback->Callback ( > + Private->HttpBootCallback, > + EventType == HttpIoRequest ? HttpBootHttpRequest : > HttpBootHttpResponse, > + EventType == HttpIoRequest ? FALSE : TRUE, > + sizeof (EFI_HTTP_MESSAGE), > + (VOID *) Message > + ); > +return Status; > + } > + return EFI_SUCCESS; > +} > + > +/** >Create a HttpIo instance for the file download. > >@param[in]PrivateThe pointer to the driver's private data. > @@ -490,6 +523,8 @@ HttpBootCreateHttpIo ( > Private->Controller, > Private->UsingIpv6 ? IP_VERSION_6 : IP_VERSION_4, > &ConfigData, > + HttpBootHttpIoCallback, > + (VOID *) Private, > &Private->HttpIo > ); >if (EFI_ERROR (Status)) { > @@ -686,6 +721,8 @@ HttpBootGetBootFileCallback ( > { >HTTP_BOOT_CALLBACK_DATA *CallbackData; >HTTP_BOOT_ENTITY_DATA*NewEntityData; > + EFI_STATUS Status; > + EFI_HTTP_BOOT_CALLBACK_PROTOCOL *HttpBootCallback; > >// >// We only care about the entity data. > @@ -695,6 +732,19 @@ HttpBootGetBootFileCallback ( >} > >CallbackData = (HTTP_BOOT_CALLBACK_DATA *) Context; > + HttpBootCallback = CallbackData->Private->HttpBootCallback; > + if (HttpBootCallback != NULL) { > +Status = HttpBootCallback->Callback ( > + HttpBootCallback, > + HttpBootHttpEntityBody, > + TRUE, > + (UINT32)Length, > + Data > + ); > +if (EFI_ERROR (Status)) { > + return Status; > +} > + } >// >// Copy data if caller has provided a buffer. >// > @@ -977,6 +1027,7 @@ HttpBootGetBootFile ( >Context.Buffer = Buffer; >Context.BufferSize =