14e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park/**
24e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * @defgroup MCD_API                    MobiCore Driver API
34e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * @addtogroup MCD_API
44e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * @{
54e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park *
64e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * @if DOXYGEN_MCDRV_API
74e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park *   @mainpage MobiCore Driver API.
84e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * @endif
94e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park *
104e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * MobiCore Driver API.
114e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park *
124e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * The MobiCore (MC) Driver API provides access functions to the MobiCore runtime environment and the contained Trustlets.
134e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park *
144e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * @image html DoxyOverviewDrvApi500x.png
154e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * @image latex DoxyOverviewDrvApi500x.png "MobiCore Overview" width=12cm
164e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park *
174e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * <!-- Copyright Giesecke & Devrient GmbH 2009 - 2012 -->
187b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim *
194e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * Redistribution and use in source and binary forms, with or without
204e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * modification, are permitted provided that the following conditions
214e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * are met:
224e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * 1. Redistributions of source code must retain the above copyright
234e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park *    notice, this list of conditions and the following disclaimer.
244e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * 2. Redistributions in binary form must reproduce the above copyright
254e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park *    notice, this list of conditions and the following disclaimer in the
264e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park *    documentation and/or other materials provided with the distribution.
274e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * 3. The name of the author may not be used to endorse or promote
284e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park *    products derived from this software without specific prior
294e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park *    written permission.
304e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park *
314e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
324e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
334e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
344e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
354e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
364e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
374e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
384e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
394e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
404e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
414e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
424e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park */
434e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park#ifndef MCDRIVER_H_
444e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park#define MCDRIVER_H_
454e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park
464e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park#if (!defined(__MC_CLIENT_LIB_API)) && __cplusplus
477b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim#define __MC_CLIENT_LIB_API       extern "C"
484e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park#else
497b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim#define __MC_CLIENT_LIB_API
504e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park#endif // __cplusplus
514e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park
524e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park
534e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park#include <stdint.h>
544e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park#include <stdbool.h>
554e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park
564e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park#include "mcUuid.h"
574e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park#include "mcVersionInfo.h"
584e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park
597b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim/*
607b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim *  MobiCore driver API error codes.
617b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim *  MAJOR part of error code is stable.
627b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim *  MCP part contains MCP result code. See MCI/mcimcp.h
637b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim *  DETAIL part may be used in testing for specific error code.
647b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim *
657b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim *  Detail error codes may change in different releases
667b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim *  Please do not test DETAIL part when comparing error codes.
677b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim */
687b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim#define MC_DRV_ERROR_MAJOR(ecode)    ((ecode)       & 0xFF)     /**< Get MAJOR part of error code. */
697b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim#define MC_DRV_ERROR_MCP(ecode)     (((ecode)>>8)   & 0xFF)     /**< Get MCP part of error code. */
707b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim#define MC_DRV_ERROR_DETAIL(ecode)  (((ecode)>>16)  & 0x0FFF)   /**< Get detail part of error code. */
717b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim
727b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kimtypedef uint32_t mcResult_t;
734e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park/**
744e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * Return values of MobiCore driver functions.
754e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park */
767b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim#define MC_DRV_OK                                   0x00000000 /**< Function call succeeded. */
777b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim#define MC_DRV_NO_NOTIFICATION                      0x00000001 /**< No notification available. */
787b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim#define MC_DRV_ERR_NOTIFICATION                     0x00000002 /**< Error during notification on communication level. */
797b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim#define MC_DRV_ERR_NOT_IMPLEMENTED                  0x00000003 /**< Function not implemented. */
807b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim#define MC_DRV_ERR_OUT_OF_RESOURCES                 0x00000004 /**< No more resources available. */
817b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim#define MC_DRV_ERR_INIT                             0x00000005 /**< Driver initialization failed. */
827b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim#define MC_DRV_ERR_UNKNOWN                          0x00000006 /**< Unknown error. */
837b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim#define MC_DRV_ERR_UNKNOWN_DEVICE                   0x00000007 /**< The specified device is unknown. */
847b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim#define MC_DRV_ERR_UNKNOWN_SESSION                  0x00000008 /**< The specified session is unknown. */
857b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim#define MC_DRV_ERR_INVALID_OPERATION                0x00000009 /**< The specified operation is not allowed. */
867b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim#define MC_DRV_ERR_INVALID_RESPONSE                 0x0000000a /**< The response header from the MC is invalid. */
877b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim#define MC_DRV_ERR_TIMEOUT                          0x0000000b /**< Function call timed out. */
887b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim#define MC_DRV_ERR_NO_FREE_MEMORY                   0x0000000c /**< Can not allocate additional memory. */
897b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim#define MC_DRV_ERR_FREE_MEMORY_FAILED               0x0000000d /**< Free memory failed. */
907b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim#define MC_DRV_ERR_SESSION_PENDING                  0x0000000e /**< Still some open sessions pending. */
917b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim#define MC_DRV_ERR_DAEMON_UNREACHABLE               0x0000000f /**< MC daemon not reachable */
927b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim#define MC_DRV_ERR_INVALID_DEVICE_FILE              0x00000010 /**< The device file of the kernel module could not be opened. */
937b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim#define MC_DRV_ERR_INVALID_PARAMETER                0x00000011 /**< Invalid parameter. */
947b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim#define MC_DRV_ERR_KERNEL_MODULE                    0x00000012 /**< Error from Kernel Module, see DETAIL for errno. */
957b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim#define MC_DRV_ERR_BULK_MAPPING                     0x00000013 /**< Error during mapping of additional bulk memory to session. */
967b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim#define MC_DRV_ERR_BULK_UNMAPPING                   0x00000014 /**< Error during unmapping of additional bulk memory to session. */
977b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim#define MC_DRV_INFO_NOTIFICATION                    0x00000015 /**< Notification received, exit code available. */
987b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim#define MC_DRV_ERR_NQ_FAILED                        0x00000016 /**< Set up of NWd connection failed. */
997b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim
1007b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim#define MC_DRV_ERR_DAEMON_VERSION                   0x00000017 /**< Wrong daemon version. */
1017b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim#define MC_DRV_ERR_CONTAINER_VERSION                0x00000018 /**< Wrong container version. */
1027b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim
1037b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim// those should become MCP or even detail codes on top of MC_DRV_ERR_MCP_ERROR
1047b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim#define MC_DRV_ERR_WRONG_PUBLIC_KEY                 0x00000019 /**< System Trustlet public key is wrong. */
1057b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim#define MC_DRV_ERR_CONTAINER_TYPE_MISMATCH          0x0000001a /**< Wrong containter type(s). */
1067b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim#define MC_DRV_ERR_CONTAINER_LOCKED                 0x0000001b /**< Container is locked (or not activated). */
1077b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim#define MC_DRV_ERR_SP_NO_CHILD                      0x0000001c /**< SPID is not registered with root container. */
1087b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim#define MC_DRV_ERR_TL_NO_CHILD                      0x0000001d /**< UUID is not registered with sp container. */
1097b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim#define MC_DRV_ERR_UNWRAP_ROOT_FAILED               0x0000001e /**< Unwrapping of root container failed. */
1107b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim#define MC_DRV_ERR_UNWRAP_SP_FAILED                 0x0000001f /**< Unwrapping of service provider container failed. */
1117b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim#define MC_DRV_ERR_UNWRAP_TRUSTLET_FAILED           0x00000020 /**< Unwrapping of Trustlet container failed. */
1127b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim
1137b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim// use separate numbers for those in the future
1147b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim#define MC_DRV_ERR_DEVICE_ALREADY_OPEN              MC_DRV_ERR_INVALID_OPERATION /** < Device is already open. */
1157b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim#define MC_DRV_ERR_SOCKET_CONNECT                   MC_DRV_ERR_DAEMON_UNREACHABLE /**< MC daemon socket not reachable. */
1167b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim#define MC_DRV_ERR_SOCKET_WRITE                     MC_DRV_ERR_DAEMON_UNREACHABLE /**< MC daemon socket write error. */
1177b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim#define MC_DRV_ERR_SOCKET_READ                      MC_DRV_ERR_DAEMON_UNREACHABLE /**< MC daemon socket read error. */
1187b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim#define MC_DRV_ERR_SOCKET_LENGTH                    MC_DRV_ERR_DAEMON_UNREACHABLE /**< MC daemon socket read error. */
1197b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim#define MC_DRV_ERR_DAEMON_SOCKET                    MC_DRV_ERR_DAEMON_UNREACHABLE /**< MC daemon had problems with socket. */
1207b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim#define MC_DRV_ERR_DEVICE_FILE_OPEN                 MC_DRV_ERR_INVALID_DEVICE_FILE /**< The device file of the kernel module could not be opened. */
1217b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim#define MC_DRV_ERR_NULL_POINTER                     MC_DRV_ERR_INVALID_PARAMETER /**< Null pointer passed as parameter. */
1227b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim#define MC_DRV_ERR_TCI_TOO_BIG                      MC_DRV_ERR_INVALID_PARAMETER /**< Requested TCI length is too high. */
1237b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim#define MC_DRV_ERR_WSM_NOT_FOUND                    MC_DRV_ERR_INVALID_PARAMETER /**< Requested TCI was not allocated with mallocWsm(). */
1247b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim#define MC_DRV_ERR_TCI_GREATER_THAN_WSM             MC_DRV_ERR_INVALID_PARAMETER /**< Requested TCI length is bigger than allocated WSM. */
1257b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim#define MC_DRV_ERR_TRUSTLET_NOT_FOUND               MC_DRV_ERR_INVALID_DEVICE_FILE /** < Trustlet could not be found in mcRegistry. */
1267b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim#define MC_DRV_ERR_DAEMON_KMOD_ERROR                MC_DRV_ERR_DAEMON_UNREACHABLE /**< Daemon cannot use Kernel module as expected. */
1277b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim#define MC_DRV_ERR_DAEMON_MCI_ERROR                 MC_DRV_ERR_DAEMON_UNREACHABLE /**< Daemon cannot use MCI as expected. */
1287b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim#define MC_DRV_ERR_MCP_ERROR                        MC_DRV_ERR_DAEMON_UNREACHABLE /**< MobiCore Control Protocol error. See MC_DRV_ERROR_MCP(). */
1297b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim#define MC_DRV_ERR_INVALID_LENGTH                   MC_DRV_ERR_NO_FREE_MEMORY /**< Invalid length. */
1307b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim#define MC_DRV_ERR_KMOD_NOT_OPEN                    MC_DRV_ERR_NO_FREE_MEMORY /**< Device not open. */
1317b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim#define MC_DRV_ERR_BUFFER_ALREADY_MAPPED            MC_DRV_ERR_BULK_MAPPING /**< Buffer is already mapped to this Trustlet. */
1327b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim#define MC_DRV_ERR_BLK_BUFF_NOT_FOUND               MC_DRV_ERR_BULK_UNMAPPING /**< Unable to find internal handle for buffer. */
1337b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim
1347b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim#define MC_DRV_ERR_DAEMON_DEVICE_NOT_OPEN           0x00000021 /**< No device associated with connection. */
1357b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim#define MC_DRV_ERR_DAEMON_WSM_HANDLE_NOT_FOUND      MC_DRV_ERR_WSM_NOT_FOUND /**< Daemon could not find WSM handle. */
1367b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim#define MC_DRV_ERR_DAEMON_UNKNOWN_SESSION           MC_DRV_ERR_UNKNOWN_SESSION /**< The specified session is unknown to Daemon. */
1374e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park
1387b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim#define MAKE_MC_DRV_MCP_ERROR(mcpCode)              (MC_DRV_ERR_MCP_ERROR | ((mcpCode&0x000FFFFF)<<8))
1397b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim#define MAKE_MC_DRV_KMOD_WITH_ERRNO(theErrno)       (MC_DRV_ERR_KERNEL_MODULE| (((theErrno)&0x0000FFFF)<<16))
1404e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park
1414e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park/**
1424e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * Driver control command.
1434e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park */
1444e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Parktypedef enum {
1454e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park    MC_CTRL_DUMMY = 1 /**< Dummy. */
1464e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park} mcDriverCtrl_t;
1474e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park
1484e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park
1494e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park/** Structure of Session Handle, includes the Session ID and the Device ID the Session belongs to.
1504e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * The session handle will be used for session-based MobiCore communication.
1514e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * It will be passed to calls which address a communication end point in the MobiCore environment.
1524e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park */
1534e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Parktypedef struct {
1547b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim    uint32_t sessionId; /**< MobiCore session ID */
1557b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim    uint32_t deviceId; /**< Device ID the session belongs to */
1564e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park} mcSessionHandle_t;
1574e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park
1584e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park/** Information structure about additional mapped Bulk buffer between the Trustlet Connector (Nwd) and
1594e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * the Trustlet (Swd). This structure is initialized from a Trustlet Connector by calling mcMap().
1604e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * In order to use the memory within a Trustlet the Trustlet Connector has to inform the Trustlet with
1614e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * the content of this structure via the TCI.
1624e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park */
1634e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Parktypedef struct {
1647b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim    void *sVirtualAddr;         /**< The virtual address of the Bulk buffer regarding the address space of the Trustlet, already includes a possible offset! */
1657b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim    uint32_t sVirtualLen;       /**< Length of the mapped Bulk buffer */
1664e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park} mcBulkMap_t;
1674e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park
1684e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park
1694e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park#define MC_DEVICE_ID_DEFAULT       0 /**< The default device ID */
1704e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park#define MC_INFINITE_TIMEOUT        ((int32_t)(-1)) /**< Wait infinite for a response of the MC. */
1714e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park#define MC_NO_TIMEOUT              0   /**< Do not wait for a response of the MC. */
1724e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park#define MC_MAX_TCI_LEN             0x100000 /**< TCI/DCI must not exceed 1MiB */
1734e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park
1744e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park/* Mark only the following functions for export */
1754e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park#pragma GCC visibility push(default)
1764e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park
1774e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park/** Open a new connection to a MobiCore device.
1784e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park *
1794e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * mcOpenDevice() initializes all device specific resources required to communicate
1804e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * with an MobiCore instance located on the specified device in the system. If the device
1814e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * does not exist the function will return MC_DRV_ERR_UNKNOWN_DEVICE.
1824e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park *
1834e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * @param [in] deviceId Identifier for the MobiCore device to be used. MC_DEVICE_ID_DEFAULT refers to the default device.
1844e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park *
1854e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * @return MC_DRV_OK if operation has been successfully completed.
1864e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * @return MC_DRV_ERR_INVALID_OPERATION if device already opened.
1874e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * @return MC_DRV_ERR_DAEMON_UNREACHABLE when problems with daemon occur.
1884e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * @return MC_DRV_ERR_UNKNOWN_DEVICE when deviceId is unknown.
1894e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * @return MC_DRV_ERR_INVALID_DEVICE_FILE if kernel module under /dev/mobicore cannot be opened
1904e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park *
1914e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * Uses a Mutex.
1924e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park */
1934e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park__MC_CLIENT_LIB_API mcResult_t mcOpenDevice(
1944e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park    uint32_t deviceId
1954e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park);
1964e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park
1974e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park/** Close the connection to a MobiCore device.
1984e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * When closing a device, active sessions have to be closed beforehand.
1994e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * Resources associated with the device will be released.
2004e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * The device may be opened again after it has been closed.
2014e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park *
2024e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * @param [in] deviceId Identifier for the MobiCore device. MC_DEVICE_ID_DEFAULT refers to the default device.
2034e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park *
2044e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * @return MC_DRV_OK if operation has been successfully completed.
2054e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * @return MC_DRV_ERR_UNKNOWN_DEVICE when device id is invalid.
2064e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * @return MC_DRV_ERR_SESSION_PENDING when a session is still open.
2074e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * @return MC_DRV_ERR_DAEMON_UNREACHABLE when problems with daemon occur.
2084e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park *
2094e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * Uses a Mutex.
2104e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park */
2114e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park__MC_CLIENT_LIB_API mcResult_t mcCloseDevice(
2124e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park    uint32_t deviceId
2134e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park);
2144e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park
2154e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park/** Open a new session to a Trustlet. The trustlet with the given UUID has to be available in the flash filesystem.
2164e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park *
2174e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * Write MCP open message to buffer and notify MobiCore about the availability of a new command.
2184e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * Waits till the MobiCore responses with the new session ID (stored in the MCP buffer).
2194e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park *
2204e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * @param [in,out] session On success, the session data will be returned. Note that session.deviceId has to be the device id of an opened device.
2214e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * @param [in] uuid UUID of the Trustlet to be opened.
2224e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * @param [in] tci TCI buffer for communicating with the trustlet.
2234e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * @param [in] tciLen Length of the TCI buffer. Maximum allowed value is MC_MAX_TCI_LEN.
2244e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park *
2254e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * @return MC_DRV_OK if operation has been successfully completed.
2264e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * @return MC_DRV_INVALID_PARAMETER if session parameter is invalid.
2274e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * @return MC_DRV_ERR_UNKNOWN_DEVICE when device id is invalid.
2284e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * @return MC_DRV_ERR_DAEMON_UNREACHABLE when problems with daemon socket occur.
2294e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * @return MC_DRV_ERR_UNKNOWN_DEVICE when daemon returns an error.
2304e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park *
2314e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * Uses a Mutex.
2324e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park */
2334e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park__MC_CLIENT_LIB_API mcResult_t mcOpenSession(
2344e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park    mcSessionHandle_t  *session,
2354e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park    const mcUuid_t       *uuid,
2364e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park    uint8_t            *tci,
2374e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park    uint32_t           tciLen
2384e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park);
2394e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park
2404e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park/** Close a Trustlet session.
2414e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park *
2424e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * Closes the specified MobiCore session. The call will block until the session has been closed.
2434e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park *
2444e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * @pre Device deviceId has to be opened in advance.
2454e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park *
2464e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * @param [in] session Session to be closed.
2474e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park *
2484e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * @return MC_DRV_OK if operation has been successfully completed.
2494e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * @return MC_DRV_INVALID_PARAMETER if session parameter is invalid.
2504e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * @return MC_DRV_ERR_UNKNOWN_SESSION when session id is invalid.
2514e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * @return MC_DRV_ERR_UNKNOWN_DEVICE when device id of session is invalid.
2524e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * @return MC_DRV_ERR_DAEMON_UNREACHABLE when problems with daemon occur.
2534e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * @return MC_DRV_ERR_INVALID_DEVICE_FILE when daemon cannot open trustlet file.
2544e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park *
2554e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * Uses a Mutex.
2564e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park */
2574e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park__MC_CLIENT_LIB_API mcResult_t mcCloseSession(
2584e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park    mcSessionHandle_t *session
2594e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park);
2604e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park
2614e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park/** Notify a session.
2624e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * Notifies the session end point about available message data.
2634e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * If the session parameter is correct, notify will always succeed.
2644e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * Corresponding errors can only be received by mcWaitNotification().
2654e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * @pre A session has to be opened in advance.
2664e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park *
2674e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * @param session The session to be notified.
2684e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park *
2694e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * @return MC_DRV_OK if operation has been successfully completed.
2704e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * @return MC_DRV_INVALID_PARAMETER if session parameter is invalid.
2714e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * @return MC_DRV_ERR_UNKNOWN_SESSION when session id is invalid.
2724e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * @return MC_DRV_ERR_UNKNOWN_DEVICE when device id of session is invalid.
2734e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park */
2744e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park__MC_CLIENT_LIB_API mcResult_t mcNotify(
2754e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park    mcSessionHandle_t *session
2764e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park);
2774e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park
2784e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park/** Wait for a notification.
2794e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park *
2804e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * Wait for a notification issued by the MobiCore for a specific session.
2814e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * The timeout parameter specifies the number of milliseconds the call will wait for a notification.
2824e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * If the caller passes 0 as timeout value the call will immediately return. If timeout value is below 0 the call will block
2834e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * until a notification for the session has been received.
2844e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park *
2854e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * @attention if timeout is below 0, call will block:
2864e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * Caller has to trust the other side to send a notification to wake him up again.
2874e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park *
2884e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * @param [in] session The session the notification should correspond to.
2894e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * @param [in] timeout Time in milliseconds to wait (MC_NO_TIMEOUT : direct return, > 0 : milliseconds, MC_INFINITE_TIMEOUT : wait infinitely)
2904e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park *
2914e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * @return MC_DRV_OK if notification is available.
2924e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * @return MC_DRV_ERR_TIMEOUT if no notification arrived in time.
2934e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * @return MC_DRV_INFO_NOTIFICATION if a problem with the session was encountered. Get more details with mcGetSessionErrorCode().
2944e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * @return MC_DRV_ERR_NOTIFICATION if a problem with the socket occurred.
2954e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * @return MC_DRV_INVALID_PARAMETER if a parameter is invalid.
2964e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * @return MC_DRV_ERR_UNKNOWN_SESSION when session id is invalid.
2974e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * @return MC_DRV_ERR_UNKNOWN_DEVICE when device id of session is invalid.
2984e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park */
2994e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park__MC_CLIENT_LIB_API mcResult_t mcWaitNotification(
3004e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park    mcSessionHandle_t  *session,
3014e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park    int32_t            timeout
3024e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park);
3034e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park
3044e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park/**
3054e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * Allocate a block of world shared memory (WSM).
3064e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * The MC driver allocates a contiguous block of memory which can be used as WSM.
3074e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * This implicates that the allocated memory is aligned according to the alignment parameter.
3084e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * Always returns a buffer of size WSM_SIZE aligned to 4K.
3094e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park *
3104e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * @param [in]  deviceId The ID of an opened device to retrieve the WSM from.
3114e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * @param [in]  align The alignment (number of pages) of the memory block (e.g. 0x00000001 for 4kb).
3127b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim * @param [in]  len Length of the block in bytes.
3134e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * @param [out] wsm Virtual address of the world shared memory block.
3144e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * @param [in]  wsmFlags Platform specific flags describing the memory to be allocated.
3154e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park *
3164e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * @attention: align and wsmFlags are currently ignored
3174e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park *
3184e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * @return MC_DRV_OK if operation has been successfully completed.
3194e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * @return MC_DRV_INVALID_PARAMETER if a parameter is invalid.
3204e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * @return MC_DRV_ERR_UNKNOWN_DEVICE when device id is invalid.
3214e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * @return MC_DRV_ERR_NO_FREE_MEMORY if no more contiguous memory is available in this size or for this process.
3224e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park *
3234e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * Uses a Mutex.
3244e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park */
3254e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park__MC_CLIENT_LIB_API mcResult_t mcMallocWsm(
3264e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park    uint32_t  deviceId,
3274e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park    uint32_t  align,
3284e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park    uint32_t  len,
3294e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park    uint8_t   **wsm,
3304e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park    uint32_t  wsmFlags
3314e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park);
3324e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park
3334e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park/**
3344e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * Free a block of world shared memory (WSM).
3354e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * The MC driver will free a block of world shared memory (WSM) previously allocated with
3364e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * mcMallocWsm(). The caller has to assure that the address handed over to the driver
3374e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * is a valid WSM address.
3384e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park *
3394e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * @param [in] deviceId The ID to which the given address belongs.
3404e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * @param [in] wsm Address of WSM block to be freed.
3414e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park *
3424e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * @return MC_DRV_OK if operation has been successfully completed.
3434e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * @return MC_DRV_INVALID_PARAMETER if a parameter is invalid.
3444e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * @return MC_DRV_ERR_UNKNOWN_DEVICE when device id is invalid.
3454e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * @return MC_DRV_ERR_FREE_MEMORY_FAILED on failures.
3464e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park *
3474e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * Uses a Mutex.
3484e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park */
3494e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park__MC_CLIENT_LIB_API mcResult_t mcFreeWsm(
3504e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park    uint32_t  deviceId,
3514e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park    uint8_t   *wsm
3524e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park);
3534e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park
3544e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park/**
3554e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * Map additional bulk buffer between a Trustlet Connector (TLC) and the Trustlet (TL) for a session.
3564e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * Memory allocated in user space of the TLC can be mapped as additional communication channel
3574e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * (besides TCI) to the Trustlet. Limitation of the Trustlet memory structure apply: only 6 chunks can be mapped
3584e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * with a maximum chunk size of 1 MiB each.
3594e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park *
3604e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * @attention It is up to the application layer (TLC) to inform the Trustlet about the additional mapped bulk memory.
3614e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park *
3624e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * @param [in] session Session handle with information of the deviceId and the sessionId. The
3634e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * given buffer is mapped to the session specified in the sessionHandle.
3644e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * @param [in] buf Virtual address of a memory portion (relative to TLC) to be shared with the Trustlet, already includes a possible offset!
3654e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * @param [in] len length of buffer block in bytes.
3664e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * @param [out] mapInfo Information structure about the mapped Bulk buffer between the TLC (Nwd) and
3674e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * the TL (Swd).
3684e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park *
3694e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * @return MC_DRV_OK if operation has been successfully completed.
3704e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * @return MC_DRV_INVALID_PARAMETER if a parameter is invalid.
3714e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * @return MC_DRV_ERR_UNKNOWN_SESSION when session id is invalid.
3724e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * @return MC_DRV_ERR_UNKNOWN_DEVICE when device id of session is invalid.
3734e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * @return MC_DRV_ERR_DAEMON_UNREACHABLE when problems with daemon occur.
3744e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * @return MC_DRV_ERR_BULK_MAPPING when buf is already uses as bulk buffer or when registering the buffer failed.
3754e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park *
3764e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * Uses a Mutex.
3774e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park */
3784e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park__MC_CLIENT_LIB_API mcResult_t mcMap(
3794e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park    mcSessionHandle_t  *session,
3804e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park    void               *buf,
3814e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park    uint32_t           len,
3824e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park    mcBulkMap_t        *mapInfo
3834e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park);
3844e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park
3854e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park/**
3864e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * Remove additional mapped bulk buffer between Trustlet Connector (TLC) and the Trustlet (TL) for a session.
3874e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park *
3884e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * @attention The bulk buffer will immediately be unmapped from the session context.
3894e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * @attention The application layer (TLC) must inform the TL about unmapping of the additional bulk memory before calling mcUnmap!
3904e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park *
3914e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * @param [in] session Session handle with information of the deviceId and the sessionId. The
3924e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * given buffer is unmapped from the session specified in the sessionHandle.
3934e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * @param [in] buf Virtual address of a memory portion (relative to TLC) shared with the TL, already includes a possible offset!
3944e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * @param [in] mapInfo Information structure about the mapped Bulk buffer between the TLC (Nwd) and
3954e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * the TL (Swd).
3964e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * @attention The clientlib currently ignores the len field in mapInfo.
3974e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park *
3984e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * @return MC_DRV_OK if operation has been successfully completed.
3994e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * @return MC_DRV_INVALID_PARAMETER if a parameter is invalid.
4004e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * @return MC_DRV_ERR_UNKNOWN_SESSION when session id is invalid.
4014e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * @return MC_DRV_ERR_UNKNOWN_DEVICE when device id of session is invalid.
4024e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * @return MC_DRV_ERR_DAEMON_UNREACHABLE when problems with daemon occur.
4034e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * @return MC_DRV_ERR_BULK_UNMAPPING when buf was not registered earlier or when unregistering failed.
4044e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park *
4054e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * Uses a Mutex.
4064e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park */
4074e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park__MC_CLIENT_LIB_API mcResult_t mcUnmap(
4084e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park    mcSessionHandle_t  *session,
4094e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park    void               *buf,
4104e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park    mcBulkMap_t        *mapInfo
4114e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park);
4124e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park
4134e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park
4144e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park/**
4154e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * @attention: Not implemented.
4164e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * Execute driver specific command.
4174e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * mcDriverCtrl() can be used to execute driver specific commands.
4184e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * Besides the control command MC_CTRL_GET_VERSION commands are implementation specific.
4194e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * Please refer to the corresponding specification of the driver manufacturer.
4204e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park *
4214e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * @param [in] param Command ID of the command to be executed.
4224e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * @param [in, out] data  Command data and response depending on command.
4234e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * @param [in] len Length of the data block.
4244e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park *
4254e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * @return MC_DRV_ERR_NOT_IMPLEMENTED.
4264e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park */
4274e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park__MC_CLIENT_LIB_API mcResult_t mcDriverCtrl(
4284e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park    mcDriverCtrl_t  param,
4294e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park    uint8_t         *data,
4304e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park    uint32_t        len
4314e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park);
4324e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park
4334e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park/**
4344e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * Get additional error information of the last error that occured on a session.
4354e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * After the request the stored error code will be deleted.
4364e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park *
4374e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * @param [in] session Session handle with information of the deviceId and the sessionId.
4384e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * @param [out] lastErr >0 Trustlet has terminated itself with this value, <0 Trustlet is dead because of an error within the MobiCore (e.g. Kernel exception).
4397b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim * See also notificationPayload_t enum in MCI definition at "mcinq.h".
4404e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park *
4414e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * @return MC_DRV_OK if operation has been successfully completed.
4424e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * @return MC_DRV_INVALID_PARAMETER if a parameter is invalid.
4434e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * @return MC_DRV_ERR_UNKNOWN_SESSION when session id is invalid.
4444e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * @return MC_DRV_ERR_UNKNOWN_DEVICE when device id of session is invalid.
4454e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park */
4464e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park__MC_CLIENT_LIB_API mcResult_t mcGetSessionErrorCode(
4474e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park    mcSessionHandle_t  *session,
4484e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park    int32_t            *lastErr
4494e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park);
4504e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park
4514e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park/**
4524e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * Get MobiCore version information of a device.
4534e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park *
4544e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * @param [in] deviceId of an open device.
4554e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * @param [out] versionInfo MobiCore version info.
4564e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park *
4574e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * @return MC_DRV_OK if operation has been successfully completed.
4584e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * @return MC_DRV_ERR_UNKNOWN_DEVICE when device is not open.
4594e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * @return MC_DRV_INVALID_PARAMETER if a parameter is invalid.
4604e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * @return MC_DRV_ERR_DAEMON_UNREACHABLE when problems with daemon occur.
4614e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park */
4624e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park__MC_CLIENT_LIB_API mcResult_t mcGetMobiCoreVersion(
4634e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park    uint32_t  deviceId,
4647b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim    mcVersionInfo_t *versionInfo
4654e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park);
4664e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park#pragma GCC visibility pop
4674e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park#endif /** MCDRIVER_H_ */
4684e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park
4694e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park/** @} */
470