// +FHDR------------------------------------------------------------
//                 Copyright (c) 2022 SmartLogic.
//                       ALL RIGHTS RESERVED
// -----------------------------------------------------------------
// Filename      : log_server.h
// Author        : xianfeng.du
// Created On    : 2023-02-06
// Last Modified :
// -----------------------------------------------------------------
// Description:
//
//
// -FHDR------------------------------------------------------------

#ifndef __SPU_LOG_SERVER_H__
#define __SPU_LOG_SERVER_H__

#include "typedef.h"
#include "log_client.h"
#include "msg_transfer_layer.h"

#define SPU_LOG_SERVER_RING_SIZE    (2)               /* ping pong buffer */
#define SPU_LOG_SERVER_BUF_DEPTH    (2048)            /* ping pong buffer深度为2048个消息*/
#define SPU_LOG_SERVER_BUF_SIZE     (SPU_LOG_CLIENT_BUF_SIZE)
#define SPU_LOG_SERVER_BUF_BASE     (SPU_LOG_CLIENT_BUF_BASE+SPU_LOG_CLIENT_BUF_SIZE*SPU_LOG_CLIENT_BUF_DEPTH*MAX_NUM_SPU) /* 一共15MB，当前只用6+2=8MB */

#define MSG_TRANSFER_LOG_MSG_TYPE    0x124

typedef struct tSpuLogServerInfo {
	uint16_t isrFlag;
	uint16_t pingpong;
	uint16_t idx[MAX_INSTANCE_NUM][SPU_LOG_SERVER_RING_SIZE];
	uint32_t serverBufBase[MAX_INSTANCE_NUM][SPU_LOG_SERVER_RING_SIZE];
	uint32_t serverBufSize;
	uint32_t clientBufSize;
	uint32_t clientBufBase[MAX_NUM_SPU];
} SpuLogServerInfo_t;

typedef struct tMsgTransferHeader {
	uint8_t numMsg;
	uint8_t cellIndex;
	uint16_t rsv;
	uint32_t msgType;
	uint32_t msgLen;
	//uint16_t log_size;
	//uint16_t rsv;
	uint32_t log_size;
	uint32_t log_data[0];
} MsgTransferHeader_t;

void spu_log_server_init(void);
void spu_log_server_proc(void);
void spu_log_server_isr(void);

#endif /* __SPU_LOG_SERVER_H__ */

