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