Simon Glass | 46508c9 | 2018-11-15 18:44:03 -0700 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
| 2 | /* |
| 3 | * Copyright 2018, Google Inc. |
| 4 | * Written by Simon Glass <sjg@chromium.org> |
| 5 | */ |
| 6 | |
| 7 | #include <common.h> |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 8 | #include <command.h> |
Simon Glass | 46508c9 | 2018-11-15 18:44:03 -0700 | [diff] [blame] | 9 | #include <dm.h> |
| 10 | #include <spl.h> |
Simon Glass | 3ba929a | 2020-10-30 21:38:53 -0600 | [diff] [blame] | 11 | #include <asm/global_data.h> |
Simon Glass | 46508c9 | 2018-11-15 18:44:03 -0700 | [diff] [blame] | 12 | #include <asm/state.h> |
| 13 | |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 14 | static int do_sb_handoff(struct cmd_tbl *cmdtp, int flag, int argc, |
Simon Glass | e14f1a2 | 2018-11-15 18:44:09 -0700 | [diff] [blame] | 15 | char *const argv[]) |
| 16 | { |
| 17 | #if CONFIG_IS_ENABLED(HANDOFF) |
| 18 | if (gd->spl_handoff) |
| 19 | printf("SPL handoff magic %lx\n", gd->spl_handoff->arch.magic); |
| 20 | else |
| 21 | printf("SPL handoff info not received\n"); |
| 22 | |
| 23 | return 0; |
| 24 | #else |
| 25 | printf("Command not supported\n"); |
| 26 | |
| 27 | return CMD_RET_USAGE; |
| 28 | #endif |
| 29 | } |
| 30 | |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 31 | static int do_sb_state(struct cmd_tbl *cmdtp, int flag, int argc, |
| 32 | char *const argv[]) |
Simon Glass | 46508c9 | 2018-11-15 18:44:03 -0700 | [diff] [blame] | 33 | { |
| 34 | struct sandbox_state *state; |
| 35 | |
| 36 | state = state_get_current(); |
| 37 | state_show(state); |
| 38 | |
| 39 | return 0; |
| 40 | } |
| 41 | |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 42 | static struct cmd_tbl cmd_sb_sub[] = { |
Simon Glass | e14f1a2 | 2018-11-15 18:44:09 -0700 | [diff] [blame] | 43 | U_BOOT_CMD_MKENT(handoff, 1, 0, do_sb_handoff, "", ""), |
Simon Glass | 46508c9 | 2018-11-15 18:44:03 -0700 | [diff] [blame] | 44 | U_BOOT_CMD_MKENT(state, 1, 0, do_sb_state, "", ""), |
| 45 | }; |
| 46 | |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 47 | static int do_sb(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) |
Simon Glass | 46508c9 | 2018-11-15 18:44:03 -0700 | [diff] [blame] | 48 | { |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 49 | struct cmd_tbl *c; |
Simon Glass | 46508c9 | 2018-11-15 18:44:03 -0700 | [diff] [blame] | 50 | |
| 51 | /* Skip past 'sb' */ |
| 52 | argc--; |
| 53 | argv++; |
| 54 | |
| 55 | c = find_cmd_tbl(argv[0], cmd_sb_sub, ARRAY_SIZE(cmd_sb_sub)); |
| 56 | if (c) |
| 57 | return c->cmd(cmdtp, flag, argc, argv); |
| 58 | else |
| 59 | return CMD_RET_USAGE; |
| 60 | } |
| 61 | |
| 62 | U_BOOT_CMD( |
| 63 | sb, 8, 1, do_sb, |
| 64 | "Sandbox status commands", |
Simon Glass | e14f1a2 | 2018-11-15 18:44:09 -0700 | [diff] [blame] | 65 | "handoff - Show handoff data received from SPL\n" |
| 66 | "sb state - Show sandbox state" |
Simon Glass | 46508c9 | 2018-11-15 18:44:03 -0700 | [diff] [blame] | 67 | ); |