]> git.proxmox.com Git - mirror_edk2.git/blob - ArmPkg/Include/Library/OpteeLib.h
a7b2ff1b6b57e01afaaacc15290746d31e077db2
[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_SUCCESS 0x00000000
39 #define OPTEE_ORIGIN_COMMUNICATION 0x00000002
40 #define OPTEE_ERROR_COMMUNICATION 0xFFFF000E
41
42 typedef struct {
43 UINT64 BufferAddress;
44 UINT64 Size;
45 UINT64 SharedMemoryReference;
46 } OPTEE_MESSAGE_PARAM_MEMORY;
47
48 typedef struct {
49 UINT64 A;
50 UINT64 B;
51 UINT64 C;
52 } OPTEE_MESSAGE_PARAM_VALUE;
53
54 typedef struct {
55 UINT64 Attribute;
56 union {
57 OPTEE_MESSAGE_PARAM_MEMORY Memory;
58 OPTEE_MESSAGE_PARAM_VALUE Value;
59 } Union;
60 } OPTEE_MESSAGE_PARAM;
61
62 #define OPTEE_MAX_CALL_PARAMS 4
63
64 typedef struct {
65 UINT32 Command;
66 UINT32 Function;
67 UINT32 Session;
68 UINT32 CancelId;
69 UINT32 Pad;
70 UINT32 Return;
71 UINT32 ReturnOrigin;
72 UINT32 NumParams;
73
74 // NumParams tells the actual number of element in Params
75 OPTEE_MESSAGE_PARAM Params[OPTEE_MAX_CALL_PARAMS];
76 } OPTEE_MESSAGE_ARG;
77
78 typedef struct {
79 EFI_GUID Uuid; // [in] GUID/UUID of the Trusted Application
80 UINT32 Session; // [out] Session id
81 UINT32 Return; // [out] Return value
82 UINT32 ReturnOrigin; // [out] Origin of the return value
83 } OPTEE_OPEN_SESSION_ARG;
84
85 typedef struct {
86 UINT32 Function; // [in] Trusted Application function, specific to the TA
87 UINT32 Session; // [in] Session id
88 UINT32 Return; // [out] Return value
89 UINT32 ReturnOrigin; // [out] Origin of the return value
90 OPTEE_MESSAGE_PARAM Params[OPTEE_MAX_CALL_PARAMS]; // Params for function to be invoked
91 } OPTEE_INVOKE_FUNCTION_ARG;
92
93 BOOLEAN
94 EFIAPI
95 IsOpteePresent (
96 VOID
97 );
98
99 EFI_STATUS
100 EFIAPI
101 OpteeInit (
102 VOID
103 );
104
105 EFI_STATUS
106 EFIAPI
107 OpteeOpenSession (
108 IN OUT OPTEE_OPEN_SESSION_ARG *OpenSessionArg
109 );
110
111 EFI_STATUS
112 EFIAPI
113 OpteeCloseSession (
114 IN UINT32 Session
115 );
116
117 EFI_STATUS
118 EFIAPI
119 OpteeInvokeFunction (
120 IN OUT OPTEE_INVOKE_FUNCTION_ARG *InvokeFunctionArg
121 );
122
123 #endif