/******************************************************************
 * @file  msg_interface.h
 * @brief:    [file description] 
 * @author: guicheng.liu
 * @Date 2022年7月2日
 * COPYRIGHT NOTICE: (c) smartlogictech. All rights reserved. 
 * Change_date         Owner         Change_content
 * 2022年7月2日        guicheng.liu       create file

*****************************************************************/

#ifndef     MSG_INTERFACE_H
#define     MSG_INTERFACE_H
#include <type_define.h>
#include "msg_transfer_layer.h"
#include "debug_addr.h"

uint32_t osp_phy_msg_send(       char* msg_ptr, 
                                uint32_t msg_len);
uint32_t osp_phy_multi_msgs_send(uint32_t queue_num, 
                                char** msg_ptr, 
                                uint32_t* msg_len,
                                uint32_t msg_num);
//uint32_t osp_phy_msg_recv(uint32_t queue_num);
uint32_t osp_phy_msg_free(uint32_t queue_num, 
                                uint32_t el_ind, 
                                char* buf);
//uint32_t osp_phy_msg_open(uint32_t num_tx_queues, queue_info_s *tx_queue_info, 
//                               uint32_t num_rx_queues, queue_info_s *rx_queue_info);

typedef enum
{
    TASK_MSG_SEND=0,
    TASK_MSG_SEND_OK,
    TASK_MSG_SEND_ERR,
    TASK_MSG_MAX //3
}task_msg_info_e;

#define TASK_MSG_RECORD(core_id, task_id, state) \
{\
    uint32_t offset = ((core_id)*PHY_TASK_MAX + (task_id)*TASK_MSG_MAX + (state))*4;\
    STORE_EX_W((char*)(DEBUG_TASK_MSG_ADDR+offset), LOAD_EX_W((char*)(DEBUG_TASK_MSG_ADDR+offset))+1);\
}

#define MSG_TRANSFER_RECORD(core_id, state) \
{\
    uint32_t offset = ((core_id)*TASK_MSG_MAX + (state))*4;\
    STORE_EX_W((char*)(DEBUG_MSG_TRAN_SEND_ADDR+offset), LOAD_EX_W((char*)(DEBUG_MSG_TRAN_SEND_ADDR+offset))+1);\
}


int32_t phy_et_msg_send(uint32_t msg_addr,
                            uint32_t msg_len,
                            uint8_t  msg_type,
                            uint8_t  src_core_id,
                            uint8_t  dst_core_id,
                            uint8_t  src_task_id,
                            uint8_t  dst_task_id);

#endif
