// +FHDR------------------------------------------------------------
//                 Copyright (c) 2022 SmartLogic.
//                       ALL RIGHTS RESERVED
// -----------------------------------------------------------------
// Filename      : ucp_handshake.h
// Author        : xianfeng.du
// Created On    : 2022-07-22
// Last Modified :
// -----------------------------------------------------------------
// Description:
//
//
// -FHDR------------------------------------------------------------

#ifndef __UCP_HANDSHAKE_H__
#define __UCP_HANDSHAKE_H__

#include "typedef.h"

#define MAX_NUM_APE 8
#define MAX_NUM_SPU 12
#define MAX_NUM_CORE (MAX_NUM_SPU+1)
#define NPU_CORE_ID MAX_NUM_SPU
#define PET_RFM_SPU0_CORE_ID 8
#define PET_RFM_SPU1_CORE_ID 9
#define ECS_RFM_SPU0_CORE_ID 10
#define ECS_RFM_SPU1_CORE_ID 11

#define HANDSHKAE_REQ_VALUE 0x5A5A5A5A
#define HANDSHKAE_RESP_VALUE 0xA5A5A5A5

#ifndef PCIE_BACKHAUL
#define HANDSHKAE_MASK  0x00000e00//excluded APE cores
#elif (defined(PCIE_WITH_JESD))
#define HANDSHKAE_MASK  0x00000e00//excluded APE cores
#else
#define HANDSHKAE_MASK  0x00000f00//excluded APE cores
#endif

typedef struct tUcpHandshake{
	uint32_t request[MAX_NUM_CORE];
	uint32_t response[MAX_NUM_CORE];
	uint32_t heartbeat[MAX_NUM_CORE];
} UcpHandshake_t;

UcpHandshake_t * get_handshake_info(void);
void handshake_master_with_slave(uint32_t core_mask);
void handshake_slave_with_master(void);
uint32_t get_host_core_mask(void);
void handshake_request_from_host(uint32_t core_mask);
void handshake_response_to_host(uint32_t core_mask);

#endif



