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