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