/**
 * @file
 * @brief Test Persistent Object API, internal entry points
 * @copyright (C) 2019, Samsung Electronics Co., Ltd.
 */

#include "test_TA_po_command_id.h"
#include "test_TA_po_routine.h"
#include "test_TA_po_sample.h"
#include <stdio.h>
#include <string.h>
#include <tee_internal_api.h>
#include <unistd.h>

TEE_Result TA_CreateEntryPoint(void)
{
    return TEE_SUCCESS;
}

void TA_DestroyEntryPoint(void)
{
}

TEE_Result TA_OpenSessionEntryPoint(uint32_t paramTypes,
                                    TEE_Param params[4],
                                    void **sessionContext)
{
    (void)paramTypes;
    (void)params;
    (void)sessionContext;

    return TEE_SUCCESS;
}

void TA_CloseSessionEntryPoint(void *sessionContext)
{
    (void)sessionContext;
}

TEE_Result TA_InvokeCommandEntryPoint(void *sessionContext,
                                      uint32_t commandID,
                                      uint32_t paramTypes,
                                      TEE_Param params[4])
{
    TEE_Result rc;

    (void)sessionContext;
    (void)paramTypes;
    (void)params;

    switch (commandID) {
    case PO_CREATE:
        rc = create_po();
        break;
    case PO_WRITE:
        rc = write_po();
        break;
    case PO_READ:
        rc = read_po();
        break;
    case PO_DELETE:
        rc = delete_po();
        break;
    default:
        printf("Error: wrong commandID\n");
        rc = TEE_ERROR_GENERIC;
        break;
    }

    return rc;
}
