/*
 *
 * Copyright (C) 2015, Samsung Electronics Co., Ltd.
 *
 * Custom property support
 */

#ifndef __TA_CUSTOM_PROPERTY_H__
#define __TA_CUSTOM_PROPERTY_H__

#include <stdint.h>
#include <stdbool.h>
#include <tee_internal_api.h>

#define MAX_CUSTOM_PROP_NAME 100
#define MAX_CUSTOM_PROP_VALUE 100

typedef struct prop_custom {
    char name[MAX_CUSTOM_PROP_NAME];
    int type;
    size_t size;
    union {
        char value[MAX_CUSTOM_PROP_VALUE];
        bool b_value;
        uint32_t u32_value;
        TEE_UUID uuid_value;
        TEE_Identity identity_value;
    } qwerty;
} prop_custom_t;

#define TA_PROP_CUSTOM_START static volatile const struct prop_custom custom_properties[] \
                                __attribute__ ((section ("Custom_TA_property"), used)) = {

#define TA_PROP_CUSTOM_END };

#define TA_PROP_CUSTOM_STRING(prop_name, prop_val) \
        { \
               .name = prop_name, \
               .type = PROP_TYPE_STRING, \
               .size = sizeof(prop_val), \
               .value = prop_val, \
        },

#define TA_PROP_CUSTOM_BOOLEAN(prop_name, prop_val) \
        { \
               .name = prop_name, \
               .type = PROP_TYPE_BOOL, \
               .size = sizeof(bool), \
               .b_value = prop_val, \
        },
#define TA_PROP_CUSTOM_U32(prop_name, prop_val) \
        { \
               .name = prop_name, \
               .type = PROP_TYPE_U32, \
               .size = sizeof(uint32_t), \
               .u32_value = prop_val, \
        },

#define TA_PROP_CUSTOM_BINARY(prop_name, prop_size, ...) \
        { \
               .name = prop_name, \
               .type = PROP_TYPE_BINBLOCK, \
               .size = prop_size, \
               .value = __VA_ARGS__, \
        },

#define TA_PROP_CUSTOM_UUID(prop_name, ...) \
        { \
               .name = prop_name, \
               .type = PROP_TYPE_UUID, \
               .size = sizeof(TEE_UUID), \
               .uuid_value = __VA_ARGS__, \
        },

#define TA_PROP_CUSTOM_IDENTITY(prop_name, ...) \
        { \
               .name = prop_name, \
               .type = PROP_TYPE_IDENTITY, \
               .size = sizeof(TEE_Identity), \
               .identity_value = __VA_ARGS__, \
        },

#endif /* !__TA_CUSTOM_PROPERTY_H__ */

