Accepting request 587445 from home:michael-chang:branches:Base:System
- Fix UEFI HTTPS Boot from ISO installation image (bsc#1076132) * 0001-add-support-for-UEFI-network-protocols.patch OBS-URL: https://build.opensuse.org/request/show/587445 OBS-URL: https://build.opensuse.org/package/show/Base:System/grub2?expand=0&rev=294
This commit is contained in:
parent
1e655f7670
commit
52a7695689
@ -3,7 +3,7 @@ From: Michael Chang <mchang@suse.com>
|
||||
Date: Wed, 22 Feb 2017 14:27:50 +0800
|
||||
Subject: [PATCH] Support UEFI networking protocols
|
||||
|
||||
References: fate#320130, bsc#1015589
|
||||
References: fate#320130, bsc#1015589, bsc#1076132
|
||||
Patch-Mainline: no
|
||||
|
||||
V1:
|
||||
@ -16,13 +16,21 @@ V2:
|
||||
* Relaxed UEFI Protocol requirement
|
||||
* Support Intel OPA (Omni-Path Architecture) PXE Boot
|
||||
|
||||
V3:
|
||||
* Fix bufio in calculating address of next_buf
|
||||
* Check HTTP respond code
|
||||
* Use HEAD request method to test before GET
|
||||
* Finish HTTP transaction in one go
|
||||
* Fix bsc#1076132
|
||||
|
||||
---
|
||||
grub-core/Makefile.core.def | 18 +
|
||||
grub-core/io/bufio.c | 2 +-
|
||||
grub-core/kern/efi/efi.c | 96 ++-
|
||||
grub-core/net/drivers/efi/efinet.c | 27 +
|
||||
grub-core/net/efi/dhcp.c | 397 ++++++++++
|
||||
grub-core/net/efi/efi_netfs.c | 57 ++
|
||||
grub-core/net/efi/http.c | 360 +++++++++
|
||||
grub-core/net/efi/http.c | 419 +++++++++++
|
||||
grub-core/net/efi/ip4_config.c | 398 ++++++++++
|
||||
grub-core/net/efi/ip6_config.c | 422 +++++++++++
|
||||
grub-core/net/efi/net.c | 1428 ++++++++++++++++++++++++++++++++++++
|
||||
@ -33,7 +41,7 @@ V2:
|
||||
include/grub/efi/http.h | 215 ++++++
|
||||
include/grub/net/efi.h | 144 ++++
|
||||
util/grub-mknetdir.c | 23 +-
|
||||
16 files changed, 4567 insertions(+), 40 deletions(-)
|
||||
17 files changed, 4627 insertions(+), 41 deletions(-)
|
||||
create mode 100644 grub-core/net/efi/dhcp.c
|
||||
create mode 100644 grub-core/net/efi/efi_netfs.c
|
||||
create mode 100644 grub-core/net/efi/http.c
|
||||
@ -46,7 +54,7 @@ V2:
|
||||
create mode 100644 include/grub/net/efi.h
|
||||
|
||||
diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def
|
||||
index a65c27f..e93c772 100644
|
||||
index a65c27f7f..e93c77255 100644
|
||||
--- a/grub-core/Makefile.core.def
|
||||
+++ b/grub-core/Makefile.core.def
|
||||
@@ -2167,6 +2167,18 @@ module = {
|
||||
@ -81,8 +89,21 @@ index a65c27f..e93c772 100644
|
||||
};
|
||||
|
||||
module = {
|
||||
diff --git a/grub-core/io/bufio.c b/grub-core/io/bufio.c
|
||||
index 22438277d..d0b0f71b6 100644
|
||||
--- a/grub-core/io/bufio.c
|
||||
+++ b/grub-core/io/bufio.c
|
||||
@@ -132,7 +132,7 @@ grub_bufio_read (grub_file_t file, char *buf, grub_size_t len)
|
||||
return res;
|
||||
|
||||
/* Need to read some more. */
|
||||
- next_buf = (file->offset + res + len - 1) & ~((grub_off_t) bufio->block_size - 1);
|
||||
+ next_buf = (grub_divmod64 (file->offset + res + len - 1, bufio->block_size, NULL)) * bufio->block_size;
|
||||
/* Now read between file->offset + res and bufio->buffer_at. */
|
||||
if (file->offset + res < next_buf)
|
||||
{
|
||||
diff --git a/grub-core/kern/efi/efi.c b/grub-core/kern/efi/efi.c
|
||||
index d467785..0ceaa48 100644
|
||||
index d467785fc..0ceaa487c 100644
|
||||
--- a/grub-core/kern/efi/efi.c
|
||||
+++ b/grub-core/kern/efi/efi.c
|
||||
@@ -672,7 +672,7 @@ grub_efi_print_device_path (grub_efi_device_path_t *dp)
|
||||
@ -213,7 +234,7 @@ index d467785..0ceaa48 100644
|
||||
grub_printf ("/UnknownMessaging(%x)", (unsigned) subtype);
|
||||
break;
|
||||
diff --git a/grub-core/net/drivers/efi/efinet.c b/grub-core/net/drivers/efi/efinet.c
|
||||
index 82a28fb..f189209 100644
|
||||
index 82a28fb6e..f189209ba 100644
|
||||
--- a/grub-core/net/drivers/efi/efinet.c
|
||||
+++ b/grub-core/net/drivers/efi/efinet.c
|
||||
@@ -24,6 +24,7 @@
|
||||
@ -286,7 +307,7 @@ index 82a28fb..f189209 100644
|
||||
|
||||
diff --git a/grub-core/net/efi/dhcp.c b/grub-core/net/efi/dhcp.c
|
||||
new file mode 100644
|
||||
index 0000000..dbef63d
|
||||
index 000000000..dbef63d8c
|
||||
--- /dev/null
|
||||
+++ b/grub-core/net/efi/dhcp.c
|
||||
@@ -0,0 +1,397 @@
|
||||
@ -689,7 +710,7 @@ index 0000000..dbef63d
|
||||
+grub_command_func_t grub_efi_net_bootp6 = grub_cmd_efi_bootp6;
|
||||
diff --git a/grub-core/net/efi/efi_netfs.c b/grub-core/net/efi/efi_netfs.c
|
||||
new file mode 100644
|
||||
index 0000000..ef371d8
|
||||
index 000000000..ef371d885
|
||||
--- /dev/null
|
||||
+++ b/grub-core/net/efi/efi_netfs.c
|
||||
@@ -0,0 +1,57 @@
|
||||
@ -752,10 +773,10 @@ index 0000000..ef371d8
|
||||
+}
|
||||
diff --git a/grub-core/net/efi/http.c b/grub-core/net/efi/http.c
|
||||
new file mode 100644
|
||||
index 0000000..816a3cd
|
||||
index 000000000..3f61fd2fa
|
||||
--- /dev/null
|
||||
+++ b/grub-core/net/efi/http.c
|
||||
@@ -0,0 +1,360 @@
|
||||
@@ -0,0 +1,419 @@
|
||||
+
|
||||
+#include <grub/efi/api.h>
|
||||
+#include <grub/efi/efi.h>
|
||||
@ -858,7 +879,8 @@ index 0000000..816a3cd
|
||||
+ response_callback_done = 1;
|
||||
+}
|
||||
+
|
||||
+struct grub_efi_http_data
|
||||
+static grub_err_t
|
||||
+efihttp_request (grub_efi_http_t *http, char *server, char *name, int use_https, int headeronly, grub_off_t *file_size)
|
||||
+{
|
||||
+ grub_efi_http_request_data_t request_data;
|
||||
+ grub_efi_http_message_t request_message;
|
||||
@ -867,46 +889,34 @@ index 0000000..816a3cd
|
||||
+ grub_efi_http_message_t response_message;
|
||||
+ grub_efi_http_token_t response_token;
|
||||
+ grub_efi_http_header_t request_headers[3];
|
||||
+};
|
||||
+
|
||||
+static grub_err_t
|
||||
+grub_efihttp_open (struct grub_efi_net_device *dev,
|
||||
+ int prefer_ip6 __attribute__ ((unused)),
|
||||
+ grub_file_t file,
|
||||
+ const char *filename __attribute__ ((unused)),
|
||||
+ int type)
|
||||
+{
|
||||
+ grub_efi_status_t status;
|
||||
+ grub_uint32_t length, i;
|
||||
+ grub_efi_boot_services_t *b = grub_efi_system_table->boot_services;
|
||||
+ grub_efi_http_t *http = dev->http;
|
||||
+ char *url = NULL;
|
||||
+
|
||||
+ struct grub_efi_http_data *data = grub_malloc (sizeof (*data));
|
||||
+
|
||||
+ grub_memset (data, 0, sizeof (*data));
|
||||
+
|
||||
+ data->request_headers[0].field_name = (grub_efi_char8_t *)"Host";
|
||||
+ data->request_headers[0].field_value = (grub_efi_char8_t *)file->device->net->server;
|
||||
+ data->request_headers[1].field_name = (grub_efi_char8_t *)"Accept";
|
||||
+ data->request_headers[1].field_value = (grub_efi_char8_t *)"*/*";
|
||||
+ data->request_headers[2].field_name = (grub_efi_char8_t *)"User-Agent";
|
||||
+ data->request_headers[2].field_value = (grub_efi_char8_t *)"UefiHttpBoot/1.0";
|
||||
+ request_headers[0].field_name = (grub_efi_char8_t *)"Host";
|
||||
+ request_headers[0].field_value = (grub_efi_char8_t *)server;
|
||||
+ request_headers[1].field_name = (grub_efi_char8_t *)"Accept";
|
||||
+ request_headers[1].field_value = (grub_efi_char8_t *)"*/*";
|
||||
+ request_headers[2].field_name = (grub_efi_char8_t *)"User-Agent";
|
||||
+ request_headers[2].field_value = (grub_efi_char8_t *)"UefiHttpBoot/1.0";
|
||||
+
|
||||
+ {
|
||||
+ grub_efi_ipv6_address_t address;
|
||||
+ const char *rest;
|
||||
+ grub_efi_char16_t *ucs2_url;
|
||||
+ grub_size_t url_len, ucs2_url_len;
|
||||
+ const char *protocol = (type == 1) ? "https" : "http";
|
||||
+ const char *protocol = (use_https == 1) ? "https" : "http";
|
||||
+
|
||||
+ if (grub_efi_string_to_ip6_address (file->device->net->server, &address, &rest) && *rest == 0)
|
||||
+ url = grub_xasprintf ("%s://[%s]%s", protocol, file->device->net->server, file->device->net->name);
|
||||
+ if (grub_efi_string_to_ip6_address (server, &address, &rest) && *rest == 0)
|
||||
+ url = grub_xasprintf ("%s://[%s]%s", protocol, server, name);
|
||||
+ else
|
||||
+ url = grub_xasprintf ("%s://%s%s", protocol, file->device->net->server, file->device->net->name);
|
||||
+ url = grub_xasprintf ("%s://%s%s", protocol, server, name);
|
||||
+
|
||||
+ if (!url)
|
||||
+ {
|
||||
+ return grub_errno;
|
||||
+ }
|
||||
+
|
||||
+ url_len = grub_strlen (url);
|
||||
+ ucs2_url_len = url_len * GRUB_MAX_UTF16_PER_UTF8;
|
||||
@ -921,21 +931,21 @@ index 0000000..816a3cd
|
||||
+ ucs2_url_len = grub_utf8_to_utf16 (ucs2_url, ucs2_url_len, (grub_uint8_t *)url, url_len, NULL); /* convert string format from ascii to usc2 */
|
||||
+ ucs2_url[ucs2_url_len] = 0;
|
||||
+ grub_free (url);
|
||||
+ data->request_data.url = ucs2_url;
|
||||
+ request_data.url = ucs2_url;
|
||||
+ }
|
||||
+
|
||||
+ data->request_data.method = GRUB_EFI_HTTPMETHODGET;
|
||||
+ request_data.method = (headeronly > 0) ? GRUB_EFI_HTTPMETHODHEAD : GRUB_EFI_HTTPMETHODGET;
|
||||
+
|
||||
+ data->request_message.data.request = &data->request_data;
|
||||
+ data->request_message.header_count = 3;
|
||||
+ data->request_message.headers = data->request_headers;
|
||||
+ data->request_message.body_length = 0;
|
||||
+ data->request_message.body = NULL;
|
||||
+ request_message.data.request = &request_data;
|
||||
+ request_message.header_count = 3;
|
||||
+ request_message.headers = request_headers;
|
||||
+ request_message.body_length = 0;
|
||||
+ request_message.body = NULL;
|
||||
+
|
||||
+ /* request token */
|
||||
+ data->request_token.event = NULL;
|
||||
+ data->request_token.status = GRUB_EFI_NOT_READY;
|
||||
+ data->request_token.message = &data->request_message;
|
||||
+ request_token.event = NULL;
|
||||
+ request_token.status = GRUB_EFI_NOT_READY;
|
||||
+ request_token.message = &request_message;
|
||||
+
|
||||
+ request_callback_done = 0;
|
||||
+ status = efi_call_5 (b->create_event,
|
||||
@ -943,63 +953,63 @@ index 0000000..816a3cd
|
||||
+ GRUB_EFI_TPL_CALLBACK,
|
||||
+ grub_efi_http_request_callback,
|
||||
+ NULL,
|
||||
+ &data->request_token.event);
|
||||
+ &request_token.event);
|
||||
+
|
||||
+ if (status != GRUB_EFI_SUCCESS)
|
||||
+ {
|
||||
+ grub_free (data->request_data.url);
|
||||
+ grub_free (request_data.url);
|
||||
+ return grub_error (GRUB_ERR_IO, "Fail to create an event! status=0x%x\n", status);
|
||||
+ }
|
||||
+
|
||||
+ status = efi_call_2 (http->request, http, &data->request_token);
|
||||
+ status = efi_call_2 (http->request, http, &request_token);
|
||||
+
|
||||
+ if (status != GRUB_EFI_SUCCESS)
|
||||
+ {
|
||||
+ efi_call_1 (b->close_event, data->request_token.event);
|
||||
+ grub_free (data->request_data.url);
|
||||
+ efi_call_1 (b->close_event, request_token.event);
|
||||
+ grub_free (request_data.url);
|
||||
+ return grub_error (GRUB_ERR_IO, "Fail to send a request! status=0x%x\n", status);
|
||||
+ }
|
||||
+ /* TODO: Add Timeout */
|
||||
+ while (!request_callback_done)
|
||||
+ efi_call_1(http->poll, http);
|
||||
+
|
||||
+ data->response_data.status_code = GRUB_EFI_HTTP_STATUS_UNSUPPORTED_STATUS;
|
||||
+ data->response_message.data.response = &data->response_data;
|
||||
+ response_data.status_code = GRUB_EFI_HTTP_STATUS_UNSUPPORTED_STATUS;
|
||||
+ response_message.data.response = &response_data;
|
||||
+ /* herader_count will be updated by the HTTP driver on response */
|
||||
+ data->response_message.header_count = 0;
|
||||
+ response_message.header_count = 0;
|
||||
+ /* headers will be populated by the driver on response */
|
||||
+ data->response_message.headers = NULL;
|
||||
+ response_message.headers = NULL;
|
||||
+ /* use zero BodyLength to only receive the response headers */
|
||||
+ data->response_message.body_length = 0;
|
||||
+ data->response_message.body = NULL;
|
||||
+ data->response_token.event = NULL;
|
||||
+ response_message.body_length = 0;
|
||||
+ response_message.body = NULL;
|
||||
+ response_token.event = NULL;
|
||||
+
|
||||
+ status = efi_call_5 (b->create_event,
|
||||
+ GRUB_EFI_EVT_NOTIFY_SIGNAL,
|
||||
+ GRUB_EFI_TPL_CALLBACK,
|
||||
+ grub_efi_http_response_callback,
|
||||
+ NULL,
|
||||
+ &data->response_token.event);
|
||||
+ &response_token.event);
|
||||
+
|
||||
+ if (status != GRUB_EFI_SUCCESS)
|
||||
+ {
|
||||
+ efi_call_1 (b->close_event, data->request_token.event);
|
||||
+ grub_free (data->request_data.url);
|
||||
+ efi_call_1 (b->close_event, request_token.event);
|
||||
+ grub_free (request_data.url);
|
||||
+ return grub_error (GRUB_ERR_IO, "Fail to create an event! status=0x%x\n", status);
|
||||
+ }
|
||||
+
|
||||
+ data->response_token.status = GRUB_EFI_SUCCESS;
|
||||
+ data->response_token.message = &data->response_message;
|
||||
+ response_token.status = GRUB_EFI_SUCCESS;
|
||||
+ response_token.message = &response_message;
|
||||
+
|
||||
+ /* wait for HTTP response */
|
||||
+ response_callback_done = 0;
|
||||
+ status = efi_call_2 (http->response, http, &data->response_token);
|
||||
+ status = efi_call_2 (http->response, http, &response_token);
|
||||
+
|
||||
+ if (status != GRUB_EFI_SUCCESS)
|
||||
+ {
|
||||
+ efi_call_1 (b->close_event, data->response_token.event);
|
||||
+ efi_call_1 (b->close_event, data->request_token.event);
|
||||
+ grub_free (data->request_data.url);
|
||||
+ efi_call_1 (b->close_event, response_token.event);
|
||||
+ efi_call_1 (b->close_event, request_token.event);
|
||||
+ grub_free (request_data.url);
|
||||
+ return grub_error (GRUB_ERR_IO, "Fail to receive a response! status=%d\n", (int)status);
|
||||
+ }
|
||||
+
|
||||
@ -1007,33 +1017,136 @@ index 0000000..816a3cd
|
||||
+ while (!response_callback_done)
|
||||
+ efi_call_1 (http->poll, http);
|
||||
+
|
||||
+ /* check the HTTP status code */
|
||||
+ if (response_message.data.response->status_code != GRUB_EFI_HTTP_STATUS_200_OK)
|
||||
+ {
|
||||
+ grub_efi_http_status_code_t status_code = response_message.data.response->status_code;
|
||||
+
|
||||
+ if (response_message.headers)
|
||||
+ efi_call_1 (b->free_pool, response_message.headers);
|
||||
+ efi_call_1 (b->close_event, response_token.event);
|
||||
+ efi_call_1 (b->close_event, request_token.event);
|
||||
+ grub_free (request_data.url);
|
||||
+ if (status_code == GRUB_EFI_HTTP_STATUS_404_NOT_FOUND)
|
||||
+ {
|
||||
+ return grub_error (GRUB_ERR_FILE_NOT_FOUND, _("file `%s' not found"), name);
|
||||
+ }
|
||||
+ else
|
||||
+ {
|
||||
+ return grub_error (GRUB_ERR_NET_UNKNOWN_ERROR,
|
||||
+ _("unsupported uefi http status code 0x%x"), status_code);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (file_size)
|
||||
+ {
|
||||
+ int i;
|
||||
+ /* parse the length of the file from the ContentLength header */
|
||||
+ for (length = 0, i = 0; i < data->response_message.header_count; ++i)
|
||||
+ for (*file_size = 0, i = 0; i < (int)response_message.header_count; ++i)
|
||||
+ {
|
||||
+ if (!grub_strcmp((const char*)data->response_message.headers[i].field_name, "Content-Length"))
|
||||
+ if (!grub_strcmp((const char*)response_message.headers[i].field_name, "Content-Length"))
|
||||
+ {
|
||||
+ length = grub_strtoul((const char*)data->response_message.headers[i].field_value, 0, 10);
|
||||
+ *file_size = grub_strtoul((const char*)response_message.headers[i].field_value, 0, 10);
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ file->size = (grub_off_t)length;
|
||||
+ if (response_message.headers)
|
||||
+ efi_call_1 (b->free_pool, response_message.headers);
|
||||
+ efi_call_1 (b->close_event, response_token.event);
|
||||
+ efi_call_1 (b->close_event, request_token.event);
|
||||
+ grub_free (request_data.url);
|
||||
+
|
||||
+ return GRUB_ERR_NONE;
|
||||
+}
|
||||
+
|
||||
+static grub_ssize_t
|
||||
+efihttp_read (struct grub_efi_net_device *dev,
|
||||
+ char *buf,
|
||||
+ grub_size_t len)
|
||||
+{
|
||||
+ grub_efi_http_message_t response_message;
|
||||
+ grub_efi_http_token_t response_token;
|
||||
+
|
||||
+ grub_efi_status_t status;
|
||||
+ grub_size_t sum = 0;
|
||||
+ grub_efi_boot_services_t *b = grub_efi_system_table->boot_services;
|
||||
+ grub_efi_http_t *http = dev->http;
|
||||
+
|
||||
+ if (!len)
|
||||
+ {
|
||||
+ grub_error (GRUB_ERR_BUG, "Invalid arguments to EFI HTTP Read");
|
||||
+ return -1;
|
||||
+ }
|
||||
+
|
||||
+ efi_call_5 (b->create_event,
|
||||
+ GRUB_EFI_EVT_NOTIFY_SIGNAL,
|
||||
+ GRUB_EFI_TPL_CALLBACK,
|
||||
+ grub_efi_http_response_callback,
|
||||
+ NULL,
|
||||
+ &response_token.event);
|
||||
+
|
||||
+ while (len)
|
||||
+ {
|
||||
+ response_message.data.response = NULL;
|
||||
+ response_message.header_count = 0;
|
||||
+ response_message.headers = NULL;
|
||||
+ response_message.body_length = len;
|
||||
+ response_message.body = buf;
|
||||
+
|
||||
+ response_token.message = &response_message;
|
||||
+ response_token.status = GRUB_EFI_NOT_READY;
|
||||
+
|
||||
+ response_callback_done = 0;
|
||||
+
|
||||
+ status = efi_call_2 (http->response, http, &response_token);
|
||||
+ if (status != GRUB_EFI_SUCCESS)
|
||||
+ {
|
||||
+ efi_call_1 (b->close_event, response_token.event);
|
||||
+ grub_error (GRUB_ERR_IO, "Error! status=%d\n", (int)status);
|
||||
+ return -1;
|
||||
+ }
|
||||
+
|
||||
+ while (!response_callback_done)
|
||||
+ efi_call_1(http->poll, http);
|
||||
+
|
||||
+ sum += response_message.body_length;
|
||||
+ buf += response_message.body_length;
|
||||
+ len -= response_message.body_length;
|
||||
+ }
|
||||
+
|
||||
+ efi_call_1 (b->close_event, response_token.event);
|
||||
+
|
||||
+ return sum;
|
||||
+}
|
||||
+
|
||||
+static grub_err_t
|
||||
+grub_efihttp_open (struct grub_efi_net_device *dev,
|
||||
+ int prefer_ip6 __attribute__ ((unused)),
|
||||
+ grub_file_t file,
|
||||
+ const char *filename __attribute__ ((unused)),
|
||||
+ int type)
|
||||
+{
|
||||
+ grub_err_t err;
|
||||
+ grub_off_t size;
|
||||
+ char *buf;
|
||||
+
|
||||
+ err = efihttp_request (dev->http, file->device->net->server, file->device->net->name, type, 1, 0);
|
||||
+ if (err != GRUB_ERR_NONE)
|
||||
+ return err;
|
||||
+
|
||||
+ err = efihttp_request (dev->http, file->device->net->server, file->device->net->name, type, 0, &size);
|
||||
+ if (err != GRUB_ERR_NONE)
|
||||
+ return err;
|
||||
+
|
||||
+ buf = grub_malloc (size);
|
||||
+ efihttp_read (dev, buf, size);
|
||||
+
|
||||
+ file->size = size;
|
||||
+ file->data = buf;
|
||||
+ file->not_easily_seekable = 0;
|
||||
+ file->data = data;
|
||||
+ file->device->net->offset = 0;
|
||||
+
|
||||
+ /* release */
|
||||
+ /* On response, this array is allocated and
|
||||
+ populated by the HTTP driver. It is the responsibility of the caller
|
||||
+ to free this memory on both request and response. */
|
||||
+ if (data->response_message.headers)
|
||||
+ efi_call_1 (b->free_pool, data->response_message.headers);
|
||||
+
|
||||
+ efi_call_1 (b->close_event, data->response_token.event);
|
||||
+ efi_call_1 (b->close_event, data->request_token.event);
|
||||
+ grub_free (data->request_data.url);
|
||||
+
|
||||
+ return GRUB_ERR_NONE;
|
||||
+}
|
||||
+
|
||||
@ -1042,71 +1155,38 @@ index 0000000..816a3cd
|
||||
+ int prefer_ip6 __attribute__ ((unused)),
|
||||
+ grub_file_t file)
|
||||
+{
|
||||
+ struct grub_efi_http_data *data = file->data;
|
||||
+
|
||||
+ if (data)
|
||||
+ grub_free (data);
|
||||
+ if (file->data)
|
||||
+ grub_free (file->data);
|
||||
+
|
||||
+ file->data = 0;
|
||||
+ file->offset = 0;
|
||||
+ file->size = 0;
|
||||
+ file->device->net->offset = 0;
|
||||
+ return GRUB_ERR_NONE;
|
||||
+}
|
||||
+
|
||||
+static grub_ssize_t
|
||||
+grub_efihttp_read (struct grub_efi_net_device *dev,
|
||||
+grub_efihttp_read (struct grub_efi_net_device *dev __attribute__((unused)),
|
||||
+ int prefer_ip6 __attribute__((unused)),
|
||||
+ grub_file_t file,
|
||||
+ char *buf,
|
||||
+ grub_size_t len)
|
||||
+{
|
||||
+ grub_efi_status_t status;
|
||||
+ grub_size_t sum = 0;
|
||||
+ grub_efi_boot_services_t *b = grub_efi_system_table->boot_services;
|
||||
+ grub_efi_http_t *http = dev->http;
|
||||
+ struct grub_efi_http_data *data = file->data;
|
||||
+ grub_size_t r = len;
|
||||
+
|
||||
+ grub_memset (data, 0, sizeof (*data));
|
||||
+ efi_call_5 (b->create_event,
|
||||
+ GRUB_EFI_EVT_NOTIFY_SIGNAL,
|
||||
+ GRUB_EFI_TPL_CALLBACK,
|
||||
+ grub_efi_http_response_callback,
|
||||
+ NULL,
|
||||
+ &data->response_token.event);
|
||||
+ if (!file->data || !buf || !len)
|
||||
+ return 0;
|
||||
+
|
||||
+ while (len)
|
||||
+ if ((file->device->net->offset + len) > file->size)
|
||||
+ r = file->size - file->device->net->offset;
|
||||
+
|
||||
+ if (r)
|
||||
+ {
|
||||
+ data->response_message.data.response = NULL;
|
||||
+ data->response_message.header_count = 0;
|
||||
+ data->response_message.headers = NULL;
|
||||
+ data->response_message.body_length = len;
|
||||
+ data->response_message.body = buf;
|
||||
+
|
||||
+ data->response_token.message = &data->response_message;
|
||||
+ data->response_token.status = GRUB_EFI_NOT_READY;
|
||||
+
|
||||
+ response_callback_done = 0;
|
||||
+
|
||||
+ status = efi_call_2 (http->response, http, &data->response_token);
|
||||
+ if (status != GRUB_EFI_SUCCESS)
|
||||
+ {
|
||||
+ efi_call_1 (b->close_event, data->response_token.event);
|
||||
+ grub_error (GRUB_ERR_IO, "Error! status=%d\n", (int)status);
|
||||
+ return -1;
|
||||
+ grub_memcpy (buf, (char *)file->data + file->device->net->offset, r);
|
||||
+ file->device->net->offset += r;
|
||||
+ }
|
||||
+
|
||||
+ while (!response_callback_done)
|
||||
+ efi_call_1(http->poll, http);
|
||||
+
|
||||
+ file->device->net->offset += data->response_message.body_length;
|
||||
+ sum += data->response_message.body_length;
|
||||
+ buf += data->response_message.body_length;
|
||||
+ len -= data->response_message.body_length;
|
||||
+ }
|
||||
+
|
||||
+ efi_call_1 (b->close_event, data->response_token.event);
|
||||
+
|
||||
+ return sum;
|
||||
+ return r;
|
||||
+}
|
||||
+
|
||||
+struct grub_efi_net_io io_http =
|
||||
@ -1118,7 +1198,7 @@ index 0000000..816a3cd
|
||||
+ };
|
||||
diff --git a/grub-core/net/efi/ip4_config.c b/grub-core/net/efi/ip4_config.c
|
||||
new file mode 100644
|
||||
index 0000000..b711a5d
|
||||
index 000000000..b711a5d94
|
||||
--- /dev/null
|
||||
+++ b/grub-core/net/efi/ip4_config.c
|
||||
@@ -0,0 +1,398 @@
|
||||
@ -1522,7 +1602,7 @@ index 0000000..b711a5d
|
||||
+ };
|
||||
diff --git a/grub-core/net/efi/ip6_config.c b/grub-core/net/efi/ip6_config.c
|
||||
new file mode 100644
|
||||
index 0000000..017c4d0
|
||||
index 000000000..017c4d05b
|
||||
--- /dev/null
|
||||
+++ b/grub-core/net/efi/ip6_config.c
|
||||
@@ -0,0 +1,422 @@
|
||||
@ -1950,7 +2030,7 @@ index 0000000..017c4d0
|
||||
+ };
|
||||
diff --git a/grub-core/net/efi/net.c b/grub-core/net/efi/net.c
|
||||
new file mode 100644
|
||||
index 0000000..0bac343
|
||||
index 000000000..0bac343b4
|
||||
--- /dev/null
|
||||
+++ b/grub-core/net/efi/net.c
|
||||
@@ -0,0 +1,1428 @@
|
||||
@ -3384,7 +3464,7 @@ index 0000000..0bac343
|
||||
+}
|
||||
diff --git a/grub-core/net/efi/pxe.c b/grub-core/net/efi/pxe.c
|
||||
new file mode 100644
|
||||
index 0000000..4b6b48c
|
||||
index 000000000..4b6b48cb1
|
||||
--- /dev/null
|
||||
+++ b/grub-core/net/efi/pxe.c
|
||||
@@ -0,0 +1,424 @@
|
||||
@ -3813,7 +3893,7 @@ index 0000000..4b6b48c
|
||||
+ };
|
||||
+
|
||||
diff --git a/grub-core/net/net.c b/grub-core/net/net.c
|
||||
index 5cc0d2f..02bbe95 100644
|
||||
index 5cc0d2f3b..02bbe956b 100644
|
||||
--- a/grub-core/net/net.c
|
||||
+++ b/grub-core/net/net.c
|
||||
@@ -32,6 +32,9 @@
|
||||
@ -3923,7 +4003,7 @@ index 5cc0d2f..02bbe95 100644
|
||||
+#endif
|
||||
}
|
||||
diff --git a/include/grub/efi/api.h b/include/grub/efi/api.h
|
||||
index 99ba068..cfedd78 100644
|
||||
index 99ba068e3..cfedd7895 100644
|
||||
--- a/include/grub/efi/api.h
|
||||
+++ b/include/grub/efi/api.h
|
||||
@@ -588,6 +588,23 @@ typedef grub_uint16_t grub_efi_ipv6_address_t[8];
|
||||
@ -4175,7 +4255,7 @@ index 99ba068..cfedd78 100644
|
||||
|
||||
diff --git a/include/grub/efi/dhcp.h b/include/grub/efi/dhcp.h
|
||||
new file mode 100644
|
||||
index 0000000..fdb88eb
|
||||
index 000000000..fdb88eb81
|
||||
--- /dev/null
|
||||
+++ b/include/grub/efi/dhcp.h
|
||||
@@ -0,0 +1,343 @@
|
||||
@ -4524,7 +4604,7 @@ index 0000000..fdb88eb
|
||||
+#endif /* ! GRUB_EFI_DHCP_HEADER */
|
||||
diff --git a/include/grub/efi/http.h b/include/grub/efi/http.h
|
||||
new file mode 100644
|
||||
index 0000000..c5e9a89
|
||||
index 000000000..c5e9a89f5
|
||||
--- /dev/null
|
||||
+++ b/include/grub/efi/http.h
|
||||
@@ -0,0 +1,215 @@
|
||||
@ -4745,7 +4825,7 @@ index 0000000..c5e9a89
|
||||
+#endif /* !GRUB_EFI_HTTP_HEADER */
|
||||
diff --git a/include/grub/net/efi.h b/include/grub/net/efi.h
|
||||
new file mode 100644
|
||||
index 0000000..de90d22
|
||||
index 000000000..de90d223e
|
||||
--- /dev/null
|
||||
+++ b/include/grub/net/efi.h
|
||||
@@ -0,0 +1,144 @@
|
||||
@ -4894,7 +4974,7 @@ index 0000000..de90d22
|
||||
+
|
||||
+#endif /* ! GRUB_NET_EFI_HEADER */
|
||||
diff --git a/util/grub-mknetdir.c b/util/grub-mknetdir.c
|
||||
index 82073d5..ae31271 100644
|
||||
index 82073d5cc..ae31271bb 100644
|
||||
--- a/util/grub-mknetdir.c
|
||||
+++ b/util/grub-mknetdir.c
|
||||
@@ -32,13 +32,15 @@
|
||||
@ -4976,5 +5056,5 @@ index 82073d5..ae31271 100644
|
||||
if (!grub_install_source_directory)
|
||||
{
|
||||
--
|
||||
2.6.2
|
||||
2.13.6
|
||||
|
||||
|
@ -1,3 +1,9 @@
|
||||
-------------------------------------------------------------------
|
||||
Mon Mar 12 07:31:10 UTC 2018 - mchang@suse.com
|
||||
|
||||
- Fix UEFI HTTPS Boot from ISO installation image (bsc#1076132)
|
||||
* 0001-add-support-for-UEFI-network-protocols.patch
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Tue Mar 6 08:21:43 UTC 2018 - mchang@suse.com
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user