net: wget: let wget_with_dns work with dns disabled
Subsystems (3)
PATCH v7 1/14 net: wget: let wget_with_dns work with dns disabled
This was marked as TODO in the code:
- Enable use of wget_with_dns even if CMD_DNS is disabled if the given uri has the ip address for the http server.
- Move the check for CMD_DNS inside wget_with_dns.
- Rename wget_with_dns to wget_do_request
--- include/net-common.h | 7 +++++-- lib/efi_loader/efi_bootmgr.c | 2 +- net/lwip/wget.c | 4 ++-- net/net-common.c | 2 +- net/wget.c | 34 ++++++++++++++++++++-------------- 5 files changed, 29 insertions(+), 20 deletions(-)
include/net-common.h +5 -2
@@ -501,13 +501,16 @@ int dhcp_run(ulong addr, const char *fname, bool autoload);int do_tftpb (struct cmd_tbl *cmdtp,int flag,int argc,char *const argv[]);/** -* wget_with_dns() - runs dns host IP address resulution before wget +* wget_do_request() - sends a wget request +* +* Sends a wget request, if DNS resolution is enabled it resolves the +* given uri. * * @dst_addr: destination address to download the file * @uri: uri string of target file of wget * Return: zero on success, negative if failed */ -int wget_with_dns (ulong dst_addr,char *uri); +int wget_do_request (ulong dst_addr,char *uri);/** * wget_validate_uri() - varidate the uri *
lib/efi_loader/efi_bootmgr.c +1 -1
@@ -479,7 +479,7 @@ static efi_status_t try_load_from_uri_path(struct efi_device_path_uri *uridp, } image_addr =hextoul (s,NULL ); - err =wget_with_dns (image_addr, uridp->uri); + err =wget_do_request (image_addr, uridp->uri);if (err <0 ) { ret =EFI_INVALID_PARAMETER ; goto err;
net/lwip/wget.c +2 -2
@@ -353,7 +353,7 @@ static int wget_loop(struct udevice *udev, ulong dst_addr, char *uri)return -1 ; } -int wget_with_dns (ulong dst_addr,char *uri) +int wget_do_request (ulong dst_addr,char *uri) {eth_set_current ();
@@ -387,7 +387,7 @@ int do_wget(struct cmd_tbl *cmdtp, int flag, int argc, char * const argv[])return CMD_RET_FAILURE ; wget_info = &default_wget_info; -if (wget_with_dns (dst_addr, nurl)) +if (wget_do_request (dst_addr, nurl))return CMD_RET_FAILURE ;return CMD_RET_SUCCESS ;
net/net-common.c +1 -1
@@ -23,5 +23,5 @@ struct wget_http_info *wget_info;int wget_request (ulong dst_addr,char *uri,struct wget_http_info *info) { wget_info = info ? info : &default_wget_info; -return wget_with_dns (dst_addr, uri); +return wget_do_request (dst_addr, uri); }
net/wget.c +20 -14
@@ -535,8 +535,7 @@ void wget_start(void)wget_send (TCP_SYN ,0 ,0 ,0 ); } -#if (IS_ENABLED (CONFIG_CMD_DNS )) -int wget_with_dns (ulong dst_addr,char *uri) +int wget_do_request (ulong dst_addr,char *uri) {int ret;char *s, *host_name, *file_name, *str_copy;
@@ -555,24 +554,32 @@ int wget_with_dns(ulong dst_addr, char *uri) s = str_copy +strlen ("http://" ); host_name =strsep (&s,"/" );if (!s) { -log_err ("Error: invalied uri, no file path\n" ); ret = -EINVAL ; goto out; } file_name = s; -/* TODO: If the given uri has ip address for the http server, skip dns */ - net_dns_resolve = host_name; - net_dns_env_var ="httpserverip" ; -if (net_loop (DNS ) <0 ) { -log_err ("Error: dns lookup of %s failed, check setup\n" , net_dns_resolve); - ret = -EINVAL ; - goto out; - } - s =env_get ("httpserverip" ); -if (!s) { + host_name =strsep (&host_name,":" ); + +if (string_to_ip (host_name).s_addr) { + s = host_name; + }else { +#if IS_ENABLED (CONFIG_CMD_DNS ) + net_dns_resolve = host_name; + net_dns_env_var ="httpserverip" ; +if (net_loop (DNS ) <0 ) { + ret = -EINVAL ; + goto out; + } + s =env_get ("httpserverip" ); +if (!s) { + ret = -EINVAL ; + goto out; + } +#else ret = -EINVAL ; goto out; +#endif }strlcpy (net_boot_file_name, s,sizeof (net_boot_file_name));
@@ -586,7 +593,6 @@ out:return ret <0 ? ret :0 ; } -#endif /** * wget_validate_uri() - validate the uri for wget
Signature · 1 line
2.43.0
PATCH v7 2/14 efi_loader: device_path: add definition of DEVICE_PATH_SUB_TYPE_MSG_IPV4
Add definition for DEVICE_PATH_SUB_TYPE_MSG_IPV4 device path subtype.
--- include/efi_api.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
include/efi_api.h +17 -0
@@ -616,6 +616,7 @@ struct efi_device_path_acpi_path {# define DEVICE_PATH_SUB_TYPE_MSG_SCSI 0x02# define DEVICE_PATH_SUB_TYPE_MSG_USB 0x05# define DEVICE_PATH_SUB_TYPE_MSG_MAC_ADDR 0x0b +# define DEVICE_PATH_SUB_TYPE_MSG_IPV4 0x0c# define DEVICE_PATH_SUB_TYPE_MSG_UART 0x0e# define DEVICE_PATH_SUB_TYPE_MSG_USB_CLASS 0x0f# define DEVICE_PATH_SUB_TYPE_MSG_USB_WWI 0x10
@@ -691,6 +692,22 @@ struct efi_device_path_uri {u8 uri[]; } __packed; +struct efi_ipv4_address { +u8 ip_addr[4 ]; +}; + +struct efi_device_path_ipv4 { +struct efi_device_path dp; +struct efi_ipv4_address local_ip_address; +struct efi_ipv4_address remote_ip_address; +u16 local_port; +u16 remote_port; +u16 protocol; +u8 static_ip_address; +struct efi_ipv4_address gateway_ip_address; +struct efi_ipv4_address subnet_mask; +} __packed; +#define DEVICE_PATH_TYPE_MEDIA_DEVICE 0x04# define DEVICE_PATH_SUB_TYPE_HARD_DRIVE_PATH 0x01# define DEVICE_PATH_SUB_TYPE_CDROM_PATH 0x02
Signature · 1 line
2.43.0
PATCH v7 3/14 efi_loader: device_path: add efi_dp_from_ipv4
In reply to Adriano CordovaAdd efi_dp_from_ipv4 to form a device path from an ipv4 address.
--- lib/efi_loader/efi_device_path.c | 47 ++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+)
lib/efi_loader/efi_device_path.c +47 -0
@@ -974,6 +974,53 @@ struct efi_device_path __maybe_unused *efi_dp_from_eth(void)return start; } +/** +* efi_dp_from_ipv4() - set device path from IPv4 address +* +* Set the device path to an ethernet device path as provided by +* efi_dp_from_eth() concatenated with a device path of subtype +* DEVICE_PATH_SUB_TYPE_MSG_IPV4, and an END node. +* +* @ip: IPv4 local address +* @mask: network mask +* @srv: IPv4 remote/server address +* Return: pointer to device path, NULL on error +*/ +static struct efi_device_path *efi_dp_from_ipv4 (struct efi_ipv4_address *ip, +struct efi_ipv4_address *mask, +struct efi_ipv4_address *srv) +{ +struct efi_device_path *dp1, *dp2, *pos; +struct { +struct efi_device_path_ipv4 ipv4dp; +struct efi_device_path end; + } dp; + +memset (&dp.ipv4dp,0 ,sizeof (dp.ipv4dp)); + dp.ipv4dp.dp.type =DEVICE_PATH_TYPE_MESSAGING_DEVICE ; + dp.ipv4dp.dp.sub_type =DEVICE_PATH_SUB_TYPE_MSG_IPV4 ; + dp.ipv4dp.dp.length =sizeof (dp.ipv4dp); + dp.ipv4dp.protocol =6 ; +if (ip) +memcpy (&dp.ipv4dp.local_ip_address, ip,sizeof (*ip)); +if (mask) +memcpy (&dp.ipv4dp.subnet_mask, mask,sizeof (*mask)); +if (srv) +memcpy (&dp.ipv4dp.remote_ip_address, srv,sizeof (*srv)); + pos = &dp.end; +memcpy (pos, &END ,sizeof (END )); + + dp1 =efi_dp_from_eth (); +if (!dp1) +return NULL ; + + dp2 =efi_dp_concat (dp1, (const struct efi_device_path *)&dp,0 ); + +efi_free_pool (dp1); + +return dp2; +} +/* Construct a device-path for memory-mapped image */ struct efi_device_path *efi_dp_from_mem(uint32_t memory_type, uint64_t start_address,
Signature · 1 line
2.43.0
PATCH v7 4/14 efi_loader: add IPv4() to device path to text protocol
In reply to Adriano CordovaFrom: Heinrich Schuchardt <[email protected]>
Implement Ipv4() node support in the device path to text protocol.
--- lib/efi_loader/efi_device_path_to_text.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+)
lib/efi_loader/efi_device_path_to_text.c +23 -0
@@ -8,6 +8,7 @@#include <blk.h> #include <efi_loader.h> #include <malloc.h> +#include <net.h> #define MAC_OUTPUT_LEN 22#define UNKNOWN_OUTPUT_LEN 23
@@ -170,6 +171,28 @@ static char *dp_msging(char *s, struct efi_device_path *dp)break ; } +case DEVICE_PATH_SUB_TYPE_MSG_IPV4 : { +struct efi_device_path_ipv4 *idp = + (struct efi_device_path_ipv4 *)dp; + + s +=sprintf (s,"IPv4(%pI4," , &idp->remote_ip_address); +switch (idp->protocol) { +case IPPROTO_TCP : + s +=sprintf (s,"TCP," ); +case IPPROTO_UDP : + s +=sprintf (s,"UDP," ); +default : + s +=sprintf (s,"0x%x," , idp->protocol); + } + s +=sprintf (s, idp->static_ip_address ?"Static" :"DHCP" ); + s +=sprintf (s,",%pI4" , &idp->local_ip_address); +if (idp->dp.length ==sizeof (struct efi_device_path_ipv4 )) + s +=sprintf (s,",%pI4,%pI4" , &idp->gateway_ip_address, + &idp->subnet_mask); + s +=sprintf (s,")" ); + +break ; + }case DEVICE_PATH_SUB_TYPE_MSG_USB_CLASS : {struct efi_device_path_usb_class *ucdp = (struct efi_device_path_usb_class *)dp;
Signature · 1 line
2.43.0
PATCH v7 5/14 efi_api: add definitions for HTTP and IP4_CONFIG2 protocols
In reply to Adriano CordovaAdd EFI definitions for EFI_IP4_CONFIG2_PROTOCOL, EFI_HTTP_SERVICE_BINDING_PROTOCOL, and EFI_HTTP_PROTOCOL. According to UEFI spec 2.10.
--- include/efi_api.h | 203 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 203 insertions(+)
include/efi_api.h +203 -0
@@ -1725,6 +1725,209 @@ struct efi_pxe_base_code_protocol {struct efi_pxe_mode *mode; }; +#define EFI_IP4_CONFIG2_PROTOCOL_GUID \ + EFI_GUID(0x5b446ed1, 0xe30b, 0x4faa, \ + 0x87, 0x1a, 0x36, 0x54, 0xec, 0xa3, 0x60, 0x80) + +enum efi_ip4_config2_data_type { +EFI_IP4_CONFIG2_DATA_TYPE_INTERFACEINFO , +EFI_IP4_CONFIG2_DATA_TYPE_POLICY , +EFI_IP4_CONFIG2_DATA_TYPE_MANUAL_ADDRESS , +EFI_IP4_CONFIG2_DATA_TYPE_GATEWAY , +EFI_IP4_CONFIG2_DATA_TYPE_DNSSERVER , +EFI_IP4_CONFIG2_DATA_TYPE_MAXIMUM , +}; + +struct efi_ip4_config2_protocol { + efi_status_t (EFIAPI * set_data)(struct efi_ip4_config2_protocol *this, + enum efi_ip4_config2_data_type data_type, + efi_uintn_t data_size, + void *data); + efi_status_t (EFIAPI * get_data)(struct efi_ip4_config2_protocol *this, + enum efi_ip4_config2_data_type data_type, + efi_uintn_t *data_size, + void *data); + efi_status_t (EFIAPI * register_data_notify)(struct efi_ip4_config2_protocol *this, + enum efi_ip4_config2_data_type data_type, + struct efi_event *event); + efi_status_t (EFIAPI * unregister_data_notify)(struct efi_ip4_config2_protocol *this, + enum efi_ip4_config2_data_type data_type, + struct efi_event *event); +}; + +struct efi_ip4_route_table { +struct efi_ipv4_address subnet_address; +struct efi_ipv4_address subnet_mask; +struct efi_ipv4_address gateway_address; +}; + +#define EFI_IP4_CONFIG2_INTERFACE_INFO_NAME_SIZE 32 + +struct efi_ip4_config2_interface_info { +u16 name[EFI_IP4_CONFIG2_INTERFACE_INFO_NAME_SIZE ]; +u8 if_type; +u32 hw_address_size; +struct efi_mac_address hw_address; +struct efi_ipv4_address station_address; +struct efi_ipv4_address subnet_mask; +u32 route_table_size; +struct efi_ip4_route_table *route_table; +}; + +enum efi_ip4_config2_policy { +EFI_IP4_CONFIG2_POLICY_STATIC , +EFI_IP4_CONFIG2_POLICY_DHCP , +EFI_IP4_CONFIG2_POLICY_MAX +}; + +struct efi_ip4_config2_manual_address { +struct efi_ipv4_address address; +struct efi_ipv4_address subnet_mask; +}; + +#define EFI_HTTP_SERVICE_BINDING_PROTOCOL_GUID \ + EFI_GUID(0xbdc8e6af, 0xd9bc, 0x4379, \ + 0xa7, 0x2a, 0xe0, 0xc4, 0xe7, 0x5d, 0xae, 0x1c) + +struct efi_service_binding_protocol { + efi_status_t (EFIAPI * create_child)(struct efi_service_binding_protocol *this, + efi_handle_t *child_handle); + efi_status_t (EFIAPI * destroy_child)(struct efi_service_binding_protocol *this, + efi_handle_t child_handle); +}; + +#define EFI_HTTP_PROTOCOL_GUID \ + EFI_GUID(0x7A59B29B, 0x910B, 0x4171, \ + 0x82, 0x42, 0xA8, 0x5A, 0x0D, 0xF2, 0x5B, 0x5B) + +enum efi_http_version { +HTTPVERSION10 , +HTTPVERSION11 , +HTTPVERSIONUNSUPPORTED +}; + +struct efi_httpv4_access_point { +bool use_default_address; +struct efi_ipv4_address local_address; +struct efi_ipv4_address local_subnet; +u16 local_port; +}; + +union efi_http_access_point { +struct efi_httpv4_access_point *ipv4_node; +struct efi_httpv6_access_point *ipv6_node; +}; + +struct efi_http_config_data { +enum efi_http_version http_version; +u32 timeout; +bool is_ipv6; +union efi_http_access_point access_point; +}; + +enum efi_http_method { +HTTP_METHOD_GET , +HTTP_METHOD_POST , +HTTP_METHOD_PATCH , +HTTP_METHOD_OPTIONS , +HTTP_METHOD_CONNECT , +HTTP_METHOD_HEAD , +HTTP_METHOD_PUT , +HTTP_METHOD_DELETE , +HTTP_METHOD_TRACE , +HTTP_METHOD_MAX +}; + +enum efi_http_status_code { +HTTP_STATUS_UNSUPPORTED_STATUS =0 , +HTTP_STATUS_100_CONTINUE , +HTTP_STATUS_101_SWITCHING_PROTOCOLS , +HTTP_STATUS_200_OK , +HTTP_STATUS_201_CREATED , +HTTP_STATUS_202_ACCEPTED , +HTTP_STATUS_203_NON_AUTHORITATIVE_INFORMATION , +HTTP_STATUS_204_NO_CONTENT , +HTTP_STATUS_205_RESET_CONTENT , +HTTP_STATUS_206_PARTIAL_CONTENT , +HTTP_STATUS_300_MULTIPLE_CHOICES , +HTTP_STATUS_301_MOVED_PERMANENTLY , +HTTP_STATUS_302_FOUND , +HTTP_STATUS_303_SEE_OTHER , +HTTP_STATUS_304_NOT_MODIFIED , +HTTP_STATUS_305_USE_PROXY , +HTTP_STATUS_307_TEMPORARY_REDIRECT , +HTTP_STATUS_400_BAD_REQUEST , +HTTP_STATUS_401_UNAUTHORIZED , +HTTP_STATUS_402_PAYMENT_REQUIRED , +HTTP_STATUS_403_FORBIDDEN , +HTTP_STATUS_404_NOT_FOUND , +HTTP_STATUS_405_METHOD_NOT_ALLOWED , +HTTP_STATUS_406_NOT_ACCEPTABLE , +HTTP_STATUS_407_PROXY_AUTHENTICATION_REQUIRED , +HTTP_STATUS_408_REQUEST_TIME_OUT , +HTTP_STATUS_409_CONFLICT , +HTTP_STATUS_410_GONE , +HTTP_STATUS_411_LENGTH_REQUIRED , +HTTP_STATUS_412_PRECONDITION_FAILED , +HTTP_STATUS_413_REQUEST_ENTITY_TOO_LARGE , +HTTP_STATUS_414_REQUEST_URI_TOO_LARGE , +HTTP_STATUS_415_UNSUPPORTED_MEDIA_TYPE , +HTTP_STATUS_416_REQUESTED_RANGE_NOT_SATISFIED , +HTTP_STATUS_417_EXPECTATION_FAILED , +HTTP_STATUS_500_INTERNAL_SERVER_ERROR , +HTTP_STATUS_501_NOT_IMPLEMENTED , +HTTP_STATUS_502_BAD_GATEWAY , +HTTP_STATUS_503_SERVICE_UNAVAILABLE , +HTTP_STATUS_504_GATEWAY_TIME_OUT , +HTTP_STATUS_505_HTTP_VERSION_NOT_SUPPORTED , +HTTP_STATUS_308_PERMANENT_REDIRECT +}; + +struct efi_http_request_data { +enum efi_http_method method; +u16 *url; +}; + +struct efi_http_response_data { +enum efi_http_status_code status_code; +}; + +struct efi_http_header { +char *field_name; +char *field_value; +}; + +struct efi_http_message { +union { +struct efi_http_request_data *request; +struct efi_http_response_data *response; + } data; +efi_uintn_t header_count; +struct efi_http_header *headers; +efi_uintn_t body_length; +void *body; +}; + +struct efi_http_token { +struct efi_event *event; +efi_status_t status; +struct efi_http_message *message; +}; + +struct efi_http_protocol { + efi_status_t (EFIAPI * get_mode_data)(struct efi_http_protocol *this, + struct efi_http_config_data *data); + efi_status_t (EFIAPI * configure)(struct efi_http_protocol *this, + struct efi_http_config_data *data); + efi_status_t (EFIAPI * request)(struct efi_http_protocol *this, + struct efi_http_token *token); + efi_status_t (EFIAPI * cancel)(struct efi_http_protocol *this, + struct efi_http_token *token); + efi_status_t (EFIAPI * response)(struct efi_http_protocol *this, + struct efi_http_token *token); + efi_status_t (EFIAPI * poll)(struct efi_http_protocol *this); +}; +#define EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID \ EFI_GUID(0x964e5b22, 0x6459, 0x11d2, \ 0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b)
Signature · 1 line
2.43.0
PATCH v7 6/14 efi_loader: efi_net: add efi_net_set_addr, efi_net_get_addr
In reply to Adriano CordovaAdd the functions efi_net_set_addr and efi_net_get_addr to set and get the ip address from efi code in a network agnostic way. This could also go in net_common, or be compiled conditionally for each network stack.
---
(no changes since v5)
Changes in v5:
- When possible use sizeof in memcpy instead of hardcoded value
Changes in v4:
- Removed unnecessary casts
- Changed char *ipstr by char ipstr[].
(no changes since v2)
include/efi_loader.h | 16 +++++ lib/efi_loader/efi_net.c | 125 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 141 insertions(+)
include/efi_loader.h +16 -0
@@ -125,6 +125,22 @@ static inline void efi_set_bootdev(const char *dev, const char *devnr, size_t buffer_size) { }#endif +#if CONFIG_IS_ENABLED (NETDEVICES ) &&CONFIG_IS_ENABLED (EFI_LOADER ) +void efi_net_get_addr (struct efi_ipv4_address *ip, +struct efi_ipv4_address *mask, +struct efi_ipv4_address *gw); +void efi_net_set_addr (struct efi_ipv4_address *ip, +struct efi_ipv4_address *mask, +struct efi_ipv4_address *gw); +#else +static inline void efi_net_get_addr (struct efi_ipv4_address *ip, +struct efi_ipv4_address *mask, +struct efi_ipv4_address *gw) { } +static inline void efi_net_set_addr (struct efi_ipv4_address *ip, +struct efi_ipv4_address *mask, +struct efi_ipv4_address *gw) { } +#endif +/* Maximum number of configuration tables */ #define EFI_MAX_CONFIGURATION_TABLES 16
lib/efi_loader/efi_net.c +125 -0
134 lines not on this page · raw message
Signature · 1 line
2.43.0
PATCH v7 7/14 efi_loader: device_path: add support for HTTP device path
In reply to Adriano CordovaAdd efi_dp_from_http to form a device path from HTTP. The device path is the concatenation of the device path returned by efi_dp_from_ipv4 together with an URI node and an END node.
--- include/efi_loader.h | 1 + lib/efi_loader/efi_device_path.c | 64 ++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+)
include/efi_loader.h +1 -0
@@ -872,6 +872,7 @@ struct efi_device_path *efi_dp_part_node(struct blk_desc *desc, int part);struct efi_device_path *efi_dp_from_file (const struct efi_device_path *dp,const char *path);struct efi_device_path *efi_dp_from_eth (void ); +struct efi_device_path *efi_dp_from_http (const char *server);struct efi_device_path *efi_dp_from_mem (uint32_t mem_type,uint64_t start_address,size_t size);
lib/efi_loader/efi_device_path.c +64 -0
70 lines not on this page · raw message
Signature · 1 line
2.43.0
PATCH v7 8/14 efi_loader: net: set EFI bootdevice device path to HTTP when loaded from wget
In reply to Adriano CordovaSet the device path of the efi boot device to an HTTP device path (as formed by efi_dp_from_http) when the next boot stage is loaded using wget (i.e., when wget is used with wget_info.set_bootdev=1).
When loaded from HTTP, the device path should account for it so that the next boot stage is aware (e.g. grub only loads its http stack if it itself was loaded from http, and it checks this from its device path).
---
Changes in v7:
- Add a check before calling efi_net_set_dp in efi_set_bootdev Changes in v6:
- Add error handling to efi_net_set_dp and put it inside efi_set_bootdev, reducing the number of calls to efi functions outside efi code.
- Free net_dp before an update
- Complete documentation for efi_net_get_dp. Error handling: returns NULL on error Changes in v5:
- Add description of net_dp
- Change a void** for an efi_device_path**
(no changes since v2)
include/efi_loader.h | 5 +++ lib/efi_loader/efi_bootbin.c | 42 ++++++++++++++---------- lib/efi_loader/efi_device_path.c | 5 +-- lib/efi_loader/efi_net.c | 55 +++++++++++++++++++++++++++++++- net/lwip/wget.c | 5 ++- net/wget.c | 2 +- 6 files changed, 91 insertions(+), 23 deletions(-)
include/efi_loader.h +5 -0
@@ -126,6 +126,10 @@ static inline void efi_set_bootdev(const char *dev, const char *devnr,#endif #if CONFIG_IS_ENABLED (NETDEVICES ) &&CONFIG_IS_ENABLED (EFI_LOADER ) +/* Call this to update the current device path of the efi net device */ +efi_status_t efi_net_set_dp (const char *dev,const char *server); +/* Call this to get the current device path of the efi net device */ +void efi_net_get_dp (struct efi_device_path **dp);void efi_net_get_addr (struct efi_ipv4_address *ip,struct efi_ipv4_address *mask,struct efi_ipv4_address *gw);
@@ -133,6 +137,7 @@ void efi_net_set_addr(struct efi_ipv4_address *ip,struct efi_ipv4_address *mask, struct efi_ipv4_address *gw);#else +static inline void efi_net_get_dp (struct efi_device_path **dp) { }static inline void efi_net_get_addr (struct efi_ipv4_address *ip,struct efi_ipv4_address *mask,struct efi_ipv4_address *gw) { }
lib/efi_loader/efi_bootbin.c +26 -16
50 lines not on this page · raw message
lib/efi_loader/efi_device_path.c +3 -2
@@ -1185,8 +1185,9 @@ efi_status_t efi_dp_from_name(const char *dev, const char *devnr, dp =efi_dp_from_mem (EFI_RESERVED_MEMORY_TYPE , (uintptr_t )image_addr, image_size); - }else if (IS_ENABLED (CONFIG_NETDEVICES ) && !strcmp (dev,"Net" )) { - dp =efi_dp_from_eth (); + }else if (IS_ENABLED (CONFIG_NETDEVICES ) && + (!strcmp (dev,"Net" ) || !strcmp (dev,"Http" ))) { +efi_net_get_dp (&dp); }else if (!strcmp (dev,"Uart" )) { dp =efi_dp_from_uart (); }else {
lib/efi_loader/efi_net.c +54 -1
80 lines not on this page · raw message
net/lwip/wget.c +2 -3
@@ -260,10 +260,9 @@ static void httpc_result_cb(void *arg, httpc_result_t httpc_result,printf ("%u bytes transferred in %lu ms (" , rx_content_len, elapsed);print_size (rx_content_len / elapsed *1000 ,"/s)\n" );printf ("Bytes transferred = %lu (%lx hex)\n" , ctx->size, ctx->size); -if (wget_info->set_bootdev) { -efi_set_bootdev ("Net" ,"" , ctx->path,map_sysmem (ctx->saved_daddr,0 ), +if (wget_info->set_bootdev) +efi_set_bootdev ("Http" , ctx->server_name, ctx->path,map_sysmem (ctx->saved_daddr,0 ), rx_content_len); - }wget_lwip_set_file_size (rx_content_len);if (env_set_hex ("filesize" , rx_content_len) ||env_set_hex ("fileaddr" , ctx->saved_daddr)) {
net/wget.c +1 -1
@@ -447,7 +447,7 @@ static void wget_handler(uchar *pkt, u16 dport,net_set_state (wget_loop_state); wget_info->file_size = net_boot_file_size;if (wget_info->method ==WGET_HTTP_METHOD_GET && wget_info->set_bootdev) { -efi_set_bootdev ("Net" ,"" , image_url, +efi_set_bootdev ("Http" ,NULL , image_url,map_sysmem (image_load_addr,0 ), net_boot_file_size);env_set_hex ("filesize" , net_boot_file_size);
Signature · 1 line
2.43.0
Re: [PATCH v7 08/14] efi_loader: net: set EFI bootdevice device path to HTTP when loaded from wget
Quoted 10 lines · Adriano Cordova
Set the device path of the efi boot device to an HTTP device path (as formed by
efi_dp_from_http) when the next boot stage is loaded using wget (i.e., when wget is used with wget_info.set_bootdev=1).When loaded from HTTP, the device path should account for it so that the next boot stage is aware (e.g. grub only loads its http stack if it itself was loaded from http, and it checks this from its device path).
Signed-off-by Adriano Cordova <[email protected]>Reviewed-by Heinrich Schuchardt <[email protected]>
I know this is applied now, but after re-checking some things in one of my labs, this breaks test_efi_helloworld_builtin on rpi_3 at least (and possibly others). There is no output from "bootefi hello".
Signature · 1 line
Tom
Re: [PATCH v7 08/14] efi_loader: net: set EFI bootdevice device path to HTTP when loaded from wget
Quoted 10 lines · Tom Rini
Quoted 8 lines · Adriano Cordova
Set the device path of the efi boot device to an HTTP device path (as formed by
efi_dp_from_http) when the next boot stage is loaded using wget (i.e., when wget is used with wget_info.set_bootdev=1).When loaded from HTTP, the device path should account for it so that the next boot stage is aware (e.g. grub only loads its http stack if it itself was loaded from http, and it checks this from its device path).
Quoted 7 lines
Quoted 2 lines
Signed-off-by Adriano Cordova <[email protected]>Reviewed-by Heinrich Schuchardt <[email protected]>I know this is applied now, but after re-checking some things in one of my labs, this breaks
test_efi_helloworld_builtinonrpi_3at least (and possibly others). There is no output from "bootefi hello".
Hello Tom,
None of the Raspberry Pi 3 related defconfigs enables bootefi hello:
rpi_3_32b_defconfig # CONFIG_CMD_BOOTEFI_HELLO is not set rpi_3_defconfig # CONFIG_CMD_BOOTEFI_HELLO is not set rpi_3_b_plus_defconfig # CONFIG_CMD_BOOTEFI_HELLO is not set rpi_arm64_defconfig # CONFIG_CMD_BOOTEFI_HELLO is not set
Which configuration have you been testing?
Please, supply the .config and the related test log.
I just tested pinea64-lts_defconfig with CONFIG_CMD_BOOTEFI_HELLO=y and get
=> bootefi hello
Card did not respond to voltage select! : -110 Booting /MemoryMapped(0x0,0xbdfbe9b0,0xbdfc1b60) Hello, world!
Running on UEFI 2.10
Firmware vendor: Das U-Boot
Firmware revision: 20250100
Have device tree
Load options: <none>
File path: <none>
Boot device: /MemoryMapped(0x0,0xbdfbe9b0,0xbdfc1b60)
So there seems to be no generic problem.
Best regards
Heinrich
Re: [PATCH v7 08/14] efi_loader: net: set EFI bootdevice device path to HTTP when loaded from wget
Quoted 46 lines · Heinrich Schuchardt
Quoted 10 lines · Tom Rini
Quoted 8 lines · Adriano Cordova
Set the device path of the efi boot device to an HTTP device path (as formed by
efi_dp_from_http) when the next boot stage is loaded using wget (i.e., when wget is used with wget_info.set_bootdev=1).When loaded from HTTP, the device path should account for it so that the next boot stage is aware (e.g. grub only loads its http stack if it itself was loaded from http, and it checks this from its device path).
Quoted 7 lines
Quoted 2 lines
Signed-off-by Adriano Cordova <[email protected]>Reviewed-by Heinrich Schuchardt <[email protected]>I know this is applied now, but after re-checking some things in one of my labs, this breaks
test_efi_helloworld_builtinonrpi_3at least (and possibly others). There is no output from "bootefi hello".Hello Tom,
None of the Raspberry Pi 3 related defconfigs enables bootefi hello:
rpi_3_32b_defconfig#CONFIG_CMD_BOOTEFI_HELLOis not setrpi_3_defconfig#CONFIG_CMD_BOOTEFI_HELLOis not setrpi_3_b_plus_defconfig#CONFIG_CMD_BOOTEFI_HELLOis not setrpi_arm64_defconfig#CONFIG_CMD_BOOTEFI_HELLOis not setWhich configuration have you been testing?
Please, supply the .config and the related test log.
I just tested pinea64-lts_defconfig with
CONFIG_CMD_BOOTEFI_HELLO=yand get=> bootefi hello
Card did not respond to voltage select! : -110 Booting /MemoryMapped(0x0,0xbdfbe9b0,0xbdfc1b60) Hello, world!
Running on UEFI 2.10
Firmware vendor: Das U-Boot
Firmware revision: 20250100
Have device tree
Load options: <none>
File path: <none>
Boot device: /MemoryMapped(0x0,0xbdfbe9b0,0xbdfc1b60)
Quoted 1 line
So there seems to be no generic problem.
For testing as much as possible, I do enable a number of additional options (as well as building them with clang). In this case, please try also enabling CONFIG_CMD_WGET. I've narrowed my config changes down to adding both CONFIG_CMD_BOOTEFI_HELLO=y and CONFIG_CMD_WGET=y to rpi_3_defconfig which results in:
============================= test session starts ============================== platform linux -- Python 3.11.2, pytest-6.2.5, py-1.11.0, pluggy-0.13.0
rootdir: /home/trini/u-boot/u-boot/test/py, configfile: pytest.ini
plugins: forked-1.6.0, xdist-2.5.0
collected 478 items / 424 deselected / 54 selected
test/py/tests/test_efi_fit.py s [ 1%]test/py/tests/test_efi_loader.py .....F
=================================== FAILURES =================================== _________________________ test_efi_helloworld_builtin __________________________ test/py/tests/test_efi_loader.py:208: in test_efi_helloworld_builtin
assert expected_text in output
E AssertionError: assert 'Hello, world' in ''
----------------------------- Captured stdout call ----------------------------- U-Boot> bootefi hello
U-Boot>
=========================== short test summary info ============================ SKIPPED [1] test/py/conftest.py:620: .config feature "fit" not enabled FAILED test/py/tests/test_efi_loader.py::test_efi_helloworld_builtin - Assert... !!!!!!!!!!!!!!!!!!!!!!!!!! stopping after 1 failures !!!!!!!!!!!!!!!!!!!!!!!!!!! =========== 1 failed, 5 passed, 1 skipped, 424 deselected in 27.01s ============
Signature · 1 line
Tom
Re: [PATCH v7 08/14] efi_loader: net: set EFI bootdevice device path to HTTP when loaded from wget
Quoted 63 lines · Tom Rini
Quoted 46 lines · Heinrich Schuchardt
Quoted 10 lines · Tom Rini
Quoted 8 lines · Adriano Cordova
Set the device path of the efi boot device to an HTTP device path (as formed by
efi_dp_from_http) when the next boot stage is loaded using wget (i.e., when wget is used with wget_info.set_bootdev=1).When loaded from HTTP, the device path should account for it so that the next boot stage is aware (e.g. grub only loads its http stack if it itself was loaded from http, and it checks this from its device path).
Quoted 7 lines
Quoted 2 lines
Signed-off-by Adriano Cordova <[email protected]>Reviewed-by Heinrich Schuchardt <[email protected]>I know this is applied now, but after re-checking some things in one of my labs, this breaks
test_efi_helloworld_builtinonrpi_3at least (and possibly others). There is no output from "bootefi hello".Hello Tom,
None of the Raspberry Pi 3 related defconfigs enables bootefi hello:
rpi_3_32b_defconfig#CONFIG_CMD_BOOTEFI_HELLOis not setrpi_3_defconfig#CONFIG_CMD_BOOTEFI_HELLOis not setrpi_3_b_plus_defconfig#CONFIG_CMD_BOOTEFI_HELLOis not setrpi_arm64_defconfig#CONFIG_CMD_BOOTEFI_HELLOis not setWhich configuration have you been testing?
Please, supply the .config and the related test log.
I just tested pinea64-lts_defconfig with
CONFIG_CMD_BOOTEFI_HELLO=yand get=> bootefi hello
Card did not respond to voltage select! : -110 Booting /MemoryMapped(0x0,0xbdfbe9b0,0xbdfc1b60) Hello, world!
Running on UEFI 2.10
Firmware vendor: Das U-Boot
Firmware revision: 20250100
Have device tree
Load options: <none>
File path: <none>
Boot device: /MemoryMapped(0x0,0xbdfbe9b0,0xbdfc1b60)Quoted 1 line
So there seems to be no generic problem.
For testing as much as possible, I do enable a number of additional options (as well as building them with clang). In this case, please try also enabling
CONFIG_CMD_WGET. I've narrowed my config changes down to adding bothCONFIG_CMD_BOOTEFI_HELLO=yandCONFIG_CMD_WGET=ytorpi_3_defconfigwhich results in:
============================= test session starts ============================== platform linux -- Python 3.11.2, pytest-6.2.5, py-1.11.0, pluggy-0.13.0
rootdir:/home/trini/u-boot/u-boot/test/py, configfile: pytest.ini
plugins: forked-1.6.0, xdist-2.5.0
collected 478 items / 424 deselected / 54 selected
test/py/tests/test_efi_fit.pys [ 1%]test/py/tests/test_efi_loader.py.....F
Quoted 14 lines
=================================== FAILURES =================================== _________________________
test_efi_helloworld_builtin__________________________test/py/tests/test_efi_loader.py:208: intest_efi_helloworld_builtin
assertexpected_textin output
E AssertionError: assert 'Hello, world' in ''
----------------------------- Captured stdout call ----------------------------- U-Boot> bootefi hello
U-Boot>
=========================== short test summary info ============================ SKIPPED [1]test/py/conftest.py:620: .config feature "fit" not enabled FAILED test/py/tests/test_efi_loader.py::test_efi_helloworld_builtin - Assert... !!!!!!!!!!!!!!!!!!!!!!!!!! stopping after 1 failures !!!!!!!!!!!!!!!!!!!!!!!!!!! =========== 1 failed, 5 passed, 1 skipped, 424 deselected in 27.01s ============
Hello Adriano,
The following command sequence reproduces the problem on my Raspberry Pi 3:
U-Boot> setenv autoload no
U-Boot> dhcplan78xx_eth Waiting for PHY auto negotiation to complete...... done BOOTP broadcast 1
DHCP client bound to address 192.168.1.83 (109 ms) U-Boot> setenv autoload yes
U-Boot> tftpboot 192.168.1.2:/arm64/helloworld.efi lan78xx_eth Waiting for PHY auto negotiation to complete...... done Using lan78xx_eth device
TFTP from server 192.168.1.2; our IP address is 192.168.103.83 Filename '/arm64/helloworld.efi'.
Load address: 0x1000000
Loading: ################################################## 4.4 KiB
198.2 KiB/s
done
Bytes transferred = 4480 (1180 hex)
U-Boot> bootefi $loadaddr
Card did not respond to voltage select! : -110
Booting /\arm64\helloworld.efi
Hello, world!
Running on UEFI 2.:
Have device tree
Load options: <none>
U-Boot> wget 192.168.1.2:/hweb/arm64/helloworld.efi lan78xx_eth Waiting for PHY auto negotiation to complete...... done HTTP/1.1 200 OK
Packets received 7, Transfer Successful
Bytes transferred = 4480 (1180 hex)
U-Boot> bootefi $loadaddr
Booting /\hweb\arm64\helloworld.efi
Hello, world!
Running on UEFI 2.:
Have device tree
Load options: <none>
U-Boot> bootefi hello
U-Boot>
I was not able to reproduce the problem with only TFTP or only wget.
qemu_arm64_defconfig shows the same issue.
efi_install_multiple_protocol_interfaces() called in efi_run_image() returns EFI_ALREADY_STARTED.
With a debug message enabled we get this output:
Path /MemoryMapped(0x0,0x7f762d10,0x7f765ec0) already installed
We have to these things to check:
* Why do we miss to uninstall the memory device-path when executing 'bootefi $loadaddr'?
* Why do we generate a memory device-path for either TFTP or wget?
Best regards
Heinrich
Re: [PATCH v7 08/14] efi_loader: net: set EFI bootdevice device path to HTTP when loaded from wget
Hi Heinrich and Tom, thanks. I reproduced it in qemu too, there was a mistake in the way I was setting the network device path. I will send a patch.
Best,
Adriano
Quoted 152 lines · Heinrich Schuchardt
Quoted 11 lines · Tom Rini
Quoted 10 lines · Heinrich Schuchardt
Quoted 9 lines · Tom Rini
Quoted 7 lines · Adriano Cordova
Set the device path of the efi boot device to an HTTP device path (as formed by
efi_dp_from_http) when the next boot stage is loaded using wget (i.e., when wget is used with wget_info.set_bootdev=1).When loaded from HTTP, the device path should account for it so that the next boot stage is aware (e.g. grub only loads its http stack if it itself was loaded from http, and it checks this from its device
path).
Quoted 18 lines
Quoted 18 lines
Quoted 8 lines
Quoted 3 lines
Signed-off-by Adriano Cordova <[email protected]>Reviewed-by Heinrich Schuchardt <[email protected]>I know this is applied now, but after re-checking some things in one of my labs, this breaks
test_efi_helloworld_builtinonrpi_3at least (and possibly others). There is no output from "bootefi hello".Hello Tom,
None of the Raspberry Pi 3 related defconfigs enables bootefi hello:
rpi_3_32b_defconfig#CONFIG_CMD_BOOTEFI_HELLOis not setrpi_3_defconfig#CONFIG_CMD_BOOTEFI_HELLOis not setrpi_3_b_plus_defconfig#CONFIG_CMD_BOOTEFI_HELLOis not setrpi_arm64_defconfig#CONFIG_CMD_BOOTEFI_HELLOis not setQuoted 5 lines
Quoted 5 lines
Which configuration have you been testing?
Please, supply the .config and the related test log.
I just tested pinea64-lts_defconfig with
CONFIG_CMD_BOOTEFI_HELLO=yandget
Quoted 13 lines
Quoted 13 lines
=> bootefi hello
Card did not respond to voltage select! : -110 Booting /MemoryMapped(0x0,0xbdfbe9b0,0xbdfc1b60) Hello, world!
Running on UEFI 2.10
Firmware vendor: Das U-Boot
Firmware revision: 20250100
Have device tree
Load options: <none>
File path: <none>
Boot device: /MemoryMapped(0x0,0xbdfbe9b0,0xbdfc1b60)Quoted 8 lines
Quoted 1 line
So there seems to be no generic problem.
For testing as much as possible, I do enable a number of additional options (as well as building them with clang). In this case, please try also enabling
CONFIG_CMD_WGET. I've narrowed my config changes down to adding bothCONFIG_CMD_BOOTEFI_HELLO=yandCONFIG_CMD_WGET=ytorpi_3_defconfigwhich results in:
============================= test session starts==============================
Quoted 6 lines
platform linux -- Python 3.11.2, pytest-6.2.5, py-1.11.0, pluggy-0.13.0
rootdir:/home/trini/u-boot/u-boot/test/py, configfile: pytest.ini
plugins: forked-1.6.0, xdist-2.5.0
collected 478 items / 424 deselected / 54 selected
test/py/tests/test_efi_fit.pys[ 1%]
Quoted 3 lines
test/py/tests/test_efi_loader.py.....F=================================== FAILURES
===================================
Quoted 1 line
_________________________
test_efi_helloworld_builtin__________________________
Quoted 4 lines
test/py/tests/test_efi_loader.py:208: intest_efi_helloworld_builtin
assertexpected_textin output
E AssertionError: assert 'Hello, world' in ''
----------------------------- Captured stdout call-----------------------------
Quoted 3 lines
U-Boot> bootefi hello
U-Boot>
=========================== short test summary info============================
Quoted 2 lines
SKIPPED [1]
test/py/conftest.py:620: .config feature "fit" not enabled FAILED test/py/tests/test_efi_loader.py::test_efi_helloworld_builtin -Assert...
Quoted 1 line
!!!!!!!!!!!!!!!!!!!!!!!!!! stopping after 1 failures
!!!!!!!!!!!!!!!!!!!!!!!!!!!
Quoted 1 line
=========== 1 failed, 5 passed, 1 skipped, 424 deselected in 27.01s
============
Quoted 1 line
Hello Adriano,
The following command sequence reproduces the problem on my Raspberry Pi 3:
U-Boot> setenv autoload no
U-Boot> dhcplan78xx_ethWaiting for PHY auto negotiation to complete...... done BOOTP broadcast 1
DHCP client bound to address 192.168.1.83 (109 ms) U-Boot> setenv autoload yes
U-Boot> tftpboot 192.168.1.2:/arm64/helloworld.efilan78xx_ethWaiting for PHY auto negotiation to complete...... done Usinglan78xx_ethdevice
TFTP from server 192.168.1.2; our IP address is 192.168.103.83 Filename '/arm64/helloworld.efi'.
Load address:0x1000000
Loading: ################################################## 4.4 KiB198.2 KiB/sdone
Bytes transferred = 4480 (1180 hex)
U-Boot> bootefi $loadaddr
Card did not respond to voltage select! : -110
Booting /\arm64\helloworld.efi
Hello, world!
Running on UEFI 2.:
Have device tree
Load options: <none>
U-Boot> wget 192.168.1.2:/hweb/arm64/helloworld.efilan78xx_ethWaiting for PHY auto negotiation to complete...... done HTTP/1.1 200 OK
Packets received 7, Transfer Successful
Bytes transferred = 4480 (1180 hex)
U-Boot> bootefi $loadaddr
Booting /\hweb\arm64\helloworld.efi
Hello, world!
Running on UEFI 2.:
Have device tree
Load options: <none>
U-Boot> bootefi hello
U-Boot>I was not able to reproduce the problem with only TFTP or only wget.
qemu_arm64_defconfigshows the same issue.
efi_install_multiple_protocol_interfaces()called inefi_run_image()returnsEFI_ALREADY_STARTED.With a debug message enabled we get this output:
Path /MemoryMapped(0x0,0x7f762d10,0x7f765ec0) already installed
We have to these things to check:
* Why do we miss to uninstall the memory device-path when executing 'bootefi $loadaddr'?
* Why do we generate a memory device-path for either TFTP or wget?Best regards
Heinrich
PATCH v7 9/14 efi_loader: net: add support to send http requests and parse http headers
In reply to Adriano CordovaAdd network-stack agnostic way to send an http request and parse http headers from efi drivers. This uses wget as a backend and communicates with it via efi_wget_info.
The function efi_net_do_request allocates a buffer on behalf of an efi application using efi_alloc and passes it to wget to receive the data. If the method is GET and the buffer is too small, it re-allocates the buffer based on the last received Content-Length header and tries again. If the method is HEAD it just issues one request. So issuing a HEAD request (to update Content-Length) and then a GET request is preferred but not required.
The function efi_net_parse_headers parses a raw buffer containing an http header into an array of EFI specific 'http_header' structs.
---
(no changes since v4)
Changes in v4:
- Remove void* casts
- Add documentation
Changes in v3:
- Add a struct wget_http_info efi_wget_info for efi_net to pass to wget when issuing wget requests, instead of using the old wget_info (see v2 of the series 'wget: Expose wget to applications').
- Let a pointer to the http status code be passed to efi_net_do_request for it to fill it for the client after a request.
include/efi_loader.h | 13 ++++ lib/efi_loader/efi_net.c | 155 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 168 insertions(+)
include/efi_loader.h +13 -0
@@ -16,6 +16,7 @@#include <image.h> #include <pe.h> #include <linux/list.h> +#include <linux/sizes.h> #include <linux/oid_registry.h> struct blk_desc ;
@@ -136,6 +137,18 @@ void efi_net_get_addr(struct efi_ipv4_address *ip,void efi_net_set_addr (struct efi_ipv4_address *ip,struct efi_ipv4_address *mask,struct efi_ipv4_address *gw); +efi_status_t efi_net_do_request (u8 *url,enum efi_http_method method,void **buffer, +u32 *status_code,ulong *file_size,char *headers_buffer); +#define MAX_HTTP_HEADERS_SIZE SZ_64K +#define MAX_HTTP_HEADERS 100 +#define MAX_HTTP_HEADER_NAME 128 +#define MAX_HTTP_HEADER_VALUE 512 +struct http_header { +uchar name[MAX_HTTP_HEADER_NAME ]; +uchar value[MAX_HTTP_HEADER_VALUE ]; +}; + +void efi_net_parse_headers (ulong *num_headers,struct http_header *headers);#else static inline void efi_net_get_dp (struct efi_device_path **dp) { } static inline void efi_net_get_addr(struct efi_ipv4_address *ip,
lib/efi_loader/efi_net.c +155 -0
170 lines not on this page · raw message
Signature · 1 line
2.43.0
PATCH v7 10/14 efi_loader: efi_net: add EFI_IP4_CONFIG2_PROTOCOL
In reply to Adriano CordovaAdd an implementation of the EFI_IP4_CONFIG2_PROTOCOL. The protocol is attached to the handle of the efi network device. This is the same handle where snp and pxe are attached to.
---
Changes in v7:
- Changed some EFI_INVALID_PARAMETER for EFI_BAD_BUFFER_SIZE (no changes since v4)
Changes in v4:
- efi_ipconfig.c is compiled if ARCH_QEMU || SANDBOX
- An #ifdef changed to IF_ENABLED
- Removed a log_err
- Reworked sanity checks in efi_ip4_config2_set_data
include/efi_loader.h | 3 + lib/efi_loader/Kconfig | 9 ++ lib/efi_loader/Makefile | 1 + lib/efi_loader/efi_ipconfig.c | 214 ++++++++++++++++++++++++++++++++++ lib/efi_loader/efi_net.c | 20 +++- 5 files changed, 242 insertions(+), 5 deletions(-) create mode 100644 lib/efi_loader/efi_ipconfig.c
include/efi_loader.h +3 -0
@@ -626,6 +626,9 @@ int efi_disk_create_partitions(efi_handle_t parent, struct blk_desc *desc,efi_status_t efi_gop_register (void );/* Called by bootefi to make the network interface available */ efi_status_t efi_net_register (void ); +/* Called by efi_net_register to make the ip4 config2 protocol available */ +efi_status_t efi_ipconfig_register (const efi_handle_t handle, +struct efi_ip4_config2_protocol *ip4config);/* Called by bootefi to make the watchdog available */ efi_status_t efi_watchdog_register (void );efi_status_t efi_initrd_register (void );
lib/efi_loader/Kconfig +9 -0
@@ -476,6 +476,15 @@ config EFI_RISCV_BOOT_PROTOCOL replace the transfer via the device-tree. The latter is not possible on systems using ACPI. +config EFI_IP4_CONFIG2_PROTOCOL + bool "EFI_IP4_CONFIG2_PROTOCOL support" + default y if ARCH_QEMU || SANDBOX + depends on NET || NET_LWIP + help + Provides an implementation of the EFI_IP4_CONFIG2_PROTOCOL, this + protocol can be used to set and get the current ip address and + other network information. + endmenu menu "Misc options"
lib/efi_loader/Makefile +1 -0
@@ -59,6 +59,7 @@ obj-$(CONFIG_EFI_ESRT) += efi_esrt.o obj-$(CONFIG_VIDEO) += efi_gop.o obj-$(CONFIG_BLK) += efi_disk.o obj-$(CONFIG_NETDEVICES) += efi_net.o +obj-$(CONFIG_EFI_IP4_CONFIG2_PROTOCOL) += efi_ipconfig.o obj-$(CONFIG_ACPI) += efi_acpi.o obj-$(CONFIG_SMBIOS) += efi_smbios.o obj-$(CONFIG_EFI_RNG_PROTOCOL) += efi_rng.o
lib/efi_loader/efi_ipconfig.c new file +214 -0
214 lines not on this page · raw message
lib/efi_loader/efi_net.c +15 -5
@@ -60,11 +60,12 @@ static struct efi_event *wait_for_packet;/** * struct efi_net_obj - EFI object representing a network interface * -* @header: EFI object header -* @net: simple network protocol interface -* @net_mode: status of the network interface -* @pxe: PXE base code protocol interface -* @pxe_mode: status of the PXE base code protocol +* @header: EFI object header +* @net: simple network protocol interface +* @net_mode: status of the network interface +* @pxe: PXE base code protocol interface +* @pxe_mode: status of the PXE base code protocol +* @ip4_config2: IP4 Config2 protocol interface */ struct efi_net_obj {struct efi_object header;
@@ -72,6 +73,9 @@ struct efi_net_obj {struct efi_simple_network_mode net_mode;struct efi_pxe_base_code_protocol pxe;struct efi_pxe_mode pxe_mode; +#if IS_ENABLED (CONFIG_EFI_IP4_CONFIG2_PROTOCOL ) +struct efi_ip4_config2_protocol ip4_config2; +#endif };/*
@@ -999,6 +1003,12 @@ efi_status_t efi_net_register(void)return r; } +#if IS_ENABLED (CONFIG_EFI_IP4_CONFIG2_PROTOCOL ) + r =efi_ipconfig_register (&netobj->header, &netobj->ip4_config2); +if (r !=EFI_SUCCESS ) + goto failure_to_add_protocol; +#endif +return EFI_SUCCESS ; failure_to_add_protocol:printf ("ERROR: Failure to add protocol\n" );
Signature · 1 line
2.43.0
PATCH v7 11/14 efi_loader: efi_net: add EFI_HTTP_PROTOCOL
In reply to Adriano CordovaAdd an EFI HTTP driver. This commit implements the EFI_HTTP_PROTOCOL and the EFI_HTTP_SERVICE_BINDING_PROTOCOL. The latter is attached to the handle of th efi network device. This is the same handle where snp, pxe, and ipconfig are attached to.
---
(no changes since v4)
Changes in v4:
- Reworked pointers to be void * instead of ulong.
- Removed some console output
- Check invalid parameters at the beginning, and do not signal an event in case parameters are invalid.
Changes in v3:
- Add documentation
- Clean up the way the buffer pointed to http_load_addr in the current http instance was being freed.
- Remove unnecessary initialization new_instance->handle = NULL in efi_http_service_binding_create_child.
include/efi_loader.h | 3 + lib/efi_loader/Kconfig | 8 + lib/efi_loader/Makefile | 1 + lib/efi_loader/efi_http.c | 548 ++++++++++++++++++++++++++++++++++++++ lib/efi_loader/efi_net.c | 20 +- 5 files changed, 578 insertions(+), 2 deletions(-) create mode 100644 lib/efi_loader/efi_http.c
include/efi_loader.h +3 -0
@@ -629,6 +629,9 @@ efi_status_t efi_net_register(void);/* Called by efi_net_register to make the ip4 config2 protocol available */ efi_status_t efi_ipconfig_register (const efi_handle_t handle,struct efi_ip4_config2_protocol *ip4config); +/* Called by efi_net_register to make the http protocol available */ +efi_status_t efi_http_register (const efi_handle_t handle, +struct efi_service_binding_protocol *http_service_binding);/* Called by bootefi to make the watchdog available */ efi_status_t efi_watchdog_register (void );efi_status_t efi_initrd_register (void );
lib/efi_loader/Kconfig +8 -0
@@ -485,6 +485,14 @@ config EFI_IP4_CONFIG2_PROTOCOL protocol can be used to set and get the current ip address and other network information. +config EFI_HTTP_PROTOCOL + bool "EFI_HTTP_PROTOCOL support" + default y if ARCH_QEMU || SANDBOX + depends on WGET + help + Provides an EFI HTTP driver implementing the EFI_HTTP_PROTOCOL. and + EFI_HTTP_SERVICE_BINDING_PROTOCOL. + endmenu menu "Misc options"
lib/efi_loader/Makefile +1 -0
@@ -60,6 +60,7 @@ obj-$(CONFIG_VIDEO) += efi_gop.o obj-$(CONFIG_BLK) += efi_disk.o obj-$(CONFIG_NETDEVICES) += efi_net.o obj-$(CONFIG_EFI_IP4_CONFIG2_PROTOCOL) += efi_ipconfig.o +obj-$(CONFIG_EFI_HTTP_PROTOCOL) += efi_http.o obj-$(CONFIG_ACPI) += efi_acpi.o obj-$(CONFIG_SMBIOS) += efi_smbios.o obj-$(CONFIG_EFI_RNG_PROTOCOL) += efi_rng.o
lib/efi_loader/efi_http.c new file +548 -0
548 lines not on this page · raw message
lib/efi_loader/efi_net.c +18 -2
@@ -66,6 +66,7 @@ static struct efi_event *wait_for_packet;* @pxe: PXE base code protocol interface * @pxe_mode: status of the PXE base code protocol * @ip4_config2: IP4 Config2 protocol interface +* @http_service_binding: Http service binding protocol interface */ struct efi_net_obj {struct efi_object header;
@@ -76,6 +77,9 @@ struct efi_net_obj {#if IS_ENABLED (CONFIG_EFI_IP4_CONFIG2_PROTOCOL )struct efi_ip4_config2_protocol ip4_config2;#endif +#if IS_ENABLED (CONFIG_EFI_HTTP_PROTOCOL ) +struct efi_service_binding_protocol http_service_binding; +#endif };/*
@@ -1009,6 +1013,19 @@ efi_status_t efi_net_register(void) goto failure_to_add_protocol;#endif +#ifdef CONFIG_EFI_HTTP_PROTOCOL + r =efi_http_register (&netobj->header, &netobj->http_service_binding); +if (r !=EFI_SUCCESS ) + goto failure_to_add_protocol; +/* +* No harm on doing the following. If the PXE handle is present, the client could +* find it and try to get its IP address from it. In here the PXE handle is present +* but the PXE protocol is not yet implmenented, so we add this in the meantime. +*/ +efi_net_get_addr ((struct efi_ipv4_address *)&netobj->pxe_mode.station_ip, + (struct efi_ipv4_address *)&netobj->pxe_mode.subnet_mask,NULL ); +#endif +return EFI_SUCCESS ; failure_to_add_protocol:printf ("ERROR: Failure to add protocol\n" );
@@ -1207,8 +1224,6 @@ static efi_status_t efi_net_set_buffer(void **buffer, size_t size)if (size <SZ_64K ) size =SZ_64K ; -efi_free_pool (*buffer); - *buffer =efi_alloc (size);if (!*buffer) ret =EFI_OUT_OF_RESOURCES ;
@@ -1305,6 +1320,7 @@ efi_status_t efi_net_do_request(u8 *url, enum efi_http_method method, void **buf wget_ret =wget_request ((ulong)*buffer, url, &efi_wget_info);if ((ulong )efi_wget_info.hdr_cont_len > efi_wget_info.buffer_size) {// Try again with updated buffer size +efi_free_pool (*buffer); ret =efi_net_set_buffer (buffer, (size_t )efi_wget_info.hdr_cont_len);if (ret !=EFI_SUCCESS ) goto out;
Signature · 1 line
2.43.0
PATCH v7 12/14 lib: uuid: display HTTP and IPV4 Config II protocols
In reply to Adriano CordovaFrom: Heinrich Schuchardt <[email protected]>
Add long texts for
* EFI HTTP Protocol
* EFI HTTP Service Binding Protocol
* EFI IPv4 Configuration II Protocol
to the uuid library.
---
(no changes since v2)
lib/uuid.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
lib/uuid.c +14 -0
@@ -175,6 +175,20 @@ static const struct {"Firmware Management" ,EFI_FIRMWARE_MANAGEMENT_PROTOCOL_GUID }, +#if IS_ENABLED(CONFIG_EFI_HTTP_PROTOCOL) + { +"HTTP" , +EFI_HTTP_PROTOCOL_GUID , + }, + { +"HTTP Service Binding" , +EFI_HTTP_SERVICE_BINDING_PROTOCOL_GUID , + }, + { +"IPv4 Config2" , +EFI_IP4_CONFIG2_PROTOCOL_GUID , + }, +#endif /* Configuration table GUIDs */ { "ACPI table",
Signature · 1 line
2.43.0
PATCH v7 13/14 efi_selftest: add test for HTTP protocol
In reply to Adriano CordovaAdd a test for the EFI_HTTP_PROTOCOL andEFI_SEVICE_BINDING_PROTOCOL.
---
Changes in v7:
- Fixed sizeof() calls when possible
- When setting up the test, check if any handle was found before looping through the handles.
(no changes since v2)
lib/efi_selftest/Makefile | 2 +- lib/efi_selftest/efi_selftest_http.c | 321 +++++++++++++++++++++++++++ 2 files changed, 322 insertions(+), 1 deletion(-) create mode 100644 lib/efi_selftest/efi_selftest_http.c
lib/efi_selftest/Makefile +1 -1
@@ -52,7 +52,7 @@ efi_selftest_watchdog.o obj-$(CONFIG_EFI_ECPT) += efi_selftest_ecpt.o obj-$(CONFIG_NETDEVICES) += efi_selftest_snp.o - +obj-$(CONFIG_EFI_HTTP_PROTOCOL) += efi_selftest_http.o obj-$(CONFIG_EFI_DEVICE_PATH_TO_TEXT) += efi_selftest_devicepath.o obj-$(CONFIG_EFI_UNICODE_COLLATION_PROTOCOL2) += \ efi_selftest_unicode_collation.o
lib/efi_selftest/efi_selftest_http.c new file +321 -0
321 lines not on this page · raw message
Signature · 1 line
2.43.0
PATCH v7 14/14 efi_selftest: add test for IPv4 Config2 protocol
In reply to Adriano CordovaAdd a test for the EFI_IP4_CONFIG2_PROTOCOL. The test sets the ip policy to static, adds an ip address, and then reads the current ip address and checks for it to be the same as the one that was set.
---
Changes in v7:
- Fixed sizeof() calls when possible
- When setting up the test, check if any handle was found before looping through the handles.
(no changes since v4)
Changes in v4:
- Removed unnecessary void* casts
(no changes since v2)
lib/efi_selftest/Makefile | 2 + lib/efi_selftest/efi_selftest_ipconfig.c | 176 +++++++++++++++++++++++ 2 files changed, 178 insertions(+) create mode 100644 lib/efi_selftest/efi_selftest_ipconfig.c
lib/efi_selftest/Makefile +2 -0
@@ -53,6 +53,8 @@ efi_selftest_watchdog.o obj-$(CONFIG_EFI_ECPT) += efi_selftest_ecpt.o obj-$(CONFIG_NETDEVICES) += efi_selftest_snp.o obj-$(CONFIG_EFI_HTTP_PROTOCOL) += efi_selftest_http.o +obj-$(CONFIG_EFI_HTTP_PROTOCOL) += efi_selftest_ipconfig.o + obj-$(CONFIG_EFI_DEVICE_PATH_TO_TEXT) += efi_selftest_devicepath.o obj-$(CONFIG_EFI_UNICODE_COLLATION_PROTOCOL2) += \ efi_selftest_unicode_collation.o
lib/efi_selftest/efi_selftest_ipconfig.c new file +176 -0
176 lines not on this page · raw message
Signature · 1 line
2.43.0