コード例 #1
0
ファイル: Libteec.cs プロジェクト: yourina/TizenFX
        /// <summary>
        /// This function allocates a new block of memory as a block of shared memory within the scope of the
        /// specified context, in accordance with the parameters.
        /// </summary>
        /// <since_tizen> 3 </since_tizen>
        /// <param name="size">The size of shared memory.</param>
        /// <param name="flags">The flags describing access modes (Input and/or Output).</param>
        /// <returns>Returns the Shared Memory handler.</returns>
        /// <privilege>http://tizen.org/privilege/tee.client</privilege>
        /// <privlevel>partner</privlevel>
        /// <feature>http://tizen.org/feature/security.tee</feature>
        /// <exception cref="UnauthorizedAccessException">Thrown when an application does not have the privilege to access this method.</exception>
        /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
        /// <exception cref="InvalidOperationException">The operation is invalid.</exception>
        public SharedMemory AllocateSharedMemory(UInt32 size, SharedMemoryFlags flags)
        {
            SharedMemory sharedmem = new SharedMemory(this);

            Interop.TEEC_SharedMemory shm = new Interop.TEEC_SharedMemory();
            shm.size  = (UIntPtr)size;
            shm.flags = (UInt32)flags;
            int ret = Interop.Libteec.AllocateSharedMemory(context_imp, ref shm);

            Interop.CheckNThrowException(ret, "AllocateSharedMemory");
            sharedmem.setShm(ref shm);
            return(sharedmem);
        }
コード例 #2
0
ファイル: Libteec.cs プロジェクト: yourina/TizenFX
        /// <summary>
        /// This function registers a block of the existing client application memory as a block of shared memory within
        /// the scope of the specified context, in accordance with the parameters.
        /// The input <paramref name="memaddr"/> must point to the shared memory region to register.
        /// </summary>
        /// <since_tizen> 3 </since_tizen>
        /// <param name="memaddr">The address of the shared memory.</param>
        /// <param name="size">The size of the shared memory.</param>
        /// <param name="flags">The flags describing the access modes (Input and/or Output).</param>
        /// <returns>Returns the SharedMemory handler.</returns>
        /// <privilege>http://tizen.org/privilege/tee.client</privilege>
        /// <privlevel>partner</privlevel>
        /// <feature>http://tizen.org/feature/security.tee</feature>
        /// <exception cref="UnauthorizedAccessException">Thrown when an application does not have the privilege to access this method.</exception>
        /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
        /// <exception cref="InvalidOperationException">The operation is invalid.</exception>
        /// <exception cref="ArgumentException">The argument <paramref name="memaddr"/> is wrong.</exception>
        public SharedMemory RegisterSharedMemory(IntPtr memaddr, UInt32 size, SharedMemoryFlags flags)
        {
            SharedMemory sharedmem = new SharedMemory(this);

            Interop.TEEC_SharedMemory shm = new Interop.TEEC_SharedMemory();
            shm.buffer = memaddr;
            shm.size   = (UIntPtr)size;
            shm.flags  = (UInt32)flags;
            int ret = Interop.Libteec.RegisterSharedMemory(context_imp, ref shm);

            Interop.CheckNThrowException(ret, "RegisterSharedMemory");
            sharedmem.setShm(ref shm);
            return(sharedmem);
        }
コード例 #3
0
ファイル: Libteec.cs プロジェクト: prjung/TizenFX
 /// <summary>
 /// Constructs a parameter object which holds information about the registered memory shared with TA.
 /// </summary>
 /// <since_tizen> 3 </since_tizen>
 /// <privilege>http://tizen.org/privilege/tee.client</privilege>
 /// <privlevel>partner</privlevel>
 /// <param name="parent">The shared memory - registered or allocated.</param>
 /// <param name="size">The size of the buffer part.</param>
 /// <param name="offset">The offset of the buffer in the shared memory.</param>
 /// <param name="type">The kind of access allowed for TA <see cref="TEFRegisteredMemoryType"/>.</param>
 public RegisteredMemoryReference(SharedMemory parent, uint size, uint offset, TEFRegisteredMemoryType type) :
     base(type)
 {
     this.Parent = parent;
     if (type == TEFRegisteredMemoryType.Whole)
     {
         this.Size   = parent.Size;
         this.Offset = 0;
     }
     else
     {
         this.Size   = size;
         this.Offset = offset;
     }
 }
コード例 #4
0
ファイル: Libteec.cs プロジェクト: prjung/TizenFX
 /// <summary>
 /// This function deregisters or deallocates a previously initialized block of the shared memory.
 /// </summary>
 /// <remarks>
 /// For a memory buffer allocated using AllocateSharedMemory, the implementation must free the
 /// underlying memory and the client application must not access this region after this function has been
 /// called. In this case, the implementation must clear the buffer and size fields of the shared memory
 /// structure before returning.
 /// For memory registered using RegisterSharedMemory, the implementation must deregister the
 /// underlying memory from the TEE, but the memory region will stay available to the client application for
 /// other purposes as the memory is owned by it.
 /// </remarks>
 /// <since_tizen> 3 </since_tizen>
 /// <param name="shm">The shared memory object returned by RegisterSharedMemory or AllocateSharedMemory.</param>
 /// <privilege>http://tizen.org/privilege/tee.client</privilege>
 /// <privlevel>partner</privlevel>
 /// <feature>http://tizen.org/feature/security.tee</feature>
 /// <exception cref="UnauthorizedAccessException">Thrown when an application does not have the privilege to access this method.</exception>
 /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
 /// <exception cref="InvalidOperationException">The operation is invalid.</exception>
 /// <exception cref="ArgumentException">The argument is wrong.</exception>
 public void ReleaseSharedMemory(SharedMemory shm)
 {
     Interop.Libteec.ReleaseSharedMemory(ref shm.shm);
 }
コード例 #5
0
ファイル: Libteec.cs プロジェクト: yourina/TizenFX
 /// <summary>
 /// This function deregisters or deallocates a previously initialized block of the shared memory.
 /// </summary>
 /// <remarks>
 /// For a memory buffer allocated using AllocateSharedMemory, the implementation must free the
 /// underlying memory and the client application must not access this region after this function has been
 /// called. In this case, the implementation must clear the buffer and size fields of the shared memory
 /// structure before returning.
 /// For memory registered using RegisterSharedMemory, the implementation must deregister the
 /// underlying memory from the TEE, but the memory region will stay available to the client application for
 /// other purposes as the memory is owned by it.
 /// </remarks>
 /// <since_tizen> 3 </since_tizen>
 /// <param name="shm">The shared memory object returned by RegisterSharedMemory or AllocateSharedMemory.</param>
 /// <privilege>http://tizen.org/privilege/tee.client</privilege>
 /// <privlevel>partner</privlevel>
 /// <feature>http://tizen.org/feature/security.tee</feature>
 /// <exception cref="UnauthorizedAccessException">Thrown when an application does not have the privilege to access this method.</exception>
 /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
 /// <exception cref="InvalidOperationException">The operation is invalid.</exception>
 /// <exception cref="ArgumentException">The argument is wrong.</exception>
 public void ReleaseSharedMemory(SharedMemory shm)
 {
     shm.Dispose();
 }