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