Merge branch '2021-01-16-assorted-improvements'

- Assorted testing improvements and fixes
- Assorted code cleanups
This commit is contained in:
Tom Rini 2021-01-18 07:55:54 -05:00
commit 19c5fdffdc
43 changed files with 490 additions and 110 deletions

View 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

View 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

View 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);

View 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

161
cmd/gpt.c
View File

@ -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"

View 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"

View 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

View 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;
/*

View 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;
}
}

View 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)

View 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;
}

View 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));

View 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);

View 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;"

View 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",

View 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>

View 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.

View 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 =

View 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)
@ -46,11 +46,15 @@
#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 */

View 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

View 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();
}

View 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

View 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; \

View File

@ -376,6 +376,17 @@ int uclass_next_device_check(struct udevice **devp);
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
*

View 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 */

View 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 */

View 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;

View 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

View 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

View File

@ -695,8 +695,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

View File

@ -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
}

View 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;

View 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

View 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

View File

@ -38,7 +38,7 @@
#include "deflate.h"
#ifdef DEBUG
# include <ctype.h>
# include <linux/ctype.h>
#endif
/* ===========================================================================

View 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

View 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;
}

View 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);
}

View 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

View 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

45
test/log/pr_cont_test.c Normal file
View File

@ -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);

View 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)

View File

@ -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);
}