]> git.proxmox.com Git - mirror_edk2.git/blob - NetworkPkg/HttpBootDxe/HttpBootClient.h
2fd7dfc7160724ffd3d318ab508bceca09fea572
[mirror_edk2.git] / NetworkPkg / HttpBootDxe / HttpBootClient.h
1 /** @file
2 Declaration of the boot file download function.
3
4 Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>
5 (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>
6 This program and the accompanying materials are licensed and made available under
7 the terms and conditions of the BSD License that accompanies this distribution.
8 The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php.
10
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13
14 **/
15
16 #ifndef __EFI_HTTP_BOOT_HTTP_H__
17 #define __EFI_HTTP_BOOT_HTTP_H__
18
19 #define HTTP_BOOT_REQUEST_TIMEOUT 5000 // 5 seconds in uints of millisecond.
20 #define HTTP_BOOT_BLOCK_SIZE 1500
21
22
23
24 #define HTTP_USER_AGENT_EFI_HTTP_BOOT "UefiHttpBoot/1.0"
25
26 //
27 // Record the data length and start address of a data block.
28 //
29 typedef struct {
30 LIST_ENTRY Link; // Link to the EntityDataList in HTTP_BOOT_CACHE_CONTENT
31 UINT8 *Block; // If NULL, the data is in previous data block.
32 UINT8 *DataStart; // Point to somewhere in the Block
33 UINTN DataLength;
34 } HTTP_BOOT_ENTITY_DATA;
35
36 //
37 // Structure for a cache item
38 //
39 typedef struct {
40 LIST_ENTRY Link; // Link to the CacheList in driver's private data.
41 EFI_HTTP_REQUEST_DATA *RequestData;
42 HTTP_IO_RESPONSE_DATA *ResponseData; // Not include any message-body data.
43 HTTP_BOOT_IMAGE_TYPE ImageType;
44 UINTN EntityLength;
45 LIST_ENTRY EntityDataList; // Entity data (message-body)
46 } HTTP_BOOT_CACHE_CONTENT;
47
48 //
49 // Callback data for HTTP_BODY_PARSER_CALLBACK()
50 //
51 typedef struct {
52 EFI_STATUS Status;
53 //
54 // Cache info.
55 //
56 HTTP_BOOT_CACHE_CONTENT *Cache;
57 BOOLEAN NewBlock;
58 UINT8 *Block;
59
60 //
61 // Caller provided buffer to load the file in.
62 //
63 UINTN CopyedSize;
64 UINTN BufferSize;
65 UINT8 *Buffer;
66 } HTTP_BOOT_CALLBACK_DATA;
67
68 /**
69 Discover all the boot information for boot file.
70
71 @param[in, out] Private The pointer to the driver's private data.
72
73 @retval EFI_SUCCESS Successfully obtained all the boot information .
74 @retval Others Failed to retrieve the boot information.
75
76 **/
77 EFI_STATUS
78 HttpBootDiscoverBootInfo (
79 IN OUT HTTP_BOOT_PRIVATE_DATA *Private
80 );
81
82 /**
83 Create a HttpIo instance for the file download.
84
85 @param[in] Private The pointer to the driver's private data.
86
87 @retval EFI_SUCCESS Successfully created.
88 @retval Others Failed to create HttpIo.
89
90 **/
91 EFI_STATUS
92 HttpBootCreateHttpIo (
93 IN HTTP_BOOT_PRIVATE_DATA *Private
94 );
95
96 /**
97 This function download the boot file by using UEFI HTTP protocol.
98
99 @param[in] Private The pointer to the driver's private data.
100 @param[in] HeaderOnly Only request the response header, it could save a lot of time if
101 the caller only want to know the size of the requested file.
102 @param[in, out] BufferSize On input the size of Buffer in bytes. On output with a return
103 code of EFI_SUCCESS, the amount of data transferred to
104 Buffer. On output with a return code of EFI_BUFFER_TOO_SMALL,
105 the size of Buffer required to retrieve the requested file.
106 @param[out] Buffer The memory buffer to transfer the file to. IF Buffer is NULL,
107 then the size of the requested file is returned in
108 BufferSize.
109 @param[out] ImageType The image type of the downloaded file.
110
111 @retval EFI_SUCCESS The file was loaded.
112 @retval EFI_INVALID_PARAMETER BufferSize is NULL or Buffer Size is not NULL but Buffer is NULL.
113 @retval EFI_OUT_OF_RESOURCES Could not allocate needed resources
114 @retval EFI_BUFFER_TOO_SMALL The BufferSize is too small to read the current directory entry.
115 BufferSize has been updated with the size needed to complete
116 the request.
117 @retval Others Unexpected error happened.
118
119 **/
120 EFI_STATUS
121 HttpBootGetBootFile (
122 IN HTTP_BOOT_PRIVATE_DATA *Private,
123 IN BOOLEAN HeaderOnly,
124 IN OUT UINTN *BufferSize,
125 OUT UINT8 *Buffer,
126 OUT HTTP_BOOT_IMAGE_TYPE *ImageType
127 );
128
129 /**
130 Clean up all cached data.
131
132 @param[in] Private The pointer to the driver's private data.
133
134 **/
135 VOID
136 HttpBootFreeCacheList (
137 IN HTTP_BOOT_PRIVATE_DATA *Private
138 );
139
140 #endif