efi_loader: Move get_efi_pxe_arch() to efi_helper

Move this function from the EFI bootmeth to the common efi_helper file.
No functional change is intended.

Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
Simon Glass 2024-11-07 14:31:44 -07:00 committed by Heinrich Schuchardt
parent 9fd623afed
commit 8aa8a33661
3 changed files with 35 additions and 23 deletions

View File

@ -25,32 +25,11 @@
#define EFI_DIRNAME "/EFI/BOOT/" #define EFI_DIRNAME "/EFI/BOOT/"
static int get_efi_pxe_arch(void)
{
/* http://www.iana.org/assignments/dhcpv6-parameters/dhcpv6-parameters.xml */
if (IS_ENABLED(CONFIG_ARM64))
return 0xb;
else if (IS_ENABLED(CONFIG_ARM))
return 0xa;
else if (IS_ENABLED(CONFIG_X86_64))
return 0x6;
else if (IS_ENABLED(CONFIG_X86))
return 0x7;
else if (IS_ENABLED(CONFIG_ARCH_RV32I))
return 0x19;
else if (IS_ENABLED(CONFIG_ARCH_RV64I))
return 0x1b;
else if (IS_ENABLED(CONFIG_SANDBOX))
return 0; /* not used */
return -EINVAL;
}
static int get_efi_pxe_vci(char *str, int max_len) static int get_efi_pxe_vci(char *str, int max_len)
{ {
int ret; int ret;
ret = get_efi_pxe_arch(); ret = efi_get_pxe_arch();
if (ret < 0) if (ret < 0)
return ret; return ret;
@ -239,7 +218,7 @@ static int distro_efi_read_bootflow_net(struct bootflow *bflow)
ret = get_efi_pxe_vci(str, sizeof(str)); ret = get_efi_pxe_vci(str, sizeof(str));
if (ret) if (ret)
return log_msg_ret("vci", ret); return log_msg_ret("vci", ret);
ret = get_efi_pxe_arch(); ret = efi_get_pxe_arch();
if (ret < 0) if (ret < 0)
return log_msg_ret("arc", ret); return log_msg_ret("arc", ret);
arch = ret; arch = ret;

View File

@ -678,4 +678,14 @@ void efi_show_tables(struct efi_system_table *systab);
*/ */
const char *efi_get_basename(void); const char *efi_get_basename(void);
/**
* efi_get_pxe_arch() - Get the architecture value for PXE
*
* See:
* http://www.iana.org/assignments/dhcpv6-parameters/dhcpv6-parameters.xml
*
* Return: Architecture value
*/
int efi_get_pxe_arch(void);
#endif /* _LINUX_EFI_H */ #endif /* _LINUX_EFI_H */

View File

@ -21,6 +21,8 @@
#include <linux/libfdt.h> #include <linux/libfdt.h>
#include <linux/list.h> #include <linux/list.h>
#undef BOOTEFI_NAME
#ifdef CONFIG_SANDBOX #ifdef CONFIG_SANDBOX
#if HOST_ARCH == HOST_ARCH_X86_64 #if HOST_ARCH == HOST_ARCH_X86_64
@ -69,6 +71,27 @@ const char *efi_get_basename(void)
return BOOTEFI_NAME; return BOOTEFI_NAME;
} }
int efi_get_pxe_arch(void)
{
/* http://www.iana.org/assignments/dhcpv6-parameters/dhcpv6-parameters.xml */
if (IS_ENABLED(CONFIG_ARM64))
return 0xb;
else if (IS_ENABLED(CONFIG_ARM))
return 0xa;
else if (IS_ENABLED(CONFIG_X86_64))
return 0x6;
else if (IS_ENABLED(CONFIG_X86))
return 0x7;
else if (IS_ENABLED(CONFIG_ARCH_RV32I))
return 0x19;
else if (IS_ENABLED(CONFIG_ARCH_RV64I))
return 0x1b;
else if (IS_ENABLED(CONFIG_SANDBOX))
return 0; /* not used */
return -EINVAL;
}
/** /**
* efi_create_current_boot_var() - Return Boot#### name were #### is replaced by * efi_create_current_boot_var() - Return Boot#### name were #### is replaced by
* the value of BootCurrent * the value of BootCurrent