Release 4.0.0-preview1-00258
[platform/core/csapi/tizenfx.git] / src / Tizen.Security.TEEC / Interop / Interop.Types.cs
1 /*
2  *  Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
3  *
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
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
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
15  */
16
17
18 using System;
19 using System.IO;
20 using System.Text;
21 using System.Runtime.InteropServices;
22
23 internal static partial class Interop
24 {
25     [StructLayout(LayoutKind.Sequential)]
26     internal struct TEEC_Context
27     {
28         public readonly IntPtr imp;
29     }
30
31     [StructLayout(LayoutKind.Sequential)]
32     internal struct TEEC_Session
33     {
34         public readonly IntPtr imp;
35     }
36
37     [StructLayout(LayoutKind.Sequential)]
38     internal struct TEEC_UUID
39     {
40         public UInt32 timeLow;
41         public UInt16 timeMid;
42         public UInt16 timeHiAndVersion;
43         [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
44         public byte[] clockSeqAndNode;
45
46         internal static TEEC_UUID ToTeecUuid(Guid guid)
47         {
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);
55             return uuid;
56         }
57     }
58
59     [StructLayout(LayoutKind.Sequential)]
60     internal struct sTEEC_SharedMemoryImp
61     {
62         public IntPtr context;
63         public IntPtr context_imp;
64         public UInt32 flags;
65         public UInt32 memid;
66     }
67
68     [StructLayout(LayoutKind.Sequential)]
69     internal struct TEEC_SharedMemory
70     {
71         public IntPtr buffer;
72         public UInt32 size;
73         public UInt32 flags;
74     }
75
76     [StructLayout(LayoutKind.Sequential)]
77     internal struct TEEC_Parameter
78     {
79         public UInt32 a;
80         public UInt32 b;
81     }
82
83     [StructLayout(LayoutKind.Sequential)]
84     internal struct TEEC_Operation
85     {
86         public UInt32 started;
87         public UInt32 paramTypes;
88         [MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
89         public TEEC_Parameter[] paramlist;
90         public IntPtr imp;
91     }
92 }
93