Merge tag 'efi-2022-07-rc1-3' of https://source.denx.de/u-boot/custodians/u-boot-efi
authorTom Rini <trini@konsulko.com>
Sat, 23 Apr 2022 22:42:00 +0000 (18:42 -0400)
committerTom Rini <trini@konsulko.com>
Sat, 23 Apr 2022 22:42:00 +0000 (18:42 -0400)
Pull request for efi-2022-07-rc1-3

Documentation:

* Document image size parameter of bootefi command

UEFI:

* avoid building partition support in SPL/TPL where not required
* improve integration of EFI subsystem and driver model
* restore ability to boot arbitrary blob

arch/arm/Kconfig
arch/arm/mach-apple/board.c
cmd/adc.c
cmd/fdt.c
configs/apple_m1_defconfig
include/config_distro_bootcmd.h
lib/fdtdec.c
net/net.c

index 3243bd0..57946f6 100644 (file)
@@ -1021,6 +1021,7 @@ config ARCH_APPLE
        select DM_VIDEO
        select IOMMU
        select LINUX_KERNEL_IMAGE_HEADER
+       select OF_BOARD_SETUP
        select OF_CONTROL
        select PINCTRL
        select POSITION_INDEPENDENT
index ffc1301..1525a9e 100644 (file)
@@ -5,6 +5,7 @@
 
 #include <common.h>
 #include <dm.h>
+#include <dm/uclass-internal.h>
 #include <efi_loader.h>
 #include <lmb.h>
 
@@ -461,3 +462,42 @@ int board_late_init(void)
 
        return 0;
 }
+
+int ft_board_setup(void *blob, struct bd_info *bd)
+{
+       struct udevice *dev;
+       const char *stdoutname;
+       int node, ret;
+
+       /*
+        * Modify the "stdout-path" property under "/chosen" to point
+        * at "/chosen/framebuffer if a keyboard is available and
+        * we're not running under the m1n1 hypervisor.
+        * Developers can override this behaviour by dropping
+        * "vidconsole" from the "stdout" environment variable.
+        */
+
+       /* EL1 means we're running under the m1n1 hypervisor. */
+       if (current_el() == 1)
+               return 0;
+
+       ret = uclass_find_device(UCLASS_KEYBOARD, 0, &dev);
+       if (ret < 0)
+               return 0;
+
+       stdoutname = env_get("stdout");
+       if (!stdoutname || !strstr(stdoutname, "vidconsole"))
+               return 0;
+
+       /* Make sure we actually have a framebuffer. */
+       node = fdt_path_offset(blob, "/chosen/framebuffer");
+       if (node < 0 || !fdtdec_get_is_enabled(blob, node))
+               return 0;
+
+       node = fdt_path_offset(blob, "/chosen");
+       if (node < 0)
+               return 0;
+       fdt_setprop_string(blob, node, "stdout-path", "/chosen/framebuffer");
+
+       return 0;
+}
index 75739bc..8de9121 100644 (file)
--- a/cmd/adc.c
+++ b/cmd/adc.c
@@ -71,13 +71,17 @@ static int do_adc_info(struct cmd_tbl *cmdtp, int flag, int argc,
 static int do_adc_single(struct cmd_tbl *cmdtp, int flag, int argc,
                         char *const argv[])
 {
+       char *varname = NULL;
        struct udevice *dev;
        unsigned int data;
-       int ret, uV;
+       int ret, uV, val;
 
        if (argc < 3)
                return CMD_RET_USAGE;
 
+       if (argc >= 3)
+               varname = argv[2];
+
        ret = adc_channel_single_shot(argv[1], simple_strtol(argv[2], NULL, 0),
                                      &data);
        if (ret) {
@@ -87,10 +91,16 @@ static int do_adc_single(struct cmd_tbl *cmdtp, int flag, int argc,
        }
 
        ret = uclass_get_device_by_name(UCLASS_ADC, argv[1], &dev);
-       if (!ret && !adc_raw_to_uV(dev, data, &uV))
+       if (!ret && !adc_raw_to_uV(dev, data, &uV)) {
+               val = uV;
                printf("%u, %d uV\n", data, uV);
-       else
+       } else {
+               val = data;
                printf("%u\n", data);
+       }
+
+       if (varname)
+               env_set_ulong(varname, val);
 
        return CMD_RET_SUCCESS;
 }
@@ -149,7 +159,7 @@ static int do_adc_scan(struct cmd_tbl *cmdtp, int flag, int argc,
 static char adc_help_text[] =
        "list - list ADC devices\n"
        "adc info <name> - Get ADC device info\n"
-       "adc single <name> <channel> - Get Single data of ADC device channel\n"
+       "adc single <name> <channel> [varname] - Get Single data of ADC device channel\n"
        "adc scan <name> [channel mask] - Scan all [or masked] ADC channels";
 
 U_BOOT_CMD_WITH_SUBCMDS(adc, "ADC sub-system", adc_help_text,
index 7d7cae8..c07342c 100644 (file)
--- a/cmd/fdt.c
+++ b/cmd/fdt.c
@@ -119,13 +119,27 @@ static int do_fdt(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
        if (strncmp(argv[1], "ad", 2) == 0) {
                unsigned long addr;
                int control = 0;
+               int quiet = 0;
                struct fdt_header *blob;
 
                /* Set the address [and length] of the fdt */
                argc -= 2;
                argv += 2;
-               if (argc && !strcmp(*argv, "-c")) {
-                       control = 1;
+               while (argc > 0 && **argv == '-') {
+                       char *arg = *argv;
+
+                       while (*++arg) {
+                               switch (*arg) {
+                               case 'c':
+                                       control = 1;
+                                       break;
+                               case 'q':
+                                       quiet = 1;
+                                       break;
+                               default:
+                                       return CMD_RET_USAGE;
+                               }
+                       }
                        argc--;
                        argv++;
                }
@@ -145,7 +159,8 @@ static int do_fdt(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
 
                addr = hextoul(argv[0], NULL);
                blob = map_sysmem(addr, 0);
-               if (!fdt_valid(&blob))
+               if ((quiet && fdt_check_header(blob)) ||
+                   (!quiet && !fdt_valid(&blob)))
                        return 1;
                if (control)
                        gd->fdt_blob = blob;
@@ -159,12 +174,13 @@ static int do_fdt(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
                        /* Optional new length */
                        len = hextoul(argv[1], NULL);
                        if (len < fdt_totalsize(blob)) {
-                               printf("New length %d < existing length %d, ignoring\n",
-                                      len, fdt_totalsize(blob));
+                               if (!quiet)
+                                       printf("New length %d < existing length %d, ignoring\n",
+                                              len, fdt_totalsize(blob));
                        } else {
                                /* Open in place with a new length */
                                err = fdt_open_into(blob, blob, len);
-                               if (err != 0) {
+                               if (!quiet && err != 0) {
                                        printf("libfdt fdt_open_into(): %s\n",
                                               fdt_strerror(err));
                                }
@@ -1055,7 +1071,7 @@ static int fdt_print(const char *pathp, char *prop, int depth)
 /********************************************************************/
 #ifdef CONFIG_SYS_LONGHELP
 static char fdt_help_text[] =
-       "addr [-c]  <addr> [<length>]   - Set the [control] fdt location to <addr>\n"
+       "addr [-cq]  <addr> [<length>]   - Set the [control] fdt location to <addr>\n"
 #ifdef CONFIG_OF_LIBFDT_OVERLAY
        "fdt apply <addr>                    - Apply overlay to the DT\n"
 #endif
index b73e541..886fc4a 100644 (file)
@@ -13,5 +13,7 @@ CONFIG_NVME_APPLE=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_USB_KEYBOARD=y
+CONFIG_SYS_WHITE_ON_BLACK=y
+CONFIG_NO_FB_CLEAR=y
 CONFIG_VIDEO_SIMPLE=y
 # CONFIG_GENERATE_SMBIOS_TABLE is not set
index 2f90929..c550238 100644 (file)
 #ifdef CONFIG_CMD_BOOTEFI_BOOTMGR
 #define BOOTENV_EFI_BOOTMGR                                               \
        "boot_efi_bootmgr="                                               \
-               "if fdt addr ${fdt_addr_r}; then "                        \
+               "if fdt addr -q ${fdt_addr_r}; then "                     \
                        "bootefi bootmgr ${fdt_addr_r};"                  \
                "else "                                                   \
                        "bootefi bootmgr;"                                \
        "boot_efi_binary="                                                \
                "load ${devtype} ${devnum}:${distro_bootpart} "           \
                        "${kernel_addr_r} efi/boot/"BOOTEFI_NAME"; "      \
-               "if fdt addr ${fdt_addr_r}; then "                        \
+               "if fdt addr -q ${fdt_addr_r}; then "                     \
                        "bootefi ${kernel_addr_r} ${fdt_addr_r};"         \
                "else "                                                   \
                        "bootefi ${kernel_addr_r} ${fdtcontroladdr};"     \
        "setenv bootp_arch " BOOTENV_EFI_PXE_ARCH ";"                     \
        "if dhcp ${kernel_addr_r}; then "                                 \
                "tftpboot ${fdt_addr_r} dtb/${efi_fdtfile};"              \
-               "if fdt addr ${fdt_addr_r}; then "                        \
+               "if fdt addr -q ${fdt_addr_r}; then "                     \
                        "bootefi ${kernel_addr_r} ${fdt_addr_r}; "        \
                "else "                                                   \
                        "bootefi ${kernel_addr_r} ${fdtcontroladdr};"     \
index 0c0ec03..e2208cb 100644 (file)
@@ -1230,7 +1230,7 @@ static void *fdt_find_separate(void)
 
 #ifdef CONFIG_SPL_BUILD
        /* FDT is at end of BSS unless it is in a different memory region */
-       if (CONFIG_IS_ENABLED(SEPARATE_BSS))
+       if (IS_ENABLED(CONFIG_SPL_SEPARATE_BSS))
                fdt_blob = (ulong *)&_image_binary_end;
        else
                fdt_blob = (ulong *)&__bss_end;
index 072a82d..034a5d6 100644 (file)
--- a/net/net.c
+++ b/net/net.c
@@ -1538,14 +1538,19 @@ int is_serverip_in_cmd(void)
 int net_parse_bootfile(struct in_addr *ipaddr, char *filename, int max_len)
 {
        char *colon;
+       struct in_addr ip;
+       ip.s_addr = 0;
 
        if (net_boot_file_name[0] == '\0')
                return 0;
 
        colon = strchr(net_boot_file_name, ':');
        if (colon) {
-               if (ipaddr)
-                       *ipaddr = string_to_ip(net_boot_file_name);
+               ip = string_to_ip(net_boot_file_name);
+               if (ipaddr && ip.s_addr)
+                       *ipaddr = ip;
+       }
+       if (ip.s_addr) {
                strncpy(filename, colon + 1, max_len);
        } else {
                strncpy(filename, net_boot_file_name, max_len);