summaryrefslogtreecommitdiffstats
path: root/ArmPkg/Include/Library/OpteeLib.h
blob: a7b2ff1b6b57e01afaaacc15290746d31e077db2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/** @file
  OP-TEE specific header file.

  Copyright (c) 2018, Linaro Ltd. All rights reserved.<BR>

  This program and the accompanying materials
  are licensed and made available under the terms and conditions of the BSD License
  which accompanies this distribution.  The full text of the license may be found at
  http://opensource.org/licenses/bsd-license.php

  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.

**/

#ifndef _OPTEE_H_
#define _OPTEE_H_

/*
 * The 'Trusted OS Call UID' is supposed to return the following UUID for
 * OP-TEE OS. This is a 128-bit value.
 */
#define OPTEE_OS_UID0          0x384fb3e0
#define OPTEE_OS_UID1          0xe7f811e3
#define OPTEE_OS_UID2          0xaf630002
#define OPTEE_OS_UID3          0xa5d5c51b

#define OPTEE_MESSAGE_ATTRIBUTE_TYPE_NONE                0x0
#define OPTEE_MESSAGE_ATTRIBUTE_TYPE_VALUE_INPUT         0x1
#define OPTEE_MESSAGE_ATTRIBUTE_TYPE_VALUE_OUTPUT        0x2
#define OPTEE_MESSAGE_ATTRIBUTE_TYPE_VALUE_INOUT         0x3
#define OPTEE_MESSAGE_ATTRIBUTE_TYPE_MEMORY_INPUT        0x9
#define OPTEE_MESSAGE_ATTRIBUTE_TYPE_MEMORY_OUTPUT       0xa
#define OPTEE_MESSAGE_ATTRIBUTE_TYPE_MEMORY_INOUT        0xb

#define OPTEE_MESSAGE_ATTRIBUTE_TYPE_MASK                0xff

#define OPTEE_SUCCESS                           0x00000000
#define OPTEE_ORIGIN_COMMUNICATION              0x00000002
#define OPTEE_ERROR_COMMUNICATION               0xFFFF000E

typedef struct {
  UINT64    BufferAddress;
  UINT64    Size;
  UINT64    SharedMemoryReference;
} OPTEE_MESSAGE_PARAM_MEMORY;

typedef struct {
  UINT64    A;
  UINT64    B;
  UINT64    C;
} OPTEE_MESSAGE_PARAM_VALUE;

typedef struct {
  UINT64 Attribute;
  union {
    OPTEE_MESSAGE_PARAM_MEMORY   Memory;
    OPTEE_MESSAGE_PARAM_VALUE    Value;
  } Union;
} OPTEE_MESSAGE_PARAM;

#define OPTEE_MAX_CALL_PARAMS       4

typedef struct {
  UINT32    Command;
  UINT32    Function;
  UINT32    Session;
  UINT32    CancelId;
  UINT32    Pad;
  UINT32    Return;
  UINT32    ReturnOrigin;
  UINT32    NumParams;

  // NumParams tells the actual number of element in Params
  OPTEE_MESSAGE_PARAM  Params[OPTEE_MAX_CALL_PARAMS];
} OPTEE_MESSAGE_ARG;

typedef struct {
  EFI_GUID  Uuid;           // [in] GUID/UUID of the Trusted Application
  UINT32    Session;        // [out] Session id
  UINT32    Return;         // [out] Return value
  UINT32    ReturnOrigin;   // [out] Origin of the return value
} OPTEE_OPEN_SESSION_ARG;

typedef struct {
  UINT32    Function;       // [in] Trusted Application function, specific to the TA
  UINT32    Session;        // [in] Session id
  UINT32    Return;         // [out] Return value
  UINT32    ReturnOrigin;   // [out] Origin of the return value
  OPTEE_MESSAGE_PARAM  Params[OPTEE_MAX_CALL_PARAMS]; // Params for function to be invoked
} OPTEE_INVOKE_FUNCTION_ARG;

BOOLEAN
EFIAPI
IsOpteePresent (
  VOID
  );

EFI_STATUS
EFIAPI
OpteeInit (
  VOID
  );

EFI_STATUS
EFIAPI
OpteeOpenSession (
  IN OUT OPTEE_OPEN_SESSION_ARG      *OpenSessionArg
  );

EFI_STATUS
EFIAPI
OpteeCloseSession (
  IN UINT32                      Session
  );

EFI_STATUS
EFIAPI
OpteeInvokeFunction (
  IN OUT OPTEE_INVOKE_FUNCTION_ARG       *InvokeFunctionArg
  );

#endif