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

#ifndef __SPU_LOG_CLIENT_H__
#define __SPU_LOG_CLIENT_H__

#include "typedef.h"
#include "ucp_handshake.h"

#define SPU_LOG_CLIENT_BUF_BASE     (0xB2E00000)      /* 一共15MB，当前只用6+2=8MB */
#define SPU_LOG_CLIENT_BUF_SIZE     (512)             /* Log软件队列一个队列的消息长512Bytes */
#define SPU_LOG_CLIENT_BUF_DEPTH    (128)             /* Log软件队列每个APE的深度为128个消息*/

typedef struct tSpuLogClientInfo {
    uint32_t alloc;
    uint32_t bufBase;
    uint32_t bufSize;
    uint16_t ringSize;
    uint16_t ringMask;
} SpuLogClientInfo_t;

typedef struct tSpuLogCommonInfo {
    uint32_t alloc[MAX_NUM_SPU];
} SpuLogCommonInfo_t;

typedef union tSpuLogMsgInfo {
    uint32_t value;
    struct {
        uint32_t cell_id : 4;
        uint32_t core_id : 4;
        uint32_t buf_idx : 8;
        uint32_t buf_size : 16;
        //uint32_t rsv : 0;
    };
} SpuLogMsgInfo_t;

void spu_log_client_init(void);
uint8_t* spu_log_client_mem_alloc(uint16_t* idx);

#endif /* __SPU_LOG_CLIENT_H__ */

