blob: 5c685c3fd12e7504186e2b6685dcb23fed72bc00 [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
49#define PKT_SIZE 4096
50#define MAX_EQUIP_ID 12
51
52/* Maximum number of pkt reg supported at initialization*/
53extern unsigned int diag_max_registration;
54extern unsigned int diag_threshold_registration;
55
56#define APPEND_DEBUG(ch) \
57do { \
58 diag_debug_buf[diag_debug_buf_idx] = ch; \
59 (diag_debug_buf_idx < 1023) ? \
60 (diag_debug_buf_idx++) : (diag_debug_buf_idx = 0); \
61} while (0)
62
63struct diag_master_table {
64 uint16_t cmd_code;
65 uint16_t subsys_id;
66 uint32_t client_id;
67 uint16_t cmd_code_lo;
68 uint16_t cmd_code_hi;
69 int process_id;
70};
71
72struct bindpkt_params_per_process {
73 /* Name of the synchronization object associated with this proc */
74 char sync_obj_name[MAX_SYNC_OBJ_NAME_SIZE];
75 uint32_t count; /* Number of entries in this bind */
76 struct bindpkt_params *params; /* first bind params */
77};
78
79struct bindpkt_params {
80 uint16_t cmd_code;
81 uint16_t subsys_id;
82 uint16_t cmd_code_lo;
83 uint16_t cmd_code_hi;
84 /* For Central Routing, used to store Processor number */
85 uint16_t proc_id;
86 uint32_t event_id;
87 uint32_t log_code;
88 /* For Central Routing, used to store SMD channel pointer */
89 uint32_t client_id;
90};
91
92struct diag_write_device {
93 void *buf;
94 int length;
95};
96
97struct diag_client_map {
98 char name[20];
99 int pid;
100};
101
102/* This structure is defined in USB header file */
103#ifndef CONFIG_DIAG_OVER_USB
104struct diag_request {
105 char *buf;
106 int length;
107 int actual;
108 int status;
109 void *context;
110};
111#endif
112
113struct diagchar_dev {
114
115 /* State for the char driver */
116 unsigned int major;
117 unsigned int minor_start;
118 int num;
119 struct cdev *cdev;
120 char *name;
121 int dropped_count;
122 struct class *diagchar_class;
123 int ref_count;
124 struct mutex diagchar_mutex;
125 wait_queue_head_t wait_q;
126 struct diag_client_map *client_map;
127 int *data_ready;
128 int num_clients;
129 struct diag_write_device *buf_tbl;
130
131 /* Memory pool parameters */
132 unsigned int itemsize;
133 unsigned int poolsize;
134 unsigned int itemsize_hdlc;
135 unsigned int poolsize_hdlc;
136 unsigned int itemsize_write_struct;
137 unsigned int poolsize_write_struct;
138 unsigned int debug_flag;
139 /* State for the mempool for the char driver */
140 mempool_t *diagpool;
141 mempool_t *diag_hdlc_pool;
142 mempool_t *diag_write_struct_pool;
143 struct mutex diagmem_mutex;
144 int count;
145 int count_hdlc_pool;
146 int count_write_struct_pool;
147 int used;
148
149 /* State for diag forwarding */
150 unsigned char *buf_in_1;
151 unsigned char *buf_in_2;
152 unsigned char *buf_in_cntl;
153 unsigned char *buf_in_qdsp_1;
154 unsigned char *buf_in_qdsp_2;
155 unsigned char *buf_in_qdsp_cntl;
156 unsigned char *buf_in_wcnss;
157 unsigned char *buf_in_wcnss_cntl;
158 unsigned char *usb_buf_out;
159 unsigned char *apps_rsp_buf;
160 smd_channel_t *ch;
161 smd_channel_t *ch_cntl;
162 smd_channel_t *chqdsp;
163 smd_channel_t *chqdsp_cntl;
164 smd_channel_t *ch_wcnss;
165 smd_channel_t *ch_wcnss_cntl;
166 int in_busy_1;
167 int in_busy_2;
168 int in_busy_qdsp_1;
169 int in_busy_qdsp_2;
170 int in_busy_wcnss;
171 int read_len_legacy;
172 unsigned char *hdlc_buf;
173 unsigned hdlc_count;
174 unsigned hdlc_escape;
175#ifdef CONFIG_DIAG_OVER_USB
176 int usb_connected;
177 struct usb_diag_ch *legacy_ch;
178 struct work_struct diag_proc_hdlc_work;
179 struct work_struct diag_read_work;
180#endif
181 struct workqueue_struct *diag_wq;
182 struct work_struct diag_drain_work;
183 struct work_struct diag_read_smd_work;
184 struct work_struct diag_read_smd_cntl_work;
185 struct work_struct diag_read_smd_qdsp_work;
186 struct work_struct diag_read_smd_qdsp_cntl_work;
187 struct work_struct diag_read_smd_wcnss_work;
188 struct work_struct diag_read_smd_wcnss_cntl_work;
189 uint8_t *msg_masks;
190 uint8_t *log_masks;
191 int log_masks_length;
192 uint8_t *event_masks;
193 struct diag_master_table *table;
194 uint8_t *pkt_buf;
195 int pkt_length;
196 struct diag_request *write_ptr_1;
197 struct diag_request *write_ptr_2;
198 struct diag_request *usb_read_ptr;
199 struct diag_request *write_ptr_svc;
200 struct diag_request *write_ptr_qdsp_1;
201 struct diag_request *write_ptr_qdsp_2;
202 struct diag_request *write_ptr_wcnss;
203 int logging_mode;
204 int logging_process_id;
205#ifdef CONFIG_DIAG_SDIO_PIPE
206 unsigned char *buf_in_sdio;
207 unsigned char *usb_buf_mdm_out;
208 struct sdio_channel *sdio_ch;
209 int read_len_mdm;
210 int in_busy_sdio;
211 struct usb_diag_ch *mdm_ch;
212 struct work_struct diag_read_mdm_work;
213 struct workqueue_struct *diag_sdio_wq;
214 struct work_struct diag_read_sdio_work;
215 struct work_struct diag_remove_sdio_work;
Shalabh Jain5d9ba342011-08-10 13:51:54 -0700216 struct work_struct diag_close_sdio_work;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700217 struct diag_request *usb_read_mdm_ptr;
218 struct diag_request *write_ptr_mdm;
219#endif
220};
221
222extern struct diagchar_dev *driver;
223#endif