1 // SPDX-License-Identifier: GPL-2.0
3 * (C) Copyright 2024, Advanced Micro Devices, Inc.
10 #define TA_HELLO_WORLD_CMD_INC_VALUE 0
11 /* This needs to match the UUID of the Hello World TA. */
12 #define TA_HELLO_WORLD_UUID \
13 { 0x8aaaf200, 0x2450, 0x11e4, \
14 { 0xab, 0xe2, 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b} }
16 static int hello_world_ta(unsigned int value)
18 const struct tee_optee_ta_uuid uuid = TA_HELLO_WORLD_UUID;
19 struct tee_open_session_arg session_arg;
20 struct udevice *tee = NULL;
21 struct tee_invoke_arg arg;
22 struct tee_param param[2];
25 tee = tee_find_device(tee, NULL, NULL, NULL);
29 memset(&session_arg, 0, sizeof(session_arg));
30 tee_optee_ta_uuid_to_octets(session_arg.uuid, &uuid);
31 rc = tee_open_session(tee, &session_arg, 0, NULL);
33 printf("tee_open_session(): failed(%d)\n", rc);
37 arg.func = TA_HELLO_WORLD_CMD_INC_VALUE;
38 arg.session = session_arg.session;
40 param[0].attr = TEE_PARAM_ATTR_TYPE_VALUE_INOUT;
41 param[0].u.value.a = value;
43 printf("Value before: 0x%x\n", (int)param[0].u.value.a);
44 printf("Calling TA\n");
45 tee_invoke_func(tee, &arg, 1, param);
47 printf("Value after: 0x%x\n", (int)param[0].u.value.a);
48 return tee_close_session(tee, session_arg.session);
51 static int do_optee_hello_world_ta(struct cmd_tbl *cmdtp, int flag, int argc,
56 if (strcmp(argv[1], NULL))
57 value = hextoul(argv[1], NULL);
59 ret = hello_world_ta(value);
61 return CMD_RET_FAILURE;
63 return CMD_RET_SUCCESS;
66 U_BOOT_LONGHELP(optee,
67 "hello [<value>] Invoke the OP-TEE 'Hello World' TA\n");
69 U_BOOT_CMD_WITH_SUBCMDS(optee, "OP-TEE commands", optee_help_text,
70 U_BOOT_SUBCMD_MKENT(hello, 2, 1, do_optee_hello_world_ta));