]> bbs.cooldavid.org Git - net-next-2.6.git/blame - drivers/staging/dream/include/mach/msm_rpcrouter.h
PM / Runtime: Fix typo in status comparison causing warning
[net-next-2.6.git] / drivers / staging / dream / include / mach / msm_rpcrouter.h
CommitLineData
e79753ed
PM
1/** include/asm-arm/arch-msm/msm_rpcrouter.h
2 *
3 * Copyright (C) 2007 Google, Inc.
4 * Copyright (c) 2007-2009 QUALCOMM Incorporated
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#if CONFIG_MSM_AMSS_VERSION >= 6350
26/* RPC API version structure
27 * Version bit 31 : 1->hashkey versioning,
28 * 0->major-minor (backward compatible) versioning
29 * hashkey versioning:
30 * Version bits 31-0 hashkey
31 * major-minor (backward compatible) versioning
32 * Version bits 30-28 reserved (no match)
33 * Version bits 27-16 major (must match)
34 * Version bits 15-0 minor (greater or equal)
35 */
36#define RPC_VERSION_MODE_MASK 0x80000000
37#define RPC_VERSION_MAJOR_MASK 0x0fff0000
38#define RPC_VERSION_MAJOR_OFFSET 16
39#define RPC_VERSION_MINOR_MASK 0x0000ffff
40
41#define MSM_RPC_VERS(major, minor) \
42 ((uint32_t)((((major) << RPC_VERSION_MAJOR_OFFSET) & \
43 RPC_VERSION_MAJOR_MASK) | \
44 ((minor) & RPC_VERSION_MINOR_MASK)))
45#define MSM_RPC_GET_MAJOR(vers) (((vers) & RPC_VERSION_MAJOR_MASK) >> \
46 RPC_VERSION_MAJOR_OFFSET)
47#define MSM_RPC_GET_MINOR(vers) ((vers) & RPC_VERSION_MINOR_MASK)
48#else
49#define MSM_RPC_VERS(major, minor) (major)
50#define MSM_RPC_GET_MAJOR(vers) (vers)
51#define MSM_RPC_GET_MINOR(vers) 0
52#endif
53
54struct msm_rpc_endpoint;
55
56struct rpcsvr_platform_device
57{
58 struct platform_device base;
59 uint32_t prog;
60 uint32_t vers;
61};
62
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
69struct rpc_request_hdr
70{
71 uint32_t xid;
72 uint32_t type; /* 0 */
73 uint32_t rpc_vers; /* 2 */
74 uint32_t prog;
75 uint32_t vers;
76 uint32_t procedure;
77 uint32_t cred_flavor;
78 uint32_t cred_length;
79 uint32_t verf_flavor;
80 uint32_t verf_length;
81};
82
83typedef struct
84{
85 uint32_t low;
86 uint32_t high;
87} rpc_reply_progmismatch_data;
88
89typedef struct
90{
91} rpc_denied_reply_hdr;
92
93typedef struct
94{
95 uint32_t verf_flavor;
96 uint32_t verf_length;
97 uint32_t accept_stat;
98#define RPC_ACCEPTSTAT_SUCCESS 0
99#define RPC_ACCEPTSTAT_PROG_UNAVAIL 1
100#define RPC_ACCEPTSTAT_PROG_MISMATCH 2
101#define RPC_ACCEPTSTAT_PROC_UNAVAIL 3
102#define RPC_ACCEPTSTAT_GARBAGE_ARGS 4
103#define RPC_ACCEPTSTAT_SYSTEM_ERR 5
104#define RPC_ACCEPTSTAT_PROG_LOCKED 6
105 /*
106 * Following data is dependant on accept_stat
107 * If ACCEPTSTAT == PROG_MISMATCH then there is a
108 * 'rpc_reply_progmismatch_data' structure following the header.
109 * Otherwise the data is procedure specific
110 */
111} rpc_accepted_reply_hdr;
112
113struct rpc_reply_hdr
114{
115 uint32_t xid;
116 uint32_t type;
117 uint32_t reply_stat;
118#define RPCMSG_REPLYSTAT_ACCEPTED 0
119#define RPCMSG_REPLYSTAT_DENIED 1
120 union {
121 rpc_accepted_reply_hdr acc_hdr;
122 rpc_denied_reply_hdr dny_hdr;
123 } data;
124};
125
126/* flags for msm_rpc_connect() */
127#define MSM_RPC_UNINTERRUPTIBLE 0x0001
128
129/* use IS_ERR() to check for failure */
130struct msm_rpc_endpoint *msm_rpc_open(void);
131/* Connect with the specified server version */
132struct msm_rpc_endpoint *msm_rpc_connect(uint32_t prog, uint32_t vers, unsigned flags);
133uint32_t msm_rpc_get_vers(struct msm_rpc_endpoint *ept);
134/* check if server version can handle client requested version */
135int msm_rpc_is_compatible_version(uint32_t server_version,
136 uint32_t client_version);
137
138int msm_rpc_close(struct msm_rpc_endpoint *ept);
139int msm_rpc_write(struct msm_rpc_endpoint *ept,
140 void *data, int len);
141int msm_rpc_read(struct msm_rpc_endpoint *ept,
142 void **data, unsigned len, long timeout);
143void msm_rpc_setup_req(struct rpc_request_hdr *hdr,
144 uint32_t prog, uint32_t vers, uint32_t proc);
145int msm_rpc_register_server(struct msm_rpc_endpoint *ept,
146 uint32_t prog, uint32_t vers);
147int msm_rpc_unregister_server(struct msm_rpc_endpoint *ept,
148 uint32_t prog, uint32_t vers);
149
150/* simple blocking rpc call
151 *
152 * request is mandatory and must have a rpc_request_hdr
153 * at the start. The header will be filled out for you.
154 *
155 * reply provides a buffer for replies of reply_max_size
156 */
157int msm_rpc_call_reply(struct msm_rpc_endpoint *ept, uint32_t proc,
158 void *request, int request_size,
159 void *reply, int reply_max_size,
160 long timeout);
161int msm_rpc_call(struct msm_rpc_endpoint *ept, uint32_t proc,
162 void *request, int request_size,
163 long timeout);
164
165struct msm_rpc_server
166{
167 struct list_head list;
168 uint32_t flags;
169
170 uint32_t prog;
171 uint32_t vers;
172
173 int (*rpc_call)(struct msm_rpc_server *server,
174 struct rpc_request_hdr *req, unsigned len);
175};
176
177int msm_rpc_create_server(struct msm_rpc_server *server);
178
179#endif