blob: 7690bf84cfcd8aa1122ed9279a658d821a22b0d3 [file] [log] [blame]
lh9ed821d2023-04-07 01:36:19 -07001/*******************************************************************************
2 * Copyright by ZTE Corporation.
3 *
4 * File Name:
5 * File Mark:
6 * Description:
7 * Others:
8 * Version: 0.1
9 * Author: zhangdongdong
10 * Date: 2015-10-21
11 * History 1:
12 * Date:
13 * Version:
14 * Author:
15 * Modification:
16 * History 2:
17 ********************************************************************************/
18
19#ifndef _DRVS_RPMSG_H
20#define _DRVS_RPMSG_H
21
22/*******************************************************************************
23* Include files *
24*******************************************************************************/
25#include "ram_config.h"
26
27/*******************************************************************************
28* Macro *
29*******************************************************************************/
30#define RPMSG_WRITE_INT (0x1)
31#define RPMSG_READ_POLL (0x1<<1)
32
33#define CHANNEL_FLAG 0x1
34
35#define M0AP_CHANNEL_MAXID 10
36/*******************************************************************************
37* Types *
38*******************************************************************************/
39
40/*-----------------------[Begin] [used by normal]-----------------------------*/
41/*channels definition*/
42#define DRIVER channel_0
43#define PSM channel_1
44#define USB_ADB channel_2
45
46
47#define WAN1 channel_3
48#define WAN2 channel_4
49#define WAN3 channel_5
50#define WAN4 channel_6
51
52#define DTMF channel_7
53#define DEV_BUFFREE channel_8
54
55#define AMT channel_9
56#define RAMDUMP channel_10
57
58#define VSIM channel_11
59#define ISMS channel_12
60
61#define IPSEC1 channel_13
62#define IPSEC2 channel_14
63#define IPSEC3 channel_15
64#define IPSEC4 channel_16
65
66
67typedef enum _T_ZDrvRpMsg_MsgActor
68{
69#ifdef _OS_TOS
70 ICP_MSG_ACTOR_A9,
71#endif
72 ICP_MSG_ACTOR_ZSP,
73 ICP_RPMSG_ACTOR_M0,
74 MAX_RPMSG_ACTOR
75} T_ZDrvRpMsg_MsgActor;
76
77typedef enum _T_ZDrvRpMsg_ChID
78{
79 CHANNEL_BASEID,
80
81 channel_0 = CHANNEL_BASEID, //driver just for AP<->PS
82 channel_1, //PSM
83 channel_2, //USB_DETCT
84 channel_3, //USB_ADB
85 channel_4, //WAN
86 channel_5, //LAN1
87 channel_6, //LAN2
88 channel_7, //DEV_BUFMALLOC
89 channel_8, //DEV_BUFFREE
90 channel_9, //AT
91 CHANNEL_PS2M0_MAXID,
92
93 channel_10 = CHANNEL_PS2M0_MAXID, //AMT
94 channel_11, //LOG
95 channel_12, //FOTA
96
97 channel_13,
98 channel_14,
99 channel_15,
100 channel_16,
101 channel_17,
102 channel_18,
103 channel_19,
104 channel_20,
105 channel_21,
106 channel_22,
107 channel_23,
108 channel_24,
109 channel_25,
110 channel_26,
111 channel_27,
112 channel_28,
113 channel_29,
114 channel_30,
115 channel_31,
116 channel_32,
117 channel_33,
118 channel_34,
119 channel_35,
120 channel_36,
121 channel_37,
122 channel_38,
123 channel_39,
124 channel_40,
125 channel_41,
126 channel_42,
127 channel_43,
128 channel_44,
129 channel_45,
130 channel_46,
131 channel_47,
132 channel_48,
133 channel_49,
134 channel_50,
135 channel_51,
136 channel_52,
137 channel_53,
138 channel_54,
139 channel_55,
140 channel_56,
141 channel_57,
142 channel_58,
143 channel_59,
144 channel_60,
145 channel_61,
146 channel_62,
147 channel_63,
148
149 PSAP_CHANNEL_MAXID
150}T_ZDrvRpMsg_ChID;
151
152typedef struct _T_ZDrvRpMsg_Msg
153{
154 T_ZDrvRpMsg_MsgActor actorID;
155 T_ZDrvRpMsg_ChID chID;
156 UINT32 flag; /*bit0:is need send icp int 1:y; 0:n*/
157 /*bit1: read mode 1:poll; 0:semaphore*/
158 VOID *buf;
159 UINT32 len;
160} T_ZDrvRpMsg_Msg;
161
162typedef enum _T_ZDrvRpMsg_ErrCode
163{
164 RPMSG_INVALID_PARAMETER = -101, //²ÎÊý²»ÕýÈ·
165 RPMSG_SPACE_NOT_ENOUGH = -102, //¿Õ¼ä²»×ã¹»
166 RPMSG_CHANNEL_ALREADY_EXIST = -103, //ͨµÀÒѾ­´æÔÚ
167 RPMSG_CHANNEL_INEXISTANCE = -104, //ͨµÀ²»´æÔÚ
168 RPMSG_CHANNEL_MSG_ERR = -105, //ͨµÀÖÐÏûÏ¢´íÎó
169 RPMSG_CHANNEL_NOMSG = -107, //ͨµÀÖÐûÓÐÏûÏ¢
170}
171T_ZDrvRpMsg_ErrCode;
172
173typedef VOID (*T_ZDrvRpMsg_CallbackFunction)(VOID *buf, UINT32 len);/*for normal*/
174
175/*******************************************************************************
176* Function Prototypes *
177*******************************************************************************/
178
179/*******************************************************************************
180* Function: zDrvRpMsg_CreateChannel
181* Description: This function is used for create channel to send message;
182* Parameters:
183* Input:
184* actorID:remote cpu
185* chID: ID of channel
186* size: size of channel
187* Output:None
188*
189* Returns:
190* DRV_SUCCESS: successfully .
191* DRV_ERROR: fail .
192*
193* Others:
194********************************************************************************/
195SINT32 zDrvRpMsg_CreateChannel (T_ZDrvRpMsg_MsgActor actorID, T_ZDrvRpMsg_ChID chID, UINT32 size);
196
197/*******************************************************************************
198* Function: zDrvRpMsg_RegCallBack
199* Description: This function is used for registing callback functions;
200* Parameters:
201* Input:
202* actor: core id.
203* chID : channel id
204* callback: callback function
205* Output:None
206*
207* Returns:
208* DRV_SUCCESS: successfully .
209* other: fail .
210*
211*
212* Others:
213********************************************************************************/
214SINT32 zDrvRpMsg_RegCallBack(T_ZDrvRpMsg_MsgActor actorID, T_ZDrvRpMsg_ChID chID, T_ZDrvRpMsg_CallbackFunction callback);
215
216/*******************************************************************************
217* Function: zDrvRpMsg_MaskInt
218* Description: This function is used for mask ICP interrupt from another core;
219* Parameters:
220* Input:
221* actor: which core.
222* bit_map: which interrupts will be masked.
223* Output:None
224*
225* Returns:
226* None
227*
228*
229* Others:
230********************************************************************************/
231SINT32 zDrvRpMsg_MaskInt(T_ZDrvRpMsg_MsgActor actorID, T_ZDrvRpMsg_ChID chID);
232
233/*******************************************************************************
234* Function: zDrvRpMsg_UnmaskInt
235* Description: This function is used for unmask ICP interrupt from another core;
236* Parameters:
237* Input:
238* actor: which core.
239* bit_map: which interrupts will be unmasked.
240* Output:None
241*
242* Returns:
243* None
244*
245*
246* Others:
247********************************************************************************/
248SINT32 zDrvRpMsg_UnmaskInt(T_ZDrvRpMsg_MsgActor actorID, T_ZDrvRpMsg_ChID chID);
249
250/*******************************************************************************
251* Function: zDrvRpMsg_Write
252* Description: This function is used for sending message to remote cpu, mutex;
253* Parameters:
254* Input:
255* pMsg: the msg which will be sent
256* Output:None
257*
258* Returns:
259* DRV_SUCCESS: successfully send msg.
260* other: fail to send msg.
261*
262*
263* Others:
264********************************************************************************/
265SINT32 zDrvRpMsg_Write(const T_ZDrvRpMsg_Msg *pMsg);
266
267/*******************************************************************************
268* Function: zDrvRpMsg_WriteWithId
269* Description: This function is used for ps&phy to send msg to remote cpu.
270* Parameters:
271* Input:
272* msgId:msg id that ps will put into the ring buffer
273* pMsg: the msg which will be sent
274* Output:None
275*
276* Returns:
277* DRV_SUCCESS: successfully send msg.
278* other: fail to send msg.
279*
280*
281* Others:
282********************************************************************************/
283SINT32 zDrvRpMsg_WriteWithId(UINT32 msgId, const T_ZDrvRpMsg_Msg *pMsg);
284
285/*******************************************************************************
286* Function: zDrvRpMsg_WriteLockIrq
287* Description: This function is used for sending message to remote cpu, no mutex;
288* Parameters:
289* Input:
290* pMsg: the msg which will be sent
291* Output:None
292*
293* Returns:
294* DRV_SUCCESS: successfully send msg.
295* other: fail to send msg.
296*
297*
298* Others:
299********************************************************************************/
300SINT32 zDrvRpMsg_WriteLockIrq(const T_ZDrvRpMsg_Msg *pMsg);
301
302/*******************************************************************************
303* Function: zDrvRpMsg_Read
304* Description: This function is used for reading message;
305* Parameters:
306* Input:
307* pMsg:message which will be read
308* Output:
309* pMsg
310*
311* Returns:
312* DRV_SUCCESS: successfully .
313* other: fail .
314*
315* Others:
316********************************************************************************/
317SINT32 zDrvRpMsg_Read(const T_ZDrvRpMsg_Msg *pMsg);
318
319/*******************************************************************************
320* Function: zDrvRpMsg_ReadWithId
321* Description: This function is used for ps&phy to read message from remote cpu;
322* Parameters:
323* Input:
324* pMsgId:msg id that ps will get from the ring buffer
325* pMsg:message which will be read
326* Output:
327* pMsg
328*
329* Returns:
330* DRV_SUCCESS: successfully .
331* other: fail .
332*
333* Others:
334********************************************************************************/
335SINT32 zDrvRpMsg_ReadWithId(UINT32 *pMsgId, const T_ZDrvRpMsg_Msg *pMsg);
336
337/*******************************************************************************
338* Function: zDrvRpMsg_ReadWithIdLockIrq
339* Description: This function is used for reading message;
340* Parameters:
341* Input:
342* pMsgId:msg id that ps will get from the ring buffer
343* pMsg:message which will be read
344* Output:
345* pMsg
346*
347* Returns:
348* DRV_SUCCESS: successfully .
349* other: fail .
350*
351* Others:
352********************************************************************************/
353SINT32 zDrvRpMsg_ReadWithIdLockIrq(UINT32 *pMsgId, const T_ZDrvRpMsg_Msg *pMsg);
354
355/*******************************************************************************
356* Function: zDrvRpMsg_ReadLockIrq
357* Description: This function is used for reading message;
358* Parameters:
359* Input:
360* pMsg:message which will be read
361* Output:
362* pMsg
363*
364* Returns:
365* DRV_SUCCESS: successfully .
366* other: fail .
367*
368* Others:
369********************************************************************************/
370SINT32 zDrvRpMsg_ReadLockIrq(const T_ZDrvRpMsg_Msg *pMsg);
371
372/*******************************************************************************
373* Function: zDrvRpMsg_ChIsEmpty
374* Description: This function is used for checking the channel used to receive message is empty or not;
375* Parameters:
376* Input:
377* actorID:remote cpu
378* chID:channel id
379* Output:None
380*
381* Returns:
382* TRUE: channel is empty .
383* FALSE: channel is not empty .
384*
385* Others:
386********************************************************************************/
387BOOL zDrvRpMsg_ChIsEmpty(T_ZDrvRpMsg_MsgActor actorID, T_ZDrvRpMsg_ChID chID);
388
389/*******************************************************************************
390* Function: zDrvRpMsg_WriteChIsEmpty
391* Description: This function is used for checking the channel used to send message is empty or not;
392* Parameters:
393* Input:
394* actorID:remote cpu
395* chID:channel id
396* Output:None
397*
398* Returns:
399* TRUE: channel is empty .
400* FALSE: channel is not empty .
401*
402* Others:
403********************************************************************************/
404BOOL zDrvRpMsg_WriteChIsEmpty(T_ZDrvRpMsg_MsgActor actorID, T_ZDrvRpMsg_ChID chID);
405
406/*******************************************************************************
407* Function: zDrvRpMsg_CreateBlock
408* Description: This function is used for create block channel to send message;
409* Parameters:
410* Input:
411* actorID:remote cpu
412* chID: ID of channel
413* blkSize: size of block, 4 bytes reserve at leaset
414* blkNums: numbers of block
415* memtype: 0:iram 1:ddr
416* Output:None
417*
418* Returns:
419* DRV_SUCCESS: successfully .
420* DRV_ERROR: fail .
421*
422* Others:
423********************************************************************************/
424SINT32 zDrvRpMsg_CreateBlock(T_ZDrvRpMsg_MsgActor actorID, T_ZDrvRpMsg_ChID chID, UINT32 blkSize, UINT32 blkNums, UINT32 memType);
425
426/*******************************************************************************
427* Function: zDrvRpMsg_GetWriteAddr
428* Description: This function is used for getting write addr;
429* Parameters:
430* Input:
431* actorID:remote processor id
432* chID:channel id
433* Output:
434* wrAddr:addr for write
435*
436* Returns:
437* positive: success
438* negative: fail .
439*
440* Others:
441********************************************************************************/
442SINT32 zDrvRpMsg_GetWriteAddr(T_ZDrvRpMsg_MsgActor actorID, T_ZDrvRpMsg_ChID chID, VOID **wrAddr);
443
444/*******************************************************************************
445* Function: zDrvRpMsg_WriteUpdate
446* Description: This function is used for reading message;
447* Parameters:
448* Input:
449* actorID:remote processor id
450* chID:channel id
451* addr:addr for update
452* len:update len
453* intFlag: 0:without icp int 1:with icp int
454* Output:
455* NULL
456*
457* Returns:
458* positive: len
459* negative: fail .
460*
461* Others:
462********************************************************************************/
463SINT32 zDrvRpMsg_WriteUpdate(T_ZDrvRpMsg_MsgActor actorID, T_ZDrvRpMsg_ChID chID, UINT32 addr, UINT32 len, BOOL intFlag);
464
465/*******************************************************************************
466* Function: zDrvRpMsg_GetReadAddr
467* Description: This function is used for getting read addr;
468* Parameters:
469* Input:
470* actorID:remote processor id
471* chID:channel id
472* Output:
473* rdAddr:addr for read
474*
475* Returns:
476* positive: len
477* negative: fail .
478*
479* Others:
480********************************************************************************/
481SINT32 zDrvRpMsg_GetReadAddr(T_ZDrvRpMsg_MsgActor actorID, T_ZDrvRpMsg_ChID chID, VOID **rdAddr);
482
483/*******************************************************************************
484* Function: zDrvRpMsg_ReadUpdate
485* Description: This function is used for reading message;
486* Parameters:
487* Input:
488* actorID:remote processor id
489* chID:channel id
490* addr:update addr
491* Output:
492* NULL
493*
494* Returns:
495* positive: len
496* negative: fail .
497*
498* Others:
499********************************************************************************/
500SINT32 zDrvRpMsg_ReadUpdate(T_ZDrvRpMsg_MsgActor actorID, T_ZDrvRpMsg_ChID chID, UINT32 addr);
501
502/*******************************************************************************
503* Function: zDrvRpMsg_Initiate
504* Description: This function is used to init rpmsg module;
505* Parameters:
506* Input:
507* null
508*
509* Output:None
510*
511* Returns:
512* DRV_SUCCESS: successfully .
513* other: fail .
514*
515*
516* Others:
517********************************************************************************/
518SINT32 zDrvRpMsg_Initiate (VOID);
519
520/*******************************************************************************
521* Function: zDrvRpMsg_ReadExit
522* Description: This function is used to exit from the block read func,for ctrm;
523* Parameters:
524* Input:
525* null
526*
527* Output:None
528*
529* Returns:
530* null .
531*
532*
533*
534* Others:
535********************************************************************************/
536VOID zDrvRpMsg_ReadExit(T_ZDrvRpMsg_MsgActor actor, T_ZDrvRpMsg_ChID chID);
537
538#endif