#ifndef __TLAPIMARSHALDRTIMA_H__
#define __TLAPIMARSHALDRTIMA_H__

#include "TlApi/TlApiError.h"
#include "TlApiDrTimaCommon.h"
#include "log.h"
#include "dashboard.h"

/*Constant value from mst_secdrv.h*/
#define TRACK_DATA_SIZE 512

void InitialiseTIMADriver(
	void
);

/** Each function must have its own ID.
 * Extend this list if you add a new function.
 */
typedef enum {
	TIMA_DRIVER_GENERATE_DIGEST = 1,
	TIMA_DRIVER_PHYS_MEM_ACCESS_COPY,
	TIMA_DRIVER_SEC_LOG,
	TIMA_DRIVER_DBG_LOG,
	TIMA_DRIVER_MST,
	TIMA_DRIVER_GET_SECURE_BOOT_STATUS,
	TIMA_DRIVER_SCRYPTO,
	TIMA_DRIVER_ALLOWLIST,
	TIMA_DRIVER_SET_HDM_POLICY
} timaFuncID_t;

/** Marshaled function parameters.
 * structs and union of marshaling parameters via TlApi.
 *
 * @note The structs can NEVER be packed !
 * @note The structs can NOT used via sizeof(..) !
 */

/** Maximum number of parameters. */
#define MAX_MAR_LIST_LENGTH 8			   /**< Maximum list of possible marshaling parameters. */

/** Union of marshaling parameters. */
/* If adding any function, add the marshaling structure here */
typedef struct {
	uint32_t functionId;			       /**< Function identifier. */
	union {
		struct digestData_t *pDigestData;
		struct physMemAccessData_t *pPhysMemAccessData;
		struct driverAccessData_t *pDriverAccessData;
		tlApiResult_t retVal;
		char log_msg[LOG_MSG_SIZE];
		char mst_track_data[TRACK_DATA_SIZE];
		sec_entry_t dashboard_entry_type;
		struct scrypto_t *pSCrypto;
		struct update_allowlist_t *wl;
		struct set_hdm_policy_t *policy;
		uint32_t parameter[MAX_MAR_LIST_LENGTH];	/* untyped parameter list (expends union to 8 entries) */
	} payload;
} TimaMarshalingParam_t,
*TimaMarshalingParam_ptr;

/* Driver ID. These will be managed by G&D */
#define TIMA_DRV_ID 0x40003

_NORETURN static void TIMADriverIPC_Handler(
	void
);

/** Invalid session id. Returned in case of an error. */
#define DR_SID_INVALID      0xffffffff

#endif // __TLAPIMARSHALDRTIMA_H__

/** @} */
