2 * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License
21 using System.Runtime.InteropServices;
23 internal static partial class Interop
25 [StructLayout(LayoutKind.Sequential)]
26 internal struct TEEC_Context
28 public readonly IntPtr imp;
31 [StructLayout(LayoutKind.Sequential)]
32 internal struct TEEC_Session
34 public readonly IntPtr imp;
37 [StructLayout(LayoutKind.Sequential)]
38 internal struct TEEC_UUID
40 public UInt32 timeLow;
41 public UInt16 timeMid;
42 public UInt16 timeHiAndVersion;
43 [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
44 public byte[] clockSeqAndNode;
46 internal static TEEC_UUID ToTeecUuid(Guid guid)
48 TEEC_UUID uuid = new TEEC_UUID();
49 byte[] bin = guid.ToByteArray();
50 uuid.timeLow = BitConverter.ToUInt32(bin, 0);
51 uuid.timeMid = BitConverter.ToUInt16(bin, 4);
52 uuid.timeHiAndVersion = BitConverter.ToUInt16(bin, 6);
53 uuid.clockSeqAndNode = new byte[8];
54 Array.Copy(bin, 8, uuid.clockSeqAndNode, 0, 8);
59 [StructLayout(LayoutKind.Sequential)]
60 internal class TEEC_SharedMemory
68 [StructLayout(LayoutKind.Sequential)]
69 internal struct TEEC_Value
75 [StructLayout(LayoutKind.Sequential)]
76 internal struct TEEC_TempMemoryReference
82 [StructLayout(LayoutKind.Sequential)]
83 internal struct TEEC_RegisteredMemoryReference
85 public TEEC_SharedMemory parent;
90 [StructLayout(LayoutKind.Explicit)]
91 internal struct TEEC_Parameter
94 public TEEC_TempMemoryReference tmpref;
96 public TEEC_RegisteredMemoryReference memref;
98 public TEEC_Value value;
101 [StructLayout(LayoutKind.Sequential)]
102 internal struct TEEC_Operation
104 public UInt32 started;
105 public UInt32 paramTypes;
106 [MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
107 public TEEC_Parameter[] paramlist;