]>
Commit | Line | Data |
---|---|---|
d933e70a JW |
1 | /** @file\r |
2 | Declaration of the boot file download function.\r | |
3 | \r | |
95b5c32f | 4 | Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.<BR>\r |
90f658c4 | 5 | (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>\r |
d933e70a JW |
6 | This program and the accompanying materials are licensed and made available under \r |
7 | the terms and conditions of the BSD License that accompanies this distribution. \r | |
8 | The full text of the license may be found at\r | |
9 | http://opensource.org/licenses/bsd-license.php. \r | |
10 | \r | |
11 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r | |
12 | WITHOUT 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 | |
30 | typedef 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 | |
40 | typedef 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 | |
52 | typedef 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 | |
95b5c32f FS |
67 | \r |
68 | HTTP_BOOT_PRIVATE_DATA *Private;\r | |
d933e70a JW |
69 | } HTTP_BOOT_CALLBACK_DATA;\r |
70 | \r | |
71 | /**\r | |
72 | Discover all the boot information for boot file.\r | |
73 | \r | |
74 | @param[in, out] Private The pointer to the driver's private data.\r | |
75 | \r | |
76 | @retval EFI_SUCCESS Successfully obtained all the boot information .\r | |
77 | @retval Others Failed to retrieve the boot information.\r | |
78 | \r | |
79 | **/\r | |
80 | EFI_STATUS\r | |
81 | HttpBootDiscoverBootInfo (\r | |
82 | IN OUT HTTP_BOOT_PRIVATE_DATA *Private\r | |
83 | );\r | |
84 | \r | |
85 | /**\r | |
86 | Create a HttpIo instance for the file download.\r | |
87 | \r | |
88 | @param[in] Private The pointer to the driver's private data.\r | |
89 | \r | |
90 | @retval EFI_SUCCESS Successfully created.\r | |
91 | @retval Others Failed to create HttpIo.\r | |
92 | \r | |
93 | **/\r | |
94 | EFI_STATUS\r | |
95 | HttpBootCreateHttpIo (\r | |
96 | IN HTTP_BOOT_PRIVATE_DATA *Private\r | |
97 | );\r | |
98 | \r | |
99 | /**\r | |
100 | This function download the boot file by using UEFI HTTP protocol.\r | |
101 | \r | |
102 | @param[in] Private The pointer to the driver's private data.\r | |
103 | @param[in] HeaderOnly Only request the response header, it could save a lot of time if\r | |
104 | the caller only want to know the size of the requested file.\r | |
105 | @param[in, out] BufferSize On input the size of Buffer in bytes. On output with a return\r | |
106 | code of EFI_SUCCESS, the amount of data transferred to\r | |
107 | Buffer. On output with a return code of EFI_BUFFER_TOO_SMALL,\r | |
108 | the size of Buffer required to retrieve the requested file.\r | |
109 | @param[out] Buffer The memory buffer to transfer the file to. IF Buffer is NULL,\r | |
110 | then the size of the requested file is returned in\r | |
111 | BufferSize.\r | |
587d204c | 112 | @param[out] ImageType The image type of the downloaded file.\r |
d933e70a JW |
113 | \r |
114 | @retval EFI_SUCCESS The file was loaded.\r | |
115 | @retval EFI_INVALID_PARAMETER BufferSize is NULL or Buffer Size is not NULL but Buffer is NULL.\r | |
116 | @retval EFI_OUT_OF_RESOURCES Could not allocate needed resources\r | |
117 | @retval EFI_BUFFER_TOO_SMALL The BufferSize is too small to read the current directory entry.\r | |
118 | BufferSize has been updated with the size needed to complete\r | |
119 | the request.\r | |
120 | @retval Others Unexpected error happened.\r | |
121 | \r | |
122 | **/\r | |
123 | EFI_STATUS\r | |
124 | HttpBootGetBootFile (\r | |
125 | IN HTTP_BOOT_PRIVATE_DATA *Private,\r | |
126 | IN BOOLEAN HeaderOnly,\r | |
127 | IN OUT UINTN *BufferSize,\r | |
587d204c FS |
128 | OUT UINT8 *Buffer,\r |
129 | OUT HTTP_BOOT_IMAGE_TYPE *ImageType\r | |
d933e70a JW |
130 | );\r |
131 | \r | |
132 | /**\r | |
133 | Clean up all cached data.\r | |
134 | \r | |
135 | @param[in] Private The pointer to the driver's private data.\r | |
136 | \r | |
137 | **/\r | |
138 | VOID\r | |
139 | HttpBootFreeCacheList (\r | |
140 | IN HTTP_BOOT_PRIVATE_DATA *Private\r | |
141 | );\r | |
142 | \r | |
143 | #endif\r |