[Feature]Upload Modem source code
Change-Id: Id4294f30faced84d3e6fd6d5e61e1111bf287a37
diff --git a/mcu/interface/protocol/l5/mipc/common/custom_l5_mipc_cmd.def b/mcu/interface/protocol/l5/mipc/common/custom_l5_mipc_cmd.def
new file mode 100644
index 0000000..72f8644
--- /dev/null
+++ b/mcu/interface/protocol/l5/mipc/common/custom_l5_mipc_cmd.def
@@ -0,0 +1,3 @@
+
+MIPC_CMD(RELAY)
+MIPC_CMD(AAA)
diff --git a/mcu/interface/protocol/l5/mipc/common/custom_l5_mipc_cmd.h b/mcu/interface/protocol/l5/mipc/common/custom_l5_mipc_cmd.h
new file mode 100644
index 0000000..17caf6f
--- /dev/null
+++ b/mcu/interface/protocol/l5/mipc/common/custom_l5_mipc_cmd.h
@@ -0,0 +1,11 @@
+#ifndef _CUSTOM_L5_MIPC_CMD_H_
+#define _CUSTOM_L5_MIPC_CMD_H_
+
+#undef MIPC_CMD
+#define MIPC_CMD(msg) MIPC_VENDOR_##msg##_CMD, MIPC_VENDOR_##msg##_RSP,
+enum {
+ MIPC_VENDOR_CMD_START = MIPC_CMD_BEGIN + 0xF00,
+#include "custom_l5_mipc_cmd.def"
+};
+
+#endif
diff --git a/mcu/interface/protocol/l5/mipc/common/custom_l5_mipc_ntf.def b/mcu/interface/protocol/l5/mipc/common/custom_l5_mipc_ntf.def
new file mode 100644
index 0000000..dc33b8a
--- /dev/null
+++ b/mcu/interface/protocol/l5/mipc/common/custom_l5_mipc_ntf.def
@@ -0,0 +1,2 @@
+
+MIPC_NTF(AT, custom_mipc_at_ntf)
diff --git a/mcu/interface/protocol/l5/mipc/common/custom_l5_mipc_ntf.h b/mcu/interface/protocol/l5/mipc/common/custom_l5_mipc_ntf.h
new file mode 100644
index 0000000..6018faf
--- /dev/null
+++ b/mcu/interface/protocol/l5/mipc/common/custom_l5_mipc_ntf.h
@@ -0,0 +1,11 @@
+#ifndef _CUSTOM_L5_MIPC_NTF_H_
+#define _CUSTOM_L5_MIPC_NTF_H_
+
+#undef MIPC_NTF
+#define MIPC_NTF(msg, handler) MIPC_VENDOR_##msg##_NTF,
+enum {
+ MIPC_VENDOR_NTF_START = MIPC_NTF_BEGIN + 0xF00,
+#include "custom_l5_mipc_ntf.def"
+};
+
+#endif
diff --git a/mcu/interface/protocol/l5/mipc/common/custom_l5_mipc_req.def b/mcu/interface/protocol/l5/mipc/common/custom_l5_mipc_req.def
new file mode 100644
index 0000000..ae2174a
--- /dev/null
+++ b/mcu/interface/protocol/l5/mipc/common/custom_l5_mipc_req.def
@@ -0,0 +1,4 @@
+
+MIPC_REQ(RELAY, custom_mipc_relay_req)
+MIPC_REQ(XXX, custom_mipc_xxx_req)
+MIPC_REQ(AT, custom_mipc_at_req)
diff --git a/mcu/interface/protocol/l5/mipc/common/custom_l5_mipc_req.h b/mcu/interface/protocol/l5/mipc/common/custom_l5_mipc_req.h
new file mode 100644
index 0000000..bc4047e
--- /dev/null
+++ b/mcu/interface/protocol/l5/mipc/common/custom_l5_mipc_req.h
@@ -0,0 +1,11 @@
+#ifndef _CUSTOM_L5_MIPC_REQ_H_
+#define _CUSTOM_L5_MIPC_REQ_H_
+
+#undef MIPC_REQ
+#define MIPC_REQ(msg, handler) MIPC_VENDOR_##msg##_REQ, MIPC_VENDOR_##msg##_CNF,
+enum {
+ MIPC_VENDOR_REQ_START = MIPC_REQ_BEGIN + 0xF00,
+#include "custom_l5_mipc_req.def"
+};
+
+#endif
diff --git a/mcu/interface/protocol/l5/mipc/common/mipc.h b/mcu/interface/protocol/l5/mipc/common/mipc.h
new file mode 100644
index 0000000..2f6b26c
--- /dev/null
+++ b/mcu/interface/protocol/l5/mipc/common/mipc.h
@@ -0,0 +1,57 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* Copyright (c) [2020], MediaTek Inc. All rights reserved.
+* This software/firmware and related documentation ("MediaTek Software") are
+* protected under relevant copyright laws.
+*
+* The information contained herein is confidential and proprietary to
+* MediaTek Inc. and/or its licensors. Except as otherwise provided in the
+* applicable licensing terms with MediaTek Inc. and/or its licensors, any
+* reproduction, modification, use or disclosure of MediaTek Software, and
+* information contained herein, in whole or in part, shall be strictly
+* prohibited.
+*****************************************************************************/
+
+#ifndef _MIPC_H_
+#define _MIPC_H_
+
+/*!
+ \defgroup COMMON
+ @{
+*/
+
+#include "platform.h"
+#include "mipc_msg_tlv_const.h"
+
+typedef enum MIPC_MSG_enum mipc_msg_id_enum;
+typedef enum mipc_result_const_enum mipc_result_enum;
+
+#define MIPC_VERSION (0x00000002)
+
+#define MIPC_SIM0 (1 << 0)
+#define MIPC_SIM1 (1 << 1)
+#define MIPC_SIM2 (1 << 2)
+#define MIPC_SIM3 (1 << 3)
+#define MIPC_PS_START (4)
+#define MIPC_PS0 (1 << 4)
+#define MIPC_PS1 (1 << 5)
+#define MIPC_PS2 (1 << 6)
+#define MIPC_PS3 (1 << 7)
+#define MIPC_ALL (0xff)
+
+//#define MIPC_T_LOCAL_START (0x100)
+
+#define MIPC_MSG_TYPE_MASK (0xC000)
+#define MIPC_MSG_TYPE_REQ_CNF (0x0000)
+#define MIPC_MSG_TYPE_IND (0x4000)
+#define MIPC_MSG_TYPE_CMD_RSP (0x8000)
+#define MIPC_MSG_TYPE_NTF (0xC000)
+//
+
+
+/*!
+ @}
+*/
+
+#endif
diff --git a/mcu/interface/protocol/l5/mipc/common/mipc_internal.h b/mcu/interface/protocol/l5/mipc/common/mipc_internal.h
new file mode 100644
index 0000000..103aa43
--- /dev/null
+++ b/mcu/interface/protocol/l5/mipc/common/mipc_internal.h
@@ -0,0 +1,169 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* Copyright (c) [2020], MediaTek Inc. All rights reserved.
+* This software/firmware and related documentation ("MediaTek Software") are
+* protected under relevant copyright laws.
+*
+* The information contained herein is confidential and proprietary to
+* MediaTek Inc. and/or its licensors. Except as otherwise provided in the
+* applicable licensing terms with MediaTek Inc. and/or its licensors, any
+* reproduction, modification, use or disclosure of MediaTek Software, and
+* information contained herein, in whole or in part, shall be strictly
+* prohibited.
+*****************************************************************************/
+
+#ifndef _MIPC_INTERNAL_H_
+#define _MIPC_INTERNAL_H_
+
+/*!
+ \defgroup INTERNAL
+ @{
+*/
+
+#include "platform.h"
+#include "mipc_msg_tlv_const.h"
+
+/** Filter rule */
+#define IPC_FILTER_BY_PROTOCOL (0x0001 << 0)
+#define IPC_FILTER_BY_SRC_PORT (0x0001 << 1)
+#define IPC_FILTER_BY_DST_PORT (0x0001 << 2)
+#define IPC_FILTER_BY_SRC_IPV4 (0x0001 << 3)
+#define IPC_FILTER_BY_DST_IPV4 (0x0001 << 4)
+#define IPC_FILTER_BY_SRC_IPV6 (0x0001 << 5)
+#define IPC_FILTER_BY_DST_IPV6 (0x0001 << 6)
+#define IPC_FILTER_BY_ICMPV4_TYPE (0x0001 << 7)
+#define IPC_FILTER_BY_ICMPV6_TYPE (0x0001 << 8)
+#define IPC_FILTER_BY_EBI (0x0001 << 9)
+#define IPC_FILTER_BY_PDN_ID (0x0001 << 10)
+#define IPC_FILTER_BY_NETIF_ID (0x0001 << 11)
+#define IPC_FILTER_BY_TCP_FLAGS (0x0001 << 12)
+#define IPC_FILTER_BY_SPI (0x0001 << 13)
+
+#define IPC_IP_TYPE_IPV4 1
+#define IPC_IP_TYPE_IPV6 2
+
+/*
+ * IANA IP Protocol Numbers.
+ * Ref: http://www.iana.org/assignments/protocol-numbers/protocol-numbers.xml
+ */
+#define IPC_HDR_PROT_IPV6_HOP 0 /* IPv6 Hop-by-Hop Option */
+#define IPC_HDR_PROT_ICMP 1 /* Internet Control Message */
+#define IPC_HDR_PROT_IPV4_ENC 4 /* IPv4 encapsulation */
+#define IPC_HDR_PROT_TCP 6 /* Transmission Control */
+#define IPC_HDR_PROT_UDP 17 /* User Datagram */
+#define IPC_HDR_PROT_IPV6_ENC 41 /* IPv6 encapsulation */
+#define IPC_HDR_PROT_IPV6_ROUTE 43 /* Routing Header for IPv6 */
+#define IPC_HDR_PROT_IPV6_FRAG 44 /* Fragment Header for IPv6 */
+#define IPC_HDR_PROT_ESP 50 /* Encap Security Payload */
+#define IPC_HDR_PROT_AH 51 /* Authentication Header */
+#define IPC_HDR_PROT_ICMPV6 58 /* ICMP for IPv6 */
+#define IPC_HDR_PROT_IPV6_NONEXT 59 /* No Next Header for IPv6 */
+#define IPC_HDR_PROT_IPV6_DEST 60 /* Destination Options for IPv6 */
+
+/*
+ * TCP_FLAG.
+ */
+#define IPC_HDR_TCP_FLAG_FIN 0x01
+#define IPC_HDR_TCP_FLAG_SYN 0x02
+#define IPC_HDR_TCP_FLAG_RST 0x04 // Reset
+#define IPC_HDR_TCP_FLAG_PUSH 0x08
+#define IPC_HDR_TCP_FLAG_ACK 0x10
+#define IPC_HDR_TCP_FLAG_URG 0x20 // Urgent
+#define IPC_HDR_TCP_FLAG_ECE 0x40 // ECN Echo
+#define IPC_HDR_TCP_FLAG_CWR 0x80 // Congestion Window Reduced
+#define IPC_HDR_TCP_FLAG_NS 0x100 // ECN-nonce concealment protection (added to header by RFC 3540)
+
+typedef enum {
+ NCCMNI_NET_IF_0 = 0,
+ NCCMNI_NET_IF_1,
+ NCCMNI_NET_IF_2,
+ NCCMNI_NET_IF_3,
+ NCCMNI_NET_IF_4,
+ NCCMNI_NET_IF_5,
+ NCCMNI_NET_IF_6,
+ NCCMNI_NET_IF_7,
+ NCCMNI_NET_IF_8,
+ NCCMNI_NET_IF_9,
+ NCCMNI_NET_IF_10,
+ NCCMNI_NET_IF_11,
+ NCCMNI_NET_IF_12,
+ NCCMNI_NET_IF_13,
+ NCCMNI_NET_IF_14,
+ NCCMNI_NET_IF_15,
+ NCCMNI_NET_IF_16,
+ NCCMNI_NET_IF_17,
+ NCCMNI_NET_IF_18,
+ NCCMNI_NET_IF_19,
+ NCCMNI_NET_IF_20,
+ NCCMNI_NET_IF_21,
+ NCCMNI_NET_IF_22,
+ NCCMNI_NET_IF_23,
+ NCCMNI_NET_IF_24,
+ NCCMNI_NET_IF_25,
+ NCCMNI_NET_IF_26,
+ NCCMNI_NET_IF_27,
+ NCCMNI_NET_IF_28,
+ NCCMNI_NET_IF_29,
+ NCCMNI_NET_IF_30,
+ NCCMNI_NET_IF_31,
+ NCCMNI_NET_IF_MAX = 0xFF,
+} NCCMNI_NET_IF_T;
+
+#pragma pack (push)
+#pragma pack (1)
+/*the largest fields is 4 bytes*/
+
+/** @set filter req struct */
+typedef struct {
+ uint8_t nccmni_net_if;
+ uint8_t reserve1;
+ uint16_t nccmni_seq;
+ uint32_t valid_field; //mandatory, a bitmap, refer to IPC_FILTER_BY_XXX
+ uint8_t ip_type; //IPC_IP_TYPE_IPV4 or IPC_IP_TYPE_IPV6
+ uint8_t ctrl_protocol; //IPC_HDR_PROT_XXX
+ uint16_t src_port;
+ uint16_t dst_port;
+ uint16_t tcp_flags; //IPC_HDR_TCP_FLAG_XXX
+ uint32_t spi; //
+ uint8_t src_v4_addr[4]; //Source IPv4 address to filter.
+ uint8_t dst_v4_addr[4]; //Destination IPv4 address to filter.
+ uint8_t src_v6_addr[16]; //Source IPv6 address to filter.
+ uint8_t dst_v6_addr[16]; //Destination IPv6 address to filter.
+ uint8_t icmpv4_type; // Type field of ICMPv4 header to filter.
+ uint8_t icmpv6_type; // Type field of ICMPv6 header to filter.
+ uint16_t reserve;
+ uint32_t features;
+} mipc_internal_set_filter_req_t_struct4;
+
+typedef struct {
+ uint8_t nccmni_net_if;
+ uint8_t reserve1;
+ uint16_t nccmni_seq;
+ int32_t filter_id; //>=0: filter id, <0: set failed
+} mipc_internal_set_filter_cnf_t_struct4;
+
+typedef struct {
+ uint8_t nccmni_net_if;
+ uint8_t reserve1;
+ uint16_t nccmni_seq;
+ int32_t is_deregister_all_filter; //0: deregister the filter id only, 1: deregister all filter
+ int32_t filter_id; //filter id to deregister
+} mipc_internal_reset_filter_req_t_struct4;
+
+typedef struct {
+ uint8_t nccmni_net_if;
+ uint8_t reserve1;
+ uint16_t nccmni_seq;
+ int32_t is_success; //1: success
+} mipc_internal_reset_filter_cnf_t_struct4;
+
+/*the largest fields is 8 bytes*/
+#pragma pack (pop)
+
+/*!
+ @}
+*/
+
+#endif
+
diff --git a/mcu/interface/protocol/l5/mipc/common/platform.h b/mcu/interface/protocol/l5/mipc/common/platform.h
new file mode 100644
index 0000000..1be8c61
--- /dev/null
+++ b/mcu/interface/protocol/l5/mipc/common/platform.h
@@ -0,0 +1,52 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* Copyright (c) [2020], MediaTek Inc. All rights reserved.
+* This software/firmware and related documentation ("MediaTek Software") are
+* protected under relevant copyright laws.
+*
+* The information contained herein is confidential and proprietary to
+* MediaTek Inc. and/or its licensors. Except as otherwise provided in the
+* applicable licensing terms with MediaTek Inc. and/or its licensors, any
+* reproduction, modification, use or disclosure of MediaTek Software, and
+* information contained herein, in whole or in part, shall be strictly
+* prohibited.
+*****************************************************************************/
+
+#ifndef _PLATFORM_H_
+#define _PLATFORM_H_
+
+#include <stdint.h>
+#include <limits.h>
+
+#if (__WORDSIZE == 64)
+#define BUILD_64 (1)
+#endif
+
+//we don't use long double, so the largest base data type size will be 8 bytes
+//aligned to 2^3 = 8
+#define ALIGN_BITS (3)
+#define ALIGN_SIZE (1 << ALIGN_BITS)
+#define ALIGN(x) ((((x) + (ALIGN_SIZE - 1)) >> ALIGN_BITS) << ALIGN_BITS)
+
+#if (BUILD_64 == 1)
+#define POINTER_TO_UINT(x) ((unsigned long long)(x))
+#else
+#define POINTER_TO_UINT(x) ((unsigned long)(x))
+#endif
+
+#if defined(_MSC_VER) && !defined(KAL_ON_OSCAR)
+#include "platform_windows.h"
+#elif defined (_LINUX)
+#ifndef offsetof
+#define offsetof(t, m) ((size_t)&((t *)0)->m)
+#endif
+#include "platform_linux.h"
+#else
+#ifndef offsetof
+#define offsetof(t, m) ((size_t)&((t *)0)->m)
+#endif
+#include "platform_mtk.h"
+#endif
+
+#endif
diff --git a/mcu/interface/protocol/l5/mipc/common/platform_linux.h b/mcu/interface/protocol/l5/mipc/common/platform_linux.h
new file mode 100644
index 0000000..8d91084
--- /dev/null
+++ b/mcu/interface/protocol/l5/mipc/common/platform_linux.h
@@ -0,0 +1,126 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* Copyright (c) [2020], MediaTek Inc. All rights reserved.
+* This software/firmware and related documentation ("MediaTek Software") are
+* protected under relevant copyright laws.
+*
+* The information contained herein is confidential and proprietary to
+* MediaTek Inc. and/or its licensors. Except as otherwise provided in the
+* applicable licensing terms with MediaTek Inc. and/or its licensors, any
+* reproduction, modification, use or disclosure of MediaTek Software, and
+* information contained herein, in whole or in part, shall be strictly
+* prohibited.
+*****************************************************************************/
+
+#ifndef _PLATFORM_LINUX_H_
+#define _PLATFORM_LINUX_H_
+
+#include "pthread.h"
+#include "unistd.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdint.h>
+#include <sys/types.h>
+#include <sys/time.h>
+
+#define DLL_EXPORT
+
+#define HTOML(x) (x)
+#define HTOMS(x) (x)
+#define MTOHL(x) (x)
+#define MTOHS(x) (x)
+#define ALLOC malloc
+#define FREE free
+#define SLEEP(x) sleep(x)
+#define MEMCPY memcpy
+#define MEMCMP memcmp
+#define MEMSET memset
+
+typedef uint32_t (*THREAD_FUNC)(void *priv_ptr);
+typedef void (*CALLBACK) (void *cb_priv_ptr);
+
+typedef struct {
+ pthread_t tid;
+ THREAD_FUNC func;
+ void *func_priv_ptr;
+} THREAD;
+
+typedef struct {
+ pthread_cond_t cond;
+ pthread_mutex_t lock;
+ int32_t ready;
+ void *result_ptr;
+ uint32_t timeout_ms;
+} EVENT;
+
+typedef struct {
+ pthread_mutex_t hMutex;
+} MUTEX;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+THREAD *CREATE_THREAD(THREAD_FUNC func, void *func_priv_ptr);
+void DELETE_THREAD(THREAD *thread_ptr);
+
+//
+MUTEX *CREATE_MUTEX();
+void DELETE_MUTEX(MUTEX *mutex_ptr);
+void LOCK_MUTEX(MUTEX *mutex_ptr);
+void UNLOCK_MUTEX(MUTEX *mutex_ptr);
+//
+#ifdef ENABLE_MIPC_SUPPORT_CHECKER
+int32_t CHECK_MIPC_SUPPORT();
+#endif
+//
+void INIT();
+//
+void SETCOM(const char *port_name_ptr);
+int32_t GETCOM();
+const char *FINDCOM(const char *process_name_ptr);
+int32_t OPENCOM(const char *port_name_ptr);
+void CLOSECOM();
+int32_t WRITECOM(uint8_t *buf_ptr, const uint32_t buf_len);
+int32_t READCOM(uint8_t *buf_ptr, const uint32_t buf_len);
+
+uint64_t GETTID();
+
+#ifdef __cplusplus
+}
+#endif
+
+
+void OPENCAP(const char *process_name_ptr);
+void WRITECAP(uint32_t write_len, uint8_t *data, uint32_t msg_direction);
+void WRITEERROR(char *error_msg);
+void WRITEDEBUG(char *debug_msg);
+
+#define ErrMsg(format, ...) while(1){char error_msg[256]={0}; snprintf(error_msg,sizeof(error_msg)-1,format,##__VA_ARGS__);WRITEERROR(error_msg);break;}
+#define DbgMsg(format, ...) while(1){char debug_msg[256]={0}; snprintf(debug_msg,sizeof(debug_msg)-1,format,##__VA_ARGS__);WRITEDEBUG(debug_msg);break;}
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+//
+DLL_EXPORT void UNIT_TEST_READ_BUF_ADD(uint8_t *ptr, uint32_t ptr_len);
+DLL_EXPORT uint8_t *UNIT_TEST_WRITE_BUF_GET(uint32_t *len_ptr);
+
+//
+DLL_EXPORT EVENT *CREATE_EVENT(uint32_t timeout_ms);
+DLL_EXPORT void DELETE_EVENT(EVENT *event_ptr);
+DLL_EXPORT int32_t WAIT_EVENT(EVENT *event_ptr);
+DLL_EXPORT void WAKE_EVENT(EVENT *event_ptr, void *result_ptr);
+//
+DLL_EXPORT void UNIT_TEST_RESET();
+//
+DLL_EXPORT void WAIT_MD_READY_API(CALLBACK cb, void* cb_priv);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/mcu/interface/protocol/l5/mipc/common/platform_mtk.h b/mcu/interface/protocol/l5/mipc/common/platform_mtk.h
new file mode 100644
index 0000000..417a5d7
--- /dev/null
+++ b/mcu/interface/protocol/l5/mipc/common/platform_mtk.h
@@ -0,0 +1,41 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* Copyright (c) [2020], MediaTek Inc. All rights reserved.
+* This software/firmware and related documentation ("MediaTek Software") are
+* protected under relevant copyright laws.
+*
+* The information contained herein is confidential and proprietary to
+* MediaTek Inc. and/or its licensors. Except as otherwise provided in the
+* applicable licensing terms with MediaTek Inc. and/or its licensors, any
+* reproduction, modification, use or disclosure of MediaTek Software, and
+* information contained herein, in whole or in part, shall be strictly
+* prohibited.
+*****************************************************************************/
+
+#ifndef _PLATFORM_MTK_H_
+#define _PLATFORM_MTK_H_
+
+#include "kal_public_defs.h"
+#include "kal_public_api.h"
+
+#define DLL_EXPORT
+
+#define HTOML(x) (x)
+#define HTOMS(x) (x)
+#define MTOHL(x) (x)
+#define MTOHS(x) (x)
+#define ALLOC get_ctrl_buffer
+#define FREE free_ctrl_buffer
+#define SLEEP(x) kal_sleep_task(x)
+#define MEMCPY memcpy
+#define MEMCMP memcmp
+#define MEMSET memset
+
+#define SRC_FILE_OFFSET (0)
+#define ErrMsg(format, ...)
+#define DbgMsg(format, ...)
+#define InfoMsg(format, ...)
+#define Info2Msg(format, ...)
+
+#endif
diff --git a/mcu/interface/protocol/l5/mipc/common/platform_windows.h b/mcu/interface/protocol/l5/mipc/common/platform_windows.h
new file mode 100644
index 0000000..3dd63e3
--- /dev/null
+++ b/mcu/interface/protocol/l5/mipc/common/platform_windows.h
@@ -0,0 +1,111 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* Copyright (c) [2020], MediaTek Inc. All rights reserved.
+* This software/firmware and related documentation ("MediaTek Software") are
+* protected under relevant copyright laws.
+*
+* The information contained herein is confidential and proprietary to
+* MediaTek Inc. and/or its licensors. Except as otherwise provided in the
+* applicable licensing terms with MediaTek Inc. and/or its licensors, any
+* reproduction, modification, use or disclosure of MediaTek Software, and
+* information contained herein, in whole or in part, shall be strictly
+* prohibited.
+*****************************************************************************/
+
+#ifndef _PLATFORM_WINDOWS_H_
+#define _PLATFORM_WINDOWS_H_
+
+#include "windows.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+#include <io.h>
+#include <fcntl.h>
+#include <sys/stat.h>
+
+#ifdef NO_EXPORT
+#define DLL_EXPORT
+#else
+#define DLL_EXPORT __declspec(dllexport)
+#endif
+
+#define HTOML(x) (x)
+#define HTOMS(x) (x)
+#define MTOHL(x) (x)
+#define MTOHS(x) (x)
+#define ALLOC malloc
+#define FREE free
+#define SLEEP(x) Sleep((x)*1000)
+#define MEMCPY memcpy
+#define MEMCMP memcmp
+#define MEMSET memset
+
+typedef uint32_t (*THREAD_FUNC)(void *priv_ptr);
+typedef void (*MIPC_CALLBACK) (void *cb_priv_ptr);
+
+typedef struct {
+ HANDLE tid;
+ THREAD_FUNC func;
+ void *func_priv_ptr;
+} THREAD;
+
+typedef struct {
+ HANDLE hEvent;
+ void *result_ptr;
+ uint32_t timeout_ms;
+} EVENT;
+
+typedef struct {
+ HANDLE hMutex;
+} MUTEX;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+THREAD *CREATE_THREAD(THREAD_FUNC func, void *func_priv_ptr);
+void DELETE_THREAD(THREAD *thread_ptr);
+
+//
+EVENT *CREATE_EVENT();
+void DELETE_EVENT(EVENT *event_ptr);
+int32_t WAIT_EVENT(EVENT *event_ptr);
+void WAKE_EVENT(EVENT *event_ptr, void *result_ptr);
+//
+MUTEX *CREATE_MUTEX();
+void DELETE_MUTEX(MUTEX *mutex_ptr);
+void LOCK_MUTEX(MUTEX *mutex_ptr);
+void UNLOCK_MUTEX(MUTEX *mutex_ptr);
+//
+int32_t CHECK_MIPC_SUPPORT();
+//
+void INIT();
+//
+DLL_EXPORT void SETCOM(const char *port_name_ptr);
+int32_t GETCOM();
+const char *FINDCOM(const char *process_name_ptr);
+int32_t OPENCOM(const char *port_name_ptr);
+void CLOSECOM();
+int32_t WRITECOM(uint8_t *buf_ptr, const uint32_t buf_len);
+int32_t READCOM(uint8_t *buf_ptr, const uint32_t buf_len);
+
+uint64_t GETTID();
+
+#ifdef __cplusplus
+}
+#endif
+
+
+void OPENCAP(const char *process_name_ptr);
+void WRITECAP(uint32_t write_len, uint8_t *data, uint32_t msg_direction);
+void WRITEERROR(char *error_msg);
+void WRITEDEBUG(char *debug_msg);
+
+#define ErrMsg(format, ...) while(1){char error_msg[256]={0}; snprintf(error_msg,sizeof(error_msg)-1,format,##__VA_ARGS__);WRITEERROR(error_msg);break;}
+#define DbgMsg(format, ...) while(1){char debug_msg[256]={0}; snprintf(debug_msg,sizeof(debug_msg)-1,format,##__VA_ARGS__);WRITEDEBUG(debug_msg);break;}
+
+DLL_EXPORT void WAIT_MD_READY_API(MIPC_CALLBACK cb, void* cb_priv);
+
+#endif
diff --git a/mcu/interface/protocol/l5/mipc/msg/mipc_hashmap.h b/mcu/interface/protocol/l5/mipc/msg/mipc_hashmap.h
new file mode 100644
index 0000000..26c7951
--- /dev/null
+++ b/mcu/interface/protocol/l5/mipc/msg/mipc_hashmap.h
@@ -0,0 +1,71 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* Copyright (c) [2020], MediaTek Inc. All rights reserved.
+* This software/firmware and related documentation ("MediaTek Software") are
+* protected under relevant copyright laws.
+*
+* The information contained herein is confidential and proprietary to
+* MediaTek Inc. and/or its licensors. Except as otherwise provided in the
+* applicable licensing terms with MediaTek Inc. and/or its licensors, any
+* reproduction, modification, use or disclosure of MediaTek Software, and
+* information contained herein, in whole or in part, shall be strictly
+* prohibited.
+*****************************************************************************/
+
+#ifndef _MIPC_HASHMAP_H_
+#define _MIPC_HASHMAP_H_
+
+#include <platform.h>
+#include <mipc_list.h>
+
+#define MAX_MIPC_HASHMAP_SIZE (32)
+
+typedef uint8_t (*mipc_hashmap_hash_func)(const void *key_ptr, const uint16_t key_len);
+
+typedef struct {
+ uint8_t size;
+ uint16_t count;
+ mipc_hashmap_hash_func hash_func;
+} mipc_hashmap_t;
+#define MIPC_HASHMAP_T_SIZE (ALIGN(sizeof(mipc_hashmap_t)))
+
+typedef struct {
+ mipc_list_t list;
+ mipc_hashmap_t *hashmap_ptr;
+ uint8_t *key_ptr;
+ uint8_t *val_ptr;
+ uint16_t key_len;
+ uint16_t val_len;
+} mipc_hashmap_element_t;
+#define MIPC_HASHMAP_ELEMENT_T_SIZE (ALIGN(sizeof(mipc_hashmap_element_t)))
+
+typedef void (*MIPC_HASHMAP_ITERATE_CB)(mipc_hashmap_element_t *hashmap_element_ptr, void *cb_priv_ptr);
+
+//create a new hashmap
+mipc_hashmap_t *mipc_hashmap_init(uint8_t size, mipc_hashmap_hash_func hash_func);
+
+//clean the hashmap
+void mipc_hashmap_clean(mipc_hashmap_t *hashmap_ptr);
+
+//release the hashmap
+void mipc_hashmap_deinit(mipc_hashmap_t *hashmap_ptr);
+
+void mipc_hashmap_iterate(mipc_hashmap_t *hashmap_ptr, MIPC_HASHMAP_ITERATE_CB cb, void *cb_priv_ptr);
+
+//add a key and value pair into the hashmap
+mipc_hashmap_element_t *mipc_hashmap_add(mipc_hashmap_t *hashmap_ptr, const void *key_ptr, const uint16_t key_len, const void *val_ptr, const uint16_t val_len);
+mipc_hashmap_element_t *mipc_hashmap_add2(mipc_hashmap_t *hashmap_ptr, const void *key_ptr, const uint16_t key_len, const void *t_val_ptr, const uint16_t t_val_len, const void *b_val_ptr, const uint16_t b_val_len);
+
+//delete hashmap_element
+int32_t mipc_hashmap_del(mipc_hashmap_element_t *hashmap_element_ptr);
+
+//get the value by a key from the hashmap
+mipc_hashmap_element_t *mipc_hashmap_get(mipc_hashmap_t *hashmap_ptr, const void *key_ptr, const uint16_t key_len);
+
+#define MIPC_HASHMAP_GET_KEY_LEN(e) ((e) ? (e)->key_len : 0)
+#define MIPC_HASHMAP_GET_KEY_PTR(e) ((e) ? (e)->key_ptr : NULL)
+#define MIPC_HASHMAP_GET_VAL_LEN(e) ((e) ? (e)->val_len : 0)
+#define MIPC_HASHMAP_GET_VAL_PTR(e) ((e) ? (e)->val_ptr : NULL)
+
+#endif
diff --git a/mcu/interface/protocol/l5/mipc/msg/mipc_list.h b/mcu/interface/protocol/l5/mipc/msg/mipc_list.h
new file mode 100644
index 0000000..30377b9
--- /dev/null
+++ b/mcu/interface/protocol/l5/mipc/msg/mipc_list.h
@@ -0,0 +1,36 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* Copyright (c) [2020], MediaTek Inc. All rights reserved.
+* This software/firmware and related documentation ("MediaTek Software") are
+* protected under relevant copyright laws.
+*
+* The information contained herein is confidential and proprietary to
+* MediaTek Inc. and/or its licensors. Except as otherwise provided in the
+* applicable licensing terms with MediaTek Inc. and/or its licensors, any
+* reproduction, modification, use or disclosure of MediaTek Software, and
+* information contained herein, in whole or in part, shall be strictly
+* prohibited.
+*****************************************************************************/
+
+#ifndef _MIPC_LIST_H_
+#define _MIPC_LIST_H_
+
+#include <platform.h>
+
+typedef struct mipc_list {
+ struct mipc_list *next_ptr;
+ struct mipc_list *prev_ptr;
+} mipc_list_t;
+
+#define MIPC_LIST_INIT(name) {&(name), &(name)}
+
+void mipc_list_init(mipc_list_t *head_ptr);
+void mipc_list_add_tail(mipc_list_t *head_ptr, mipc_list_t *list_ptr);
+void mipc_list_add_head(mipc_list_t *head_ptr, mipc_list_t *list_ptr);
+void mipc_list_del(mipc_list_t *list_ptr);
+
+//
+#define mipc_list_entry(ptr, type, member) ((type *)((unsigned char *)(ptr)-POINTER_TO_UINT(&((type *)0)->member)))
+
+#endif
diff --git a/mcu/interface/protocol/l5/mipc/msg/mipc_msg.h b/mcu/interface/protocol/l5/mipc/msg/mipc_msg.h
new file mode 100644
index 0000000..afe0dab
--- /dev/null
+++ b/mcu/interface/protocol/l5/mipc/msg/mipc_msg.h
@@ -0,0 +1,250 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* Copyright (c) [2020], MediaTek Inc. All rights reserved.
+* This software/firmware and related documentation ("MediaTek Software") are
+* protected under relevant copyright laws.
+*
+* The information contained herein is confidential and proprietary to
+* MediaTek Inc. and/or its licensors. Except as otherwise provided in the
+* applicable licensing terms with MediaTek Inc. and/or its licensors, any
+* reproduction, modification, use or disclosure of MediaTek Software, and
+* information contained herein, in whole or in part, shall be strictly
+* prohibited.
+*****************************************************************************/
+
+#ifndef _MIPC_MSG_H_
+#define _MIPC_MSG_H_
+
+#include "platform.h"
+#include "mipc.h"
+#include "mipc_hashmap.h"
+
+/*!
+ \brief MIPC MSG API result
+*/
+
+#define MAX_T_NUM (0x7fff)
+#define MIPC_USIR_BIT (0x8000)
+
+typedef enum {
+ MIPC_MSG_API_RESULT_SUCCESS = 0, /*!< API result is SUCCESS */
+ MIPC_MSG_API_RESULT_FAIL = 1 /*!< API result is FAIL */
+} mipc_msg_api_result_enum;
+
+typedef enum {
+ MIPC_MSG_SIM0 = MIPC_SIM0,
+ MIPC_MSG_SIM1 = MIPC_SIM1,
+ MIPC_MSG_SIM2 = MIPC_SIM2,
+ MIPC_MSG_SIM3 = MIPC_SIM3,
+ MIPC_MSG_PS0 = MIPC_PS0,
+ MIPC_MSG_PS1 = MIPC_PS1,
+ MIPC_MSG_PS2 = MIPC_PS2,
+ MIPC_MSG_PS3 = MIPC_PS3,
+ MIPC_MSG_ALL = MIPC_ALL
+} mipc_msg_sim_ps_id_enum;
+
+#pragma pack (push)
+#pragma pack (1)
+
+#define MIPC_MSG_HDR_FLAG_RESERVE0 (1 << 0)
+#define MIPC_MSG_HDR_FLAG_RESERVE1 (1 << 1)
+#define MIPC_MSG_HDR_FLAG_RESERVE2 (1 << 2)
+#define MIPC_MSG_HDR_FLAG_RESERVE3 (1 << 3)
+#define MIPC_MSG_HDR_FLAG_RESERVE4 (1 << 4)
+#define MIPC_MSG_HDR_FLAG_RESERVE5 (1 << 5)
+#define MIPC_MSG_HDR_FLAG_RESERVE6 (1 << 6)
+#define MIPC_MSG_HDR_FLAG_MORE (1 << 7)
+
+typedef struct {
+ uint32_t magic;
+ uint16_t padding[2];
+ uint8_t msg_sim_ps_id; //sim_ps_id (bit-wise)
+ uint8_t msg_flag;
+ uint16_t msg_id; //type[2] + id[14]
+ uint16_t msg_txid;
+ uint16_t msg_len;
+} mipc_msg_hdr_t;
+
+#define MIPC_MSG_TLV_HDR \
+ uint16_t type; \
+ uint16_t len
+
+typedef struct {
+ MIPC_MSG_TLV_HDR;
+} mipc_msg_tlv_t;
+
+#define MIPC_MSG_ARRAY_VAL \
+ uint32_t reserved; /* always 0 (for futrue use)*/ \
+ uint32_t reserved2; /* always 0 (for futrue use)*/ \
+ uint16_t array_base_t; \
+ uint16_t array_size
+
+typedef struct {
+ MIPC_MSG_TLV_HDR;
+ MIPC_MSG_ARRAY_VAL;
+} mipc_msg_tlv_array_t;
+#pragma pack (pop)
+
+typedef struct {
+ /** @brief message header*/
+ mipc_msg_hdr_t hdr;
+
+ /** @brief message payload len*/
+ uint16_t tlvs_len;
+ /** @brief message payload (TLVs)*/
+ mipc_hashmap_t *tlvs_ptr;
+
+ //for array
+ uint16_t array_free_t;
+} mipc_msg_t;
+
+typedef void (*MIPC_MSG_ITERATE_CB)(mipc_msg_tlv_t *tlv_ptr, void *cb_priv_ptr);
+
+#define mipc_msg_add_tlv8(m, t, v_ptr) mipc_msg_add_tlv(m, t, 1, v_ptr)
+#define mipc_msg_add_tlv16(m, t, v_ptr) mipc_msg_add_tlv(m, t, 2, v_ptr)
+#define mipc_msg_add_tlv32(m, t, v_ptr) mipc_msg_add_tlv(m, t, 4, v_ptr)
+#define mipc_msg_add_tlv_int8(m, t, v) {int8_t tmp = v; mipc_msg_add_tlv(m, t, sizeof(tmp), &tmp);}
+#define mipc_msg_add_tlv_int16(m, t, v) {int16_t tmp = HTOMS(v); mipc_msg_add_tlv(m, t, sizeof(tmp), &tmp);}
+#define mipc_msg_add_tlv_int32(m, t, v) {int32_t tmp = HTOML(v); mipc_msg_add_tlv(m, t, sizeof(tmp), &tmp);}
+#define mipc_msg_add_tlv_uint8(m, t, v) {uint8_t tmp = v; mipc_msg_add_tlv(m, t, sizeof(tmp), &tmp);}
+#define mipc_msg_add_tlv_uint16(m, t, v) {uint16_t tmp = HTOMS(v); mipc_msg_add_tlv(m, t, sizeof(tmp), &tmp);}
+#define mipc_msg_add_tlv_uint32(m, t, v) {uint32_t tmp = HTOML(v); mipc_msg_add_tlv(m, t, sizeof(tmp), &tmp);}
+
+#define mipc_msg_add_idx8(m, a, i, v_ptr) mipc_msg_add_idx(m, a, i, 1, v_ptr)
+#define mipc_msg_add_idx16(m, a, i, v_ptr) mipc_msg_add_idx(m, a, i, 2, v_ptr)
+#define mipc_msg_add_idx32(m, a, i, v_ptr) mipc_msg_add_idx(m, a, i, 4, v_ptr)
+#define mipc_msg_add_idx_int8(m, a, i, v) {int8_t tmp = v; mipc_msg_add_idx(m, a, i, sizeof(tmp), &tmp);}
+#define mipc_msg_add_idx_int16(m, a, i, v) {int16_t tmp = HTOMS(v); mipc_msg_add_idx(m, a, i, sizeof(tmp), &tmp);}
+#define mipc_msg_add_idx_int32(m, a, i, v) {int32_t tmp = HTOML(v); mipc_msg_add_idx(m, a, i, sizeof(tmp), &tmp);}
+#define mipc_msg_add_idx_uint8(m, a, i, v) {uint8_t tmp = v; mipc_msg_add_idx(m, a, i, sizeof(tmp), &tmp);}
+#define mipc_msg_add_idx_uint16(m, a, i, v) {uint16_t tmp = HTOMS(v); mipc_msg_add_idx(m, a, i, sizeof(tmp), &tmp);}
+#define mipc_msg_add_idx_uint32(m, a, i, v) {uint32_t tmp = HTOML(v); mipc_msg_add_idx(m, a, i, sizeof(tmp), &tmp);}
+
+#define MIPC_MSG_GET_TLV_TYPE(tlv_ptr) ((tlv_ptr) ? (tlv_ptr)->type : 0)
+#define MIPC_MSG_GET_TLV_LEN(tlv_ptr) ((tlv_ptr) ? (tlv_ptr)->len : 0)
+#define MIPC_MSG_GET_TLV_VAL_PTR(tlv_ptr) ((void *)(((uint8_t *)tlv_ptr) + sizeof(mipc_msg_tlv_t)))
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+DLL_EXPORT mipc_msg_t *mipc_msg_init(
+ uint16_t msg_id,
+ mipc_msg_sim_ps_id_enum sim_ps_id
+);
+
+DLL_EXPORT mipc_msg_t *mipc_msg_init_with_txid(
+ uint16_t msg_id,
+ mipc_msg_sim_ps_id_enum sim_ps_id,
+ uint16_t msg_txid
+);
+
+//only copy message header
+mipc_msg_t *mipc_msg_copy_hdr(
+ mipc_msg_t *msg_ptr
+);
+
+//only copy message TLVs
+mipc_msg_api_result_enum mipc_msg_copy_tlv(
+ mipc_msg_t *src_msg_ptr,
+ mipc_msg_t *dst_msg_ptr
+);
+
+
+DLL_EXPORT void mipc_msg_deinit(
+ mipc_msg_t *msg_ptr
+);
+
+DLL_EXPORT mipc_msg_api_result_enum mipc_msg_add_tlv(
+ mipc_msg_t *msg_ptr,
+ uint16_t type,
+ uint16_t len,
+ const void *val_ptr
+);
+
+//for 1st level array
+#define mipc_msg_add_tlv_array(m, t, s) mipc_msg_add_array(m, NULL, 0, t, s)
+
+DLL_EXPORT mipc_msg_tlv_array_t *mipc_msg_add_array(
+ mipc_msg_t *msg_ptr,
+ mipc_msg_tlv_array_t *array_tlv_ptr, //can be NULL if it's a first dimension
+ uint16_t idx, //shouild be 0 if array_tlv_ptr is NULL
+ uint16_t type, //only valid if array_tlv_ptr is NULL
+ uint16_t array_size
+);
+
+DLL_EXPORT mipc_msg_api_result_enum mipc_msg_add_idx(
+ mipc_msg_t *msg_ptr,
+ mipc_msg_tlv_array_t *array_tlv_ptr,
+ uint16_t idx,
+ uint16_t len,
+ const void *val_ptr
+);
+
+mipc_msg_tlv_t *mipc_msg_get_tlv(
+ mipc_msg_t *msg_ptr,
+ uint16_t type
+);
+
+uint16_t mipc_msg_get_tlv_num(
+ mipc_msg_t *msg_ptr,
+ uint16_t type
+);
+
+mipc_msg_tlv_t *mipc_msg_get_idx(
+ mipc_msg_t *msg_ptr,
+ uint16_t type,
+ uint16_t idx
+);
+
+DLL_EXPORT void *mipc_msg_get_val_ptr(
+ mipc_msg_t *msg_ptr,
+ uint16_t type,
+ uint16_t *val_len_ptr
+);
+
+DLL_EXPORT char *mipc_msg_get_val_str(
+ mipc_msg_t *msg_ptr,
+ uint16_t type,
+ uint16_t *val_len_ptr
+);
+
+DLL_EXPORT void *mipc_msg_get_idx_ptr(
+ mipc_msg_t *msg_ptr,
+ uint16_t type,
+ uint16_t idx,
+ uint16_t *val_len_ptr
+);
+
+#define mipc_msg_get_val_int8(m, t, def_val) ((mipc_msg_get_val_ptr(m, t, NULL)) ? *(int8_t *)mipc_msg_get_val_ptr(m, t, NULL) : def_val)
+#define mipc_msg_get_val_int16(m, t, def_val) ((mipc_msg_get_val_ptr(m, t, NULL)) ? MTOHS(*(int16_t *)mipc_msg_get_val_ptr(m, t, NULL)) : def_val)
+#define mipc_msg_get_val_int32(m, t, def_val) ((mipc_msg_get_val_ptr(m, t, NULL)) ? MTOHL(*(int32_t *)mipc_msg_get_val_ptr(m, t, NULL)) : def_val)
+#define mipc_msg_get_val_uint8(m, t, def_val) ((mipc_msg_get_val_ptr(m, t, NULL)) ? *(uint8_t *)mipc_msg_get_val_ptr(m, t, NULL) : def_val)
+#define mipc_msg_get_val_uint16(m, t, def_val) ((mipc_msg_get_val_ptr(m, t, NULL)) ? MTOHS(*(uint16_t *)mipc_msg_get_val_ptr(m, t, NULL)) : def_val)
+#define mipc_msg_get_val_uint32(m, t, def_val) ((mipc_msg_get_val_ptr(m, t, NULL)) ? MTOHL(*(uint32_t *)mipc_msg_get_val_ptr(m, t, NULL)) : def_val)
+//
+#define mipc_msg_get_idx_int8(m, t, i, def_val) ((mipc_msg_get_idx_ptr(m, t, i, NULL)) ? *(int8_t *)mipc_msg_get_idx_ptr(m, t, i, NULL) : def_val)
+#define mipc_msg_get_idx_int16(m, t, i, def_val) ((mipc_msg_get_idx_ptr(m, t, i, NULL)) ? MTOHS(*(int16_t *)mipc_msg_get_idx_ptr(m, t, i, NULL)) : def_val)
+#define mipc_msg_get_idx_int32(m, t, i, def_val) ((mipc_msg_get_idx_ptr(m, t, i, NULL)) ? MTOHL(*(int32_t *)mipc_msg_get_idx_ptr(m, t, i, NULL)) : def_val)
+#define mipc_msg_get_idx_uint8(m, t, i, def_val) ((mipc_msg_get_idx_ptr(m, t, i, NULL)) ? *(uint8_t *)mipc_msg_get_idx_ptr(m, t, i, NULL) : def_val)
+#define mipc_msg_get_idx_uint16(m, t, i, def_val) ((mipc_msg_get_idx_ptr(m, t, i, NULL)) ? MTOHS(*(uint16_t *)mipc_msg_get_idx_ptr(m, t, i, NULL)) : def_val)
+#define mipc_msg_get_idx_uint32(m, t, i, def_val) ((mipc_msg_get_idx_ptr(m, t, i, NULL)) ? MTOHL(*(uint32_t *)mipc_msg_get_idx_ptr(m, t, i, NULL)) : def_val)
+
+//
+DLL_EXPORT void mipc_msg_iterate(mipc_msg_t *msg_ptr, MIPC_MSG_ITERATE_CB cb, void *cb_priv_ptr);
+//
+DLL_EXPORT uint8_t *mipc_msg_serialize(mipc_msg_t *msg_ptr, uint16_t *msg_len_ptr);
+DLL_EXPORT uint8_t *mipc_msg_usir_serialize(mipc_msg_t *msg_ptr, uint16_t *msg_len_ptr, uint8_t context_usir_support);
+DLL_EXPORT mipc_msg_t *mipc_msg_deserialize(uint8_t *msg_raw_ptr, uint16_t msg_raw_len);
+//
+DLL_EXPORT int32_t mipc_msg_compare(mipc_msg_t *msg_ptr1, mipc_msg_t *msg_ptr2);
+//
+int32_t ind_msg_id_to_bit(mipc_msg_id_enum msg_id);
+int32_t cmd_msg_id_to_bit(mipc_msg_id_enum msg_id);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/mcu/interface/protocol/l5/mipc/msg/mipc_msg_host.h b/mcu/interface/protocol/l5/mipc/msg/mipc_msg_host.h
new file mode 100644
index 0000000..00bc887
--- /dev/null
+++ b/mcu/interface/protocol/l5/mipc/msg/mipc_msg_host.h
@@ -0,0 +1,144 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* Copyright (c) [2020], MediaTek Inc. All rights reserved.
+* This software/firmware and related documentation ("MediaTek Software") are
+* protected under relevant copyright laws.
+*
+* The information contained herein is confidential and proprietary to
+* MediaTek Inc. and/or its licensors. Except as otherwise provided in the
+* applicable licensing terms with MediaTek Inc. and/or its licensors, any
+* reproduction, modification, use or disclosure of MediaTek Software, and
+* information contained herein, in whole or in part, shall be strictly
+* prohibited.
+*****************************************************************************/
+
+#ifndef _MIPC_MSG_HOST_H_
+#define _MIPC_MSG_HOST_H_
+
+#include "platform.h"
+#include "mipc.h"
+#include "mipc_hashmap.h"
+#include "mipc_msg.h"
+
+/*!
+ \brief MIPC MSG HOST API result
+*/
+typedef enum {
+ ERR_NO_ERR = 0,
+ ERR_UNEXPECTED_MSG = -1,
+ ERR_UNEXPECTED_MSG_TYPE = -2,
+ ERR_CB_IS_NULL = -3,
+ ERR_WRITE_ERROR = -4,
+ ERR_TIME_OUT = -5
+} mipc_ret_cause_enum;
+
+typedef void (*MIPC_API_CB)(
+ mipc_msg_sim_ps_id_enum sim_ps_id,
+ void *result_ptr,
+ void *cb_priv_ptr
+);
+
+typedef void (*MIPC_MSG_CB)(mipc_msg_t *msg_ptr, void *priv_ptr);
+typedef void (*MIPC_MSG_CB2)(mipc_msg_t *msg_ptr, MIPC_API_CB cb, void *priv_ptr);
+
+typedef enum {
+ MIPC_TRANSACTION_TYPE_SYNC = 0,
+ MIPC_TRANSACTION_TYPE_ASYNC = 1
+} mipc_transaction_type_enum;
+
+typedef enum{
+ MIPC_HOST_TO_DEVICE = 0,
+ MIPC_DEVICE_TO_HOST = 1
+} mipc_msg_direction_enum;
+
+typedef struct {
+ uint16_t msg_txid;
+ mipc_transaction_type_enum transaction_type;
+ //for sync
+ EVENT *event_ptr;
+ //for async
+ uint8_t cb_mode;
+ union {
+ struct {
+ MIPC_MSG_CB msg_cb;
+ void *cb_priv_ptr;
+ } cb1;
+ struct {
+ MIPC_MSG_CB2 msg_cb;
+ MIPC_API_CB api_cb;
+ void *cb_priv_ptr;
+ } cb2;
+ } a;
+} mipc_transaction_t;
+
+typedef struct {
+ uint32_t key;
+ uint8_t cb_mode;
+ union {
+ struct {
+ MIPC_MSG_CB msg_cb;
+ void *cb_priv_ptr;
+ } cb1;
+ struct {
+ MIPC_MSG_CB2 msg_cb;
+ MIPC_API_CB api_cb;
+ void *cb_priv_ptr;
+ } cb2;
+ } a;
+} mipc_ind_t;
+
+typedef struct {
+ uint32_t key;
+ uint8_t cb_mode;
+ union {
+ struct {
+ MIPC_MSG_CB msg_cb;
+ void *cb_priv_ptr;
+ } cb1;
+ struct {
+ MIPC_MSG_CB2 msg_cb;
+ MIPC_API_CB api_cb;
+ void *cb_priv_ptr;
+ } cb2;
+ } a;
+} mipc_cmd_t;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+//
+DLL_EXPORT mipc_msg_t *mipc_msg_sync_timeout(mipc_msg_t *msg_ptr);
+DLL_EXPORT mipc_ret_cause_enum mipc_msg_sync_timeout_with_cause(mipc_msg_t *msg_ptr, mipc_msg_t **cnf_ptr);
+DLL_EXPORT mipc_msg_t *mipc_msg_sync(mipc_msg_t *msg_ptr);
+DLL_EXPORT mipc_ret_cause_enum mipc_msg_sync_with_cause(mipc_msg_t *msg_ptr, mipc_msg_t **cnf_ptr);
+DLL_EXPORT mipc_ret_cause_enum mipc_msg_async_api(mipc_msg_t *msg_ptr, void *msg_cb, MIPC_API_CB api_cb, void *cb_priv_ptr);
+#define mipc_msg_async(m, cb, cb_priv) mipc_msg_async_api(m, cb, NULL, cb_priv)
+//
+DLL_EXPORT int32_t mipc_msg_register_ind_api(mipc_msg_sim_ps_id_enum sim_ps_id, mipc_msg_id_enum msg_id, void *msg_cb, MIPC_API_CB api_cb, void *cb_priv_ptr);
+#define mipc_msg_register_ind(s, m, cb, cb_priv) mipc_msg_register_ind_api(s, m, cb, NULL, cb_priv)
+//
+DLL_EXPORT int32_t mipc_msg_unregister_ind_api(mipc_msg_sim_ps_id_enum sim_ps_id, mipc_msg_id_enum msg_id);
+//
+DLL_EXPORT int32_t mipc_msg_register_cmd_api(mipc_msg_id_enum msg_id, void *msg_cb, MIPC_API_CB api_cb, void *cb_priv_ptr);
+#define mipc_msg_register_cmd(m, cb, cb_priv) mipc_msg_register_cmd_api(m, cb, NULL, cb_priv)
+//
+DLL_EXPORT int32_t mipc_msg_unregister_cmd_api(mipc_msg_id_enum msg_id);
+//
+DLL_EXPORT int32_t mipc_msg_rsp(mipc_msg_t *msg_ptr);
+//
+DLL_EXPORT int32_t mipc_init(const char *process_name_ptr);
+DLL_EXPORT int32_t mipc_init_debug(const char *process_name_ptr);
+DLL_EXPORT void mipc_deinit();
+DLL_EXPORT void mipc_msg_set_timeout_once(uint32_t timeout_ms);
+DLL_EXPORT void mipc_set_host_api_timeout(uint32_t timeout_ms);
+
+DLL_EXPORT void UNIT_TEST_SET_MSG(mipc_msg_t *msg_ptr);
+DLL_EXPORT void UNIT_TEST_SEND_MSG(mipc_msg_t *msg_ptr);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif