#ifndef ACCESSCONTROL_H
#define ACCESSCONTROL_H
/*===========================================================================
  Copyright (c) 2010-2013 by Qualcomm Technologies, Incorporated.  All Rights Reserved.
  ============================================================================*/

/*===========================================================================

  EDIT HISTORY FOR FILE

  This section contains comments describing changes made to this file.
  Notice that changes are listed in reverse chronological order.

  $Header: //components/rel/ssg.tz/1.10.1/securemsm/accesscontrol/api/AccessControl.h#1 $
  $DateTime: 2020/01/05 22:02:39 $
  $Author: pwbldsvc $

  when       who     what, where, why
  --------   ---     ----------------------------------------------------------
  06/01/12   sg      Add APIs to add/remove VMIDs permissions from an xPU
  09/14/10   tk      First version.
  ============================================================================*/

/*----------------------------------------------------------------------------
 * Include Files
 * -------------------------------------------------------------------------*/
#include "vm.h"
#include "ACCommon.h"
#include "SMMUDynamicSID.h"
#include "HALvmidmt.h"
/*----------------------------------------------------------------------------
 * Preprocessor Definitions and Constants
 * -------------------------------------------------------------------------*/
#define ONE 1
#define bool32  uint32

#define AC_MAX_SUBSYS_CHANNEL_VMS 4

/*----------------------------------------------------------------------------
 * Type Declarations
 * -------------------------------------------------------------------------*/

typedef struct
{
    uint64 uMemoryStart;
    uint64 uMemorySize;
}ACRegion;

typedef struct
{
    HAL_vmidmt_InstanceType           eVmidmtInstance;
    SMMU_Instance_e_type              eSmmuInstance;
    ACRegion                          *pMappings;
    uint32                            *pExternalSidList;
    uint32                            *pInternalSidList;
    uint32                            uNumMappings;
    uint32                            uNumExternalSids;
    uint32                            uNumInternalSids;
}ACDeviceInfo;

struct _ACMemoryInfoType
{
    uint32 uTzPerm;
    uint64 uSize;
    uint64 uMemoryStart;
    uint64 uSharedVmMask;
    uint64 uReadVmMask;
    uint64 uWriteVmMask;
    ACVirtualMachineId eCallerVmId;
    bool32 uInUse;
    uint64 uHandle;
    struct _ACMemoryInfoType *pNext;
};
typedef struct _ACMemoryInfoType ACMemoryInfoType;

 struct ACTZSubsysChannel
{
    uint64 IPAaddr;
    uint64 IPAsize;
    uint32 dstVM[AC_MAX_SUBSYS_CHANNEL_VMS];
    uint32 dstVMperm[AC_MAX_SUBSYS_CHANNEL_VMS];
	uint32 dstVMCnt;
};

typedef struct ACTZSubsysChannel ACTZSubsysSecChannel;
typedef struct ACTZSubsysChannel ACTZSubsysMSAChannel;

/*----------------------------------------------------------------------------
 * Function Declarations and Documentation
 * -------------------------------------------------------------------------*/
/**
  @brief ACTypeIs: Checks if the type of VM is equal to what is passed
  @param eType: Type of AC which is to be checked
  @param eVm: VM which needs to be verified
  @return TURE if the type is correct, otherwise FALSE
  */
bool32 ACTypeIs(ACVirtualMachineId eVm, ACVMTypeId eType);

/**
  @brief ACFreeMemory - Wrapper around hyp & tz malloc free
  @return AC_SUCCESS/AC_FAILURE
  */
void ACFreeMemory(void *pNode, uint64 uSize);

/**
  @brief ACAllocateMemory - Wrapper around hyp & tz malloc
  @return AC_SUCCESS/AC_FAILURE
  */
void *ACAllocateMemory(uint64 uSize);

/**
  @brief ACIsVminVmList - Checks if a specified VM is in the given list of VMs
  @return TRUE/FALSE
  */
bool32  ACIsVminVmList(ACVirtualMachineId eVM, ACVirtualMachineId *VMList, uint32 VMlistcnt);

#endif
