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 65struct rpc_request_hdr 66{ 67 uint32_t xid; 68 uint32_t type; /* 0 */ 69 uint32_t rpc_vers; /* 2 */ 70 uint32_t prog; 71 uint32_t vers; 72 uint32_t procedure; 73 uint32_t cred_flavor; 74 uint32_t cred_length; 75 uint32_t verf_flavor; 76 uint32_t verf_length; 77}; 78 79typedef struct 80{ 81 uint32_t low; 82 uint32_t high; 83} rpc_reply_progmismatch_data; 84 85typedef struct 86{ 87} rpc_denied_reply_hdr; 88 89typedef 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 /* 102 * Following data is dependant on accept_stat 103 * If ACCEPTSTAT == PROG_MISMATCH then there is a 104 * 'rpc_reply_progmismatch_data' structure following the header. 105 * Otherwise the data is procedure specific 106 */ 107} rpc_accepted_reply_hdr; 108 109struct rpc_reply_hdr 110{ 111 uint32_t xid; 112 uint32_t type; 113 uint32_t reply_stat; 114#define RPCMSG_REPLYSTAT_ACCEPTED 0 115#define RPCMSG_REPLYSTAT_DENIED 1 116 union { 117 rpc_accepted_reply_hdr acc_hdr; 118 rpc_denied_reply_hdr dny_hdr; 119 } data; 120}; 121 122/* flags for msm_rpc_connect() */ 123#define MSM_RPC_UNINTERRUPTIBLE 0x0001 124 125/* use IS_ERR() to check for failure */ 126struct msm_rpc_endpoint *msm_rpc_open(void); 127/* Connect with the specified server version */ 128struct msm_rpc_endpoint *msm_rpc_connect(uint32_t prog, uint32_t vers, unsigned flags); 129uint32_t msm_rpc_get_vers(struct msm_rpc_endpoint *ept); 130/* check if server version can handle client requested version */ 131int msm_rpc_is_compatible_version(uint32_t server_version, 132 uint32_t client_version); 133 134int msm_rpc_close(struct msm_rpc_endpoint *ept); 135int msm_rpc_write(struct msm_rpc_endpoint *ept, 136 void *data, int len); 137int msm_rpc_read(struct msm_rpc_endpoint *ept, 138 void **data, unsigned len, long timeout); 139void msm_rpc_setup_req(struct rpc_request_hdr *hdr, 140 uint32_t prog, uint32_t vers, uint32_t proc); 141int msm_rpc_register_server(struct msm_rpc_endpoint *ept, 142 uint32_t prog, uint32_t vers); 143int msm_rpc_unregister_server(struct msm_rpc_endpoint *ept, 144 uint32_t prog, uint32_t vers); 145 146/* simple blocking rpc call 147 * 148 * request is mandatory and must have a rpc_request_hdr 149 * at the start. The header will be filled out for you. 150 * 151 * reply provides a buffer for replies of reply_max_size 152 */ 153int msm_rpc_call_reply(struct msm_rpc_endpoint *ept, uint32_t proc, 154 void *request, int request_size, 155 void *reply, int reply_max_size, 156 long timeout); 157int msm_rpc_call(struct msm_rpc_endpoint *ept, uint32_t proc, 158 void *request, int request_size, 159 long timeout); 160 161struct msm_rpc_server 162{ 163 struct list_head list; 164 uint32_t flags; 165 166 uint32_t prog; 167 uint32_t vers; 168 169 int (*rpc_call)(struct msm_rpc_server *server, 170 struct rpc_request_hdr *req, unsigned len); 171}; 172 173int msm_rpc_create_server(struct msm_rpc_server *server); 174 175#endif 176