]> git.proxmox.com Git - mirror_edk2.git/blob - ArmPkg/Include/Library/OpteeLib.h
6884d5681831c90ce1c402929aba82403d131785
[mirror_edk2.git] / ArmPkg / Include / Library / OpteeLib.h
1 /** @file
2 OP-TEE specific header file.
3
4 Copyright (c) 2018, Linaro Ltd. All rights reserved.<BR>
5
6 This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
10
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13
14 **/
15
16 #ifndef _OPTEE_H_
17 #define _OPTEE_H_
18
19 /*
20 * The 'Trusted OS Call UID' is supposed to return the following UUID for
21 * OP-TEE OS. This is a 128-bit value.
22 */
23 #define OPTEE_OS_UID0 0x384fb3e0
24 #define OPTEE_OS_UID1 0xe7f811e3
25 #define OPTEE_OS_UID2 0xaf630002
26 #define OPTEE_OS_UID3 0xa5d5c51b
27
28 #define OPTEE_MESSAGE_ATTRIBUTE_TYPE_NONE 0x0
29 #define OPTEE_MESSAGE_ATTRIBUTE_TYPE_VALUE_INPUT 0x1
30 #define OPTEE_MESSAGE_ATTRIBUTE_TYPE_VALUE_OUTPUT 0x2
31 #define OPTEE_MESSAGE_ATTRIBUTE_TYPE_VALUE_INOUT 0x3
32 #define OPTEE_MESSAGE_ATTRIBUTE_TYPE_MEMORY_INPUT 0x9
33 #define OPTEE_MESSAGE_ATTRIBUTE_TYPE_MEMORY_OUTPUT 0xa
34 #define OPTEE_MESSAGE_ATTRIBUTE_TYPE_MEMORY_INOUT 0xb
35
36 #define OPTEE_MESSAGE_ATTRIBUTE_TYPE_MASK 0xff
37
38 #define OPTEE_ORIGIN_COMMUNICATION 0x00000002
39 #define OPTEE_ERROR_COMMUNICATION 0xFFFF000E
40
41 typedef struct {
42 UINT64 BufferAddress;
43 UINT64 Size;
44 UINT64 SharedMemoryReference;
45 } OPTEE_MESSAGE_PARAM_MEMORY;
46
47 typedef struct {
48 UINT64 A;
49 UINT64 B;
50 UINT64 C;
51 } OPTEE_MESSAGE_PARAM_VALUE;
52
53 typedef struct {
54 UINT64 Attribute;
55 union {
56 OPTEE_MESSAGE_PARAM_MEMORY Memory;
57 OPTEE_MESSAGE_PARAM_VALUE Value;
58 } Union;
59 } OPTEE_MESSAGE_PARAM;
60
61 #define OPTEE_MAX_CALL_PARAMS 4
62
63 typedef struct {
64 UINT32 Command;
65 UINT32 Function;
66 UINT32 Session;
67 UINT32 CancelId;
68 UINT32 Pad;
69 UINT32 Return;
70 UINT32 ReturnOrigin;
71 UINT32 NumParams;
72
73 // NumParams tells the actual number of element in Params
74 OPTEE_MESSAGE_PARAM Params[OPTEE_MAX_CALL_PARAMS];
75 } OPTEE_MESSAGE_ARG;
76
77 typedef struct {
78 EFI_GUID Uuid; // [in] GUID/UUID of the Trusted Application
79 UINT32 Session; // [out] Session id
80 UINT32 Return; // [out] Return value
81 UINT32 ReturnOrigin; // [out] Origin of the return value
82 } OPTEE_OPEN_SESSION_ARG;
83
84 typedef struct {
85 UINT32 Function; // [in] Trusted Application function, specific to the TA
86 UINT32 Session; // [in] Session id
87 UINT32 Return; // [out] Return value
88 UINT32 ReturnOrigin; // [out] Origin of the return value
89 OPTEE_MESSAGE_PARAM Params[OPTEE_MAX_CALL_PARAMS]; // Params for function to be invoked
90 } OPTEE_INVOKE_FUNCTION_ARG;
91
92 BOOLEAN
93 EFIAPI
94 IsOpteePresent (
95 VOID
96 );
97
98 EFI_STATUS
99 EFIAPI
100 OpteeInit (
101 VOID
102 );
103
104 EFI_STATUS
105 EFIAPI
106 OpteeOpenSession (
107 IN OUT OPTEE_OPEN_SESSION_ARG *OpenSessionArg
108 );
109
110 EFI_STATUS
111 EFIAPI
112 OpteeCloseSession (
113 IN UINT32 Session
114 );
115
116 EFI_STATUS
117 EFIAPI
118 OpteeInvokeFunction (
119 IN OUT OPTEE_INVOKE_FUNCTION_ARG *InvokeFunctionArg
120 );
121
122 #endif