PageRenderTime 37ms CodeModel.GetById 18ms app.highlight 16ms RepoModel.GetById 1ms app.codeStats 0ms

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