1 /**
2 ******************************************************************************
3 * @file rtl8721d_ipc_api.c
4 * @author
5 * @version V1.0.0
6 * @date 2018-06-11
7 * @brief This file contains all the API for the IPC function
8 * library.
9 ******************************************************************************
10 * @attention
11 *
12 * This module is a confidential and proprietary property of RealTek and
13 * possession or use of this module requires written permission of RealTek.
14 *
15 * Copyright(c) 2016, Realtek Semiconductor Corporation. All rights reserved.
16 ******************************************************************************
17 */
18
19 #include "ameba_soc.h"
20
21 /**
22 * @brief init ipc channel according to ipc_init_config[].
23 * @retval None
24 */
ipc_table_init(VOID)25 void ipc_table_init(VOID)
26 {
27 u32 i;
28
29 for (i = 0;;) {
30 /* Check if search to end */
31 if (ipc_init_config[i].USER_MSG_TYPE == 0xFFFFFFFF) {
32 break;
33 }
34
35 if((ipc_init_config[i].func != NULL) || (ipc_init_config[i].IrqData != NULL)) {
36 IPC_INTUserHandler(i, (void*)ipc_init_config[i].func, ipc_init_config[i].IrqData);
37 }
38
39 i++;
40 }
41 }
42
43 /**
44 * @brief exchange messages between KM0 and KM4.
45 * @param IPC_ChNum: the IPC channel number.
46 * @param Message: pointer to the message to be exchanged,and should not stored in stack.
47 * @retval None
48 */
ipc_send_message(u8 IPC_ChNum,u32 Message)49 void ipc_send_message(u8 IPC_ChNum, u32 Message)
50 {
51 u32 CpuId = IPC_CPUID();
52 IPC_TypeDef *IPC_DEV;
53
54 if(CpuId == 1)
55 IPC_DEV = IPCM4_DEV;
56 else if(CpuId == 0)
57 IPC_DEV = IPCM0_DEV;
58
59 if(IPC_USER_POINT == ipc_init_config[IPC_ChNum].USER_MSG_TYPE) {
60 /*message is shared between two cpu ,so it can't store in stack
61 * assume stack down growth, and 0x100 is an estimated value
62 */
63 //alios todo
64 //assert_param((Message > (u32)(vTaskStackAddr() + vTaskStackSize()*4)) || (Message < (u32)vTaskStackAddr()));
65 }
66
67 IPC_DEV->IPCx_USR[IPC_ChNum] = (u32)Message;
68 IPC_INTRequest(IPC_DEV, IPC_ChNum);
69 }
70
71 /**
72 * @brief get ipc message.
73 * @param IPC_ChNum: the IPC channel number.
74 * @retval : pointer to the message to be exchanged.
75 * @note for data massage, corresponding data cache should be invalidate before access.
76 */
ipc_get_message(u8 IPC_ChNum)77 u32 ipc_get_message(u8 IPC_ChNum)
78 {
79 u32 CpuId = IPC_CPUID();
80 IPC_TypeDef *IPC_DEV;
81
82 /*KM4 read mesaage for km0*/
83 if(CpuId == 1)
84 IPC_DEV = IPCM0_DEV;
85 else if(CpuId == 0)
86 IPC_DEV = IPCM4_DEV;
87
88 return IPC_DEV->IPCx_USR[IPC_ChNum];
89 }
90 /******************* (C) COPYRIGHT 2016 Realtek Semiconductor *****END OF FILE****/
91