HttpBootClient.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. /** @file
  2. Declaration of the boot file download function.
  3. Copyright (c) 2015 - 2021, Intel Corporation. All rights reserved.<BR>
  4. (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>
  5. SPDX-License-Identifier: BSD-2-Clause-Patent
  6. **/
  7. #ifndef __EFI_HTTP_BOOT_HTTP_H__
  8. #define __EFI_HTTP_BOOT_HTTP_H__
  9. #define HTTP_BOOT_BLOCK_SIZE 1500
  10. #define HTTP_USER_AGENT_EFI_HTTP_BOOT "UefiHttpBoot/1.0"
  11. //
  12. // Record the data length and start address of a data block.
  13. //
  14. typedef struct {
  15. LIST_ENTRY Link; // Link to the EntityDataList in HTTP_BOOT_CACHE_CONTENT
  16. UINT8 *Block; // If NULL, the data is in previous data block.
  17. UINT8 *DataStart; // Point to somewhere in the Block
  18. UINTN DataLength;
  19. } HTTP_BOOT_ENTITY_DATA;
  20. //
  21. // Structure for a cache item
  22. //
  23. typedef struct {
  24. LIST_ENTRY Link; // Link to the CacheList in driver's private data.
  25. EFI_HTTP_REQUEST_DATA *RequestData;
  26. HTTP_IO_RESPONSE_DATA *ResponseData; // Not include any message-body data.
  27. HTTP_BOOT_IMAGE_TYPE ImageType;
  28. UINTN EntityLength;
  29. LIST_ENTRY EntityDataList; // Entity data (message-body)
  30. } HTTP_BOOT_CACHE_CONTENT;
  31. //
  32. // Callback data for HTTP_BODY_PARSER_CALLBACK()
  33. //
  34. typedef struct {
  35. EFI_STATUS Status;
  36. //
  37. // Cache info.
  38. //
  39. HTTP_BOOT_CACHE_CONTENT *Cache;
  40. BOOLEAN NewBlock;
  41. UINT8 *Block;
  42. //
  43. // Caller provided buffer to load the file in.
  44. //
  45. UINTN CopyedSize;
  46. UINTN BufferSize;
  47. UINT8 *Buffer;
  48. HTTP_BOOT_PRIVATE_DATA *Private;
  49. } HTTP_BOOT_CALLBACK_DATA;
  50. /**
  51. Discover all the boot information for boot file.
  52. @param[in, out] Private The pointer to the driver's private data.
  53. @retval EFI_SUCCESS Successfully obtained all the boot information .
  54. @retval Others Failed to retrieve the boot information.
  55. **/
  56. EFI_STATUS
  57. HttpBootDiscoverBootInfo (
  58. IN OUT HTTP_BOOT_PRIVATE_DATA *Private
  59. );
  60. /**
  61. Create a HttpIo instance for the file download.
  62. @param[in] Private The pointer to the driver's private data.
  63. @retval EFI_SUCCESS Successfully created.
  64. @retval Others Failed to create HttpIo.
  65. **/
  66. EFI_STATUS
  67. HttpBootCreateHttpIo (
  68. IN HTTP_BOOT_PRIVATE_DATA *Private
  69. );
  70. /**
  71. This function download the boot file by using UEFI HTTP protocol.
  72. @param[in] Private The pointer to the driver's private data.
  73. @param[in] HeaderOnly Only request the response header, it could save a lot of time if
  74. the caller only want to know the size of the requested file.
  75. @param[in, out] BufferSize On input the size of Buffer in bytes. On output with a return
  76. code of EFI_SUCCESS, the amount of data transferred to
  77. Buffer. On output with a return code of EFI_BUFFER_TOO_SMALL,
  78. the size of Buffer required to retrieve the requested file.
  79. @param[out] Buffer The memory buffer to transfer the file to. IF Buffer is NULL,
  80. then the size of the requested file is returned in
  81. BufferSize.
  82. @param[out] ImageType The image type of the downloaded file.
  83. @retval EFI_SUCCESS The file was loaded.
  84. @retval EFI_INVALID_PARAMETER BufferSize is NULL or Buffer Size is not NULL but Buffer is NULL.
  85. @retval EFI_OUT_OF_RESOURCES Could not allocate needed resources
  86. @retval EFI_BUFFER_TOO_SMALL The BufferSize is too small to read the current directory entry.
  87. BufferSize has been updated with the size needed to complete
  88. the request.
  89. @retval Others Unexpected error happened.
  90. **/
  91. EFI_STATUS
  92. HttpBootGetBootFile (
  93. IN HTTP_BOOT_PRIVATE_DATA *Private,
  94. IN BOOLEAN HeaderOnly,
  95. IN OUT UINTN *BufferSize,
  96. OUT UINT8 *Buffer,
  97. OUT HTTP_BOOT_IMAGE_TYPE *ImageType
  98. );
  99. /**
  100. Clean up all cached data.
  101. @param[in] Private The pointer to the driver's private data.
  102. **/
  103. VOID
  104. HttpBootFreeCacheList (
  105. IN HTTP_BOOT_PRIVATE_DATA *Private
  106. );
  107. #endif