]> git.proxmox.com Git - mirror_edk2.git/blame - NetworkPkg/HttpBootDxe/HttpBootClient.h
NetworkPkg: Handling timeout case in httpboot 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
90f658c4 5(C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>\r
d933e70a
JW
6This program and the accompanying materials are licensed and made available under \r
7the terms and conditions of the BSD License that accompanies this distribution. \r
8The full text of the license may be found at\r
9http://opensource.org/licenses/bsd-license.php. \r
10 \r
11THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
12WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
13\r
14**/\r
15\r
16#ifndef __EFI_HTTP_BOOT_HTTP_H__\r
17#define __EFI_HTTP_BOOT_HTTP_H__\r
18\r
19#define HTTP_BOOT_REQUEST_TIMEOUT 5000 // 5 seconds in uints of millisecond.\r
7570696c 20#define HTTP_BOOT_RESPONSE_TIMEOUT 5000 // 5 seconds in uints of millisecond.\r
b5780309 21#define HTTP_BOOT_BLOCK_SIZE 1500\r
d933e70a 22\r
d933e70a
JW
23\r
24\r
25#define HTTP_USER_AGENT_EFI_HTTP_BOOT "UefiHttpBoot/1.0"\r
26\r
27//\r
28// Record the data length and start address of a data block.\r
29//\r
30typedef struct {\r
31 LIST_ENTRY Link; // Link to the EntityDataList in HTTP_BOOT_CACHE_CONTENT\r
32 UINT8 *Block; // If NULL, the data is in previous data block.\r
33 UINT8 *DataStart; // Point to somewhere in the Block\r
34 UINTN DataLength;\r
35} HTTP_BOOT_ENTITY_DATA;\r
36\r
37//\r
38// Structure for a cache item\r
39//\r
40typedef struct {\r
41 LIST_ENTRY Link; // Link to the CacheList in driver's private data.\r
42 EFI_HTTP_REQUEST_DATA *RequestData;\r
ef422fc5 43 HTTP_IO_RESPONSE_DATA *ResponseData; // Not include any message-body data.\r
587d204c 44 HTTP_BOOT_IMAGE_TYPE ImageType;\r
d933e70a
JW
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
587d204c 110 @param[out] ImageType The image type of the downloaded file.\r
d933e70a
JW
111\r
112 @retval EFI_SUCCESS The file was loaded.\r
113 @retval EFI_INVALID_PARAMETER BufferSize is NULL or Buffer Size is not NULL but Buffer is NULL.\r
114 @retval EFI_OUT_OF_RESOURCES Could not allocate needed resources\r
115 @retval EFI_BUFFER_TOO_SMALL The BufferSize is too small to read the current directory entry.\r
116 BufferSize has been updated with the size needed to complete\r
117 the request.\r
118 @retval Others Unexpected error happened.\r
119\r
120**/\r
121EFI_STATUS\r
122HttpBootGetBootFile (\r
123 IN HTTP_BOOT_PRIVATE_DATA *Private,\r
124 IN BOOLEAN HeaderOnly,\r
125 IN OUT UINTN *BufferSize,\r
587d204c
FS
126 OUT UINT8 *Buffer,\r
127 OUT HTTP_BOOT_IMAGE_TYPE *ImageType\r
d933e70a
JW
128 );\r
129\r
130/**\r
131 Clean up all cached data.\r
132\r
133 @param[in] Private The pointer to the driver's private data.\r
134\r
135**/\r
136VOID\r
137HttpBootFreeCacheList (\r
138 IN HTTP_BOOT_PRIVATE_DATA *Private\r
139 );\r
140\r
141#endif\r