blob: 292fbc3fa0c240874d4a7d972761201417b068a6 [file] [log] [blame]
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001/* Copyright (c) 2008-2011, Code Aurora Forum. All rights reserved.
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 */
12
13#ifndef DIAGCHAR_H
14#define DIAGCHAR_H
15
16#include <linux/init.h>
17#include <linux/module.h>
18#include <linux/mempool.h>
19#include <linux/mutex.h>
20#include <linux/workqueue.h>
21#include <mach/msm_smd.h>
22#include <asm/atomic.h>
23#include <asm/mach-types.h>
24/* Size of the USB buffers used for read and write*/
25#define USB_MAX_OUT_BUF 4096
26#define IN_BUF_SIZE 16384
27#define MAX_IN_BUF_SIZE 32768
28#define MAX_SYNC_OBJ_NAME_SIZE 32
29/* Size of the buffer used for deframing a packet
30 reveived from the PC tool*/
31#define HDLC_MAX 4096
32#define HDLC_OUT_BUF_SIZE 8192
33#define POOL_TYPE_COPY 1
34#define POOL_TYPE_HDLC 2
35#define POOL_TYPE_WRITE_STRUCT 4
36#define POOL_TYPE_ALL 7
37#define MODEM_DATA 1
38#define QDSP_DATA 2
39#define APPS_DATA 3
40#define SDIO_DATA 4
41#define WCNSS_DATA 5
42#define MODEM_PROC 0
43#define APPS_PROC 1
44#define QDSP_PROC 2
45#define WCNSS_PROC 3
46#define MSG_MASK_SIZE 8000
47#define LOG_MASK_SIZE 8000
48#define EVENT_MASK_SIZE 1000
Shalabh Jain69890aa2011-10-10 12:59:16 -070049#define USER_SPACE_DATA 8000
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070050#define PKT_SIZE 4096
51#define MAX_EQUIP_ID 12
52
53/* Maximum number of pkt reg supported at initialization*/
54extern unsigned int diag_max_registration;
55extern unsigned int diag_threshold_registration;
56
57#define APPEND_DEBUG(ch) \
58do { \
59 diag_debug_buf[diag_debug_buf_idx] = ch; \
60 (diag_debug_buf_idx < 1023) ? \
61 (diag_debug_buf_idx++) : (diag_debug_buf_idx = 0); \
62} while (0)
63
64struct diag_master_table {
65 uint16_t cmd_code;
66 uint16_t subsys_id;
67 uint32_t client_id;
68 uint16_t cmd_code_lo;
69 uint16_t cmd_code_hi;
70 int process_id;
71};
72
73struct bindpkt_params_per_process {
74 /* Name of the synchronization object associated with this proc */
75 char sync_obj_name[MAX_SYNC_OBJ_NAME_SIZE];
76 uint32_t count; /* Number of entries in this bind */
77 struct bindpkt_params *params; /* first bind params */
78};
79
80struct bindpkt_params {
81 uint16_t cmd_code;
82 uint16_t subsys_id;
83 uint16_t cmd_code_lo;
84 uint16_t cmd_code_hi;
85 /* For Central Routing, used to store Processor number */
86 uint16_t proc_id;
87 uint32_t event_id;
88 uint32_t log_code;
89 /* For Central Routing, used to store SMD channel pointer */
90 uint32_t client_id;
91};
92
93struct diag_write_device {
94 void *buf;
95 int length;
96};
97
98struct diag_client_map {
99 char name[20];
100 int pid;
101};
102
103/* This structure is defined in USB header file */
104#ifndef CONFIG_DIAG_OVER_USB
105struct diag_request {
106 char *buf;
107 int length;
108 int actual;
109 int status;
110 void *context;
111};
112#endif
113
114struct diagchar_dev {
115
116 /* State for the char driver */
117 unsigned int major;
118 unsigned int minor_start;
119 int num;
120 struct cdev *cdev;
121 char *name;
122 int dropped_count;
123 struct class *diagchar_class;
124 int ref_count;
125 struct mutex diagchar_mutex;
126 wait_queue_head_t wait_q;
127 struct diag_client_map *client_map;
128 int *data_ready;
129 int num_clients;
130 struct diag_write_device *buf_tbl;
131
132 /* Memory pool parameters */
133 unsigned int itemsize;
134 unsigned int poolsize;
135 unsigned int itemsize_hdlc;
136 unsigned int poolsize_hdlc;
137 unsigned int itemsize_write_struct;
138 unsigned int poolsize_write_struct;
139 unsigned int debug_flag;
140 /* State for the mempool for the char driver */
141 mempool_t *diagpool;
142 mempool_t *diag_hdlc_pool;
143 mempool_t *diag_write_struct_pool;
144 struct mutex diagmem_mutex;
145 int count;
146 int count_hdlc_pool;
147 int count_write_struct_pool;
148 int used;
149
150 /* State for diag forwarding */
151 unsigned char *buf_in_1;
152 unsigned char *buf_in_2;
153 unsigned char *buf_in_cntl;
154 unsigned char *buf_in_qdsp_1;
155 unsigned char *buf_in_qdsp_2;
156 unsigned char *buf_in_qdsp_cntl;
157 unsigned char *buf_in_wcnss;
158 unsigned char *buf_in_wcnss_cntl;
159 unsigned char *usb_buf_out;
160 unsigned char *apps_rsp_buf;
Shalabh Jain69890aa2011-10-10 12:59:16 -0700161 unsigned char *user_space_data;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700162 smd_channel_t *ch;
163 smd_channel_t *ch_cntl;
164 smd_channel_t *chqdsp;
165 smd_channel_t *chqdsp_cntl;
166 smd_channel_t *ch_wcnss;
167 smd_channel_t *ch_wcnss_cntl;
168 int in_busy_1;
169 int in_busy_2;
170 int in_busy_qdsp_1;
171 int in_busy_qdsp_2;
172 int in_busy_wcnss;
173 int read_len_legacy;
174 unsigned char *hdlc_buf;
175 unsigned hdlc_count;
176 unsigned hdlc_escape;
177#ifdef CONFIG_DIAG_OVER_USB
178 int usb_connected;
179 struct usb_diag_ch *legacy_ch;
180 struct work_struct diag_proc_hdlc_work;
181 struct work_struct diag_read_work;
182#endif
183 struct workqueue_struct *diag_wq;
184 struct work_struct diag_drain_work;
185 struct work_struct diag_read_smd_work;
186 struct work_struct diag_read_smd_cntl_work;
187 struct work_struct diag_read_smd_qdsp_work;
188 struct work_struct diag_read_smd_qdsp_cntl_work;
189 struct work_struct diag_read_smd_wcnss_work;
190 struct work_struct diag_read_smd_wcnss_cntl_work;
191 uint8_t *msg_masks;
192 uint8_t *log_masks;
193 int log_masks_length;
194 uint8_t *event_masks;
195 struct diag_master_table *table;
196 uint8_t *pkt_buf;
197 int pkt_length;
198 struct diag_request *write_ptr_1;
199 struct diag_request *write_ptr_2;
200 struct diag_request *usb_read_ptr;
201 struct diag_request *write_ptr_svc;
202 struct diag_request *write_ptr_qdsp_1;
203 struct diag_request *write_ptr_qdsp_2;
204 struct diag_request *write_ptr_wcnss;
205 int logging_mode;
206 int logging_process_id;
207#ifdef CONFIG_DIAG_SDIO_PIPE
208 unsigned char *buf_in_sdio;
209 unsigned char *usb_buf_mdm_out;
210 struct sdio_channel *sdio_ch;
211 int read_len_mdm;
212 int in_busy_sdio;
213 struct usb_diag_ch *mdm_ch;
214 struct work_struct diag_read_mdm_work;
215 struct workqueue_struct *diag_sdio_wq;
216 struct work_struct diag_read_sdio_work;
217 struct work_struct diag_remove_sdio_work;
Shalabh Jain5d9ba342011-08-10 13:51:54 -0700218 struct work_struct diag_close_sdio_work;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700219 struct diag_request *usb_read_mdm_ptr;
220 struct diag_request *write_ptr_mdm;
221#endif
222};
223
224extern struct diagchar_dev *driver;
225#endif