90 lines
2.0 KiB
C
90 lines
2.0 KiB
C
/*
|
|
* Copyright (c) 2021-2022 Amlogic, Inc. All rights reserved.
|
|
*
|
|
* SPDX-License-Identifier: MIT
|
|
*/
|
|
|
|
#ifndef __MAILBOX_COMMON_H__
|
|
#define __MAILBOX_COMMON_H__
|
|
|
|
#include "common.h"
|
|
#include "mailbox-api.h"
|
|
#include "gcc_compiler_attributes.h"
|
|
|
|
#ifndef UNUSED
|
|
#define UNUSED(x) ((void)(x))
|
|
#endif
|
|
#define aml_writel32(val, reg) (REG32(reg) = val)
|
|
#define aml_readl32(reg) (REG32(reg))
|
|
|
|
#define xMutexInit() xSemaphoreCreateMutex()
|
|
#define xMuteLock(x) xSemaphoreTake((x), portMAX_DELAY)
|
|
#define xMuteUnlock(x) xSemaphoreGive((x))
|
|
|
|
#define MBOX_CL_ID_TAB_LEN (128)
|
|
|
|
#define ACK_OK 1
|
|
#define ACK_FAIL 2
|
|
|
|
#define MAILBOX_BUFFER_SIZE MBOX_MAX_SIZE
|
|
|
|
enum sync_type {
|
|
MB_ASYNC = 1,
|
|
MB_SYNC,
|
|
};
|
|
|
|
struct MbStat {
|
|
uint32_t cmd : 16;
|
|
uint32_t size : 9;
|
|
uint32_t sync : 7;
|
|
};
|
|
|
|
union MbStat_in {
|
|
struct MbStat st;
|
|
uint32_t reg;
|
|
};
|
|
|
|
struct __packed mbHeadInfo {
|
|
uint32_t status;
|
|
uint64_t taskid;
|
|
uint64_t complete;
|
|
uint64_t ullclt;
|
|
};
|
|
|
|
struct __packed mboxData {
|
|
uint32_t status;
|
|
uint64_t taskid;
|
|
uint64_t complete;
|
|
uint64_t ullclt;
|
|
uint8_t data[MBOX_DATA_SIZE];
|
|
};
|
|
|
|
struct __packed mboxPackInfo {
|
|
struct mboxData mbdata;
|
|
uint32_t ulCmd;
|
|
uint32_t ulSize;
|
|
};
|
|
|
|
extern struct xMboxChan *pxMboxChans;
|
|
extern struct xMboxIdTab *pxMboxIdTabs;
|
|
extern void *pvClientIdTab;
|
|
extern void *g_tbl_ao;
|
|
void vEnterCritical(void);
|
|
void vExitCritical(void);
|
|
void vSetMboxStats(uint32_t reg, struct MbStat st);
|
|
void vClrMboxStats(uint32_t reg);
|
|
struct xMboxChan *xGetMboxChan(uint8_t ucClientChId);
|
|
struct xMboxChan *xGetMboxChanById(uint8_t ucMboxChId);
|
|
uint32_t ulRevAddrMbox(uint8_t ucMboxChId);
|
|
void vMboxWrite(uint32_t to, void *from, long count);
|
|
void vMboxRead(void *to, uint32_t from, long count);
|
|
void *pvMboxMemSet(void *pDst, int iVal, size_t xCnt);
|
|
void *pvMboxMemCpy(void *pDst, const void *pSrc, size_t xLen);
|
|
void xGetPayloadHead(uint32_t addr, void *head);
|
|
uint32_t ulChkHtblInit(void *pHtbl);
|
|
int iMboxClientIdTabInit(void **pTab);
|
|
void vInitMboxChLock(void);
|
|
BaseType_t xRegMboxClientChId(uint8_t ucClientChId);
|
|
BaseType_t xFreeMboxClientChId(uint8_t ucClientChId);
|
|
#endif
|