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