You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ipxe_download.h 4.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. /*
  2. * Copyright (C) 2010 VMware, Inc. All Rights Reserved.
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License as
  6. * published by the Free Software Foundation; either version 2 of the
  7. * License, or any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful, but
  10. * WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  17. */
  18. #ifndef IPXE_DOWNLOAD_H
  19. #define IPXE_DOWNLOAD_H
  20. FILE_LICENCE ( GPL2_OR_LATER );
  21. /** @file
  22. *
  23. * iPXE Download Protocol
  24. *
  25. * EFI applications started by iPXE may use this interface to download files.
  26. */
  27. typedef struct _IPXE_DOWNLOAD_PROTOCOL IPXE_DOWNLOAD_PROTOCOL;
  28. /** Token to represent a currently downloading file */
  29. typedef VOID *IPXE_DOWNLOAD_FILE;
  30. /**
  31. * Callback function that is invoked when data arrives for a particular file.
  32. *
  33. * Not all protocols will deliver data in order. Clients should not rely on the
  34. * order of data delivery matching the order in the file.
  35. *
  36. * Some protocols are capable of determining the file size near the beginning
  37. * of data transfer. To allow the client to allocate memory more efficiently,
  38. * iPXE may give a hint about the file size by calling the Data callback with
  39. * a zero BufferLength and the file size in FileOffset. Clients should be
  40. * prepared to deal with more or less data than the hint actually arriving.
  41. *
  42. * @v Context Context provided to the Start function
  43. * @v Buffer New data
  44. * @v BufferLength Length of new data in bytes
  45. * @v FileOffset Offset of new data in the file
  46. * @ret Status EFI_SUCCESS to continue the download,
  47. * or any error code to abort.
  48. */
  49. typedef
  50. EFI_STATUS
  51. (EFIAPI *IPXE_DOWNLOAD_DATA_CALLBACK)(
  52. IN VOID *Context,
  53. IN VOID *Buffer,
  54. IN UINTN BufferLength,
  55. IN UINTN FileOffset
  56. );
  57. /**
  58. * Callback function that is invoked when the file is finished downloading, or
  59. * when a connection unexpectedly closes or times out.
  60. *
  61. * The finish callback is also called when a download is aborted by the Abort
  62. * function (below).
  63. *
  64. * @v Context Context provided to the Start function
  65. * @v Status Reason for termination: EFI_SUCCESS when the entire
  66. * file was transferred successfully, or an error
  67. * otherwise
  68. */
  69. typedef
  70. void
  71. (EFIAPI *IPXE_DOWNLOAD_FINISH_CALLBACK)(
  72. IN VOID *Context,
  73. IN EFI_STATUS Status
  74. );
  75. /**
  76. * Start downloading a file, and register callback functions to handle the
  77. * download.
  78. *
  79. * @v This iPXE Download Protocol instance
  80. * @v Url URL to download from
  81. * @v DataCallback Callback that will be invoked when data arrives
  82. * @v FinishCallback Callback that will be invoked when the download ends
  83. * @v Context Context passed to the Data and Finish callbacks
  84. * @v File Token that can be used to abort the download
  85. * @ret Status EFI status code
  86. */
  87. typedef
  88. EFI_STATUS
  89. (EFIAPI *IPXE_DOWNLOAD_START)(
  90. IN IPXE_DOWNLOAD_PROTOCOL *This,
  91. IN CHAR8 *Url,
  92. IN IPXE_DOWNLOAD_DATA_CALLBACK DataCallback,
  93. IN IPXE_DOWNLOAD_FINISH_CALLBACK FinishCallback,
  94. IN VOID *Context,
  95. OUT IPXE_DOWNLOAD_FILE *File
  96. );
  97. /**
  98. * Forcibly abort downloading a file that is currently in progress.
  99. *
  100. * It is not safe to call this function after the Finish callback has executed.
  101. *
  102. * @v This iPXE Download Protocol instance
  103. * @v File Token obtained from Start
  104. * @v Status Reason for aborting the download
  105. * @ret Status EFI status code
  106. */
  107. typedef
  108. EFI_STATUS
  109. (EFIAPI *IPXE_DOWNLOAD_ABORT)(
  110. IN IPXE_DOWNLOAD_PROTOCOL *This,
  111. IN IPXE_DOWNLOAD_FILE File,
  112. IN EFI_STATUS Status
  113. );
  114. /**
  115. * Poll for more data from iPXE. This function will invoke the registered
  116. * callbacks if data is available or if downloads complete.
  117. *
  118. * @v This iPXE Download Protocol instance
  119. * @ret Status EFI status code
  120. */
  121. typedef
  122. EFI_STATUS
  123. (EFIAPI *IPXE_DOWNLOAD_POLL)(
  124. IN IPXE_DOWNLOAD_PROTOCOL *This
  125. );
  126. /**
  127. * The iPXE Download Protocol.
  128. *
  129. * iPXE will attach a iPXE Download Protocol to the DeviceHandle in the Loaded
  130. * Image Protocol of all child EFI applications.
  131. */
  132. struct _IPXE_DOWNLOAD_PROTOCOL {
  133. IPXE_DOWNLOAD_START Start;
  134. IPXE_DOWNLOAD_ABORT Abort;
  135. IPXE_DOWNLOAD_POLL Poll;
  136. };
  137. #define IPXE_DOWNLOAD_PROTOCOL_GUID \
  138. { \
  139. 0x3eaeaebd, 0xdecf, 0x493b, { 0x9b, 0xd1, 0xcd, 0xb2, 0xde, 0xca, 0xe7, 0x19 } \
  140. }
  141. #endif