blob: 0a9a864cdeffcde7b2effaf96d578326cbf508a5 [file] [log] [blame]
b.liue9582032025-04-17 19:18:16 +08001// SPDX-License-Identifier: GPL-2.0+
2/*
3 * Copyright 2018
4 * Michalis Pappas <mpappas@fastmail.fm>
5 */
6#include <common.h>
7#include <command.h>
8#include <linux/arm-smccc.h>
9#include <linux/compiler.h>
10
11static int do_call(struct cmd_tbl *cmdtp, int flag, int argc,
12 char *const argv[])
13{
14 struct arm_smccc_res res;
15
16 unsigned long fid;
17
18 unsigned long a1;
19 unsigned long a2;
20 unsigned long a3;
21 unsigned long a4;
22 unsigned long a5;
23 unsigned long a6;
24 unsigned long a7;
25
26 if (argc < 2)
27 return CMD_RET_USAGE;
28
29 fid = simple_strtoul(argv[1], NULL, 16);
30
31 a1 = argc > 2 ? simple_strtoul(argv[2], NULL, 16) : 0;
32 a2 = argc > 3 ? simple_strtoul(argv[3], NULL, 16) : 0;
33 a3 = argc > 4 ? simple_strtoul(argv[4], NULL, 16) : 0;
34 a4 = argc > 5 ? simple_strtoul(argv[5], NULL, 16) : 0;
35 a5 = argc > 6 ? simple_strtoul(argv[6], NULL, 16) : 0;
36 a6 = argc > 7 ? simple_strtoul(argv[7], NULL, 16) : 0;
37 a7 = argc > 8 ? simple_strtoul(argv[8], NULL, 16) : 0;
38
39 if (!strcmp(argv[0], "smc"))
40 arm_smccc_smc(fid, a1, a2, a3, a4, a5, a6, a7, &res);
41 else
42 arm_smccc_hvc(fid, a1, a2, a3, a4, a5, a6, a7, &res);
43
44 printf("Res: 0x%lx 0x%lx 0x%lx 0x%lx\n", res.a0, res.a1, res.a2, res.a3);
45
46 return 0;
47}
48
49#ifdef CONFIG_CMD_SMC
50U_BOOT_CMD(
51 smc, 9, 2, do_call,
52 "Issue a Secure Monitor Call",
53 "<fid> [arg1 ... arg6] [id]\n"
54 " - fid Function ID\n"
55 " - arg SMC arguments, passed to X1-X6 (default to zero)\n"
56 " - id Secure OS ID / Session ID, passed to W7 (defaults to zero)\n"
57);
58#endif
59
60#ifdef CONFIG_CMD_HVC
61U_BOOT_CMD(
62 hvc, 9, 2, do_call,
63 "Issue a Hypervisor Call",
64 "<fid> [arg1...arg6] [id]\n"
65 " - fid Function ID\n"
66 " - arg HVC arguments, passed to X1-X6 (default to zero)\n"
67 " - id Session ID, passed to W7 (defaults to zero)\n"
68);
69#endif