Re: [U-Boot] [PATCH v3 1/7] efi_loader: Add network access support
Hi Alexander. On 19 May 2016 at 10:18, Alexander Graf wrote: > > On 05/18/2016 07:21 PM, Simon Glass wrote: >> >> +Tom >> >> Hi Alex, >> >> On 16 May 2016 at 12:06, Alexander Graf wrote: >>> >>> >>> On 16.05.16 15:24, Simon Glass wrote: Hi Alexander, On 14 May 2016 at 14:34, Alexander Graf wrote: > > >> Am 14.05.2016 um 21:49 schrieb Simon Glass : >> >> Hi Alexander, >> >>> On 10 May 2016 at 15:25, Alexander Graf wrote: >>> We can now successfully boot EFI applications from disk, but users >>> may want to also run them from a PXE setup. >>> >>> This patch implements rudimentary network support, allowing a payload >>> to send and receive network packets. >>> >>> With this patch, I was able to successfully run grub2 with network >>> access inside of QEMU's -M xlnx-ep108 and on a zcu102 system. >>> >>> Signed-off-by: Alexander Graf >>> >>> --- >>> >>> v2 -> v3: >>> >>> - Align initialization sequence with net code >>> - Set device to initialized after init call >>> - Align tx buffers to DMA alignment (rx gets memcpy'd) >>> - Add comment about eth_rx() >>> --- >>> cmd/bootefi.c| 7 ++ >>> include/efi_api.h| 119 ++ >>> include/efi_loader.h | 7 ++ >>> include/net.h| 2 +- >>> lib/efi_loader/Makefile | 1 + >>> lib/efi_loader/efi_net.c | 314 >>> +++ >>> net/bootp.c | 2 + >>> net/net.c| 4 +- >>> net/tftp.c | 2 + >>> 9 files changed, 455 insertions(+), 3 deletions(-) >>> create mode 100644 lib/efi_loader/efi_net.c >>> >>> diff --git a/cmd/bootefi.c b/cmd/bootefi.c >>> index 7f552fc..d3a2331 100644 >>> --- a/cmd/bootefi.c >>> +++ b/cmd/bootefi.c >>> @@ -197,6 +197,13 @@ static unsigned long do_bootefi_exec(void *efi, >>> void *fdt) >>> #ifdef CONFIG_LCD >>> efi_gop_register(); >>> #endif >>> +#ifdef CONFIG_NET >>> + void *nethandle = loaded_image_info.device_handle; >>> + efi_net_register(&nethandle); >>> + >>> + if (!memcmp(bootefi_device_path[0].str, "N\0e\0t", 6)) >>> + loaded_image_info.device_handle = nethandle; >>> +#endif >>> >>> /* Call our payload! */ >>> #ifdef DEBUG_EFI >>> diff --git a/include/efi_api.h b/include/efi_api.h >>> index 51d7586..20035d7 100644 >>> --- a/include/efi_api.h >>> +++ b/include/efi_api.h >>> @@ -412,4 +412,123 @@ struct efi_gop >>> struct efi_gop_mode *mode; >>> }; >>> >>> +#define EFI_SIMPLE_NETWORK_GUID \ >>> + EFI_GUID(0xa19832b9, 0xac25, 0x11d3, \ >>> +0x9a, 0x2d, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d) >>> + >>> +struct efi_mac_address { >>> + char mac_addr[32]; >>> +}; >>> + >>> +struct efi_ip_address { >>> + u8 ip_addr[16]; >>> +}; >>> + >>> +enum efi_simple_network_state { >>> + EFI_NETWORK_STOPPED, >>> + EFI_NETWORK_STARTED, >>> + EFI_NETWORK_INITIALIZED, >>> +}; >>> + >>> +struct efi_simple_network_mode { >>> + enum efi_simple_network_state state; >>> + u32 hwaddr_size; >>> + u32 media_header_size; >>> + u32 max_packet_size; >>> + u32 nvram_size; >>> + u32 nvram_access_size; >>> + u32 receive_filter_mask; >>> + u32 receive_filter_setting; >>> + u32 max_mcast_filter_count; >>> + u32 mcast_filter_count; >>> + struct efi_mac_address mcast_filter[16]; >>> + struct efi_mac_address current_address; >>> + struct efi_mac_address broadcast_address; >>> + struct efi_mac_address permanent_address; >>> + u8 if_type; >>> + u8 mac_changeable; >>> + u8 multitx_supported; >>> + u8 media_present_supported; >>> + u8 media_present; >>> +}; >>> + >>> +#define EFI_SIMPLE_NETWORK_RECEIVE_UNICAST 0x01, >>> +#define EFI_SIMPLE_NETWORK_RECEIVE_MULTICAST 0x02, >>> +#define EFI_SIMPLE_NETWORK_RECEIVE_BROADCAST 0x04, >>> +#define EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS 0x08, >>> +#define EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS_MULTICAST 0x10, >>> + >>> +struct efi_simple_network >>> +{ >>> + u64 revision; >>> + efi_status_t (EFIAPI *start)(struct efi_simple_network *this); >>> + efi_status_t (EFIAPI *stop)(struct efi_simple_network *this); >>> + efi_status_t (EFIAPI *initialize)(struct efi_simple_network >>> *this, >>> + ulong extra_rx, ulong extra_tx); >>> + efi_status_t (EFIAPI *reset)(struct efi_simple_network *this, >>> +
Re: [U-Boot] [PATCH v3 1/7] efi_loader: Add network access support
On 05/18/2016 07:21 PM, Simon Glass wrote: +Tom Hi Alex, On 16 May 2016 at 12:06, Alexander Graf wrote: On 16.05.16 15:24, Simon Glass wrote: Hi Alexander, On 14 May 2016 at 14:34, Alexander Graf wrote: Am 14.05.2016 um 21:49 schrieb Simon Glass : Hi Alexander, On 10 May 2016 at 15:25, Alexander Graf wrote: We can now successfully boot EFI applications from disk, but users may want to also run them from a PXE setup. This patch implements rudimentary network support, allowing a payload to send and receive network packets. With this patch, I was able to successfully run grub2 with network access inside of QEMU's -M xlnx-ep108 and on a zcu102 system. Signed-off-by: Alexander Graf --- v2 -> v3: - Align initialization sequence with net code - Set device to initialized after init call - Align tx buffers to DMA alignment (rx gets memcpy'd) - Add comment about eth_rx() --- cmd/bootefi.c| 7 ++ include/efi_api.h| 119 ++ include/efi_loader.h | 7 ++ include/net.h| 2 +- lib/efi_loader/Makefile | 1 + lib/efi_loader/efi_net.c | 314 +++ net/bootp.c | 2 + net/net.c| 4 +- net/tftp.c | 2 + 9 files changed, 455 insertions(+), 3 deletions(-) create mode 100644 lib/efi_loader/efi_net.c diff --git a/cmd/bootefi.c b/cmd/bootefi.c index 7f552fc..d3a2331 100644 --- a/cmd/bootefi.c +++ b/cmd/bootefi.c @@ -197,6 +197,13 @@ static unsigned long do_bootefi_exec(void *efi, void *fdt) #ifdef CONFIG_LCD efi_gop_register(); #endif +#ifdef CONFIG_NET + void *nethandle = loaded_image_info.device_handle; + efi_net_register(&nethandle); + + if (!memcmp(bootefi_device_path[0].str, "N\0e\0t", 6)) + loaded_image_info.device_handle = nethandle; +#endif /* Call our payload! */ #ifdef DEBUG_EFI diff --git a/include/efi_api.h b/include/efi_api.h index 51d7586..20035d7 100644 --- a/include/efi_api.h +++ b/include/efi_api.h @@ -412,4 +412,123 @@ struct efi_gop struct efi_gop_mode *mode; }; +#define EFI_SIMPLE_NETWORK_GUID \ + EFI_GUID(0xa19832b9, 0xac25, 0x11d3, \ +0x9a, 0x2d, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d) + +struct efi_mac_address { + char mac_addr[32]; +}; + +struct efi_ip_address { + u8 ip_addr[16]; +}; + +enum efi_simple_network_state { + EFI_NETWORK_STOPPED, + EFI_NETWORK_STARTED, + EFI_NETWORK_INITIALIZED, +}; + +struct efi_simple_network_mode { + enum efi_simple_network_state state; + u32 hwaddr_size; + u32 media_header_size; + u32 max_packet_size; + u32 nvram_size; + u32 nvram_access_size; + u32 receive_filter_mask; + u32 receive_filter_setting; + u32 max_mcast_filter_count; + u32 mcast_filter_count; + struct efi_mac_address mcast_filter[16]; + struct efi_mac_address current_address; + struct efi_mac_address broadcast_address; + struct efi_mac_address permanent_address; + u8 if_type; + u8 mac_changeable; + u8 multitx_supported; + u8 media_present_supported; + u8 media_present; +}; + +#define EFI_SIMPLE_NETWORK_RECEIVE_UNICAST 0x01, +#define EFI_SIMPLE_NETWORK_RECEIVE_MULTICAST 0x02, +#define EFI_SIMPLE_NETWORK_RECEIVE_BROADCAST 0x04, +#define EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS 0x08, +#define EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS_MULTICAST 0x10, + +struct efi_simple_network +{ + u64 revision; + efi_status_t (EFIAPI *start)(struct efi_simple_network *this); + efi_status_t (EFIAPI *stop)(struct efi_simple_network *this); + efi_status_t (EFIAPI *initialize)(struct efi_simple_network *this, + ulong extra_rx, ulong extra_tx); + efi_status_t (EFIAPI *reset)(struct efi_simple_network *this, + int extended_verification); + efi_status_t (EFIAPI *shutdown)(struct efi_simple_network *this); + efi_status_t (EFIAPI *receive_filters)(struct efi_simple_network *this, + u32 enable, u32 disable, int reset_mcast_filter, + ulong mcast_filter_count, + struct efi_mac_address *mcast_filter); + efi_status_t (EFIAPI *station_address)(struct efi_simple_network *this, + int reset, struct efi_mac_address *new_mac); + efi_status_t (EFIAPI *statistics)(struct efi_simple_network *this, + int reset, ulong *stat_size, void *stat_table); + efi_status_t (EFIAPI *mcastiptomac)(struct efi_simple_network *this, + int ipv6, struct efi_ip_address *ip, + struct efi_mac_address *mac); + efi_status_t (EFIAPI *nvdata)(struct efi_simple_network *this, + int read_write, ulong offset, ulong buffer_size, + char *buffer); + efi_status_t
Re: [U-Boot] [PATCH v3 1/7] efi_loader: Add network access support
+Tom Hi Alex, On 16 May 2016 at 12:06, Alexander Graf wrote: > > > On 16.05.16 15:24, Simon Glass wrote: >> Hi Alexander, >> >> On 14 May 2016 at 14:34, Alexander Graf wrote: >>> >>> Am 14.05.2016 um 21:49 schrieb Simon Glass : Hi Alexander, > On 10 May 2016 at 15:25, Alexander Graf wrote: > We can now successfully boot EFI applications from disk, but users > may want to also run them from a PXE setup. > > This patch implements rudimentary network support, allowing a payload > to send and receive network packets. > > With this patch, I was able to successfully run grub2 with network > access inside of QEMU's -M xlnx-ep108 and on a zcu102 system. > > Signed-off-by: Alexander Graf > > --- > > v2 -> v3: > > - Align initialization sequence with net code > - Set device to initialized after init call > - Align tx buffers to DMA alignment (rx gets memcpy'd) > - Add comment about eth_rx() > --- > cmd/bootefi.c| 7 ++ > include/efi_api.h| 119 ++ > include/efi_loader.h | 7 ++ > include/net.h| 2 +- > lib/efi_loader/Makefile | 1 + > lib/efi_loader/efi_net.c | 314 > +++ > net/bootp.c | 2 + > net/net.c| 4 +- > net/tftp.c | 2 + > 9 files changed, 455 insertions(+), 3 deletions(-) > create mode 100644 lib/efi_loader/efi_net.c > > diff --git a/cmd/bootefi.c b/cmd/bootefi.c > index 7f552fc..d3a2331 100644 > --- a/cmd/bootefi.c > +++ b/cmd/bootefi.c > @@ -197,6 +197,13 @@ static unsigned long do_bootefi_exec(void *efi, void > *fdt) > #ifdef CONFIG_LCD >efi_gop_register(); > #endif > +#ifdef CONFIG_NET > + void *nethandle = loaded_image_info.device_handle; > + efi_net_register(&nethandle); > + > + if (!memcmp(bootefi_device_path[0].str, "N\0e\0t", 6)) > + loaded_image_info.device_handle = nethandle; > +#endif > >/* Call our payload! */ > #ifdef DEBUG_EFI > diff --git a/include/efi_api.h b/include/efi_api.h > index 51d7586..20035d7 100644 > --- a/include/efi_api.h > +++ b/include/efi_api.h > @@ -412,4 +412,123 @@ struct efi_gop >struct efi_gop_mode *mode; > }; > > +#define EFI_SIMPLE_NETWORK_GUID \ > + EFI_GUID(0xa19832b9, 0xac25, 0x11d3, \ > +0x9a, 0x2d, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d) > + > +struct efi_mac_address { > + char mac_addr[32]; > +}; > + > +struct efi_ip_address { > + u8 ip_addr[16]; > +}; > + > +enum efi_simple_network_state { > + EFI_NETWORK_STOPPED, > + EFI_NETWORK_STARTED, > + EFI_NETWORK_INITIALIZED, > +}; > + > +struct efi_simple_network_mode { > + enum efi_simple_network_state state; > + u32 hwaddr_size; > + u32 media_header_size; > + u32 max_packet_size; > + u32 nvram_size; > + u32 nvram_access_size; > + u32 receive_filter_mask; > + u32 receive_filter_setting; > + u32 max_mcast_filter_count; > + u32 mcast_filter_count; > + struct efi_mac_address mcast_filter[16]; > + struct efi_mac_address current_address; > + struct efi_mac_address broadcast_address; > + struct efi_mac_address permanent_address; > + u8 if_type; > + u8 mac_changeable; > + u8 multitx_supported; > + u8 media_present_supported; > + u8 media_present; > +}; > + > +#define EFI_SIMPLE_NETWORK_RECEIVE_UNICAST 0x01, > +#define EFI_SIMPLE_NETWORK_RECEIVE_MULTICAST 0x02, > +#define EFI_SIMPLE_NETWORK_RECEIVE_BROADCAST 0x04, > +#define EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS 0x08, > +#define EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS_MULTICAST 0x10, > + > +struct efi_simple_network > +{ > + u64 revision; > + efi_status_t (EFIAPI *start)(struct efi_simple_network *this); > + efi_status_t (EFIAPI *stop)(struct efi_simple_network *this); > + efi_status_t (EFIAPI *initialize)(struct efi_simple_network *this, > + ulong extra_rx, ulong extra_tx); > + efi_status_t (EFIAPI *reset)(struct efi_simple_network *this, > + int extended_verification); > + efi_status_t (EFIAPI *shutdown)(struct efi_simple_network *this); > + efi_status_t (EFIAPI *receive_filters)(struct efi_simple_network > *this, > + u32 enable, u32 disable, int reset_mcast_filter, > + ulong mcast_filter_count, > + struct efi_mac_address *
Re: [U-Boot] [PATCH v3 1/7] efi_loader: Add network access support
On 16.05.16 15:24, Simon Glass wrote: > Hi Alexander, > > On 14 May 2016 at 14:34, Alexander Graf wrote: >> >> >>> Am 14.05.2016 um 21:49 schrieb Simon Glass : >>> >>> Hi Alexander, >>> On 10 May 2016 at 15:25, Alexander Graf wrote: We can now successfully boot EFI applications from disk, but users may want to also run them from a PXE setup. This patch implements rudimentary network support, allowing a payload to send and receive network packets. With this patch, I was able to successfully run grub2 with network access inside of QEMU's -M xlnx-ep108 and on a zcu102 system. Signed-off-by: Alexander Graf --- v2 -> v3: - Align initialization sequence with net code - Set device to initialized after init call - Align tx buffers to DMA alignment (rx gets memcpy'd) - Add comment about eth_rx() --- cmd/bootefi.c| 7 ++ include/efi_api.h| 119 ++ include/efi_loader.h | 7 ++ include/net.h| 2 +- lib/efi_loader/Makefile | 1 + lib/efi_loader/efi_net.c | 314 +++ net/bootp.c | 2 + net/net.c| 4 +- net/tftp.c | 2 + 9 files changed, 455 insertions(+), 3 deletions(-) create mode 100644 lib/efi_loader/efi_net.c diff --git a/cmd/bootefi.c b/cmd/bootefi.c index 7f552fc..d3a2331 100644 --- a/cmd/bootefi.c +++ b/cmd/bootefi.c @@ -197,6 +197,13 @@ static unsigned long do_bootefi_exec(void *efi, void *fdt) #ifdef CONFIG_LCD efi_gop_register(); #endif +#ifdef CONFIG_NET + void *nethandle = loaded_image_info.device_handle; + efi_net_register(&nethandle); + + if (!memcmp(bootefi_device_path[0].str, "N\0e\0t", 6)) + loaded_image_info.device_handle = nethandle; +#endif /* Call our payload! */ #ifdef DEBUG_EFI diff --git a/include/efi_api.h b/include/efi_api.h index 51d7586..20035d7 100644 --- a/include/efi_api.h +++ b/include/efi_api.h @@ -412,4 +412,123 @@ struct efi_gop struct efi_gop_mode *mode; }; +#define EFI_SIMPLE_NETWORK_GUID \ + EFI_GUID(0xa19832b9, 0xac25, 0x11d3, \ +0x9a, 0x2d, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d) + +struct efi_mac_address { + char mac_addr[32]; +}; + +struct efi_ip_address { + u8 ip_addr[16]; +}; + +enum efi_simple_network_state { + EFI_NETWORK_STOPPED, + EFI_NETWORK_STARTED, + EFI_NETWORK_INITIALIZED, +}; + +struct efi_simple_network_mode { + enum efi_simple_network_state state; + u32 hwaddr_size; + u32 media_header_size; + u32 max_packet_size; + u32 nvram_size; + u32 nvram_access_size; + u32 receive_filter_mask; + u32 receive_filter_setting; + u32 max_mcast_filter_count; + u32 mcast_filter_count; + struct efi_mac_address mcast_filter[16]; + struct efi_mac_address current_address; + struct efi_mac_address broadcast_address; + struct efi_mac_address permanent_address; + u8 if_type; + u8 mac_changeable; + u8 multitx_supported; + u8 media_present_supported; + u8 media_present; +}; + +#define EFI_SIMPLE_NETWORK_RECEIVE_UNICAST 0x01, +#define EFI_SIMPLE_NETWORK_RECEIVE_MULTICAST 0x02, +#define EFI_SIMPLE_NETWORK_RECEIVE_BROADCAST 0x04, +#define EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS 0x08, +#define EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS_MULTICAST 0x10, + +struct efi_simple_network +{ + u64 revision; + efi_status_t (EFIAPI *start)(struct efi_simple_network *this); + efi_status_t (EFIAPI *stop)(struct efi_simple_network *this); + efi_status_t (EFIAPI *initialize)(struct efi_simple_network *this, + ulong extra_rx, ulong extra_tx); + efi_status_t (EFIAPI *reset)(struct efi_simple_network *this, + int extended_verification); + efi_status_t (EFIAPI *shutdown)(struct efi_simple_network *this); + efi_status_t (EFIAPI *receive_filters)(struct efi_simple_network *this, + u32 enable, u32 disable, int reset_mcast_filter, + ulong mcast_filter_count, + struct efi_mac_address *mcast_filter); + efi_status_t (EFIAPI *station_address)(struct efi_simple_network *this, + int reset, struct efi_mac_address *new_mac); + efi_s
Re: [U-Boot] [PATCH v3 1/7] efi_loader: Add network access support
Hi Alexander, On 14 May 2016 at 14:34, Alexander Graf wrote: > > >> Am 14.05.2016 um 21:49 schrieb Simon Glass : >> >> Hi Alexander, >> >>> On 10 May 2016 at 15:25, Alexander Graf wrote: >>> We can now successfully boot EFI applications from disk, but users >>> may want to also run them from a PXE setup. >>> >>> This patch implements rudimentary network support, allowing a payload >>> to send and receive network packets. >>> >>> With this patch, I was able to successfully run grub2 with network >>> access inside of QEMU's -M xlnx-ep108 and on a zcu102 system. >>> >>> Signed-off-by: Alexander Graf >>> >>> --- >>> >>> v2 -> v3: >>> >>> - Align initialization sequence with net code >>> - Set device to initialized after init call >>> - Align tx buffers to DMA alignment (rx gets memcpy'd) >>> - Add comment about eth_rx() >>> --- >>> cmd/bootefi.c| 7 ++ >>> include/efi_api.h| 119 ++ >>> include/efi_loader.h | 7 ++ >>> include/net.h| 2 +- >>> lib/efi_loader/Makefile | 1 + >>> lib/efi_loader/efi_net.c | 314 >>> +++ >>> net/bootp.c | 2 + >>> net/net.c| 4 +- >>> net/tftp.c | 2 + >>> 9 files changed, 455 insertions(+), 3 deletions(-) >>> create mode 100644 lib/efi_loader/efi_net.c >>> >>> diff --git a/cmd/bootefi.c b/cmd/bootefi.c >>> index 7f552fc..d3a2331 100644 >>> --- a/cmd/bootefi.c >>> +++ b/cmd/bootefi.c >>> @@ -197,6 +197,13 @@ static unsigned long do_bootefi_exec(void *efi, void >>> *fdt) >>> #ifdef CONFIG_LCD >>>efi_gop_register(); >>> #endif >>> +#ifdef CONFIG_NET >>> + void *nethandle = loaded_image_info.device_handle; >>> + efi_net_register(&nethandle); >>> + >>> + if (!memcmp(bootefi_device_path[0].str, "N\0e\0t", 6)) >>> + loaded_image_info.device_handle = nethandle; >>> +#endif >>> >>>/* Call our payload! */ >>> #ifdef DEBUG_EFI >>> diff --git a/include/efi_api.h b/include/efi_api.h >>> index 51d7586..20035d7 100644 >>> --- a/include/efi_api.h >>> +++ b/include/efi_api.h >>> @@ -412,4 +412,123 @@ struct efi_gop >>>struct efi_gop_mode *mode; >>> }; >>> >>> +#define EFI_SIMPLE_NETWORK_GUID \ >>> + EFI_GUID(0xa19832b9, 0xac25, 0x11d3, \ >>> +0x9a, 0x2d, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d) >>> + >>> +struct efi_mac_address { >>> + char mac_addr[32]; >>> +}; >>> + >>> +struct efi_ip_address { >>> + u8 ip_addr[16]; >>> +}; >>> + >>> +enum efi_simple_network_state { >>> + EFI_NETWORK_STOPPED, >>> + EFI_NETWORK_STARTED, >>> + EFI_NETWORK_INITIALIZED, >>> +}; >>> + >>> +struct efi_simple_network_mode { >>> + enum efi_simple_network_state state; >>> + u32 hwaddr_size; >>> + u32 media_header_size; >>> + u32 max_packet_size; >>> + u32 nvram_size; >>> + u32 nvram_access_size; >>> + u32 receive_filter_mask; >>> + u32 receive_filter_setting; >>> + u32 max_mcast_filter_count; >>> + u32 mcast_filter_count; >>> + struct efi_mac_address mcast_filter[16]; >>> + struct efi_mac_address current_address; >>> + struct efi_mac_address broadcast_address; >>> + struct efi_mac_address permanent_address; >>> + u8 if_type; >>> + u8 mac_changeable; >>> + u8 multitx_supported; >>> + u8 media_present_supported; >>> + u8 media_present; >>> +}; >>> + >>> +#define EFI_SIMPLE_NETWORK_RECEIVE_UNICAST 0x01, >>> +#define EFI_SIMPLE_NETWORK_RECEIVE_MULTICAST 0x02, >>> +#define EFI_SIMPLE_NETWORK_RECEIVE_BROADCAST 0x04, >>> +#define EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS 0x08, >>> +#define EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS_MULTICAST 0x10, >>> + >>> +struct efi_simple_network >>> +{ >>> + u64 revision; >>> + efi_status_t (EFIAPI *start)(struct efi_simple_network *this); >>> + efi_status_t (EFIAPI *stop)(struct efi_simple_network *this); >>> + efi_status_t (EFIAPI *initialize)(struct efi_simple_network *this, >>> + ulong extra_rx, ulong extra_tx); >>> + efi_status_t (EFIAPI *reset)(struct efi_simple_network *this, >>> + int extended_verification); >>> + efi_status_t (EFIAPI *shutdown)(struct efi_simple_network *this); >>> + efi_status_t (EFIAPI *receive_filters)(struct efi_simple_network >>> *this, >>> + u32 enable, u32 disable, int reset_mcast_filter, >>> + ulong mcast_filter_count, >>> + struct efi_mac_address *mcast_filter); >>> + efi_status_t (EFIAPI *station_address)(struct efi_simple_network >>> *this, >>> + int reset, struct efi_mac_address *new_mac); >>> + efi_status_t (EFIAPI *statistics)(struct efi_simple_network *this, >>> + int reset, ulong *stat_size, void *stat_table); >>> + efi_status_t (EFIAPI *mcasti
Re: [U-Boot] [PATCH v3 1/7] efi_loader: Add network access support
> Am 14.05.2016 um 21:49 schrieb Simon Glass : > > Hi Alexander, > >> On 10 May 2016 at 15:25, Alexander Graf wrote: >> We can now successfully boot EFI applications from disk, but users >> may want to also run them from a PXE setup. >> >> This patch implements rudimentary network support, allowing a payload >> to send and receive network packets. >> >> With this patch, I was able to successfully run grub2 with network >> access inside of QEMU's -M xlnx-ep108 and on a zcu102 system. >> >> Signed-off-by: Alexander Graf >> >> --- >> >> v2 -> v3: >> >> - Align initialization sequence with net code >> - Set device to initialized after init call >> - Align tx buffers to DMA alignment (rx gets memcpy'd) >> - Add comment about eth_rx() >> --- >> cmd/bootefi.c| 7 ++ >> include/efi_api.h| 119 ++ >> include/efi_loader.h | 7 ++ >> include/net.h| 2 +- >> lib/efi_loader/Makefile | 1 + >> lib/efi_loader/efi_net.c | 314 >> +++ >> net/bootp.c | 2 + >> net/net.c| 4 +- >> net/tftp.c | 2 + >> 9 files changed, 455 insertions(+), 3 deletions(-) >> create mode 100644 lib/efi_loader/efi_net.c >> >> diff --git a/cmd/bootefi.c b/cmd/bootefi.c >> index 7f552fc..d3a2331 100644 >> --- a/cmd/bootefi.c >> +++ b/cmd/bootefi.c >> @@ -197,6 +197,13 @@ static unsigned long do_bootefi_exec(void *efi, void >> *fdt) >> #ifdef CONFIG_LCD >>efi_gop_register(); >> #endif >> +#ifdef CONFIG_NET >> + void *nethandle = loaded_image_info.device_handle; >> + efi_net_register(&nethandle); >> + >> + if (!memcmp(bootefi_device_path[0].str, "N\0e\0t", 6)) >> + loaded_image_info.device_handle = nethandle; >> +#endif >> >>/* Call our payload! */ >> #ifdef DEBUG_EFI >> diff --git a/include/efi_api.h b/include/efi_api.h >> index 51d7586..20035d7 100644 >> --- a/include/efi_api.h >> +++ b/include/efi_api.h >> @@ -412,4 +412,123 @@ struct efi_gop >>struct efi_gop_mode *mode; >> }; >> >> +#define EFI_SIMPLE_NETWORK_GUID \ >> + EFI_GUID(0xa19832b9, 0xac25, 0x11d3, \ >> +0x9a, 0x2d, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d) >> + >> +struct efi_mac_address { >> + char mac_addr[32]; >> +}; >> + >> +struct efi_ip_address { >> + u8 ip_addr[16]; >> +}; >> + >> +enum efi_simple_network_state { >> + EFI_NETWORK_STOPPED, >> + EFI_NETWORK_STARTED, >> + EFI_NETWORK_INITIALIZED, >> +}; >> + >> +struct efi_simple_network_mode { >> + enum efi_simple_network_state state; >> + u32 hwaddr_size; >> + u32 media_header_size; >> + u32 max_packet_size; >> + u32 nvram_size; >> + u32 nvram_access_size; >> + u32 receive_filter_mask; >> + u32 receive_filter_setting; >> + u32 max_mcast_filter_count; >> + u32 mcast_filter_count; >> + struct efi_mac_address mcast_filter[16]; >> + struct efi_mac_address current_address; >> + struct efi_mac_address broadcast_address; >> + struct efi_mac_address permanent_address; >> + u8 if_type; >> + u8 mac_changeable; >> + u8 multitx_supported; >> + u8 media_present_supported; >> + u8 media_present; >> +}; >> + >> +#define EFI_SIMPLE_NETWORK_RECEIVE_UNICAST 0x01, >> +#define EFI_SIMPLE_NETWORK_RECEIVE_MULTICAST 0x02, >> +#define EFI_SIMPLE_NETWORK_RECEIVE_BROADCAST 0x04, >> +#define EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS 0x08, >> +#define EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS_MULTICAST 0x10, >> + >> +struct efi_simple_network >> +{ >> + u64 revision; >> + efi_status_t (EFIAPI *start)(struct efi_simple_network *this); >> + efi_status_t (EFIAPI *stop)(struct efi_simple_network *this); >> + efi_status_t (EFIAPI *initialize)(struct efi_simple_network *this, >> + ulong extra_rx, ulong extra_tx); >> + efi_status_t (EFIAPI *reset)(struct efi_simple_network *this, >> + int extended_verification); >> + efi_status_t (EFIAPI *shutdown)(struct efi_simple_network *this); >> + efi_status_t (EFIAPI *receive_filters)(struct efi_simple_network >> *this, >> + u32 enable, u32 disable, int reset_mcast_filter, >> + ulong mcast_filter_count, >> + struct efi_mac_address *mcast_filter); >> + efi_status_t (EFIAPI *station_address)(struct efi_simple_network >> *this, >> + int reset, struct efi_mac_address *new_mac); >> + efi_status_t (EFIAPI *statistics)(struct efi_simple_network *this, >> + int reset, ulong *stat_size, void *stat_table); >> + efi_status_t (EFIAPI *mcastiptomac)(struct efi_simple_network *this, >> + int ipv6, struct efi_ip_address *ip, >> + struct efi_mac_address *mac); >> + efi_status_t
Re: [U-Boot] [PATCH v3 1/7] efi_loader: Add network access support
Hi Alexander, On 10 May 2016 at 15:25, Alexander Graf wrote: > We can now successfully boot EFI applications from disk, but users > may want to also run them from a PXE setup. > > This patch implements rudimentary network support, allowing a payload > to send and receive network packets. > > With this patch, I was able to successfully run grub2 with network > access inside of QEMU's -M xlnx-ep108 and on a zcu102 system. > > Signed-off-by: Alexander Graf > > --- > > v2 -> v3: > > - Align initialization sequence with net code > - Set device to initialized after init call > - Align tx buffers to DMA alignment (rx gets memcpy'd) > - Add comment about eth_rx() > --- > cmd/bootefi.c| 7 ++ > include/efi_api.h| 119 ++ > include/efi_loader.h | 7 ++ > include/net.h| 2 +- > lib/efi_loader/Makefile | 1 + > lib/efi_loader/efi_net.c | 314 > +++ > net/bootp.c | 2 + > net/net.c| 4 +- > net/tftp.c | 2 + > 9 files changed, 455 insertions(+), 3 deletions(-) > create mode 100644 lib/efi_loader/efi_net.c > > diff --git a/cmd/bootefi.c b/cmd/bootefi.c > index 7f552fc..d3a2331 100644 > --- a/cmd/bootefi.c > +++ b/cmd/bootefi.c > @@ -197,6 +197,13 @@ static unsigned long do_bootefi_exec(void *efi, void > *fdt) > #ifdef CONFIG_LCD > efi_gop_register(); > #endif > +#ifdef CONFIG_NET > + void *nethandle = loaded_image_info.device_handle; > + efi_net_register(&nethandle); > + > + if (!memcmp(bootefi_device_path[0].str, "N\0e\0t", 6)) > + loaded_image_info.device_handle = nethandle; > +#endif > > /* Call our payload! */ > #ifdef DEBUG_EFI > diff --git a/include/efi_api.h b/include/efi_api.h > index 51d7586..20035d7 100644 > --- a/include/efi_api.h > +++ b/include/efi_api.h > @@ -412,4 +412,123 @@ struct efi_gop > struct efi_gop_mode *mode; > }; > > +#define EFI_SIMPLE_NETWORK_GUID \ > + EFI_GUID(0xa19832b9, 0xac25, 0x11d3, \ > +0x9a, 0x2d, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d) > + > +struct efi_mac_address { > + char mac_addr[32]; > +}; > + > +struct efi_ip_address { > + u8 ip_addr[16]; > +}; > + > +enum efi_simple_network_state { > + EFI_NETWORK_STOPPED, > + EFI_NETWORK_STARTED, > + EFI_NETWORK_INITIALIZED, > +}; > + > +struct efi_simple_network_mode { > + enum efi_simple_network_state state; > + u32 hwaddr_size; > + u32 media_header_size; > + u32 max_packet_size; > + u32 nvram_size; > + u32 nvram_access_size; > + u32 receive_filter_mask; > + u32 receive_filter_setting; > + u32 max_mcast_filter_count; > + u32 mcast_filter_count; > + struct efi_mac_address mcast_filter[16]; > + struct efi_mac_address current_address; > + struct efi_mac_address broadcast_address; > + struct efi_mac_address permanent_address; > + u8 if_type; > + u8 mac_changeable; > + u8 multitx_supported; > + u8 media_present_supported; > + u8 media_present; > +}; > + > +#define EFI_SIMPLE_NETWORK_RECEIVE_UNICAST 0x01, > +#define EFI_SIMPLE_NETWORK_RECEIVE_MULTICAST 0x02, > +#define EFI_SIMPLE_NETWORK_RECEIVE_BROADCAST 0x04, > +#define EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS 0x08, > +#define EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS_MULTICAST 0x10, > + > +struct efi_simple_network > +{ > + u64 revision; > + efi_status_t (EFIAPI *start)(struct efi_simple_network *this); > + efi_status_t (EFIAPI *stop)(struct efi_simple_network *this); > + efi_status_t (EFIAPI *initialize)(struct efi_simple_network *this, > + ulong extra_rx, ulong extra_tx); > + efi_status_t (EFIAPI *reset)(struct efi_simple_network *this, > + int extended_verification); > + efi_status_t (EFIAPI *shutdown)(struct efi_simple_network *this); > + efi_status_t (EFIAPI *receive_filters)(struct efi_simple_network > *this, > + u32 enable, u32 disable, int reset_mcast_filter, > + ulong mcast_filter_count, > + struct efi_mac_address *mcast_filter); > + efi_status_t (EFIAPI *station_address)(struct efi_simple_network > *this, > + int reset, struct efi_mac_address *new_mac); > + efi_status_t (EFIAPI *statistics)(struct efi_simple_network *this, > + int reset, ulong *stat_size, void *stat_table); > + efi_status_t (EFIAPI *mcastiptomac)(struct efi_simple_network *this, > + int ipv6, struct efi_ip_address *ip, > + struct efi_mac_address *mac); > + efi_status_t (EFIAPI *nvdata)(struct efi_simple_network *this, > + int read_write, ulong offset, ulong buffer_size, > + char *buffe
[U-Boot] [PATCH v3 1/7] efi_loader: Add network access support
We can now successfully boot EFI applications from disk, but users may want to also run them from a PXE setup. This patch implements rudimentary network support, allowing a payload to send and receive network packets. With this patch, I was able to successfully run grub2 with network access inside of QEMU's -M xlnx-ep108 and on a zcu102 system. Signed-off-by: Alexander Graf --- v2 -> v3: - Align initialization sequence with net code - Set device to initialized after init call - Align tx buffers to DMA alignment (rx gets memcpy'd) - Add comment about eth_rx() --- cmd/bootefi.c| 7 ++ include/efi_api.h| 119 ++ include/efi_loader.h | 7 ++ include/net.h| 2 +- lib/efi_loader/Makefile | 1 + lib/efi_loader/efi_net.c | 314 +++ net/bootp.c | 2 + net/net.c| 4 +- net/tftp.c | 2 + 9 files changed, 455 insertions(+), 3 deletions(-) create mode 100644 lib/efi_loader/efi_net.c diff --git a/cmd/bootefi.c b/cmd/bootefi.c index 7f552fc..d3a2331 100644 --- a/cmd/bootefi.c +++ b/cmd/bootefi.c @@ -197,6 +197,13 @@ static unsigned long do_bootefi_exec(void *efi, void *fdt) #ifdef CONFIG_LCD efi_gop_register(); #endif +#ifdef CONFIG_NET + void *nethandle = loaded_image_info.device_handle; + efi_net_register(&nethandle); + + if (!memcmp(bootefi_device_path[0].str, "N\0e\0t", 6)) + loaded_image_info.device_handle = nethandle; +#endif /* Call our payload! */ #ifdef DEBUG_EFI diff --git a/include/efi_api.h b/include/efi_api.h index 51d7586..20035d7 100644 --- a/include/efi_api.h +++ b/include/efi_api.h @@ -412,4 +412,123 @@ struct efi_gop struct efi_gop_mode *mode; }; +#define EFI_SIMPLE_NETWORK_GUID \ + EFI_GUID(0xa19832b9, 0xac25, 0x11d3, \ +0x9a, 0x2d, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d) + +struct efi_mac_address { + char mac_addr[32]; +}; + +struct efi_ip_address { + u8 ip_addr[16]; +}; + +enum efi_simple_network_state { + EFI_NETWORK_STOPPED, + EFI_NETWORK_STARTED, + EFI_NETWORK_INITIALIZED, +}; + +struct efi_simple_network_mode { + enum efi_simple_network_state state; + u32 hwaddr_size; + u32 media_header_size; + u32 max_packet_size; + u32 nvram_size; + u32 nvram_access_size; + u32 receive_filter_mask; + u32 receive_filter_setting; + u32 max_mcast_filter_count; + u32 mcast_filter_count; + struct efi_mac_address mcast_filter[16]; + struct efi_mac_address current_address; + struct efi_mac_address broadcast_address; + struct efi_mac_address permanent_address; + u8 if_type; + u8 mac_changeable; + u8 multitx_supported; + u8 media_present_supported; + u8 media_present; +}; + +#define EFI_SIMPLE_NETWORK_RECEIVE_UNICAST 0x01, +#define EFI_SIMPLE_NETWORK_RECEIVE_MULTICAST 0x02, +#define EFI_SIMPLE_NETWORK_RECEIVE_BROADCAST 0x04, +#define EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS 0x08, +#define EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS_MULTICAST 0x10, + +struct efi_simple_network +{ + u64 revision; + efi_status_t (EFIAPI *start)(struct efi_simple_network *this); + efi_status_t (EFIAPI *stop)(struct efi_simple_network *this); + efi_status_t (EFIAPI *initialize)(struct efi_simple_network *this, + ulong extra_rx, ulong extra_tx); + efi_status_t (EFIAPI *reset)(struct efi_simple_network *this, + int extended_verification); + efi_status_t (EFIAPI *shutdown)(struct efi_simple_network *this); + efi_status_t (EFIAPI *receive_filters)(struct efi_simple_network *this, + u32 enable, u32 disable, int reset_mcast_filter, + ulong mcast_filter_count, + struct efi_mac_address *mcast_filter); + efi_status_t (EFIAPI *station_address)(struct efi_simple_network *this, + int reset, struct efi_mac_address *new_mac); + efi_status_t (EFIAPI *statistics)(struct efi_simple_network *this, + int reset, ulong *stat_size, void *stat_table); + efi_status_t (EFIAPI *mcastiptomac)(struct efi_simple_network *this, + int ipv6, struct efi_ip_address *ip, + struct efi_mac_address *mac); + efi_status_t (EFIAPI *nvdata)(struct efi_simple_network *this, + int read_write, ulong offset, ulong buffer_size, + char *buffer); + efi_status_t (EFIAPI *get_status)(struct efi_simple_network *this, + u32 *int_status, void **txbuf); + efi_status_t (EFIAPI *transmit)(struct efi_simple_network *this, + ulong header_size, ulong buffer_size, void *buffer, + struct efi_m