Skip to content

Commit

Permalink
Merge tag 'efi-2022-07-rc3-2' of https://source.denx.de/u-boot/custod…
Browse files Browse the repository at this point in the history
…ians/u-boot-efi

Pull request for efi-2022-07-rc3-2

UEFI:
* Fix build errors due to
  - using sed with non-standard extension for regular expression
  - target architecture not recognized for CROSS_COMPILE=armv7a-*
  - CONFIG_EVENT not selected
* add sha384/512 on certificate revocation

Others:
* factor out the user input handling in bootmenu command
  • Loading branch information
trini committed May 8, 2022
2 parents 258a579 + 4b49477 commit 20cd584
Show file tree
Hide file tree
Showing 14 changed files with 388 additions and 171 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ include include/host_arch.h
ifeq ("", "$(CROSS_COMPILE)")
MK_ARCH="${shell uname -m}"
else
MK_ARCH="${shell echo $(CROSS_COMPILE) | sed -n 's/^\s*\([^\/]*\/\)*\([^-]*\)-\S*/\2/p'}"
MK_ARCH="${shell echo $(CROSS_COMPILE) | sed -n 's/^[[:space:]]*\([^\/]*\/\)*\([^-]*\)-[^[:space:]]*/\2/p'}"
endif
unexport HOST_ARCH
ifeq ("x86_64", $(MK_ARCH))
Expand All @@ -30,7 +30,7 @@ else ifneq (,$(findstring $(MK_ARCH), "i386" "i486" "i586" "i686"))
export HOST_ARCH=$(HOST_ARCH_X86)
else ifneq (,$(findstring $(MK_ARCH), "aarch64" "armv8l"))
export HOST_ARCH=$(HOST_ARCH_AARCH64)
else ifneq (,$(findstring $(MK_ARCH), "arm" "armv7" "armv7l"))
else ifneq (,$(findstring $(MK_ARCH), "arm" "armv7" "armv7a" "armv7l"))
export HOST_ARCH=$(HOST_ARCH_ARM)
else ifeq ("riscv32", $(MK_ARCH))
export HOST_ARCH=$(HOST_ARCH_RISCV32)
Expand Down
141 changes: 0 additions & 141 deletions cmd/bootmenu.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,21 +51,6 @@ struct bootmenu_entry {
struct bootmenu_entry *next; /* next menu entry (num+1) */
};

struct bootmenu_data {
int delay; /* delay for autoboot */
int active; /* active menu entry */
int count; /* total count of menu entries */
struct bootmenu_entry *first; /* first menu entry */
};

enum bootmenu_key {
KEY_NONE = 0,
KEY_UP,
KEY_DOWN,
KEY_SELECT,
KEY_QUIT,
};

static char *bootmenu_getoption(unsigned short int n)
{
char name[MAX_ENV_SIZE];
Expand Down Expand Up @@ -97,132 +82,6 @@ static void bootmenu_print_entry(void *data)
puts(ANSI_COLOR_RESET);
}

static void bootmenu_autoboot_loop(struct bootmenu_data *menu,
enum bootmenu_key *key, int *esc)
{
int i, c;

while (menu->delay > 0) {
printf(ANSI_CURSOR_POSITION, menu->count + 5, 3);
printf("Hit any key to stop autoboot: %d ", menu->delay);
for (i = 0; i < 100; ++i) {
if (!tstc()) {
WATCHDOG_RESET();
mdelay(10);
continue;
}

menu->delay = -1;
c = getchar();

switch (c) {
case '\e':
*esc = 1;
*key = KEY_NONE;
break;
case '\r':
*key = KEY_SELECT;
break;
case 0x3: /* ^C */
*key = KEY_QUIT;
break;
default:
*key = KEY_NONE;
break;
}

break;
}

if (menu->delay < 0)
break;

--menu->delay;
}

printf(ANSI_CURSOR_POSITION, menu->count + 5, 1);
puts(ANSI_CLEAR_LINE);

if (menu->delay == 0)
*key = KEY_SELECT;
}

static void bootmenu_loop(struct bootmenu_data *menu,
enum bootmenu_key *key, int *esc)
{
int c;

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

switch (*esc) {
case 0:
/* First char of ANSI escape sequence '\e' */
if (c == '\e') {
*esc = 1;
*key = KEY_NONE;
}
break;
case 1:
/* Second char of ANSI '[' */
if (c == '[') {
*esc = 2;
*key = KEY_NONE;
} else {
/* Alone ESC key was pressed */
*key = KEY_QUIT;
*esc = (c == '\e') ? 1 : 0;
}
break;
case 2:
case 3:
/* Third char of ANSI (number '1') - optional */
if (*esc == 2 && c == '1') {
*esc = 3;
*key = KEY_NONE;
break;
}

*esc = 0;

/* ANSI 'A' - key up was pressed */
if (c == 'A')
*key = KEY_UP;
/* ANSI 'B' - key down was pressed */
else if (c == 'B')
*key = KEY_DOWN;
/* other key was pressed */
else
*key = KEY_NONE;

break;
}

/* 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)
{
struct bootmenu_data *menu = data;
Expand Down
128 changes: 128 additions & 0 deletions common/menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@
* Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
*/

#include <ansi.h>
#include <common.h>
#include <cli.h>
#include <malloc.h>
#include <errno.h>
#include <linux/delay.h>
#include <linux/list.h>
#include <watchdog.h>

#include "menu.h"

Expand Down Expand Up @@ -421,3 +424,128 @@ int menu_destroy(struct menu *m)

return 1;
}

void bootmenu_autoboot_loop(struct bootmenu_data *menu,
enum bootmenu_key *key, int *esc)
{
int i, c;

while (menu->delay > 0) {
printf(ANSI_CURSOR_POSITION, menu->count + 5, 3);
printf("Hit any key to stop autoboot: %d ", menu->delay);
for (i = 0; i < 100; ++i) {
if (!tstc()) {
WATCHDOG_RESET();
mdelay(10);
continue;
}

menu->delay = -1;
c = getchar();

switch (c) {
case '\e':
*esc = 1;
*key = KEY_NONE;
break;
case '\r':
*key = KEY_SELECT;
break;
case 0x3: /* ^C */
*key = KEY_QUIT;
break;
default:
*key = KEY_NONE;
break;
}

break;
}

if (menu->delay < 0)
break;

--menu->delay;
}

printf(ANSI_CURSOR_POSITION ANSI_CLEAR_LINE, menu->count + 5, 1);

if (menu->delay == 0)
*key = KEY_SELECT;
}

void bootmenu_loop(struct bootmenu_data *menu,
enum bootmenu_key *key, int *esc)
{
int c;

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

switch (*esc) {
case 0:
/* First char of ANSI escape sequence '\e' */
if (c == '\e') {
*esc = 1;
*key = KEY_NONE;
}
break;
case 1:
/* Second char of ANSI '[' */
if (c == '[') {
*esc = 2;
*key = KEY_NONE;
} else {
/* Alone ESC key was pressed */
*key = KEY_QUIT;
*esc = (c == '\e') ? 1 : 0;
}
break;
case 2:
case 3:
/* Third char of ANSI (number '1') - optional */
if (*esc == 2 && c == '1') {
*esc = 3;
*key = KEY_NONE;
break;
}

*esc = 0;

/* ANSI 'A' - key up was pressed */
if (c == 'A')
*key = KEY_UP;
/* ANSI 'B' - key down was pressed */
else if (c == 'B')
*key = KEY_DOWN;
/* other key was pressed */
else
*key = KEY_NONE;

break;
}

/* enter key was pressed */
if (c == '\r')
*key = KEY_SELECT;

/* ^C was pressed */
if (c == 0x3)
*key = KEY_QUIT;
}
36 changes: 35 additions & 1 deletion doc/mkimage.1
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ Parse image file as type.
Pass \-h as the image to see the list of supported image type.
Without this option image type is autodetected.

.TP
.BI "\-q"
Quiet. Don't print the image header on successful verification.

.P
.B Create old legacy image:

Expand Down Expand Up @@ -91,6 +95,11 @@ List the contents of an image.
.BI "\-n [" "image name" "]"
Set image name to 'image name'.

.TP
.BI "\-R [" "secondary image name" "]"
Some image types support a second image for additional data. For these types,
use \-R to specify this second image.

.TP
.BI "\-d [" "image data file" "]"
Use image data from 'image data file'.
Expand All @@ -99,6 +108,15 @@ Use image data from 'image data file'.
.BI "\-x"
Set XIP (execute in place) flag.

.TP
.BI "\-s"
Create an image with no data. The header will be created, but the image itself
will not contain data (such as U-Boot or any specified kernel).

.TP
.BI "\-v"
Verbose. Print file names as they are added to the image.

.P
.B Create FIT image:

Expand Down Expand Up @@ -126,6 +144,11 @@ in each image will be replaced with 'data-offset' and 'data-size' properties.
A 'data-offset' of 0 indicates that it starts in the first (4-byte aligned)
byte after the FIT.

.TP
.BI "\-B [" "alignment" "]"
The alignment, in hexadecimal, that external data will be aligned to. This
option only has an effect when \-E is specified.

.TP
.BI "\-f [" "image tree source file" " | " "auto" "]"
Image tree source file that describes the structure and contents of the
Expand Down Expand Up @@ -161,6 +184,11 @@ the corresponding public key is written into this file for for run-time
verification. Typically the file here is the device tree binary used by
CONFIG_OF_CONTROL in U-Boot.

.TP
.BI "\-G [" "key_file" "]"
Specifies the private key file to use when signing. This option may be used
instead of \-k.

.TP
.BI "\-o [" "signing algorithm" "]"
Specifies the algorithm to be used for signing a FIT image. The default is
Expand All @@ -173,11 +201,17 @@ a 'data-offset' property defining the offset from the end of the FIT, \-p will
use 'data-position' as the absolute position from the base of the FIT.

.TP
.BI "\-r
.BI "\-r"
Specifies that keys used to sign the FIT are required. This means that they
must be verified for the image to boot. Without this option, the verification
will be optional (useful for testing but not for release).

.TP
.BI "\-N [" "engine" "]"
The openssl engine to use when signing and verifying the image. For a complete list of
available engines, refer to
.BR engine (1).

.TP
.BI "\-t
Update the timestamp in the FIT.
Expand Down
Loading

0 comments on commit 20cd584

Please sign in to comment.