Home | History | Annotate | Download | only in include
      1 /**
      2  * Copyright(c) 2011 Trusted Logic.   All rights reserved.
      3  *
      4  * Redistribution and use in source and binary forms, with or without
      5  * modification, are permitted provided that the following conditions
      6  * are met:
      7  *
      8  *  * Redistributions of source code must retain the above copyright
      9  *    notice, this list of conditions and the following disclaimer.
     10  *  * Redistributions in binary form must reproduce the above copyright
     11  *    notice, this list of conditions and the following disclaimer in
     12  *    the documentation and/or other materials provided with the
     13  *    distribution.
     14  *  * Neither the name Trusted Logic nor the names of its
     15  *    contributors may be used to endorse or promote products derived
     16  *    from this software without specific prior written permission.
     17  *
     18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     19  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     20  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
     21  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
     22  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
     23  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
     24  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     25  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     26  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     27  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
     28  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     29  */
     30 
     31 /**
     32  * Definition of the machine-specific integer types
     33  **/
     34 #ifndef __S_TYPE_H__
     35 #define __S_TYPE_H__
     36 
     37 /* C99 integer types */
     38 #if (!defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L) &&(!defined(__ANDROID32__))
     39 
     40 #include <limits.h>
     41 
     42 /* Figure out if a 64-bit integer types is available */
     43 #if \
     44     defined(_MSC_VER) || \
     45     defined(__SYMBIAN32__) || \
     46     defined(_WIN32_WCE) || \
     47     (defined(ULLONG_MAX) && ULLONG_MAX == 0xFFFFFFFFFFFFFFFFULL) || \
     48     (defined(ULONG_LONG_MAX) && ULONG_LONG_MAX == 0xFFFFFFFFFFFFFFFFULL)
     49 typedef unsigned long long uint64_t;
     50 typedef long long int64_t;
     51 #else
     52 #define __S_TYPE_INT64_UNDEFINED
     53 #endif
     54 
     55 #if UINT_MAX == 0xFFFFFFFF
     56 typedef unsigned int uint32_t;
     57 typedef int int32_t;
     58 #elif ULONG_MAX == 0xFFFFFFFF
     59 typedef unsigned long uint32_t;
     60 typedef long int32_t;
     61 #else
     62 #error This compiler is not supported.
     63 #endif
     64 
     65 #if USHRT_MAX == 0xFFFF
     66 typedef unsigned short uint16_t;
     67 typedef short  int16_t;
     68 #else
     69 #error This compiler is not supported.
     70 #endif
     71 
     72 #if UCHAR_MAX == 0xFF
     73 typedef unsigned char uint8_t;
     74 typedef signed char   int8_t;
     75 #else
     76 #error This compiler is not supported.
     77 #endif
     78 
     79 #if !defined(__cplusplus)
     80 typedef unsigned char bool;
     81 #define false ( (bool)0 )
     82 #define true  ( (bool)1 )
     83 #endif
     84 
     85 #else  /* !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L */
     86 
     87 #include <stdbool.h>
     88 #include <stdint.h>
     89 
     90 #endif  /* !(!defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L) */
     91 
     92 #include <stddef.h>
     93 
     94 #ifndef NULL
     95 #  ifdef __cplusplus
     96 #     define NULL  0
     97 #  else
     98 #     define NULL  ((void *)0)
     99 #  endif
    100 #endif
    101 
    102 #define IN
    103 #define OUT
    104 
    105 /*
    106  * Definition of other common types
    107  */
    108 
    109 typedef uint32_t S_RESULT;
    110 typedef S_RESULT TEEC_Result;
    111 typedef S_RESULT SM_ERROR;
    112 
    113 typedef uint32_t S_HANDLE;
    114 typedef S_HANDLE SM_HANDLE;
    115 #define S_HANDLE_NULL ((S_HANDLE)0)
    116 #define SM_HANDLE_INVALID  S_HANDLE_NULL
    117 
    118 /** Definition of an UUID (from RFC 4122 http://www.ietf.org/rfc/rfc4122.txt) */
    119 typedef struct S_UUID
    120 {
    121    uint32_t time_low;
    122    uint16_t time_mid;
    123    uint16_t time_hi_and_version;
    124    uint8_t clock_seq_and_node[8];
    125 }S_UUID;
    126 typedef S_UUID TEEC_UUID;
    127 typedef S_UUID SM_UUID;
    128 
    129 /* DLL Import/Export directives */
    130 
    131 #if defined(WIN32) || defined(__ARMCC_VERSION) || defined(__WINSCW__) || defined(_WIN32_WCE)
    132 #  define S_DLL_EXPORT __declspec(dllexport)
    133 #  define S_DLL_IMPORT __declspec(dllimport)
    134 #  define S_NO_RETURN  __declspec(noreturn)
    135 #elif defined(__GNUC__)
    136 #  define S_DLL_EXPORT __attribute__ ((visibility ("default")))
    137 #  define S_DLL_IMPORT __attribute__ ((visibility ("default")))
    138 #  define S_NO_RETURN  __attribute__ ((noreturn))
    139 #else
    140 #  define S_DLL_EXPORT
    141 #  define S_DLL_IMPORT
    142 #  define S_NO_RETURN
    143 #endif
    144 
    145 #endif /* __S_TYPE_H__ */
    146 
    147