[ElmSharp] Fixed the crash issue of Calendar
[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 class TEEC_SharedMemory
61     {
62         public IntPtr buffer;
63         public UInt32 size;
64         public UInt32 flags;
65         public IntPtr imp;
66     }
67
68     [StructLayout(LayoutKind.Sequential)]
69     internal struct TEEC_Value
70     {
71         public UInt32 a;
72         public UInt32 b;
73     }
74
75     [StructLayout(LayoutKind.Sequential)]
76     internal struct TEEC_TempMemoryReference
77     {
78         public IntPtr buffer;
79         public UInt32 size;
80     }
81
82     [StructLayout(LayoutKind.Sequential)]
83     internal struct TEEC_RegisteredMemoryReference
84     {
85         public TEEC_SharedMemory parent;
86         public UInt32 size;
87         public UInt32 offset;
88     }
89
90     [StructLayout(LayoutKind.Explicit)]
91     internal struct TEEC_Parameter
92     {
93         [FieldOffset(0)]
94         public TEEC_TempMemoryReference tmpref;
95         [FieldOffset(0)]
96         public TEEC_RegisteredMemoryReference memref;
97         [FieldOffset(0)]
98         public TEEC_Value value;
99     }
100
101     [StructLayout(LayoutKind.Sequential)]
102     internal struct TEEC_Operation
103     {
104         public UInt32 started;
105         public UInt32 paramTypes;
106         [MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
107         public TEEC_Parameter[] paramlist;
108         public IntPtr imp;
109     }
110 }
111