Skip to content

Commit 700cff2

Browse files
committed
Merge tag 'efi-2022-07-rc5-2' of https://source.denx.de/u-boot/custodians/u-boot-efi
Pull request for efi-2020-07-rc5-2 Documentation: * man-pages for booti and printenv UEFI * correct return value for printenv -e command * initialize console size late
2 parents aad77c2 + 68edbed commit 700cff2

File tree

9 files changed

+183
-8
lines changed

9 files changed

+183
-8
lines changed

cmd/nvedit_efi.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,10 @@ static int efi_dump_var_all(int argc, char *const argv[],
182182
}
183183
free(var_name16);
184184

185-
if (!match && argc == 1)
185+
if (!match && argc == 1) {
186186
printf("Error: \"%s\" not defined\n", argv[0]);
187+
return CMD_RET_FAILURE;
188+
}
187189

188190
return CMD_RET_SUCCESS;
189191
}

doc/usage/cmd/bootz.rst

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
.. SPDX-License-Identifier: GPL-2.0+:
2+
3+
bootz command
4+
=============
5+
6+
Synopsis
7+
--------
8+
9+
::
10+
11+
bootz [<addr> [<initrd>[:<size>]] [<fdt>]]
12+
13+
Description
14+
-----------
15+
16+
The bootz command is used to boot a Linux kernel in 'zImage' format.
17+
18+
addr
19+
address of kernel image, defaults to the value of the environment
20+
variable $loadaddr.
21+
22+
initrd
23+
address of the initial RAM disk. Use '-' to boot a kernel with a device
24+
tree but without an initial RAM disk.
25+
26+
size
27+
size of the initial RAM disk. This parameter must be specified for raw
28+
initial RAM disks.
29+
30+
fdt
31+
address of the device tree.
32+
33+
Example
34+
-------
35+
36+
This is the boot log of an OrangePi PC board:
37+
38+
::
39+
40+
=> load mmc 0:2 $fdt_addr_r dtb
41+
23093 bytes read in 7 ms (3.1 MiB/s)
42+
=> load mmc 0:2 $kernel_addr_r vmlinuz
43+
5079552 bytes read in 215 ms (22.5 MiB/s)
44+
=> load mmc 0:2 $ramdisk_addr_r initrd.img
45+
23854965 bytes read in 995 ms (22.9 MiB/s)
46+
=> bootz $kernel_addr_r $ramdisk_addr_r:$filesize $fdt_addr_r
47+
Kernel image @ 0x42000000 [ 0x000000 - 0x4d8200 ]
48+
## Flattened Device Tree blob at 43000000
49+
Booting using the fdt blob at 0x43000000
50+
EHCI failed to shut down host controller.
51+
Loading Ramdisk to 48940000, end 49ffff75 ... OK
52+
Loading Device Tree to 48937000, end 4893fa34 ... OK
53+
54+
Starting kernel ...
55+
56+
Configuration
57+
-------------
58+
59+
The bootz command is only available if CONFIG_CMD_BOOTZ=y.
60+
61+
Return value
62+
------------
63+
64+
Normally this command does not return. If an error occurs, the return value $?
65+
is set to 1 (false). If the operating system returns to U-Boot, the system is
66+
reset.

doc/usage/cmd/printenv.rst

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
.. SPDX-License-Identifier: GPL-2.0+:
2+
3+
printenv command
4+
================
5+
6+
Synopsis
7+
--------
8+
9+
::
10+
11+
printenv [-a] [name ...]
12+
printenv -e [-guid guid][-n] [name]
13+
14+
Description
15+
-----------
16+
17+
The printenv command is used to print environment or UEFI variables.
18+
19+
\-a
20+
Print environment variables starting with a period ('.').
21+
22+
\-e
23+
Print UEFI variables. Without -e environment variables are printed.
24+
25+
\-guid *guid*
26+
Specify vendor GUID *guid*. If none is specified, all UEFI variables with
27+
the specified name are printed irrespective of their vendor GUID.
28+
29+
\-n
30+
don't show hexadecimal dump of value
31+
32+
name
33+
Variable name. If no name is provided, all variables are printed.
34+
Multiple environment variable names may be specified.
35+
36+
Examples
37+
--------
38+
39+
The following examples demonstrates the effect of the *-a* flag when displaying
40+
environment variables:
41+
42+
::
43+
44+
=> setenv .foo bar
45+
=> printenv
46+
arch=sandbox
47+
baudrate=115200
48+
board=sandbox
49+
...
50+
stdout=serial,vidconsole
51+
52+
Environment size: 644/8188 bytes
53+
=> printenv -a
54+
.foo=bar
55+
arch=sandbox
56+
baudrate=115200
57+
board=sandbox
58+
...
59+
stdout=serial,vidconsole
60+
61+
Environment size: 653/8188 bytes
62+
=>
63+
64+
The next example shows the effect of the *-n* flag when displaying an UEFI
65+
variable and how to specify a vendor GUID:
66+
67+
::
68+
69+
=> printenv -e -guid 8be4df61-93ca-11d2-aa0d-00e098032b8c PlatformLangCodes
70+
PlatformLangCodes:
71+
8be4df61-93ca-11d2-aa0d-00e098032b8c (EFI_GLOBAL_VARIABLE_GUID)
72+
BS|RT|RO, DataSize = 0x6
73+
00000000: 65 6e 2d 55 53 00 en-US.
74+
=> printenv -e -n PlatformLangCodes
75+
PlatformLangCodes:
76+
8be4df61-93ca-11d2-aa0d-00e098032b8c (EFI_GLOBAL_VARIABLE_GUID)
77+
BS|RT|RO, DataSize = 0x6
78+
=>
79+
80+
Configuration
81+
=============
82+
83+
UEFI variables are only supported if CONFIG_CMD_NVEDIT_EFI=y. The value of UEFI
84+
variables can only be displayed if CONFIG_HEXDUMP=y.
85+
86+
Return value
87+
------------
88+
89+
The return value $? is 1 (false) if a specified variable is not found.
90+
Otherwise $? is set to 0 (true).

doc/usage/index.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ Shell commands
3030
cmd/bootmenu
3131
cmd/bootmeth
3232
cmd/button
33+
cmd/bootz
3334
cmd/cbsysinfo
3435
cmd/conitrace
3536
cmd/echo
@@ -48,6 +49,7 @@ Shell commands
4849
cmd/md
4950
cmd/mmc
5051
cmd/pinmux
52+
cmd/printenv
5153
cmd/pstore
5254
cmd/qfw
5355
cmd/reset

include/efi_loader.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,8 @@ extern struct list_head efi_register_notify_events;
499499
int efi_init_early(void);
500500
/* Initialize efi execution environment */
501501
efi_status_t efi_init_obj_list(void);
502+
/* Set up console modes */
503+
void efi_setup_console_size(void);
502504
/* Install device tree */
503505
efi_status_t efi_install_fdt(void *fdt);
504506
/* Run loaded UEFI image */

lib/efi_loader/efi_console.c

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,16 @@
55
* Copyright (c) 2016 Alexander Graf
66
*/
77

8+
#define LOG_CATEGORY LOGC_EFI
9+
810
#include <common.h>
911
#include <charset.h>
1012
#include <malloc.h>
1113
#include <time.h>
1214
#include <dm/device.h>
1315
#include <efi_loader.h>
1416
#include <env.h>
17+
#include <log.h>
1518
#include <stdio_dev.h>
1619
#include <video_console.h>
1720
#include <linux/delay.h>
@@ -58,7 +61,12 @@ const efi_guid_t efi_guid_text_output_protocol =
5861
#define cESC '\x1b'
5962
#define ESC "\x1b"
6063

61-
/* Default to mode 0 */
64+
/*
65+
* efi_con_mode - mode information of the Simple Text Output Protocol
66+
*
67+
* Use safe settings before efi_setup_console_size() is called.
68+
* By default enable only the 80x25 mode which must always exist.
69+
*/
6270
static struct simple_text_output_mode efi_con_mode = {
6371
.max_mode = 1,
6472
.mode = 0,
@@ -333,13 +341,13 @@ static int __maybe_unused query_vidconsole(int *rows, int *cols)
333341
}
334342

335343
/**
336-
* query_console_size() - update the mode table.
344+
* efi_setup_console_size() - update the mode table.
337345
*
338346
* By default the only mode available is 80x25. If the console has at least 50
339347
* lines, enable mode 80x50. If we can query the console size and it is neither
340348
* 80x25 nor 80x50, set it as an additional mode.
341349
*/
342-
static void query_console_size(void)
350+
void efi_setup_console_size(void)
343351
{
344352
int rows = 25, cols = 80;
345353
int ret = -ENODEV;
@@ -351,6 +359,8 @@ static void query_console_size(void)
351359
if (ret)
352360
return;
353361

362+
log_debug("Console size %dx%d\n", rows, cols);
363+
354364
/* Test if we can have Mode 1 */
355365
if (cols >= 80 && rows >= 50) {
356366
efi_cout_modes[1].present = 1;
@@ -371,7 +381,6 @@ static void query_console_size(void)
371381
}
372382
}
373383

374-
375384
/**
376385
* efi_cout_query_mode() - get terminal size for a text mode
377386
*
@@ -1262,9 +1271,6 @@ efi_status_t efi_console_register(void)
12621271
efi_status_t r;
12631272
struct efi_device_path *dp;
12641273

1265-
/* Set up mode information */
1266-
query_console_size();
1267-
12681274
/* Install protocols on root node */
12691275
r = EFI_CALL(efi_install_multiple_protocol_interfaces
12701276
(&efi_root,

lib/efi_loader/efi_setup.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,10 @@ efi_status_t efi_init_obj_list(void)
243243
goto out;
244244
}
245245

246+
/* Set up console modes */
247+
efi_setup_console_size();
248+
249+
/* Install EFI_RNG_PROTOCOL */
246250
if (IS_ENABLED(CONFIG_EFI_RNG_PROTOCOL)) {
247251
ret = efi_rng_register();
248252
if (ret != EFI_SUCCESS)

test/py/tests/test_efi_capsule/test_capsule_firmware_fit.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ def test_efi_capsule_fw2(
117117
with u_boot_console.log.section('Test Case 2-a, before reboot'):
118118
output = u_boot_console.run_command_list([
119119
'host bind 0 %s' % disk_img,
120+
'printenv -e PlatformLangCodes', # workaround for terminal size determination
120121
'efidebug boot add -b 1 TEST host 0:1 /helloworld.efi -s ""',
121122
'efidebug boot order 1',
122123
'env set -e -nv -bs -rt OsIndications =0x0000000000000004',

test/py/tests/test_efi_capsule/test_capsule_firmware_raw.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ def test_efi_capsule_fw2(
115115
with u_boot_console.log.section('Test Case 2-a, before reboot'):
116116
output = u_boot_console.run_command_list([
117117
'host bind 0 %s' % disk_img,
118+
'printenv -e PlatformLangCodes', # workaround for terminal size determination
118119
'efidebug boot add -b 1 TEST host 0:1 /helloworld.efi -s ""',
119120
'efidebug boot order 1',
120121
'env set -e OsIndications',
@@ -197,6 +198,7 @@ def test_efi_capsule_fw3(
197198
with u_boot_console.log.section('Test Case 3-a, before reboot'):
198199
output = u_boot_console.run_command_list([
199200
'host bind 0 %s' % disk_img,
201+
'printenv -e PlatformLangCodes', # workaround for terminal size determination
200202
'efidebug boot add -b 1 TEST host 0:1 /helloworld.efi -s ""',
201203
'efidebug boot order 1',
202204
'env set -e -nv -bs -rt OsIndications =0x0000000000000004',

0 commit comments

Comments
 (0)