Commit | Line | Data |
---|---|---|
6fa3eb70 S |
1 | /***************************************************************************** |
2 | * | |
3 | * Filename: | |
4 | * --------- | |
5 | * eemcs_rpc.h | |
6 | * | |
7 | * Project: | |
8 | * -------- | |
9 | * | |
10 | * | |
11 | * Description: | |
12 | * ------------ | |
13 | * | |
14 | * | |
15 | * Author: | |
16 | * ------- | |
17 | * | |
18 | * | |
19 | ****************************************************************************/ | |
20 | ||
21 | #ifndef __EEMCS_RPC_H | |
22 | #define __EEMCS_RPC_H | |
23 | ||
24 | ||
25 | //#include <crypto_engine_export.h> | |
26 | //#include <sec_error.h> | |
27 | #include <linux/skbuff.h> | |
28 | ||
29 | #include "eemcs_ccci.h" | |
30 | #include "eemcs_kal.h" | |
31 | #ifdef _EEMCS_RPC_UT | |
32 | #include "eemcs_rpc_ut.h" | |
33 | #endif | |
34 | ||
35 | #define CCCI_SED_LEN_BYTES 16 | |
36 | typedef struct {unsigned char sed[CCCI_SED_LEN_BYTES]; }sed_t; | |
37 | #define SED_INITIALIZER { {[0 ... CCCI_SED_LEN_BYTES-1]=0}} | |
38 | /******************************************************************************* | |
39 | * Define marco or constant. | |
40 | *******************************************************************************/ | |
41 | #define IPC_RPC_EXCEPT_MAX_RETRY 7 | |
42 | #define IPC_RPC_MAX_RETRY (0xFFFF) | |
43 | #define IPC_RPC_REQ_BUFFER_NUM 2 /* support 2 concurrently request*/ | |
44 | #define IPC_RPC_MAX_ARG_NUM 6 /* parameter number */ | |
45 | #define IPC_RPC_MAX_BUF_SIZE 2048 | |
46 | ||
47 | #define IPC_RPC_USE_DEFAULT_INDEX -1 | |
48 | #define IPC_RPC_API_RESP_ID 0xFFFF0000 | |
49 | #define IPC_RPC_INC_BUF_INDEX(x) (x = (x + 1) % IPC_RPC_REQ_BUFFER_NUM) | |
50 | ||
51 | /******************************************************************************* | |
52 | * Define data structure. | |
53 | *******************************************************************************/ | |
54 | typedef enum | |
55 | { | |
56 | IPC_RPC_CPSVC_SECURE_ALGO_OP = 0x2001, | |
57 | IPC_RPC_GET_SECRO_OP = 0x2002, | |
58 | IPC_RPC_GET_TDD_EINT_NUM_OP = 0x4001, | |
59 | IPC_RPC_GET_TDD_GPIO_NUM_OP = 0x4002, | |
60 | IPC_RPC_GET_TDD_ADC_NUM_OP = 0x4003, | |
61 | IPC_RPC_GET_EMI_CLK_TYPE_OP = 0x4004, | |
62 | IPC_RPC_GET_EINT_ATTR_OP = 0x4005, | |
63 | ||
64 | IPC_RPC_UT_OP = 0x1234, | |
65 | IPC_RPC_IT_OP = 0x4321, | |
66 | }RPC_OP_ID; | |
67 | ||
68 | typedef struct | |
69 | { | |
70 | unsigned int len; | |
71 | void *buf; | |
72 | }RPC_PKT; | |
73 | ||
74 | typedef struct | |
75 | { | |
76 | unsigned int op_id; | |
77 | unsigned char buf[IPC_RPC_MAX_BUF_SIZE]; | |
78 | }RPC_BUF; | |
79 | ||
80 | typedef struct IPC_RPC_StreamBuffer_STRUCT | |
81 | { | |
82 | CCCI_BUFF_T ccci_header; | |
83 | kal_uint32 rpc_opid; | |
84 | kal_uint32 num_para; | |
85 | kal_uint8 buffer[IPC_RPC_MAX_BUF_SIZE]; | |
86 | ||
87 | } IPC_RPC_StreamBuffer_T; | |
88 | typedef IPC_RPC_StreamBuffer_T* pIPC_RPC_StreamBuffer_T; | |
89 | ||
90 | #if 0 | |
91 | /* Struct to define the control channel of RPC service */ | |
92 | typedef struct CCCI_RPC_STRUCT | |
93 | { | |
94 | kal_uint32 send_channel; /* RPC channel for TX */ | |
95 | kal_uint32 receive_channel; /* RPC channel for RX */ | |
96 | /* <CCCI released APIs> */ | |
97 | kal_int32 (*ccci_write_gpd)(CCCI_CHANNEL_T channel, ccci_io_request_t *p_ccci_DL_ior, ccci_io_ext_info_t* pextinfo); | |
98 | ||
99 | kal_int32 (*ccci_init_gpdior)(CCCI_CHANNEL_T channel, CCCI_IORCALLBACK ior_funp); | |
100 | kal_int32 (*ccci_deinit)(CCCI_CHANNEL_T channel); | |
101 | kal_int32 (*ccci_rpc_polling_io)(CCCI_CHANNEL_T channel,qbm_gpd * p_gpd,kal_bool is_tx); | |
102 | ||
103 | kal_bool (*check_kal_systemInit)(void); | |
104 | ||
105 | kal_uint32 ut_flag; | |
106 | ||
107 | qbm_gpd *p_polling_gpd; /* polling mode GPD */ | |
108 | kal_uint32 allocated_gpd_number; | |
109 | ||
110 | } CCCI_RPC_T; | |
111 | ||
112 | #endif | |
113 | ||
114 | #define FS_NO_ERROR 0 | |
115 | #define FS_NO_OP -1 | |
116 | #define FS_PARAM_ERROR -2 | |
117 | #define FS_NO_FEATURE -3 | |
118 | #define FS_NO_MATCH -4 | |
119 | #define FS_FUNC_FAIL -5 | |
120 | #define FS_ERROR_RESERVED -6 | |
121 | #define FS_MEM_OVERFLOW -7 | |
122 | ||
123 | /* EMCS opeartion Error. */ | |
124 | // I for Internal use, O for device status, should cover by error handling.. | |
125 | #define EMCS_ERR_NONE 0 | |
126 | #define EMCS_ERR_TIMEOUT 20 /*[O] wait Interrupt or device read fail*/ | |
127 | #define EMCS_ERR_BT_STATUS 21 /*[I] invalid MD Status.*/ | |
128 | #define EMCS_ERR_CMDCRC 22 /*[O] invalid command*/ | |
129 | #define EMCS_ERR_LOAD_BIN 23 /*[O] MD BIN file open fail*/ | |
130 | #define EMCS_ERR_MSG_OVERFLOW 24 /*[O] receive message to long*/ | |
131 | #define EMCS_ERR_PKT_OVERFLOW 25 /*[I] send package big the tx limitaion*/ | |
132 | #define EMCS_ERR_INVALID_PARA 26 /*[I] emcs driver parameter check fail*/ | |
133 | #define EMCS_ERR_GET_OWNER 27 /*[O] get device ownership fail*/ | |
134 | #define EMCS_ERR_NOMEM 28 | |
135 | #define EMCS_ERR_NOINIT 29 | |
136 | #define EMCS_ERR_INVAL_PARA 30 | |
137 | #define EMCS_ERR_TX_FAIL 31 | |
138 | #define EMCS_ERR_RX_FAIL 32 | |
139 | #define EMCS_ERROR_BUSY 33 | |
140 | #define EMCS_ERROR_NODEV 34 | |
141 | ||
142 | ||
143 | /* IPC Instance structure define */ | |
144 | typedef struct _eemcs_rpc_inst_t | |
145 | { | |
146 | ccci_ch_set ccci_ch; | |
147 | }eemcs_rpc_inst_t; | |
148 | ||
149 | #ifdef CCCI_SDIO_HEAD | |
150 | #define CCCI_RPC_HEADER_ROOM (sizeof(SDIO_H)+sizeof(CCCI_BUFF_T)) | |
151 | #else | |
152 | #define CCCI_RPC_HEADER_ROOM (sizeof(CCCI_BUFF_T)) | |
153 | #endif | |
154 | ||
155 | #define RPC_UT_SUCCESS 1 | |
156 | #define RPC_UT_FAIL -1 | |
157 | #define RPC_IT_SUCCESS 1 | |
158 | #define RPC_IT_FAIL -1 | |
159 | ||
160 | #define ut_ret_val 0xa5a5 | |
161 | #define it_ret_val 0xa5a5 | |
162 | ||
163 | #ifdef _EEMCS_RPC_UT | |
164 | #define ccci_rpc_ch_write_desc_to_q(ch_num,desc_p) eemcs_rpc_ut_UL_write_skb_to_swq(ch_num, desc_p) | |
165 | #else | |
166 | #define ccci_rpc_ch_write_desc_to_q(ch_num,desc_p) eemcs_ccci_UL_write_skb_to_swq(ch_num, desc_p) | |
167 | #endif | |
168 | #define ccci_ch_register(ch_num,cb,para) eemcs_ccci_register_callback(ch_num,cb,para) | |
169 | #define ccci_ch_unregister(ch_num) eemcs_ccci_unregister_callback(ch_num) | |
170 | #define ccci_ch_write_space_alloc(ch_num) eemcs_ccci_UL_write_room_alloc(ch_num) | |
171 | ||
172 | #define ccci_rpc_mem_alloc(sz, flag) __dev_alloc_skb(sz, flag) | |
173 | ||
174 | ||
175 | extern KAL_INT32 eemcs_rpc_callback(struct sk_buff *skb, KAL_UINT32 private_data); | |
176 | extern int eemcs_rpc_mod_init(void); | |
177 | extern void eemcs_rpc_exit(void); | |
178 | ||
179 | #endif |