mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-11-14 08:57:58 +00:00
83d290c56f
When U-Boot started using SPDX tags we were among the early adopters and there weren't a lot of other examples to borrow from. So we picked the area of the file that usually had a full license text and replaced it with an appropriate SPDX-License-Identifier: entry. Since then, the Linux Kernel has adopted SPDX tags and they place it as the very first line in a file (except where shebangs are used, then it's second line) and with slightly different comment styles than us. In part due to community overlap, in part due to better tag visibility and in part for other minor reasons, switch over to that style. This commit changes all instances where we have a single declared license in the tag as both the before and after are identical in tag contents. There's also a few places where I found we did not have a tag and have introduced one. Signed-off-by: Tom Rini <trini@konsulko.com>
105 lines
1.8 KiB
C
105 lines
1.8 KiB
C
// SPDX-License-Identifier: GPL-2.0+
|
|
/*
|
|
* Copyright (C) 2012 Boundary Devices Inc.
|
|
*/
|
|
#include <common.h>
|
|
#include <linux/errno.h>
|
|
#include <asm/io.h>
|
|
#include <asm/mach-imx/boot_mode.h>
|
|
#include <malloc.h>
|
|
#include <command.h>
|
|
|
|
static const struct boot_mode *modes[2];
|
|
|
|
static const struct boot_mode *search_modes(char *arg)
|
|
{
|
|
int i;
|
|
|
|
for (i = 0; i < ARRAY_SIZE(modes); i++) {
|
|
const struct boot_mode *p = modes[i];
|
|
if (p) {
|
|
while (p->name) {
|
|
if (!strcmp(p->name, arg))
|
|
return p;
|
|
p++;
|
|
}
|
|
}
|
|
}
|
|
return NULL;
|
|
}
|
|
|
|
static int create_usage(char *dest)
|
|
{
|
|
int i;
|
|
int size = 0;
|
|
|
|
for (i = 0; i < ARRAY_SIZE(modes); i++) {
|
|
const struct boot_mode *p = modes[i];
|
|
if (p) {
|
|
while (p->name) {
|
|
int len = strlen(p->name);
|
|
if (dest) {
|
|
memcpy(dest, p->name, len);
|
|
dest += len;
|
|
*dest++ = '|';
|
|
}
|
|
size += len + 1;
|
|
p++;
|
|
}
|
|
}
|
|
}
|
|
if (dest)
|
|
memcpy(dest - 1, " [noreset]", 11); /* include trailing 0 */
|
|
size += 10;
|
|
return size;
|
|
}
|
|
|
|
static int do_boot_mode(cmd_tbl_t *cmdtp, int flag, int argc,
|
|
char * const argv[])
|
|
{
|
|
const struct boot_mode *p;
|
|
int reset_requested = 1;
|
|
|
|
if (argc < 2)
|
|
return CMD_RET_USAGE;
|
|
p = search_modes(argv[1]);
|
|
if (!p)
|
|
return CMD_RET_USAGE;
|
|
if (argc == 3) {
|
|
if (strcmp(argv[2], "noreset"))
|
|
return CMD_RET_USAGE;
|
|
reset_requested = 0;
|
|
}
|
|
|
|
boot_mode_apply(p->cfg_val);
|
|
if (reset_requested && p->cfg_val)
|
|
do_reset(NULL, 0, 0, NULL);
|
|
return 0;
|
|
}
|
|
|
|
U_BOOT_CMD(
|
|
bmode, 3, 0, do_boot_mode,
|
|
NULL,
|
|
"");
|
|
|
|
void add_board_boot_modes(const struct boot_mode *p)
|
|
{
|
|
int size;
|
|
char *dest;
|
|
|
|
cmd_tbl_t *entry = ll_entry_get(cmd_tbl_t, bmode, cmd);
|
|
|
|
if (entry->usage) {
|
|
free(entry->usage);
|
|
entry->usage = NULL;
|
|
}
|
|
|
|
modes[0] = p;
|
|
modes[1] = soc_boot_modes;
|
|
size = create_usage(NULL);
|
|
dest = malloc(size);
|
|
if (dest) {
|
|
create_usage(dest);
|
|
entry->usage = dest;
|
|
}
|
|
}
|