Merge https://gitlab.denx.de/u-boot/custodians/u-boot-riscv
authorTom Rini <trini@konsulko.com>
Mon, 18 Jan 2021 13:04:28 +0000 (08:04 -0500)
committerTom Rini <trini@konsulko.com>
Mon, 18 Jan 2021 13:04:28 +0000 (08:04 -0500)
- Update qemu-riscv.rst build instructions.
- Add support for SPI on Kendryte K210.
- Add Microchip PolarFire SoC Icicle Kit support.
- Add support for an early timer.
  - Select TIMER_EARLY to avoid infinite recursion for Trace.

50 files changed:
arch/arm/cpu/armv8/Makefile
cmd/Kconfig
cmd/bootmenu.c
cmd/disk.c
cmd/gpt.c
common/Kconfig.boot
common/Makefile
common/autoboot.c
common/cli_readline.c
common/command.c
common/console.c
common/spl/spl_fit.c
disk/part_efi.c
doc/README.fdt-overlays [deleted file]
doc/README.gpt
doc/board/freescale/b4860qds.rst
doc/board/sifive/fu540.rst
doc/usage/base.rst [new file with mode: 0644]
doc/usage/fdt_overlays.rst [new file with mode: 0644]
doc/usage/index.rst
doc/usage/pstore.rst
drivers/core/uclass.c
drivers/mtd/mtdcore.c
drivers/power/regulator/Kconfig
drivers/ram/k3-j721e/lpddr4.c
drivers/ram/k3-j721e/lpddr4_private.h
drivers/serial/Kconfig
drivers/serial/serial-uclass.c
drivers/video/Kconfig
dts/Makefile
include/dm/uclass.h
include/log.h
include/part.h
include/part_efi.h
include/test/ut.h
include/uuid.h
lib/Kconfig
lib/aes.c
lib/string.c
lib/uuid.c
lib/zlib/deflate.c
lib/zlib/trees.c
test/Makefile
test/bloblist.c
test/cmd/mem.c
test/lib/Makefile
test/log/Makefile
test/log/pr_cont_test.c [new file with mode: 0644]
test/str_ut.c
test/ut.c

index f7b4a5e..d85ddde 100644 (file)
@@ -9,14 +9,16 @@ obj-y += cpu.o
 ifndef CONFIG_$(SPL_TPL_)TIMER
 obj-$(CONFIG_SYS_ARCH_TIMER) += generic_timer.o
 endif
+ifndef CONFIG_$(SPL_)SYS_DCACHE_OFF
 obj-y  += cache_v8.o
+obj-y  += cache.o
+endif
 ifdef CONFIG_SPL_BUILD
 obj-$(CONFIG_ARMV8_SPL_EXCEPTION_VECTORS) += exceptions.o
 else
 obj-y  += exceptions.o
 obj-y  += exception_level.o
 endif
-obj-y  += cache.o
 obj-y  += tlb.o
 obj-y  += transition.o
 ifndef CONFIG_ARMV8_PSCI
index 0107c0f..1b53e5b 100644 (file)
@@ -122,6 +122,7 @@ config CMD_CONSOLE
 
 config CMD_CPU
        bool "cpu"
+       depends on CPU
        help
          Print information about available CPUs. This normally shows the
          number of CPUs, type (e.g. manufacturer, architecture, product or
index 1ba7b62..409ef9a 100644 (file)
@@ -45,6 +45,7 @@ enum bootmenu_key {
        KEY_UP,
        KEY_DOWN,
        KEY_SELECT,
+       KEY_QUIT,
 };
 
 static char *bootmenu_getoption(unsigned short int n)
@@ -109,6 +110,9 @@ static void bootmenu_autoboot_loop(struct bootmenu_data *menu,
                        case '\r':
                                *key = KEY_SELECT;
                                break;
+                       case 0x3: /* ^C */
+                               *key = KEY_QUIT;
+                               break;
                        default:
                                *key = KEY_NONE;
                                break;
@@ -136,13 +140,25 @@ static void bootmenu_loop(struct bootmenu_data *menu,
 {
        int c;
 
-       while (!tstc()) {
-               WATCHDOG_RESET();
-               mdelay(10);
+       if (*esc == 1) {
+               if (tstc()) {
+                       c = getchar();
+               } else {
+                       WATCHDOG_RESET();
+                       mdelay(10);
+                       if (tstc())
+                               c = getchar();
+                       else
+                               c = '\e';
+               }
+       } else {
+               while (!tstc()) {
+                       WATCHDOG_RESET();
+                       mdelay(10);
+               }
+               c = getchar();
        }
 
-       c = getchar();
-
        switch (*esc) {
        case 0:
                /* First char of ANSI escape sequence '\e' */
@@ -157,7 +173,9 @@ static void bootmenu_loop(struct bootmenu_data *menu,
                        *esc = 2;
                        *key = KEY_NONE;
                } else {
-                       *esc = 0;
+               /* Alone ESC key was pressed */
+                       *key = KEY_QUIT;
+                       *esc = (c == '\e') ? 1 : 0;
                }
                break;
        case 2:
@@ -187,6 +205,10 @@ static void bootmenu_loop(struct bootmenu_data *menu,
        /* enter key was pressed */
        if (c == '\r')
                *key = KEY_SELECT;
+
+       /* ^C was pressed */
+       if (c == 0x3)
+               *key = KEY_QUIT;
 }
 
 static char *bootmenu_choice_entry(void *data)
@@ -222,6 +244,12 @@ static char *bootmenu_choice_entry(void *data)
                        for (i = 0; i < menu->active; ++i)
                                iter = iter->next;
                        return iter->key;
+               case KEY_QUIT:
+                       /* Quit by choosing the last entry - U-Boot console */
+                       iter = menu->first;
+                       while (iter->next)
+                               iter = iter->next;
+                       return iter->key;
                default:
                        break;
                }
@@ -389,7 +417,7 @@ static void menu_display_statusline(struct menu *m)
        printf(ANSI_CURSOR_POSITION, menu->count + 5, 1);
        puts(ANSI_CLEAR_LINE);
        printf(ANSI_CURSOR_POSITION, menu->count + 6, 1);
-       puts("  Press UP/DOWN to move, ENTER to select");
+       puts("  Press UP/DOWN to move, ENTER to select, ESC/CTRL+C to quit");
        puts(ANSI_CLEAR_LINE_TO_END);
        printf(ANSI_CURSOR_POSITION, menu->count + 7, 1);
        puts(ANSI_CLEAR_LINE);
index 8060e75..0bc3808 100644 (file)
@@ -120,7 +120,6 @@ int common_diskboot(struct cmd_tbl *cmdtp, const char *intf, int argc,
                        return 1;
                }
                bootstage_mark(BOOTSTAGE_ID_IDE_FIT_READ_OK);
-               fit_print_contents(fit_hdr);
        }
 #endif
 
index df75941..76a95ad 100644 (file)
--- a/cmd/gpt.c
+++ b/cmd/gpt.c
@@ -18,6 +18,7 @@
 #include <command.h>
 #include <part.h>
 #include <part_efi.h>
+#include <part.h>
 #include <exports.h>
 #include <uuid.h>
 #include <linux/ctype.h>
@@ -621,6 +622,152 @@ static int gpt_verify(struct blk_desc *blk_dev_desc, const char *str_part)
        return ret;
 }
 
+/**
+ * gpt_enumerate() - Enumerate partition names into environment variable.
+ *
+ * Enumerate partition names. Partition names are stored in gpt_partition_list
+ * environment variable. Each partition name is delimited by space.
+ *
+ * @desc: block device descriptor
+ *
+ * @Return: '0' on success and -ve error on failure
+ */
+static int gpt_enumerate(struct blk_desc *desc)
+{
+       struct part_driver *first_drv, *part_drv;
+       int str_len = 0, tmp_len;
+       char part_list[2048];
+       int n_drvs;
+       char *ptr;
+
+       part_list[0] = 0;
+       n_drvs = part_driver_get_count();
+       if (!n_drvs) {
+               printf("Failed to get partition driver count\n");
+               return -ENOENT;
+       }
+
+       first_drv = part_driver_get_first();
+       for (part_drv = first_drv; part_drv != first_drv + n_drvs; part_drv++) {
+               struct disk_partition pinfo;
+               int ret;
+               int i;
+
+               for (i = 1; i < part_drv->max_entries; i++) {
+                       ret = part_drv->get_info(desc, i, &pinfo);
+                       if (ret) {
+                               /* no more entries in table */
+                               break;
+                       }
+
+                       ptr = &part_list[str_len];
+                       tmp_len = strlen((const char *)pinfo.name);
+                       str_len += tmp_len;
+                       /* +1 for space */
+                       str_len++;
+                       if (str_len > sizeof(part_list)) {
+                               printf("Error insufficient memory\n");
+                               return -ENOMEM;
+                       }
+                       strcpy(ptr, (const char *)pinfo.name);
+                       /* One byte for space(" ") delimiter */
+                       ptr[tmp_len] = ' ';
+               }
+       }
+       if (*part_list)
+               part_list[strlen(part_list) - 1] = 0;
+       debug("setenv gpt_partition_list %s\n", part_list);
+
+       return env_set("gpt_partition_list", part_list);
+}
+
+/**
+ * gpt_setenv_part_variables() - setup partition environmental variables
+ *
+ * Setup the gpt_partition_name, gpt_partition_entry, gpt_partition_addr
+ * and gpt_partition_size environment variables.
+ *
+ * @pinfo: pointer to disk partition
+ * @i: partition entry
+ *
+ * @Return: '0' on success and -ENOENT on failure
+ */
+static int gpt_setenv_part_variables(struct disk_partition *pinfo, int i)
+{
+       int ret;
+
+       ret = env_set_hex("gpt_partition_addr", pinfo->start);
+       if (ret)
+               goto fail;
+
+       ret = env_set_hex("gpt_partition_size", pinfo->size);
+       if (ret)
+               goto fail;
+
+       ret = env_set_ulong("gpt_partition_entry", i);
+       if (ret)
+               goto fail;
+
+       ret = env_set("gpt_partition_name", (const char *)pinfo->name);
+       if (ret)
+               goto fail;
+
+       return 0;
+
+fail:
+       return -ENOENT;
+}
+
+/**
+ * gpt_setenv() - Dynamically setup environment variables.
+ *
+ * Dynamically setup environment variables for name, index, offset and size
+ * for partition in GPT table after running "gpt setenv" for a partition name.
+ *
+ * @desc: block device descriptor
+ * @name: partition name
+ *
+ * @Return: '0' on success and -ve err on failure
+ */
+static int gpt_setenv(struct blk_desc *desc, const char *name)
+{
+       struct part_driver *first_drv, *part_drv;
+       int n_drvs;
+       int ret = -1;
+
+       n_drvs = part_driver_get_count();
+       if (!n_drvs) {
+               printf("Failed to get partition driver count\n");
+               goto fail;
+       }
+
+       first_drv = part_driver_get_first();
+       for (part_drv = first_drv; part_drv != first_drv + n_drvs; part_drv++) {
+               struct disk_partition pinfo;
+               int i;
+
+               for (i = 1; i < part_drv->max_entries; i++) {
+                       ret = part_drv->get_info(desc, i, &pinfo);
+                       if (ret) {
+                               /* no more entries in table */
+                               break;
+                       }
+
+                       if (!strcmp(name, (const char *)pinfo.name)) {
+                               /* match found, setup environment variables */
+                               ret = gpt_setenv_part_variables(&pinfo, i);
+                               if (ret)
+                                       goto fail;
+
+                               return 0;
+                       }
+               }
+       }
+
+fail:
+       return ret;
+}
+
 static int do_disk_guid(struct blk_desc *dev_desc, char * const namestr)
 {
        int ret;
@@ -827,6 +974,10 @@ static int do_gpt(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
        } else if ((strcmp(argv[1], "verify") == 0)) {
                ret = gpt_verify(blk_dev_desc, argv[4]);
                printf("Verify GPT: ");
+       } else if ((strcmp(argv[1], "setenv") == 0)) {
+               ret = gpt_setenv(blk_dev_desc, argv[4]);
+       } else if ((strcmp(argv[1], "enumerate") == 0)) {
+               ret = gpt_enumerate(blk_dev_desc);
        } else if (strcmp(argv[1], "guid") == 0) {
                ret = do_disk_guid(blk_dev_desc, argv[4]);
 #ifdef CONFIG_CMD_GPT_RENAME
@@ -857,7 +1008,17 @@ U_BOOT_CMD(gpt, CONFIG_SYS_MAXARGS, 1, do_gpt,
        " to interface\n"
        " Example usage:\n"
        " gpt write mmc 0 $partitions\n"
+       "    - write the GPT to device\n"
        " gpt verify mmc 0 $partitions\n"
+       "    - verify the GPT on device against $partitions\n"
+       " gpt setenv mmc 0 $name\n"
+       "    - setup environment variables for partition $name:\n"
+       "      gpt_partition_addr, gpt_partition_size,\n"
+       "      gpt_partition_name, gpt_partition_entry\n"
+       " gpt enumerate mmc 0\n"
+       "    - store list of partitions to gpt_partition_list environment variable\n"
+       " read <interface> <dev>\n"
+       "    - read GPT into a data structure for manipulation\n"
        " gpt guid <interface> <dev>\n"
        "    - print disk GUID\n"
        " gpt guid <interface> <dev> <varname>\n"
index 58e9854..4525a12 100644 (file)
@@ -819,7 +819,10 @@ config AUTOBOOT_STOP_STR_SHA256
          This option adds the feature to only stop the autobooting,
          and therefore boot into the U-Boot prompt, when the input
          string / password matches a values that is encypted via
-         a SHA256 hash and saved in the environment.
+         a SHA256 hash and saved in the environment variable
+         "bootstopkeysha256". If the value in that variable
+         includes a ":", the portion prior to the ":" will be treated
+         as a salt value.
 
 config AUTOBOOT_USE_MENUKEY
        bool "Allow a specify key to run a menu from the environment"
index bcf352d..daeea67 100644 (file)
@@ -68,7 +68,6 @@ obj-$(CONFIG_DFU_OVER_USB) += dfu.o
 endif
 obj-$(CONFIG_SPL_HASH_SUPPORT) += hash.o
 obj-$(CONFIG_TPL_HASH_SUPPORT) += hash.o
-obj-$(CONFIG_SPL_YMODEM_SUPPORT) += xyzModem.o
 obj-$(CONFIG_SPL_LOAD_FIT) += common_fit.o
 obj-$(CONFIG_SPL_NET_SUPPORT) += miiphyutil.o
 obj-$(CONFIG_$(SPL_TPL_)OF_LIBFDT) += fdt_support.o
index e628baf..ddb6246 100644 (file)
@@ -25,7 +25,7 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
-#define MAX_DELAY_STOP_STR 32
+#define MAX_DELAY_STOP_STR 64
 
 #ifndef DEBUG_BOOTKEYS
 #define DEBUG_BOOTKEYS 0
@@ -80,6 +80,7 @@ static int passwd_abort_sha256(uint64_t etime)
        u8 sha_env[SHA256_SUM_LEN];
        u8 *sha;
        char *presskey;
+       char *c;
        const char *algo_name = "sha256";
        u_int presskey_len = 0;
        int abort = 0;
@@ -89,6 +90,14 @@ static int passwd_abort_sha256(uint64_t etime)
        if (sha_env_str == NULL)
                sha_env_str = AUTOBOOT_STOP_STR_SHA256;
 
+       presskey = malloc_cache_aligned(MAX_DELAY_STOP_STR);
+       c = strstr(sha_env_str, ":");
+       if (c && (c - sha_env_str < MAX_DELAY_STOP_STR)) {
+               /* preload presskey with salt */
+               memcpy(presskey, sha_env_str, c - sha_env_str);
+               presskey_len = c - sha_env_str;
+               sha_env_str = c + 1;
+       }
        /*
         * Generate the binary value from the environment hash value
         * so that we can compare this value with the computed hash
@@ -100,7 +109,6 @@ static int passwd_abort_sha256(uint64_t etime)
                return 0;
        }
 
-       presskey = malloc_cache_aligned(MAX_DELAY_STOP_STR);
        sha = malloc_cache_aligned(SHA256_SUM_LEN);
        size = SHA256_SUM_LEN;
        /*
index 47b8762..5c158d0 100644 (file)
@@ -493,8 +493,10 @@ static int cread_line(const char *const prompt, char *buf, unsigned int *len,
                }
 #endif
                default:
-                       cread_add_char(ichar, insert, &num, &eol_num, buf,
-                                      *len);
+                       if (ichar >= ' ' && ichar <= '~') {
+                               cread_add_char(ichar, insert, &num, &eol_num,
+                                              buf, *len);
+                       }
                        break;
                }
        }
index 068cb55..3fe6791 100644 (file)
@@ -16,6 +16,8 @@
 #include <log.h>
 #include <linux/ctype.h>
 
+DECLARE_GLOBAL_DATA_PTR;
+
 /*
  * Use puts() instead of printf() to avoid printf buffer overflow
  * for long help messages
@@ -488,9 +490,6 @@ int cmd_get_data_size(char* arg, int default_size)
 }
 #endif
 
-#if defined(CONFIG_NEEDS_MANUAL_RELOC)
-DECLARE_GLOBAL_DATA_PTR;
-
 void fixup_cmdtable(struct cmd_tbl *cmdtp, int size)
 {
        int     i;
@@ -535,7 +534,6 @@ void fixup_cmdtable(struct cmd_tbl *cmdtp, int size)
                cmdtp++;
        }
 }
-#endif
 
 int cmd_always_repeatable(struct cmd_tbl *cmdtp, int flag, int argc,
                          char *const argv[], int *repeatable)
index b15f732..f3cc45c 100644 (file)
@@ -1029,11 +1029,6 @@ done:
 
        gd->flags |= GD_FLG_DEVINIT;    /* device initialization completed */
 
-#if 0
-       /* If nothing usable installed, use only the initial console */
-       if ((stdio_devices[stdin] == NULL) && (stdio_devices[stdout] == NULL))
-               return 0;
-#endif
        print_pre_console_buffer(flushpoint);
        return 0;
 }
@@ -1105,11 +1100,6 @@ int console_init_r(void)
 
        gd->flags |= GD_FLG_DEVINIT;    /* device initialization completed */
 
-#if 0
-       /* If nothing usable installed, use only the initial console */
-       if ((stdio_devices[stdin] == NULL) && (stdio_devices[stdout] == NULL))
-               return 0;
-#endif
        print_pre_console_buffer(flushpoint);
        return 0;
 }
index 795e292..a6ad094 100644 (file)
@@ -684,8 +684,11 @@ int spl_load_simple_fit(struct spl_image_info *spl_image,
 
                ret = spl_load_fit_image(info, sector, fit, base_offset, node,
                                         &image_info);
-               if (ret < 0)
-                       continue;
+               if (ret < 0) {
+                       printf("%s: can't load image loadables index %d (ret = %d)\n",
+                              __func__, index, ret);
+                       return ret;
+               }
 
                if (!spl_fit_image_get_os(fit, node, &os_type))
                        debug("Loadable is %s\n", genimg_get_os_name(os_type));
index 60b1c1d..2f92266 100644 (file)
@@ -247,10 +247,11 @@ void part_print_efi(struct blk_desc *dev_desc)
                uuid_bin = (unsigned char *)gpt_pte[i].partition_type_guid.b;
                uuid_bin_to_str(uuid_bin, uuid, UUID_STR_FORMAT_GUID);
                printf("\ttype:\t%s\n", uuid);
-#ifdef CONFIG_PARTITION_TYPE_GUID
-               if (!uuid_guid_get_str(uuid_bin, uuid))
-                       printf("\ttype:\t%s\n", uuid);
-#endif
+               if (CONFIG_IS_ENABLED(PARTITION_TYPE_GUID)) {
+                       const char *type = uuid_guid_get_str(uuid_bin);
+                       if (type)
+                               printf("\ttype:\t%s\n", type);
+               }
                uuid_bin = (unsigned char *)gpt_pte[i].unique_partition_guid.b;
                uuid_bin_to_str(uuid_bin, uuid, UUID_STR_FORMAT_GUID);
                printf("\tguid:\t%s\n", uuid);
diff --git a/doc/README.fdt-overlays b/doc/README.fdt-overlays
deleted file mode 100644 (file)
index 39139cb..0000000
+++ /dev/null
@@ -1,114 +0,0 @@
-U-Boot FDT Overlay usage
-=============================================
-
-Overlays Syntax
----------------
-
-Overlays require slightly different syntax compared to traditional overlays.
-Please refer to dt-object-internal.txt in the dtc sources for information
-regarding the internal format of overlays:
-https://git.kernel.org/pub/scm/utils/dtc/dtc.git/tree/Documentation/dt-object-internal.txt
-
-Building Overlays
------------------
-
-In a nutshell overlays provides a means to manipulate a symbol a previous dtb
-or overlay has defined. It requires both the base and all the overlays
-to be compiled with the -@ command line switch so that symbol information is
-included.
-
-Note support for -@ option can only be found in dtc version 1.4.4 or newer.
-Only version 4.14 or higher of the Linux kernel includes a built in version
-of dtc that meets this requirement.
-
-Building an overlay follows the same process as building a traditional dtb.
-
-For example:
-
-base.dts
---------
-
-       /dts-v1/;
-       / {
-               foo: foonode {
-                       foo-property;
-               };
-       };
-
-       $ dtc -@ -I dts -O dtb -o base.dtb base.dts
-
-bar.dts
--------
-
-       /dts-v1/;
-       /plugin/;
-       / {
-               fragment@1 {
-                       target = <&foo>;
-                       __overlay__ {
-                               overlay-1-property;
-                               bar: barnode {
-                                       bar-property;
-                               };
-                       };
-               };
-       };
-
-       $ dtc -@ -I dts -O dtb -o bar.dtb bar.dts
-
-Ways to Utilize Overlays in U-boot
-----------------------------------
-
-There are two ways to apply overlays in U-boot.
-1. Include and define overlays within a FIT image and have overlays
-   automatically applied.
-
-2. Manually load and apply overlays
-
-The remainder of this document will discuss using overlays via the manual
-approach. For information on using overlays as part of a FIT image please see:
-doc/uImage.FIT/overlay-fdt-boot.txt
-
-Manually Loading and Applying Overlays
---------------------------------------
-
-1. Figure out where to place both the base device tree blob and the
-overlay. Make sure you have enough space to grow the base tree without
-overlapping anything.
-
-=> setenv fdtaddr 0x87f00000
-=> setenv fdtovaddr 0x87fc0000
-
-2. Load the base blob and overlay blobs
-
-=> load ${devtype} ${bootpart} ${fdtaddr} ${bootdir}/base.dtb
-=> load ${devtype} ${bootpart} ${fdtovaddr} ${bootdir}/overlay.dtb
-
-3. Set it as the working fdt tree.
-
-=> fdtaddr $fdtaddr
-
-4. Grow it enough so it can 'fit' all the applied overlays
-
-=> fdt resize 8192
-
-5. You are now ready to apply the overlay.
-
-=> fdt apply $fdtovaddr
-
-6. Boot system like you would do with a traditional dtb.
-
-For bootm:
-
-=> bootm ${kerneladdr} - ${fdtaddr}
-
-For bootz:
-
-=> bootz ${kerneladdr} - ${fdtaddr}
-
-Please note that in case of an error, both the base and overlays are going
-to be invalidated, so keep copies to avoid reloading.
-
-Pantelis Antoniou
-pantelis.antoniou@konsulko.com
-11/7/2017
index facd7af..ac975f6 100644 (file)
@@ -251,22 +251,24 @@ can specify a other partition type guid:
        type=0FC63DAF-8483-4772-8E79-3D69D8477DE4;"
 
 Some strings can be also used at the place of known GUID :
-       "system" = PARTITION_SYSTEM_GUID
-                  (C12A7328-F81F-11D2-BA4B-00A0C93EC93B)
-       "mbr"    = LEGACY_MBR_PARTITION_GUID
-                  (024DEE41-33E7-11D3-9D69-0008C781F39F)
-       "msft"   = PARTITION_MSFT_RESERVED_GUID
-                  (E3C9E316-0B5C-4DB8-817D-F92DF00215AE)
-       "data"   = PARTITION_BASIC_DATA_GUID
-                   (EBD0A0A2-B9E5-4433-87C0-68B6B72699C7)
-       "linux"  = PARTITION_LINUX_FILE_SYSTEM_DATA_GUID
-                  (0FC63DAF-8483-4772-8E79-3D69D8477DE4)
-       "raid"   = PARTITION_LINUX_RAID_GUID
-                  (A19D880F-05FC-4D3B-A006-743F0F84911E)
-       "swap"   = PARTITION_LINUX_SWAP_GUID
-                  (0657FD6D-A4AB-43C4-84E5-0933C84B4F4F)
-       "lvm"    = PARTITION_LINUX_LVM_GUID
-                  (E6D6D379-F507-44C2-A23C-238F2A3DF928)
+       "system"          = PARTITION_SYSTEM_GUID
+                           (C12A7328-F81F-11D2-BA4B-00A0C93EC93B)
+       "mbr"             = LEGACY_MBR_PARTITION_GUID
+                           (024DEE41-33E7-11D3-9D69-0008C781F39F)
+       "msft"            = PARTITION_MSFT_RESERVED_GUID
+                           (E3C9E316-0B5C-4DB8-817D-F92DF00215AE)
+       "data"            = PARTITION_BASIC_DATA_GUID
+                            (EBD0A0A2-B9E5-4433-87C0-68B6B72699C7)
+       "linux"           = PARTITION_LINUX_FILE_SYSTEM_DATA_GUID
+                           (0FC63DAF-8483-4772-8E79-3D69D8477DE4)
+       "raid"            = PARTITION_LINUX_RAID_GUID
+                           (A19D880F-05FC-4D3B-A006-743F0F84911E)
+       "swap"            = PARTITION_LINUX_SWAP_GUID
+                           (0657FD6D-A4AB-43C4-84E5-0933C84B4F4F)
+       "lvm"             = PARTITION_LINUX_LVM_GUID
+                           (E6D6D379-F507-44C2-A23C-238F2A3DF928)
+       "u-boot-env"      = PARTITION_U_BOOT_ENVIRONMENT
+                           (3DE21764-95BD-54BD-A5C3-4ABE786F38A8)
 
     "uuid_disk=...;name=u-boot,size=60MiB,uuid=...;
        name=kernel,size=60MiB,uuid=...,type=linux;"
index 37d7d08..de14d85 100644 (file)
@@ -134,7 +134,7 @@ B4860QDS Default Settings
 -------------------------
 
 Switch Settings
----------------
+^^^^^^^^^^^^^^^
 
 .. code-block:: none
 
@@ -167,7 +167,7 @@ B4420QDS Default Settings
 -------------------------
 
 Switch Settings
----------------
+^^^^^^^^^^^^^^^
 
 .. code-block:: none
 
index 1ce9ab1..4e4c852 100644 (file)
@@ -12,6 +12,7 @@ of running Linux.
 
 Mainline support
 ----------------
+
 The support for following drivers are already enabled:
 
 1. SiFive UART Driver.
@@ -24,7 +25,7 @@ Booting from MMC using FSBL
 ---------------------------
 
 Building
---------
+~~~~~~~~
 
 1. Add the RISC-V toolchain to your PATH.
 2. Setup ARCH & cross compilation environment variable:
@@ -37,7 +38,7 @@ Building
 4. make
 
 Flashing
---------
+~~~~~~~~
 
 The current U-Boot port is supported in S-mode only and loaded from DRAM.
 
@@ -63,11 +64,12 @@ copied to the first partition of the sdcard.
     sudo dd if=<prior_stage_firmware_binary> of=/dev/disk2s1 bs=1024
 
 Booting
--------
+~~~~~~~
+
 Once you plugin the sdcard and power up, you should see the U-Boot prompt.
 
 Sample boot log from HiFive Unleashed board
--------------------------------------------
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
 .. code-block:: none
 
@@ -417,7 +419,7 @@ Booting from MMC using U-Boot SPL
 ---------------------------------
 
 Building
---------
+~~~~~~~~
 
 Before building U-Boot SPL, OpenSBI must be built first. OpenSBI can be
 cloned and built for FU540 as below:
@@ -441,7 +443,7 @@ This will generate spl/u-boot-spl.bin and FIT image (u-boot.itb)
 
 
 Flashing
---------
+~~~~~~~~
 
 ZSBL loads the U-Boot SPL (u-boot-spl.bin) from a partition with GUID type
 5B193300-FC78-40CD-8002-E86C45580B47
@@ -471,11 +473,12 @@ Program the SD card
        sudo dd if=u-boot.itb of=/dev/sda seek=2082
 
 Booting
--------
+~~~~~~~
+
 Once you plugin the sdcard and power up, you should see the U-Boot prompt.
 
 Sample boot log from HiFive Unleashed board
--------------------------------------------
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
 .. code-block:: none
 
diff --git a/doc/usage/base.rst b/doc/usage/base.rst
new file mode 100644 (file)
index 0000000..db9cd4d
--- /dev/null
@@ -0,0 +1,23 @@
+.. SPDX-License-Identifier: GPL-2.0+
+
+base command
+============
+
+Synopsis
+--------
+
+::
+
+    base [address]
+
+Description
+-----------
+
+The *base* command sets or displays the address offset used by the memory
+commands *cmp, cp, md, mdc, mm, ms, mw, mwc*.
+
+All other commands ignore the address defined by *base*.
+
+address
+    new base address as hexadecimal number. If no value is provided, the current
+    value is displayed.
diff --git a/doc/usage/fdt_overlays.rst b/doc/usage/fdt_overlays.rst
new file mode 100644 (file)
index 0000000..ea39713
--- /dev/null
@@ -0,0 +1,134 @@
+.. SPDX-License-Identifier: GPL-2.0+
+.. Copyright (c) 2017, Pantelis Antoniou <pantelis.antoniou@konsulko.com>
+
+Device Tree Overlays
+====================
+
+Overlay Syntax
+--------------
+
+Device-tree overlays require a slightly different syntax compared to traditional
+device-trees. Please refer to dt-object-internal.txt in the device-tree compiler
+sources for information regarding the internal format of overlays:
+https://git.kernel.org/pub/scm/utils/dtc/dtc.git/tree/Documentation/dt-object-internal.txt
+
+Building Overlays
+-----------------
+
+In a nutshell overlays provides a means to manipulate a symbol a previous
+device-tree or device-tree overlay has defined. It requires both the base
+device-tree and all the overlays to be compiled with the *-@* command line
+switch of the device-tree compiler so that symbol information is included.
+
+Note
+    Support for *-@* option can only be found in dtc version 1.4.4 or newer.
+    Only version 4.14 or higher of the Linux kernel includes a built in version
+    of dtc that meets this requirement.
+
+Building a binary device-tree overlay follows the same process as building a
+traditional binary device-tree. For example:
+
+**base.dts**
+
+::
+
+       /dts-v1/;
+       / {
+               foo: foonode {
+                       foo-property;
+               };
+       };
+
+.. code-block:: console
+
+       $ dtc -@ -I dts -O dtb -o base.dtb base.dts
+
+**overlay.dts**
+
+::
+
+       /dts-v1/;
+       /plugin/;
+       / {
+               fragment@1 {
+                       target = <&foo>;
+                       __overlay__ {
+                               overlay-1-property;
+                               bar: barnode {
+                                       bar-property;
+                               };
+                       };
+               };
+       };
+
+.. code-block:: console
+
+       $ dtc -@ -I dts -O dtb -o overlay.dtbo overlay.dts
+
+Ways to Utilize Overlays in U-Boot
+----------------------------------
+
+There are two ways to apply overlays in U-Boot.
+
+* Include and define overlays within a FIT image and have overlays
+  automatically applied.
+
+* Manually load and apply overlays
+
+The remainder of this document will discuss using overlays via the manual
+approach. For information on using overlays as part of a FIT image please see:
+doc/uImage.FIT/overlay-fdt-boot.txt
+
+Manually Loading and Applying Overlays
+--------------------------------------
+
+1. Figure out where to place both the base device tree blob and the
+   overlay. Make sure you have enough space to grow the base tree without
+   overlapping anything.
+
+::
+
+    => setenv fdtaddr 0x87f00000
+    => setenv fdtovaddr 0x87fc0000
+
+2. Load the base binary device-tree and the binary device-tree overlay.
+
+::
+
+    => load ${devtype} ${bootpart} ${fdtaddr} ${bootdir}/base.dtb
+    => load ${devtype} ${bootpart} ${fdtovaddr} ${bootdir}/overlay.dtbo
+
+3. Set the base binary device-tree as the working fdt tree.
+
+::
+
+    => fdtaddr $fdtaddr
+
+4. Grow it enough so it can encompass all applied overlays
+
+::
+
+    => fdt resize 8192
+
+5. You are now ready to apply the overlay.
+
+::
+
+    => fdt apply $fdtovaddr
+
+6. Boot system like you would do with a traditional dtb.
+
+For bootm:
+
+::
+
+    => bootm ${kerneladdr} - ${fdtaddr}
+
+For bootz:
+
+::
+
+    => bootz ${kerneladdr} - ${fdtaddr}
+
+Please note that in case of an error, both the base and overlays are going
+to be invalidated, so keep copies to avoid reloading.
index 5869fba..6def250 100644 (file)
@@ -2,7 +2,9 @@ Use U-Boot
 ==========
 
 .. toctree::
+   :maxdepth: 1
 
+   fdt_overlays
    netconsole
 
 Shell commands
@@ -11,6 +13,7 @@ Shell commands
 .. toctree::
    :maxdepth: 1
 
+   base
    bootefi
    bootmenu
    button
index 8c4e527..1c83745 100644 (file)
@@ -1,8 +1,17 @@
 .. SPDX-License-Identifier: GPL-2.0+
 
-PStore command
+pstore command
 ==============
 
+Synopsis
+--------
+
+::
+
+    pstore set <addr> <len> [record-size] [console-size] [ftrace-size] [pmsg_size] [ecc-size]
+    pstore display [record-type] [nb]
+    pstore save <interface> <dev[:part]> <directory-path>
+
 Design
 ------
 
index cdb975d..f38122d 100644 (file)
@@ -757,6 +757,25 @@ int uclass_pre_remove_device(struct udevice *dev)
 }
 #endif
 
+int uclass_probe_all(enum uclass_id id)
+{
+       struct udevice *dev;
+       int ret;
+
+       ret = uclass_first_device(id, &dev);
+       if (ret || !dev)
+               return ret;
+
+       /* Scanning uclass to probe all devices */
+       while (dev) {
+               ret = uclass_next_device(&dev);
+               if (ret)
+                       return ret;
+       }
+
+       return 0;
+}
+
 UCLASS_DRIVER(nop) = {
        .id             = UCLASS_NOP,
        .name           = "nop",
index 1a4dec3..0d1f94c 100644 (file)
@@ -9,8 +9,6 @@
  */
 
 #ifndef __UBOOT__
-#include <log.h>
-#include <dm/devres.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/ptrace.h>
index d431102..fbbea18 100644 (file)
@@ -18,7 +18,7 @@ config DM_REGULATOR
 
 config SPL_DM_REGULATOR
        bool "Enable regulators for SPL"
-       depends on DM_REGULATOR
+       depends on DM_REGULATOR && SPL_POWER_SUPPORT
        ---help---
        Regulators are seldom needed in SPL. Even if they are accessed, some
        code space can be saved by accessing the PMIC registers directly.
index fc80fb1..68043d7 100644 (file)
@@ -719,7 +719,7 @@ uint32_t lpddr4_checkctlinterrupt(const lpddr4_privatedata * pd,
 
                /* MISRA compliance (Shifting operation) check */
                if (fieldshift < WORD_SHIFT) {
-                       if (((ctlirqstatus >> fieldshift) & BIT_MASK) > 0U) {
+                       if ((ctlirqstatus >> fieldshift) & LPDDR4_BIT_MASK) {
                                *irqstatus = true;
                        } else {
                                *irqstatus = false;
@@ -746,11 +746,11 @@ uint32_t lpddr4_ackctlinterrupt(const lpddr4_privatedata * pd,
                if (localinterrupt > WORD_SHIFT) {
                        localinterrupt =
                            (localinterrupt - (uint32_t) WORD_SHIFT);
-                       regval = ((uint32_t) BIT_MASK << localinterrupt);
+                       regval = (uint32_t)LPDDR4_BIT_MASK << localinterrupt;
                        CPS_REG_WRITE(&(ctlregbase->LPDDR4__INT_ACK_1__REG),
                                      regval);
                } else {
-                       regval = ((uint32_t) BIT_MASK << localinterrupt);
+                       regval = (uint32_t)LPDDR4_BIT_MASK << localinterrupt;
                        CPS_REG_WRITE(&(ctlregbase->LPDDR4__INT_ACK_0__REG),
                                      regval);
                }
@@ -823,7 +823,7 @@ uint32_t lpddr4_checkphyindepinterrupt(const lpddr4_privatedata * pd,
                phyindepirqstatus =
                    CPS_REG_READ(&(ctlregbase->LPDDR4__PI_INT_STATUS__REG));
                *irqstatus =
-                   (((phyindepirqstatus >> (uint32_t) intr) & BIT_MASK) > 0U);
+                   !!((phyindepirqstatus >> (uint32_t)intr) & LPDDR4_BIT_MASK);
        }
        return result;
 }
@@ -841,7 +841,7 @@ uint32_t lpddr4_ackphyindepinterrupt(const lpddr4_privatedata * pd,
                lpddr4_ctlregs *ctlregbase = (lpddr4_ctlregs *) pd->ctlbase;
 
                /* Write 1 to the requested bit to ACk the interrupt */
-               regval = ((uint32_t) BIT_MASK << ui32shiftinterrupt);
+               regval = (uint32_t)LPDDR4_BIT_MASK << ui32shiftinterrupt;
                CPS_REG_WRITE(&(ctlregbase->LPDDR4__PI_INT_ACK__REG), regval);
        }
 
@@ -894,7 +894,7 @@ static void lpddr4_checkwrlvlerror(lpddr4_ctlregs * ctlregbase,
            (volatile uint32_t
             *)(&(ctlregbase->LPDDR4__PHY_WRLVL_ERROR_OBS_0__REG));
        /* PHY_WRLVL_ERROR_OBS_X[1:0] should be zero */
-       errbitmask = (BIT_MASK << 1) | (BIT_MASK);
+       errbitmask = (LPDDR4_BIT_MASK << 1) | LPDDR4_BIT_MASK;
        for (snum = 0U; snum < DSLICE_NUM; snum++) {
                regval = CPS_REG_READ(regaddress);
                if ((regval & errbitmask) != 0U) {
@@ -1054,7 +1054,7 @@ static void lpddr4_seterrors(lpddr4_ctlregs * ctlregbase,
                             lpddr4_debuginfo * debuginfo, bool * errfoundptr)
 {
 
-       uint32_t errbitmask = (BIT_MASK << 0x1U) | (BIT_MASK);
+       uint32_t errbitmask = (LPDDR4_BIT_MASK << 0x1U) | LPDDR4_BIT_MASK;
        /* Check PLL observation registers for PLL lock errors */
 
        debuginfo->pllerror =
index 42c9234..3d5017e 100644 (file)
@@ -14,9 +14,9 @@
 #define VERSION_0  (0x54d5da40U)
 #define VERSION_1  (0xc1865a1U)
 
-#define BIT_MASK    (0x1U)
-#define BYTE_MASK   (0xffU)
-#define NIBBLE_MASK (0xfU)
+#define LPDDR4_BIT_MASK        (0x1U)
+#define BYTE_MASK      (0xffU)
+#define NIBBLE_MASK    (0xfU)
 
 #define WORD_SHIFT (32U)
 #define WORD_MASK (0xffffffffU)
 #define IO_CALIB_DONE ((uint32_t)0x1U << 23U)
 #define IO_CALIB_FIELD ((uint32_t)NIBBLE_MASK << 28U)
 #define IO_CALIB_STATE ((uint32_t)0xBU << 28U)
-#define RX_CAL_DONE ((uint32_t)BIT_MASK << 4U)
-#define CA_TRAIN_RL (((uint32_t)BIT_MASK << 5U) | ((uint32_t)BIT_MASK << 4U))
+#define RX_CAL_DONE ((uint32_t)LPDDR4_BIT_MASK << 4U)
+#define CA_TRAIN_RL (((uint32_t)LPDDR4_BIT_MASK << 5U) | \
+                    ((uint32_t)LPDDR4_BIT_MASK << 4U))
 #define WR_LVL_STATE (((uint32_t)NIBBLE_MASK) << 13U)
-#define GATE_LVL_ERROR_FIELDS (((uint32_t)BIT_MASK << 7U) | ((uint32_t)BIT_MASK << 6U))
-#define READ_LVL_ERROR_FIELDS ((((uint32_t)NIBBLE_MASK) << 28U) | (((uint32_t)BYTE_MASK) << 16U))
-#define DQ_LVL_STATUS (((uint32_t)BIT_MASK << 26U) | (((uint32_t)BYTE_MASK) << 18U))
+#define GATE_LVL_ERROR_FIELDS (((uint32_t)LPDDR4_BIT_MASK << 7U) | \
+                              ((uint32_t)LPDDR4_BIT_MASK << 6U))
+#define READ_LVL_ERROR_FIELDS ((((uint32_t)NIBBLE_MASK) << 28U) | \
+                              (((uint32_t)BYTE_MASK) << 16U))
+#define DQ_LVL_STATUS (((uint32_t)LPDDR4_BIT_MASK << 26U) | \
+                      (((uint32_t)BYTE_MASK) << 18U))
 
 #endif  /* LPDDR4_PRIV_H */
index b4805a2..1294943 100644 (file)
@@ -134,6 +134,22 @@ config SERIAL_SEARCH_ALL
 
          If unsure, say N.
 
+config SERIAL_PROBE_ALL
+       bool "Probe all available serial devices"
+       depends on DM_SERIAL
+       default n
+       help
+         The serial subsystem only probes for a single serial device,
+         but does not probe for other remaining serial devices.
+         With this option set, we make probing and searching for
+         all available devices optional.
+         Normally, U-Boot talks to one serial port at a time, but SBSA
+         compliant UART devices like PL011 require initialization
+         by firmware and to let the kernel use serial port for sending
+         and receiving the characters.
+
+         If unsure, say N.
+
 config SPL_DM_SERIAL
        bool "Enable Driver Model for serial drivers in SPL"
        depends on DM_SERIAL && SPL_DM
index 58a6541..ead0193 100644 (file)
@@ -172,6 +172,15 @@ int serial_init(void)
 /* Called after relocation */
 int serial_initialize(void)
 {
+       /* Scanning uclass to probe devices */
+       if (IS_ENABLED(CONFIG_SERIAL_PROBE_ALL)) {
+               int ret;
+
+               ret  = uclass_probe_all(UCLASS_SERIAL);
+               if (ret)
+                       return ret;
+       }
+
        return serial_init();
 }
 
index d39d9b2..d782eb8 100644 (file)
@@ -199,7 +199,7 @@ config PANEL
 
 config SIMPLE_PANEL
        bool "Enable simple panel support"
-       depends on PANEL
+       depends on PANEL && BACKLIGHT
        default y
        help
          This turns on a simple panel driver that enables a compatible
index 94967cf..cb31113 100644 (file)
@@ -33,7 +33,7 @@ targets += dt.dtb
 $(DTB): arch-dtbs
        $(Q)test -e $@ || (                                             \
        echo >&2;                                                       \
-       echo >&2 "Device Tree Source is not correctly specified.";      \
+       echo >&2 "Device Tree Source ($@) is not correctly specified."; \
        echo >&2 "Please define 'CONFIG_DEFAULT_DEVICE_TREE'";          \
        echo >&2 "or build with 'DEVICE_TREE=<device_tree>' argument";  \
        echo >&2;                                                       \
index b5f066d..d956837 100644 (file)
@@ -377,6 +377,17 @@ int uclass_first_device_drvdata(enum uclass_id id, ulong driver_data,
                                struct udevice **devp);
 
 /**
+ * uclass_probe_all() - Probe all devices based on an uclass ID
+ *
+ * This function probes all devices associated with a uclass by
+ * looking for its ID.
+ *
+ * @id: uclass ID to look up
+ * @return 0 if OK, other -ve on error
+ */
+int uclass_probe_all(enum uclass_id id);
+
+/**
  * uclass_id_foreach_dev() - Helper function to iteration through devices
  *
  * This creates a for() loop which works through the available devices in
index 6bce560..2d27f9f 100644 (file)
@@ -156,6 +156,9 @@ static inline int _log_nop(enum log_category_t cat, enum log_level_t level,
  */
 #if CONFIG_IS_ENABLED(LOG)
 #define _LOG_MAX_LEVEL CONFIG_VAL(LOG_MAX_LEVEL)
+#define log_emer(_fmt...)      log(LOG_CATEGORY, LOGL_EMERG, ##_fmt)
+#define log_alert(_fmt...)     log(LOG_CATEGORY, LOGL_ALERT, ##_fmt)
+#define log_crit(_fmt...)      log(LOG_CATEGORY, LOGL_CRIT, ##_fmt)
 #define log_err(_fmt...)       log(LOG_CATEGORY, LOGL_ERR, ##_fmt)
 #define log_warning(_fmt...)   log(LOG_CATEGORY, LOGL_WARNING, ##_fmt)
 #define log_notice(_fmt...)    log(LOG_CATEGORY, LOGL_NOTICE, ##_fmt)
@@ -163,12 +166,17 @@ static inline int _log_nop(enum log_category_t cat, enum log_level_t level,
 #define log_debug(_fmt...)     log(LOG_CATEGORY, LOGL_DEBUG, ##_fmt)
 #define log_content(_fmt...)   log(LOG_CATEGORY, LOGL_DEBUG_CONTENT, ##_fmt)
 #define log_io(_fmt...)                log(LOG_CATEGORY, LOGL_DEBUG_IO, ##_fmt)
+#define log_cont(_fmt...)      log(LOGC_CONT, LOGL_CONT, ##_fmt)
 #else
 #define _LOG_MAX_LEVEL LOGL_INFO
+#define log_emerg(_fmt, ...)   printf(_fmt, ##__VA_ARGS__)
+#define log_alert(_fmt, ...)   printf(_fmt, ##__VA_ARGS__)
+#define log_crit(_fmt, ...)    printf(_fmt, ##__VA_ARGS__)
 #define log_err(_fmt, ...)     printf(_fmt, ##__VA_ARGS__)
 #define log_warning(_fmt, ...) printf(_fmt, ##__VA_ARGS__)
 #define log_notice(_fmt, ...)  printf(_fmt, ##__VA_ARGS__)
 #define log_info(_fmt, ...)    printf(_fmt, ##__VA_ARGS__)
+#define log_cont(_fmt, ...)    printf(_fmt, ##__VA_ARGS__)
 #define log_debug(_fmt, ...)   debug(_fmt, ##__VA_ARGS__)
 #define log_content(_fmt...)   log_nop(LOG_CATEGORY, \
                                        LOGL_DEBUG_CONTENT, ##_fmt)
@@ -217,10 +225,9 @@ static inline int _log_nop(enum log_category_t cat, enum log_level_t level,
 #if !_DEBUG && CONFIG_IS_ENABLED(LOG)
 
 #define debug_cond(cond, fmt, args...)                 \
-       do {                                            \
-               if (1)                                  \
-                       log(LOG_CATEGORY, LOGL_DEBUG, fmt, ##args); \
-       } while (0)
+({                                                     \
+       log(LOG_CATEGORY, LOGL_DEBUG, fmt, ##args);     \
+})
 
 #else /* _DEBUG */
 
@@ -229,11 +236,11 @@ static inline int _log_nop(enum log_category_t cat, enum log_level_t level,
  * computed by a preprocessor in the best case, allowing for the best
  * optimization.
  */
-#define debug_cond(cond, fmt, args...)                 \
-       do {                                            \
-               if (cond)                               \
-                       printf(pr_fmt(fmt), ##args);    \
-       } while (0)
+#define debug_cond(cond, fmt, args...)         \
+({                                             \
+       if (cond)                               \
+               printf(pr_fmt(fmt), ##args);    \
+})
 
 #endif /* _DEBUG */
 
index fac3636..815515a 100644 (file)
@@ -9,6 +9,7 @@
 #include <blk.h>
 #include <ide.h>
 #include <uuid.h>
+#include <linker_lists.h>
 #include <linux/list.h>
 
 struct block_drvr {
@@ -481,5 +482,33 @@ int layout_mbr_partitions(struct disk_partition *p, int count,
 
 #endif
 
+#ifdef CONFIG_PARTITIONS
+/**
+ * part_driver_get_count() - get partition driver count
+ *
+ * @return - number of partition drivers
+ */
+static inline int part_driver_get_count(void)
+{
+       return ll_entry_count(struct part_driver, part_driver);
+}
+
+/**
+ * part_driver_get_first() - get first partition driver
+ *
+ * @return - pointer to first partition driver on success, otherwise NULL
+ */
+static inline struct part_driver *part_driver_get_first(void)
+{
+       return ll_entry_start(struct part_driver, part_driver);
+}
+
+#else
+static inline int part_driver_get_count(void)
+{ return 0; }
+
+static inline struct part_driver *part_driver_get_first(void)
+{ return NULL; }
+#endif /* CONFIG_PARTITIONS */
 
 #endif /* _PART_H */
index 1929e44..c68529b 100644 (file)
@@ -56,6 +56,9 @@
 #define PARTITION_LINUX_LVM_GUID \
        EFI_GUID( 0xe6d6d379, 0xf507, 0x44c2, \
                0xa2, 0x3c, 0x23, 0x8f, 0x2a, 0x3d, 0xf9, 0x28)
+#define PARTITION_U_BOOT_ENVIRONMENT \
+       EFI_GUID( 0x3de21764, 0x95bd, 0x54bd, \
+               0xa5, 0xc3, 0x4a, 0xbe, 0x78, 0x6f, 0x38, 0xa8)
 
 /* linux/include/efi.h */
 typedef u16 efi_char16_t;
index 3f2ee75..17400c7 100644 (file)
@@ -338,4 +338,22 @@ ulong ut_check_free(void);
  */
 long ut_check_delta(ulong last);
 
+/**
+ * ut_silence_console() - Silence the console if requested by the user
+ *
+ * This stops test output from appear on the console. It is the default on
+ * sandbox, unless the -v flag is given. For other boards, this does nothing.
+ *
+ * @uts: Test state (in case in future we want to keep state here)
+ */
+void ut_silence_console(struct unit_test_state *uts);
+
+/**
+ * ut_unsilence_console() - Unsilence the console after a test
+ *
+ * This restarts console output again and turns off console recording. This
+ * happens on all boards, including sandbox.
+ */
+void ut_unsilence_console(struct unit_test_state *uts);
+
 #endif
index 73c5a89..0c653cb 100644 (file)
@@ -39,10 +39,8 @@ int uuid_str_to_bin(const char *uuid_str, unsigned char *uuid_bin,
                    int str_format);
 void uuid_bin_to_str(const unsigned char *uuid_bin, char *uuid_str,
                     int str_format);
-#ifdef CONFIG_PARTITION_TYPE_GUID
 int uuid_guid_get_bin(const char *guid_str, unsigned char *guid_bin);
-int uuid_guid_get_str(const unsigned char *guid_bin, char *guid_str);
-#endif
+const char *uuid_guid_get_str(const unsigned char *guid_bin);
 void gen_rand_uuid(unsigned char *uuid_bin);
 void gen_rand_uuid_str(char *uuid_str, int str_format);
 #endif
index 9b9177f..b35a71a 100644 (file)
@@ -696,8 +696,8 @@ config LIB_DATE
 config LIB_ELF
        bool
        help
-         Supoort basic elf loading/validating functions.
-         This supports fir 32 bit and 64 bit versions.
+         Support basic elf loading/validating functions.
+         This supports for 32 bit and 64 bit versions.
 
 endmenu
 
index c998aec..05ec235 100644 (file)
--- a/lib/aes.c
+++ b/lib/aes.c
@@ -619,7 +619,7 @@ void aes_decrypt(u32 key_len, u8 *in, u8 *expkey, u8 *out)
 static void debug_print_vector(char *name, u32 num_bytes, u8 *data)
 {
 #ifdef DEBUG
-       printf("%s [%d] @0x%08x", name, num_bytes, (u32)data);
+       printf("%s [%d] @0x%p", name, num_bytes, data);
        print_buffer(0, data, 1, num_bytes, 16);
 #endif
 }
index ae7835f..73b9841 100644 (file)
@@ -567,7 +567,19 @@ void * memmove(void * dest,const void *src,size_t count)
 {
        char *tmp, *s;
 
-       if (dest <= src) {
+       if (dest <= src || (src + count) <= dest) {
+       /*
+        * Use the fast memcpy implementation (ARCH optimized or lib/string.c) when it is possible:
+        * - when dest is before src (assuming that memcpy is doing forward-copying)
+        * - when destination don't overlap the source buffer (src + count <= dest)
+        *
+        * WARNING: the first optimisation cause an issue, when __HAVE_ARCH_MEMCPY is defined,
+        *          __HAVE_ARCH_MEMMOVE is not defined and if the memcpy ARCH-specific
+        *          implementation is not doing a forward-copying.
+        *
+        * No issue today because memcpy is doing a forward-copying in lib/string.c and for ARM32
+        * architecture; no other arches use __HAVE_ARCH_MEMCPY without __HAVE_ARCH_MEMMOVE.
+        */
                memcpy(dest, src, count);
        } else {
                tmp = (char *) dest + count;
index e62d5ca..54a93aa 100644 (file)
@@ -96,7 +96,8 @@ static const struct {
        {"linux",       PARTITION_LINUX_FILE_SYSTEM_DATA_GUID},
        {"raid",        PARTITION_LINUX_RAID_GUID},
        {"swap",        PARTITION_LINUX_SWAP_GUID},
-       {"lvm",         PARTITION_LINUX_LVM_GUID}
+       {"lvm",         PARTITION_LINUX_LVM_GUID},
+       {"u-boot-env",  PARTITION_U_BOOT_ENVIRONMENT},
 };
 
 /*
@@ -122,20 +123,19 @@ int uuid_guid_get_bin(const char *guid_str, unsigned char *guid_bin)
  * uuid_guid_get_str() - this function get string for GUID.
  *
  * @param guid_bin - pointer to string with partition type guid [16B]
- * @param guid_str - pointer to allocated partition type string [7B]
+ *
+ * Returns NULL if the type GUID is not known.
  */
-int uuid_guid_get_str(const unsigned char *guid_bin, char *guid_str)
+const char *uuid_guid_get_str(const unsigned char *guid_bin)
 {
        int i;
 
-       *guid_str = 0;
        for (i = 0; i < ARRAY_SIZE(list_guid); i++) {
                if (!memcmp(list_guid[i].guid.b, guid_bin, 16)) {
-                       strcpy(guid_str, list_guid[i].string);
-                       return 0;
+                       return list_guid[i].string;
                }
        }
-       return -ENODEV;
+       return NULL;
 }
 #endif
 
index 1fe58d5..6347335 100644 (file)
@@ -1284,7 +1284,7 @@ local void check_match(s, start, match, length)
     }
     if (z_verbose > 1) {
         fprintf(stderr,"\\[%d,%d]", start-match, length);
-        do { putc(s->window[start++], stderr); } while (--length != 0);
+       do { putc(s->window[start++]); } while (--length != 0);
     }
 }
 #else
index 3e09517..700c62f 100644 (file)
@@ -38,7 +38,7 @@
 #include "deflate.h"
 
 #ifdef DEBUG
-#  include <ctype.h>
+#  include <linux/ctype.h>
 #endif
 
 /* ===========================================================================
index d4323f9..3c7bc8b 100644 (file)
@@ -2,7 +2,7 @@
 #
 # (C) Copyright 2012 The Chromium Authors
 
-ifneq ($(CONFIG_SANDBOX),)
+ifneq ($(CONFIG_$(SPL_)BLOBLIST),)
 obj-$(CONFIG_$(SPL_)CMDLINE) += bloblist.o
 endif
 obj-$(CONFIG_$(SPL_)CMDLINE) += bootm.o
index 0bb9e2d..900299d 100644 (file)
@@ -7,7 +7,6 @@
 #include <bloblist.h>
 #include <log.h>
 #include <mapmem.h>
-#include <asm/state.h>
 #include <test/suites.h>
 #include <test/test.h>
 #include <test/ut.h>
@@ -240,7 +239,6 @@ BLOBLIST_TEST(bloblist_test_checksum, 0);
 /* Test the 'bloblist info' command */
 static int bloblist_test_cmd_info(struct unit_test_state *uts)
 {
-       struct sandbox_state *state = state_get_current();
        struct bloblist_hdr *hdr;
        char *data, *data2;
 
@@ -250,8 +248,7 @@ static int bloblist_test_cmd_info(struct unit_test_state *uts)
        data2 = bloblist_ensure(TEST_TAG2, TEST_SIZE2);
 
        console_record_reset_enable();
-       if (!state->show_test_output)
-               gd->flags |= GD_FLG_SILENT;
+       ut_silence_console(uts);
        console_record_reset();
        run_command("bloblist info", 0);
        ut_assert_nextline("base:     %lx", (ulong)map_to_sysmem(hdr));
@@ -259,7 +256,7 @@ static int bloblist_test_cmd_info(struct unit_test_state *uts)
        ut_assert_nextline("alloced:  70     112 Bytes");
        ut_assert_nextline("free:     390    912 Bytes");
        ut_assert_console_end();
-       gd->flags &= ~(GD_FLG_SILENT | GD_FLG_RECORD);
+       ut_unsilence_console(uts);
 
        return 0;
 }
@@ -268,7 +265,6 @@ BLOBLIST_TEST(bloblist_test_cmd_info, 0);
 /* Test the 'bloblist list' command */
 static int bloblist_test_cmd_list(struct unit_test_state *uts)
 {
-       struct sandbox_state *state = state_get_current();
        struct bloblist_hdr *hdr;
        char *data, *data2;
 
@@ -278,8 +274,7 @@ static int bloblist_test_cmd_list(struct unit_test_state *uts)
        data2 = bloblist_ensure(TEST_TAG2, TEST_SIZE2);
 
        console_record_reset_enable();
-       if (!state->show_test_output)
-               gd->flags |= GD_FLG_SILENT;
+       ut_silence_console(uts);
        console_record_reset();
        run_command("bloblist list", 0);
        ut_assert_nextline("Address       Size  Tag Name");
@@ -288,7 +283,7 @@ static int bloblist_test_cmd_list(struct unit_test_state *uts)
        ut_assert_nextline("%08lx  %8x    2 SPL hand-off",
                           (ulong)map_to_sysmem(data2), TEST_SIZE2);
        ut_assert_console_end();
-       gd->flags &= ~(GD_FLG_SILENT | GD_FLG_RECORD);
+       ut_unsilence_console(uts);
 
        return 0;
 }
index fa6770e..fbaa8a4 100644 (file)
@@ -15,6 +15,6 @@ int do_ut_mem(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
        struct unit_test *tests = ll_entry_start(struct unit_test, mem_test);
        const int n_ents = ll_entry_count(struct unit_test, mem_test);
 
-       return cmd_ut_category("cmd_mem", "cmd_mem_", tests, n_ents, argc,
+       return cmd_ut_category("cmd_mem", "mem_test_", tests, n_ents, argc,
                               argv);
 }
index 98a9abf..97c11e3 100644 (file)
@@ -7,7 +7,7 @@ obj-$(CONFIG_EFI_LOADER) += efi_device_path.o
 obj-$(CONFIG_EFI_SECURE_BOOT) += efi_image_region.o
 obj-y += hexdump.o
 obj-y += lmb.o
-obj-y += test_print.o
+obj-$(CONFIG_CONSOLE_RECORD) += test_print.o
 obj-$(CONFIG_SSCANF) += sscanf.o
 obj-y += string.o
 obj-$(CONFIG_ERRNO_STR) += test_errno_str.o
index 88bc573..afdafa5 100644 (file)
@@ -8,6 +8,7 @@ obj-$(CONFIG_CMD_LOG) += log_filter.o
 ifdef CONFIG_UT_LOG
 
 obj-y += test-main.o
+obj-y += pr_cont_test.o
 
 ifdef CONFIG_SANDBOX
 obj-$(CONFIG_LOG_SYSLOG) += syslog_test.o
diff --git a/test/log/pr_cont_test.c b/test/log/pr_cont_test.c
new file mode 100644 (file)
index 0000000..236eff4
--- /dev/null
@@ -0,0 +1,45 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (c) 2021, Heinrich Schuchardt <xypron.glpk@gmx.de>
+ *
+ * Test continuation of log messages using pr_cont().
+ */
+
+#include <common.h>
+#include <console.h>
+#include <test/log.h>
+#include <test/test.h>
+#include <test/suites.h>
+#include <test/ut.h>
+#include <linux/printk.h>
+
+#define BUFFSIZE 64
+
+#undef CONFIG_LOGLEVEL
+#define CONFIG_LOGLEVEL 4
+
+DECLARE_GLOBAL_DATA_PTR;
+
+static int log_test_pr_cont(struct unit_test_state *uts)
+{
+       int log_fmt;
+       int log_level;
+
+       log_fmt = gd->log_fmt;
+       log_level = gd->default_log_level;
+
+       /* Write two messages, the second continuing the first */
+       gd->log_fmt = BIT(LOGF_MSG);
+       gd->default_log_level = LOGL_INFO;
+       console_record_reset_enable();
+       pr_err("ea%d ", 1);
+       pr_cont("cc%d\n", 2);
+       gd->default_log_level = log_level;
+       gd->log_fmt = log_fmt;
+       gd->flags &= ~GD_FLG_RECORD;
+       ut_assertok(ut_check_console_line(uts, "ea1 cc2"));
+       ut_assertok(ut_check_console_end(uts));
+
+       return 0;
+}
+LOG_TEST(log_test_pr_cont);
index ef1205d..cd50455 100644 (file)
@@ -19,7 +19,7 @@ static const char str3[] = "0xbI'm sorry you're alive.";
 /* Declare a new str test */
 #define STR_TEST(_name, _flags)                UNIT_TEST(_name, _flags, str_test)
 
-static int str_test_upper(struct unit_test_state *uts)
+static int str_upper(struct unit_test_state *uts)
 {
        char out[TEST_STR_SIZE];
 
@@ -55,7 +55,7 @@ static int str_test_upper(struct unit_test_state *uts)
 
        return 0;
 }
-STR_TEST(str_test_upper, 0);
+STR_TEST(str_upper, 0);
 
 static int run_strtoul(struct unit_test_state *uts, const char *str, int base,
                       ulong expect_val, int expect_endp_offset, bool upper)
index 95bdd66..44ed1ba 100644 (file)
--- a/test/ut.c
+++ b/test/ut.c
@@ -8,6 +8,9 @@
 #include <common.h>
 #include <console.h>
 #include <malloc.h>
+#ifdef CONFIG_SANDBOX
+#include <asm/state.h>
+#endif
 #include <test/test.h>
 #include <test/ut.h>
 
@@ -114,3 +117,18 @@ int ut_check_console_dump(struct unit_test_state *uts, int total_bytes)
 
        return upto == total_bytes ? 0 : 1;
 }
+
+void ut_silence_console(struct unit_test_state *uts)
+{
+#ifdef CONFIG_SANDBOX
+       struct sandbox_state *state = state_get_current();
+
+       if (!state->show_test_output)
+               gd->flags |= GD_FLG_SILENT;
+#endif
+}
+
+void ut_unsilence_console(struct unit_test_state *uts)
+{
+       gd->flags &= ~(GD_FLG_SILENT | GD_FLG_RECORD);
+}