/arch/arm/mach-msm/include/mach/msm_rpcrouter.h

https://bitbucket.org/sammyz/iscream_thunderc-2.6.35-rebase · C++ Header · 438 lines · 295 code · 77 blank · 66 comment · 0 complexity · 9c733c58fecf5166346056bb50de93fd MD5 · raw file

  1. /** include/asm-arm/arch-msm/msm_rpcrouter.h
  2. *
  3. * Copyright (C) 2007 Google, Inc.
  4. * Copyright (c) 2007-2010, Code Aurora Forum. All rights reserved.
  5. * Author: San Mehat <san@android.com>
  6. *
  7. * This software is licensed under the terms of the GNU General Public
  8. * License version 2, as published by the Free Software Foundation, and
  9. * may be copied, distributed, and modified under those terms.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. */
  17. #ifndef __ASM__ARCH_MSM_RPCROUTER_H
  18. #define __ASM__ARCH_MSM_RPCROUTER_H
  19. #include <linux/types.h>
  20. #include <linux/list.h>
  21. #include <linux/platform_device.h>
  22. /* RPC API version structure
  23. * Version bit 31 : 1->hashkey versioning,
  24. * 0->major-minor (backward compatible) versioning
  25. * hashkey versioning:
  26. * Version bits 31-0 hashkey
  27. * major-minor (backward compatible) versioning
  28. * Version bits 30-28 reserved (no match)
  29. * Version bits 27-16 major (must match)
  30. * Version bits 15-0 minor (greater or equal)
  31. */
  32. #define RPC_VERSION_MODE_MASK 0x80000000
  33. #define RPC_VERSION_MAJOR_MASK 0x0fff0000
  34. #define RPC_VERSION_MINOR_MASK 0x0000ffff
  35. /* callback ID for NULL callback function is -1 */
  36. #define MSM_RPC_CLIENT_NULL_CB_ID 0xffffffff
  37. struct msm_rpc_endpoint;
  38. struct rpcsvr_platform_device
  39. {
  40. struct platform_device base;
  41. uint32_t prog;
  42. uint32_t vers;
  43. };
  44. /* Factory AT CMD feature added based on EVE
  45. * hoonylove004@lge.com 2009-12-29, [VS740] AT CMD
  46. */
  47. #ifdef CONFIG_MACH_LGE
  48. typedef uint8_t AT_STR_t;
  49. #define ABSOLUTE_STRING_LENGTH 500 //40 [seypark@lge.com]
  50. #define MAX_STRING_RET (ABSOLUTE_STRING_LENGTH/sizeof(AT_STR_t))
  51. typedef uint8_t AT_SEND_BUFFER_t;
  52. #define MAX_SEND_LOOP_NUM 8 // 4 => 8 kageki@lge.com
  53. #define ABSOLUTE_SEND_SIZE 256
  54. #define MAX_SEND_SIZE_BUFFER ABSOLUTE_SEND_SIZE/sizeof(AT_SEND_BUFFER_t)
  55. #define LIMIT_MAX_SEND_SIZE_BUFFER MAX_SEND_SIZE_BUFFER*MAX_SEND_LOOP_NUM
  56. struct retvaluestruct
  57. {
  58. uint32_t ret_value1;
  59. uint32_t ret_value2;
  60. AT_STR_t ret_string[MAX_STRING_RET];
  61. };
  62. #endif
  63. #define RPC_DATA_IN 0
  64. /*
  65. * Structures for sending / receiving direct RPC requests
  66. * XXX: Any cred/verif lengths > 0 not supported
  67. */
  68. struct rpc_request_hdr
  69. {
  70. uint32_t xid;
  71. uint32_t type; /* 0 */
  72. uint32_t rpc_vers; /* 2 */
  73. uint32_t prog;
  74. uint32_t vers;
  75. uint32_t procedure;
  76. uint32_t cred_flavor;
  77. uint32_t cred_length;
  78. uint32_t verf_flavor;
  79. uint32_t verf_length;
  80. };
  81. typedef struct
  82. {
  83. uint32_t low;
  84. uint32_t high;
  85. } rpc_reply_progmismatch_data;
  86. typedef struct
  87. {
  88. } rpc_denied_reply_hdr;
  89. typedef struct
  90. {
  91. uint32_t verf_flavor;
  92. uint32_t verf_length;
  93. uint32_t accept_stat;
  94. #define RPC_ACCEPTSTAT_SUCCESS 0
  95. #define RPC_ACCEPTSTAT_PROG_UNAVAIL 1
  96. #define RPC_ACCEPTSTAT_PROG_MISMATCH 2
  97. #define RPC_ACCEPTSTAT_PROC_UNAVAIL 3
  98. #define RPC_ACCEPTSTAT_GARBAGE_ARGS 4
  99. #define RPC_ACCEPTSTAT_SYSTEM_ERR 5
  100. #define RPC_ACCEPTSTAT_PROG_LOCKED 6
  101. #ifdef CONFIG_MACH_LGE
  102. /* Factory AT CMD feature added based on EVE */
  103. /* hoonylove004@lge.com 2009-12-29, [VS740] AT CMD */
  104. #define RPC_RETURN_RESULT_ERROR 7
  105. #define RPC_RETURN_RESULT_OK 8
  106. #define RPC_RETURN_RESULT_MIDDLE_OK 9
  107. #endif /*LG_FW_ATS_ETA_MTC*/
  108. /*
  109. * Following data is dependant on accept_stat
  110. * If ACCEPTSTAT == PROG_MISMATCH then there is a
  111. * 'rpc_reply_progmismatch_data' structure following the header.
  112. * Otherwise the data is procedure specific
  113. */
  114. } rpc_accepted_reply_hdr;
  115. #ifdef CONFIG_MACH_LGE
  116. /* Factory AT CMD feature added based on EVE */
  117. /* hoonylove004@lge.com 2009-12-29, [VS740] AT CMD */
  118. typedef struct
  119. {
  120. uint32_t verf_flavor;
  121. uint32_t verf_length;
  122. uint32_t accept_stat;
  123. #define RPC_ACCEPTSTAT_SUCCESS 0
  124. #define RPC_ACCEPTSTAT_PROG_UNAVAIL 1
  125. #define RPC_ACCEPTSTAT_PROG_MISMATCH 2
  126. #define RPC_ACCEPTSTAT_PROC_UNAVAIL 3
  127. #define RPC_ACCEPTSTAT_GARBAGE_ARGS 4
  128. #define RPC_ACCEPTSTAT_SYSTEM_ERR 5
  129. #define RPC_ACCEPTSTAT_PROG_LOCKED 6
  130. #define RPC_RETURN_RESULT_ERROR 7
  131. #define RPC_RETURN_RESULT_OK 8
  132. #define RPC_RETURN_RESULT_MIDDLE_OK 9
  133. struct retvaluestruct retvalues;
  134. /*
  135. * Following data is dependant on accept_stat
  136. * If ACCEPTSTAT == PROG_MISMATCH then there is a
  137. * 'rpc_reply_progmismatch_data' structure following the header.
  138. * Otherwise the data is procedure specific
  139. */
  140. } rpc_accepted_AT_reply_hdr;
  141. #endif
  142. struct rpc_reply_hdr
  143. {
  144. uint32_t xid;
  145. uint32_t type;
  146. uint32_t reply_stat;
  147. #define RPCMSG_REPLYSTAT_ACCEPTED 0
  148. #define RPCMSG_REPLYSTAT_DENIED 1
  149. union {
  150. rpc_accepted_reply_hdr acc_hdr;
  151. rpc_denied_reply_hdr dny_hdr;
  152. } data;
  153. };
  154. #ifdef CONFIG_MACH_LGE
  155. /* Factory AT CMD feature added based on EVE */
  156. /* hoonylove004@lge.com 2009-12-29, [VS740] AT CMD */
  157. struct rpc_reply_AT_hdr
  158. {
  159. struct rpc_reply_hdr reply;
  160. struct retvaluestruct retvalues;
  161. };
  162. #endif
  163. struct rpc_board_dev {
  164. uint32_t prog;
  165. struct platform_device pdev;
  166. };
  167. /* flags for msm_rpc_connect() */
  168. #define MSM_RPC_UNINTERRUPTIBLE 0x0001
  169. /* use IS_ERR() to check for failure */
  170. struct msm_rpc_endpoint *msm_rpc_open(void);
  171. /* Connect with the specified server version */
  172. struct msm_rpc_endpoint *msm_rpc_connect(uint32_t prog, uint32_t vers, unsigned flags);
  173. /* Connect with a compatible server version */
  174. struct msm_rpc_endpoint *msm_rpc_connect_compatible(uint32_t prog,
  175. uint32_t vers, unsigned flags);
  176. /* check if server version can handle client requested version */
  177. int msm_rpc_is_compatible_version(uint32_t server_version,
  178. uint32_t client_version);
  179. int msm_rpc_close(struct msm_rpc_endpoint *ept);
  180. int msm_rpc_write(struct msm_rpc_endpoint *ept,
  181. void *data, int len);
  182. int msm_rpc_read(struct msm_rpc_endpoint *ept,
  183. void **data, unsigned len, long timeout);
  184. void msm_rpc_read_wakeup(struct msm_rpc_endpoint *ept);
  185. void msm_rpc_setup_req(struct rpc_request_hdr *hdr,
  186. uint32_t prog, uint32_t vers, uint32_t proc);
  187. int msm_rpc_register_server(struct msm_rpc_endpoint *ept,
  188. uint32_t prog, uint32_t vers);
  189. int msm_rpc_unregister_server(struct msm_rpc_endpoint *ept,
  190. uint32_t prog, uint32_t vers);
  191. int msm_rpc_add_board_dev(struct rpc_board_dev *board_dev, int num);
  192. int msm_rpc_clear_netreset(struct msm_rpc_endpoint *ept);
  193. int msm_rpc_get_curr_pkt_size(struct msm_rpc_endpoint *ept);
  194. /* simple blocking rpc call
  195. *
  196. * request is mandatory and must have a rpc_request_hdr
  197. * at the start. The header will be filled out for you.
  198. *
  199. * reply provides a buffer for replies of reply_max_size
  200. */
  201. int msm_rpc_call_reply(struct msm_rpc_endpoint *ept, uint32_t proc,
  202. void *request, int request_size,
  203. void *reply, int reply_max_size,
  204. long timeout);
  205. int msm_rpc_call(struct msm_rpc_endpoint *ept, uint32_t proc,
  206. void *request, int request_size,
  207. long timeout);
  208. struct msm_rpc_xdr {
  209. void *in_buf;
  210. uint32_t in_size;
  211. uint32_t in_index;
  212. wait_queue_head_t in_buf_wait_q;
  213. void *out_buf;
  214. uint32_t out_size;
  215. uint32_t out_index;
  216. struct mutex out_lock;
  217. struct msm_rpc_endpoint *ept;
  218. };
  219. int xdr_send_int8(struct msm_rpc_xdr *xdr, const int8_t *value);
  220. int xdr_send_uint8(struct msm_rpc_xdr *xdr, const uint8_t *value);
  221. int xdr_send_int16(struct msm_rpc_xdr *xdr, const int16_t *value);
  222. int xdr_send_uint16(struct msm_rpc_xdr *xdr, const uint16_t *value);
  223. int xdr_send_int32(struct msm_rpc_xdr *xdr, const int32_t *value);
  224. int xdr_send_uint32(struct msm_rpc_xdr *xdr, const uint32_t *value);
  225. int xdr_send_bytes(struct msm_rpc_xdr *xdr, const void **data, uint32_t *size);
  226. int xdr_recv_int8(struct msm_rpc_xdr *xdr, int8_t *value);
  227. int xdr_recv_uint8(struct msm_rpc_xdr *xdr, uint8_t *value);
  228. int xdr_recv_int16(struct msm_rpc_xdr *xdr, int16_t *value);
  229. int xdr_recv_uint16(struct msm_rpc_xdr *xdr, uint16_t *value);
  230. int xdr_recv_int32(struct msm_rpc_xdr *xdr, int32_t *value);
  231. int xdr_recv_uint32(struct msm_rpc_xdr *xdr, uint32_t *value);
  232. int xdr_recv_bytes(struct msm_rpc_xdr *xdr, void **data, uint32_t *size);
  233. struct msm_rpc_server
  234. {
  235. struct list_head list;
  236. uint32_t flags;
  237. uint32_t prog;
  238. uint32_t vers;
  239. struct mutex cb_req_lock;
  240. struct msm_rpc_endpoint *cb_ept;
  241. struct msm_rpc_xdr cb_xdr;
  242. uint32_t version;
  243. int (*rpc_call)(struct msm_rpc_server *server,
  244. struct rpc_request_hdr *req, unsigned len);
  245. int (*rpc_call2)(struct msm_rpc_server *server,
  246. struct rpc_request_hdr *req,
  247. struct msm_rpc_xdr *xdr);
  248. #ifdef CONFIG_MACH_LGE
  249. /* Factory AT CMD feature added based on EVE */
  250. /* hoonylove004@lge.com 2009-12-29, [VS740] AT CMD */
  251. struct retvaluestruct retvalue;
  252. #endif
  253. };
  254. int msm_rpc_create_server(struct msm_rpc_server *server);
  255. int msm_rpc_create_server2(struct msm_rpc_server *server);
  256. #define MSM_RPC_MSGSIZE_MAX 8192
  257. struct msm_rpc_client;
  258. struct msm_rpc_client {
  259. struct task_struct *read_thread;
  260. struct task_struct *cb_thread;
  261. struct msm_rpc_endpoint *ept;
  262. wait_queue_head_t reply_wait;
  263. uint32_t prog, ver;
  264. void *buf;
  265. struct msm_rpc_xdr xdr;
  266. struct msm_rpc_xdr cb_xdr;
  267. uint32_t version;
  268. int (*cb_func)(struct msm_rpc_client *, void *, int);
  269. int (*cb_func2)(struct msm_rpc_client *, struct rpc_request_hdr *req,
  270. struct msm_rpc_xdr *);
  271. void *cb_buf;
  272. int cb_size;
  273. struct list_head cb_item_list;
  274. struct mutex cb_item_list_lock;
  275. wait_queue_head_t cb_wait;
  276. int cb_avail;
  277. atomic_t next_cb_id;
  278. struct mutex cb_list_lock;
  279. struct list_head cb_list;
  280. uint32_t exit_flag;
  281. struct completion complete;
  282. struct completion cb_complete;
  283. struct mutex req_lock;
  284. };
  285. struct msm_rpc_client_info {
  286. uint32_t pid;
  287. uint32_t cid;
  288. uint32_t prog;
  289. uint32_t vers;
  290. };
  291. struct msm_rpc_client *msm_rpc_register_client(
  292. const char *name,
  293. uint32_t prog, uint32_t ver,
  294. uint32_t create_cb_thread,
  295. int (*cb_func)(struct msm_rpc_client *, void *, int));
  296. struct msm_rpc_client *msm_rpc_register_client2(
  297. const char *name,
  298. uint32_t prog, uint32_t ver,
  299. uint32_t create_cb_thread,
  300. int (*cb_func)(struct msm_rpc_client *, struct rpc_request_hdr *req,
  301. struct msm_rpc_xdr *xdr));
  302. int msm_rpc_unregister_client(struct msm_rpc_client *client);
  303. int msm_rpc_client_req(struct msm_rpc_client *client, uint32_t proc,
  304. int (*arg_func)(struct msm_rpc_client *,
  305. void *, void *), void *arg_data,
  306. int (*result_func)(struct msm_rpc_client *,
  307. void *, void *), void *result_data,
  308. long timeout);
  309. int msm_rpc_client_req2(struct msm_rpc_client *client, uint32_t proc,
  310. int (*arg_func)(struct msm_rpc_client *,
  311. struct msm_rpc_xdr *, void *),
  312. void *arg_data,
  313. int (*result_func)(struct msm_rpc_client *,
  314. struct msm_rpc_xdr *, void *),
  315. void *result_data,
  316. long timeout);
  317. void *msm_rpc_start_accepted_reply(struct msm_rpc_client *client,
  318. uint32_t xid, uint32_t accept_status);
  319. int msm_rpc_send_accepted_reply(struct msm_rpc_client *client, uint32_t size);
  320. void *msm_rpc_server_start_accepted_reply(struct msm_rpc_server *server,
  321. uint32_t xid, uint32_t accept_status);
  322. int msm_rpc_server_send_accepted_reply(struct msm_rpc_server *server,
  323. uint32_t size);
  324. int msm_rpc_add_cb_func(struct msm_rpc_client *client, void *cb_func);
  325. void *msm_rpc_get_cb_func(struct msm_rpc_client *client, uint32_t cb_id);
  326. void msm_rpc_remove_cb_func(struct msm_rpc_client *client, void *cb_func);
  327. int msm_rpc_server_cb_req(struct msm_rpc_server *server,
  328. struct msm_rpc_client_info *clnt_info,
  329. uint32_t cb_proc,
  330. int (*arg_func)(struct msm_rpc_server *server,
  331. void *buf, void *data),
  332. void *arg_data,
  333. int (*ret_func)(struct msm_rpc_server *server,
  334. void *buf, void *data),
  335. void *ret_data, long timeout);
  336. int msm_rpc_server_cb_req2(struct msm_rpc_server *server,
  337. struct msm_rpc_client_info *clnt_info,
  338. uint32_t cb_proc,
  339. int (*arg_func)(struct msm_rpc_server *server,
  340. struct msm_rpc_xdr *xdr, void *data),
  341. void *arg_data,
  342. int (*ret_func)(struct msm_rpc_server *server,
  343. struct msm_rpc_xdr *xdr, void *data),
  344. void *ret_data, long timeout);
  345. void msm_rpc_server_get_requesting_client(
  346. struct msm_rpc_client_info *clnt_info);
  347. int xdr_send_pointer(struct msm_rpc_xdr *xdr, void **obj,
  348. uint32_t obj_size, void *xdr_op);
  349. int xdr_recv_pointer(struct msm_rpc_xdr *xdr, void **obj,
  350. uint32_t obj_size, void *xdr_op);
  351. int xdr_send_array(struct msm_rpc_xdr *xdr, void **addr, uint32_t *size,
  352. uint32_t maxsize, uint32_t elm_size, void *xdr_op);
  353. int xdr_recv_array(struct msm_rpc_xdr *xdr, void **addr, uint32_t *size,
  354. uint32_t maxsize, uint32_t elm_size, void *xdr_op);
  355. int xdr_recv_req(struct msm_rpc_xdr *xdr, struct rpc_request_hdr *req);
  356. int xdr_recv_reply(struct msm_rpc_xdr *xdr, struct rpc_reply_hdr *reply);
  357. int xdr_start_request(struct msm_rpc_xdr *xdr, uint32_t prog,
  358. uint32_t ver, uint32_t proc);
  359. int xdr_start_accepted_reply(struct msm_rpc_xdr *xdr, uint32_t accept_status);
  360. int xdr_send_msg(struct msm_rpc_xdr *xdr);
  361. #endif