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