
/*
 * =====================================================================================
 *
 *       Filename:  hdm_hypervisor.h
 *
 *    Description:  HDM definitions for hypervisor manipulation
 *
 *        Version:  1.0
 *        Created:  09/16/2019 15:26:11 PM
 *       Revision:  none
 *       Compiler:  gcc
 *
 *        Company:  Samsung Electronics
 *        Copyright (c) 2015 by Samsung Electronics, All rights reserved.
 *
 * =====================================================================================
 */

#ifndef _HDM_HYPERVISOR_H_
#define _HDM_HYPERVISOR_H_

/**
 * HDM includes
 */
#include "hdm_core.h"

/**
 * Custom QCOM includes
 */
#ifdef CONFIG_QSEE

#include "hdm_defs.h"
#include "hdm_rpmb.h"
#include "qsee_services.h"

/**
 * Shared memory data
 */
typedef struct {
        uint32_t magic;
        uint32_t command;
        uint32_t policy;
        uint32_t ret;
} hdm_shared_mem_data_t;

/**
 * Shared memory
 */
#ifdef SM7125
#define HDM_SHARED_MEM_BASE_ADDR    0xA1000000
#elif SM8450
#define HDM_SHARED_MEM_BASE_ADDR    0x800B01000
#else
#define HDM_SHARED_MEM_BASE_ADDR    0x9FB00000
#endif
#define HDM_SHARED_MEM_LEN          sizeof(hdm_shared_mem_data_t)

/**
 * Return code for QCOM Hypervisor
 */
#define HDM_HYPERVISOR_RETURN_OK 0x00000001

/**
 * @brief
 * hdm_deregister_shared_buffer
 * Clear and deregister Shared Buffer Area.
 * Returns current policy
 * 
 * @param[in] policy - current applied policy
 * @return TEE_Result
*/
TEE_Result hdm_deregister_shared_buffer(uint32_t *policy);

#else /** Custom TEEgris includes */

#include <tees_el2if.h>

#endif /* CONFIG_QSEE */

/**
 * @brief
 * hypervisor_communication
 * If command is write: Apply command bitmap (device block) on hypervisor.
 * If command is read: policy is useless
 *
 * @param[in] policy - policy device block
 * @param[in] command - read/write operation
 * @return TEE_Result
*/
TEE_Result hypervisor_communication(uint32_t policy, uint32_t command);

#endif /* _HDM_HYPERVISOR_H_ */
