Project

General

Profile

Qualcomm Kernel » History » Version 16

laforge, 12/26/2016 06:59 PM

1 6 laforge
{{>toc}}
2
3 1 laforge
h1. Qualcomm Kernel
4
5 13 laforge
Random notes about the Qualcomm Kernel as used on the MDM9615 and MDM9x07.  May also apply to other Qualcomm Linux based systems such as Android smartphones.
6 1 laforge
7
h2. diag
8
9
h3. diag forwarding
10
11
<pre>
12
drivers/char/diag/diagfwd.[ch]
13
drivers/usb/gadget/f_diag.[ch]
14
drivers/usb/misc/diag_bridge.c
15
</pre>
16
17
* the usb diag gadget handles diag packet read/write over usb
18
* issues events like USB_DIAG_READ_DONE
19
* picked up by diagfwd.c
20
** can forward diag requests via SMD shared memory to other processors
21
22
h3. diag char
23
24 6 laforge
The kernel exports a /dev/diag char device which userspce processes can
25
use to register/listen for DIAG events from the system, or actually
26
register a DIAG 'subsystem' themselves which can then be controlled from
27
QXDM.
28
29 1 laforge
<pre>
30
drivers/char/diag/diagchar_core.c
31
</pre>
32
33
* ioctl()s for diag configuration
34
* supports several concurrent diag clients
35
* diag logging can be directed to USB/HSIC, character device and more
36
** {USB,CALLBACK,MEMORY_DEVICE,UART,NO_LOGGING}_MODE
37
38 5 laforge
drivers/char/diag/diag_dci.c
39 1 laforge
40
* DCI table is a routing table where pid/sockets can register for a
41
  given DCI.  socket close/cleanup code releases all DCI routes for
42
  that socket.
43
44 7 laforge
h4. DIAG_IOCTL_COMMAND_REG
45
46
* Register a new DIAG command so it can be used from the outside world (QXDM)
47
* use 'struct diag_cmd_reg_entry_t' per command
48
* driver keeps a driver->cmd_reg_list of registered commands
49
50
h4. DIAG_IOCTL_COMMAND_DEREG
51
52
* unregister debug command
53
54
h4. DIAG_IOCTL_GET_DELAYED_RSP_ID
55
56
h4. DIAG_IOCTL_DCI_REG
57
58
h4. DIAG_IOCTL_DCI_DEINIT
59
60
h4. DIAG_IOCTL_DCI_SUPPORT
61
62
h4. DIAG_IOCTL_DCI_HEALTH_STATS
63
64
h4. DIAG_IOCTL_DCI_LOG_STATUS
65
66
h4. DIAG_IOCTL_DCI_EVENT_STATUS
67
68
h4. DIAG_IOCTL_DCI_CLEAR_LOGS
69
70
h4. DIAG_IOCTL_DCI_CLEAR_EVENTS
71
72
h4. DIAG_IOCTL_LSM_DEINIT
73
74
h4. DIAG_IOCTL_SWITCH_LOGGING
75
76
* switch between USB and shared-memory diag
77
* 
78
79
h4. DIAG_IOCTL_REMOTE_DEV
80
81
h4. DIAG_IOCTL_VOTE_REAL_TIME
82
83
h4. DIAG_IOCTL_GET_REAL_TIME
84
85
h4. DIAG_IOCTL_PERIPHERAL_BUF_CONFIG
86
87
h4. DIAG_IOCTL_PERIPHERAL_BUF_DRAIN
88
89
h4. DIAG_IOCTL_REGISTER_CALLBACK
90
91
* doen't really do anything but checking arguments ?!?
92
93
h4. DIAG_IOCTL_HDLC_TOGGLE
94
95
enable or disable HDLC framing of /dev/diag
96 6 laforge
97 12 laforge
98
h2. IRSC (IPC Router Security Control)
99
100
FIXME
101
102 1 laforge
h2. SMD (shared memory)
103
104
* SMD sub-systems:
105
** Modem (assumed to be hexagon with modem firmware?)
106
** Q6 (formerly known as LPASS == Low Power Audio SubSystem)
107
** DSPS
108
** WCNSS (Wireless Connectivity Sub System) aka 'riva'
109
** RPM (Resource Power Manager)
110
* inter-processor-interrupts for various 'edges'
111
112
h3. core driver
113
114
* arch/arm/mach-msm/smd.c
115
116
h4. api
117
118
* smd_open()
119
* smd_close()
120
* smd_write*()
121
* smd_read*()
122 3 laforge
* smsm_*()
123 1 laforge
124 16 laforge
h3. smd_tty
125
126
Seems to expose tty devices (/dev/smdN) bound to SMD channels.
127
128
h3. smd_nmea
129
130
Exposes a tty device (/dev/nmea) bound to a SMD channel named "GPSNMEA".
131
132 12 laforge
h3. MSM IPC (Inter Process Communications) socket
133 1 laforge
134 12 laforge
Qualcomm implements a socket-based inter process communication on Linux.  It is implemented using a new address family, @AF_MSM_IPC@ (27).
135
136
The socket is used as datagram type socket (SOCK_DGRAM).
137
138
The socket address of a related socket consists of:
139
140
* the socket family (AF_MSM_IPC)
141
* a @struct msm_ipc_addr@, consisting of
142
** a single address type byte
143
** a port address (node_id, port_id)
144
** a port name (service, instance)
145
146 1 laforge
* arch/arm/mach-msm/ipc_socket.c
147
* AF_MSM_IPC
148 3 laforge
149
h3. packet ports
150 1 laforge
151
* Some kind of packet oriented interface towards the SMD
152
* msm_smd_pkt.c contains driver
153
** smdpkt0..7+smd22 devices, 2048 byte buffer
154
** open/release/read/write/poll syscalls implemented
155 10 laforge
156
h3. available SMD devices
157
158
From an EC25:
159
<pre>
160
Primary allocation table:
161
root@mdm9607-perf:~# cat /sys/kernel/debug/smd/ch
162
ID|CHANNEL NAME       |T|PROC |STATE  |FIFO SZ|RDPTR  |WRPTR  |FLAGS   |DATAPEN
163
-------------------------------------------------------------------------------
164
 4|rpm_requests       |P|APPS |OPENED |0x00400|0x001E0|0x001E0|DCCiwRsB|0x00000
165
  |                   | |RPM  |OPENED |0x00400|0x00118|0x00118|DCCiwrsB|0x00000
166
-------------------------------------------------------------------------------
167
 5|rpm_requests       |P|MDMSW| Access Restricted
168
  |                   | |RPM  | Access Restricted
169
-------------------------------------------------------------------------------
170
 6|rpm_requests       |P|WCNSS| Access Restricted
171
  |                   | |RPM  | Access Restricted
172
-------------------------------------------------------------------------------
173
 7|rpm_requests       |P|TZ   | Access Restricted
174
  |                   | |RPM  | Access Restricted
175
-------------------------------------------------------------------------------
176
 8|rpm_requests       |P|ADSP | Access Restricted
177
  |                   | |RPM  | Access Restricted
178
-------------------------------------------------------------------------------
179
180
181
APPS <-> MDMSW Primary allocation table:
182
ID|CHANNEL NAME       |T|PROC |STATE  |FIFO SZ|RDPTR  |WRPTR  |FLAGS   |DATAPEN
183
-------------------------------------------------------------------------------
184
 0|DS                 |S|APPS |OPENED |0x02000|0x00000|0x00000|dcCiwrsb|0x00000
185
  |                   | |MDMSW|OPENED |0x02000|0x00000|0x00000|dCciwrsb|0x00000
186
-------------------------------------------------------------------------------
187
 1|IPCRTR             |P|APPS |OPENED |0x02000|0x012E4|0x012E4|DCCiwrsB|0x00000
188
  |                   | |MDMSW|OPENED |0x02000|0x011F8|0x011F8|DCCiwrsB|0x00000
189
-------------------------------------------------------------------------------
190
 2|SSM_RTR_MODEM_APPS |P|APPS |CLOSED |0x02000|0x00000|0x00000|dcciwrsb|0x00000
191
  |                   | |MDMSW|OPENING|0x02000|0x00000|0x00000|DCCiwrSb|0x00000
192
-------------------------------------------------------------------------------
193
 3|DIAG_2_CMD         |P|APPS |OPENED |0x02000|0x00000|0x00000|DCCiwrsb|0x00000
194
  |                   | |MDMSW|OPENED |0x02000|0x00000|0x00000|DCCiwrsb|0x00000
195
-------------------------------------------------------------------------------
196
 4|DIAG_2             |P|APPS |OPENED |0x02000|0x00000|0x00000|DCCiwrsb|0x00000
197
  |                   | |MDMSW|OPENED |0x02000|0x00000|0x00000|DCCiwrsb|0x00000
198
-------------------------------------------------------------------------------
199
 5|DIAG_CNTL          |P|APPS |OPENED |0x02000|0x00062|0x00062|DCCiwrsb|0x00000
200
  |                   | |MDMSW|OPENED |0x02000|0x007F5|0x007F5|DCCiwrsB|0x00000
201
-------------------------------------------------------------------------------
202
 6|DIAG_CMD           |P|APPS |OPENED |0x02000|0x00000|0x00000|DCCiwrsb|0x00000
203
  |                   | |MDMSW|OPENED |0x02000|0x00000|0x00000|DCCiwrsb|0x00000
204
-------------------------------------------------------------------------------
205
 7|DIAG               |P|APPS |OPENED |0x02000|0x00000|0x00000|DCCiwrsb|0x00000
206
  |                   | |MDMSW|OPENED |0x02000|0x00026|0x00026|DCCiwrsB|0x00000
207
-------------------------------------------------------------------------------
208
 8|apr_audio_svc      |P|APPS |OPENED |0x02000|0x002F0|0x002F0|DCCiwrsB|0x00000
209
  |                   | |MDMSW|OPENED |0x02000|0x00248|0x00248|DCCiwrsB|0x00000
210
-------------------------------------------------------------------------------
211
 9|apr_apps2          |P|APPS |CLOSED |0x02000|0x00000|0x00000|dcciwrsb|0x00000
212
  |                   | |MDMSW|OPENING|0x02000|0x00000|0x00000|DCCiwrSb|0x00000
213
-------------------------------------------------------------------------------
214
10|DATA1              |P|APPS |OPENED |0x02000|0x00000|0x00000|DCCiwrsB|0x00000
215
  |                   | |MDMSW|OPENED |0x02000|0x00000|0x00000|dCciwrsb|0x00000
216
-------------------------------------------------------------------------------
217
11|DATA2              |P|APPS |CLOSED |0x02000|0x00000|0x00000|dcciwrsb|0x00000
218
  |                   | |MDMSW|OPENING|0x02000|0x00000|0x00000|dCciwrSb|0x00000
219
-------------------------------------------------------------------------------
220
12|DATA3              |P|APPS |OPENED |0x02000|0x00000|0x00000|dcCiwrsb|0x00000
221
  |                   | |MDMSW|OPENED |0x02000|0x00000|0x00000|dCciwrsb|0x00000
222
-------------------------------------------------------------------------------
223
13|DATA4              |P|APPS |OPENED |0x02000|0x00000|0x00000|DCCiwrsB|0x00000
224
  |                   | |MDMSW|OPENED |0x02000|0x00000|0x00000|dCciwrsb|0x00000
225
-------------------------------------------------------------------------------
226
14|DATA11             |S|APPS |OPENED |0x02000|0x00089|0x00089|dcCiwRsb|0x00000
227
  |                   | |MDMSW|OPENED |0x02000|0x0012B|0x0012B|dCciwrsB|0x00000
228
-------------------------------------------------------------------------------
229
15|DATA40             |P|APPS |CLOSED |0x02000|0x00000|0x00000|dcciwrsb|0x00000
230
  |                   | |MDMSW|OPENING|0x02000|0x00000|0x00000|dcciwrSb|0x00000
231
-------------------------------------------------------------------------------
232
16|DATA5_CNTL         |P|APPS |CLOSED |0x00400|0x00000|0x00000|dcciwrsb|0x00000
233
  |                   | |MDMSW|OPENING|0x00400|0x00000|0x00000|DCCiwrSb|0x00000
234
-------------------------------------------------------------------------------
235
17|DATA40_CNTL        |P|APPS |OPENED |0x02000|0x00000|0x00000|DCCiwrsB|0x00000
236
  |                   | |MDMSW|OPENED |0x02000|0x00100|0x00100|DCCiwrsB|0x00000
237
-------------------------------------------------------------------------------
238
</pre>
239 6 laforge
240 14 laforge
From an [[EC20]]:
241
242
<pre>
243
/sys/kernel/debug/smd # cat ch 
244
ch00:   OPENED(0000/0000) dcCiwrsb <->   OPENED(0000/0000) dCciwrsB :  2000
245
ch04:   OPENED(27336/27336) DCCiwrsB <->   OPENED(6552/6552) DCCiwrsB :  8000
246
ch05:   OPENED(0000/0000) DCCiwrsb <->   OPENED(12568/12568) DCCiwrsB : 10000
247
ch06:   OPENED(1872/1872) DCCiwrsB <->   OPENED(0216/0216) DCCiwrsB :  2000
248
ch07:   CLOSED(0000/0000) dcciwrsb <->  OPENING(0000/0000) DCCiwrSb :  2000
249
ch08:   CLOSED(0000/0000) dcciwrsb <->  OPENING(0000/0000) DCCiwrSb :   400
250
ch09:   OPENED(0952/0952) DCCiwrsb <->   OPENED(0438/0438) DCCiwrsB :   400
251
ch10:   OPENED(0000/0000) DCCiwrsb <->   OPENED(0000/0000) DCCiwrsb :  2000
252
ch11:   CLOSED(0000/0000) dcciwrsb <->  OPENING(0000/0000) DCCiwrSb :  2000
253
ch12:   OPENED(0000/0000) DCCiwrsb <->   OPENED(0000/0000) DCCiwrsb :  2000
254
ch13:   CLOSED(0000/0000) dcciwrsb <->  OPENING(0000/0000) DCCiwrSb :  2000
255
ch14:   OPENED(0480/0480) DCCiwrsB <->   OPENED(0376/0376) DCCiwrsB :   400
256
ch15:   CLOSED(0000/0000) dcciwrsb <->  OPENING(0000/0000) DCCiwrSb :  2000
257
ch16:   CLOSED(0000/0000) dcciwrsb <->  OPENING(0000/0000) DCCiwrSb :  2000
258
ch17:   CLOSED(0000/0000) dcciwrsb <->  OPENING(0000/0000) DCCiwrSb :   400
259
ch18:   OPENED(0000/0000) DCCiwrsb <->   OPENED(0000/0000) DCCiwrsb :  2000
260
ch19:   OPENED(0952/0952) DCCiwrsb <->   OPENED(0370/0370) DCCiwrsB :   400
261
ch20:   OPENED(0021/0021) DCCiwrsb <->   OPENED(0078/0078) DCCiwrsB :  2000
262
ch21:   CLOSED(0000/0000) dcciwrsb <->  OPENING(0000/0000) DCCiwrSb :  2000
263
ch22:   CLOSED(0000/0000) dcciwrsb <->  OPENING(0000/0000) dCciwrSb :  2000
264
ch23:   OPENED(0000/0000) dcCiwrsb <->   OPENED(0000/0000) dCciwrsB :  2000
265
ch24:   OPENED(0000/0000) DCCiwrsb <->   OPENED(0000/0000) dCciwrsb :  2000
266
ch25:   CLOSED(0000/0000) dcciwrsb <->  OPENING(0000/0000) dCciwrSb :  2000
267
ch26:   CLOSED(0000/0000) dcciwrsb <->  OPENING(0000/0000) dCciwrSb :  2000
268
ch27:   CLOSED(0000/0000) dcciwrsb <->  OPENING(0000/0000) dcciwrSb :  2000
269
ch28:   OPENED(0000/0000) DCCiwrsb <->   OPENED(0000/0000) DCCiwrsB :  2000
270
ch29:   CLOSED(0000/0000) dcciwrsb <->  OPENING(0000/0000) dcciwrSb :  2000
271
ch30:   OPENED(0295/0295) DCCiwrsB <->   OPENED(0563/0563) DCCiwrsB :   400
272
ch31:   OPENED(0237/0237) DCCiwrsB <->   OPENED(0415/0415) DCCiwrsB :   400
273
ch32:   OPENED(0237/0237) DCCiwrsB <->   OPENED(0415/0415) DCCiwrsB :   400
274
ch33:   OPENED(0237/0237) DCCiwrsB <->   OPENED(0415/0415) DCCiwrsB :   400
275
ch34:   OPENED(0000/0000) DCCiwrsb <->   OPENED(0000/0000) dCciwrsb :  2000
276
</pre>
277
278
<pre>
279
/sys/kernel/debug/smd # cat tbl
280
name=DS cid=0 ch type=0 xfer type=1 ref_count=2
281
name= cid=0 ch type=0 xfer type=0 ref_count=0
282
name= cid=0 ch type=0 xfer type=0 ref_count=0
283
name= cid=0 ch type=0 xfer type=0 ref_count=0
284
name=MSGR_SMD_P1 cid=4 ch type=11 xfer type=2 ref_count=2
285
name=MSGR_SMD_P0 cid=5 ch type=11 xfer type=2 ref_count=2
286
name=IPCRTR cid=6 ch type=1 xfer type=2 ref_count=1
287
name=IPCRTR cid=7 ch type=2 xfer type=2 ref_count=1
288
name=sys_mon cid=8 ch type=1 xfer type=2 ref_count=1
289
name=DIAG_CNTL cid=9 ch type=1 xfer type=2 ref_count=2
290
name=DIAG cid=10 ch type=1 xfer type=2 ref_count=2
291
name=apr_audio_svc cid=11 ch type=1 xfer type=2 ref_count=1
292
name=apr_voice_svc cid=12 ch type=2 xfer type=2 ref_count=2
293
name=apr_apps2 cid=13 ch type=1 xfer type=2 ref_count=1
294
name=RPCRPY_CNTL cid=14 ch type=0 xfer type=2 ref_count=2
295
name=IPCROUTER cid=15 ch type=0 xfer type=0 ref_count=1
296
name=SSM_RTR cid=16 ch type=0 xfer type=2 ref_count=1
297
name=sys_mon cid=17 ch type=0 xfer type=2 ref_count=1
298
name=DIAG_2 cid=18 ch type=0 xfer type=2 ref_count=2
299
name=DIAG_CNTL cid=19 ch type=0 xfer type=2 ref_count=2
300
name=DIAG cid=20 ch type=0 xfer type=2 ref_count=2
301
name=apr_voice_svc cid=21 ch type=0 xfer type=2 ref_count=1
302
name=DATA1 cid=22 ch type=0 xfer type=2 ref_count=2
303
name=DATA2 cid=23 ch type=0 xfer type=2 ref_count=2
304
name=DATA3 cid=24 ch type=0 xfer type=2 ref_count=2
305
name=DATA4 cid=25 ch type=0 xfer type=2 ref_count=2
306
name=DATA11 cid=26 ch type=0 xfer type=1 ref_count=2
307
name=DATA40 cid=27 ch type=0 xfer type=2 ref_count=2
308
name=DATA40_CNTL cid=28 ch type=0 xfer type=2 ref_count=2
309
name=DATA8 cid=29 ch type=0 xfer type=2 ref_count=2
310
name=DATA5_CNTL cid=30 ch type=0 xfer type=2 ref_count=2
311
name=DATA6_CNTL cid=31 ch type=0 xfer type=2 ref_count=2
312
name=DATA7_CNTL cid=32 ch type=0 xfer type=2 ref_count=2
313
name=DATA8_CNTL cid=33 ch type=0 xfer type=2 ref_count=2
314
name=GPSNMEA cid=34 ch type=0 xfer type=2 ref_count=2
315
</pre>
316
317
318 6 laforge
h2. smem_log
319
320
This is some kidn of high speed shared memory based event log to which all processors can log events.
321
322
Userspace applications can use write() to @/dev/smem_log@ to add log entries.
323
324
Qualcomm uses a proprietary minimal shim layer offering SMEM_LOG_EVENT and SMEM_LOG_EVENT6 macros
325
that can be used to write events with an event ID plus three data words or six data words, respectively.
326
327
The shared memory log can be read from linux userspace via debugfs, see the devices in @/sys/kernel/debug/smem_log@
328
and simply use @cat@ on them. You will get lines like
329
<pre>
330
MODM: 3982377401 000d0000: 00000001: 03000019 01000028 01000015 53505041 00000061 5f696d71
331
MODM: 3982378159      QCSI: 00000004: 00040029 00240015 00000003 00000001 0000002b 00000000
332
MODM: 3982378619 000d0000: 00000001: 03000019 0100002b 01000015 53505041 00000061 5f696d71
333
APPS: 3982397356      QCCI: 00000005: 0004001d 0024000e 00000003 00000003 00000019 00000000
334
APPS: 3982400571      QCCI: 00000005: 00040029 0024000e 00000003 00000003 00000019 00000000
335
MODM: 1841235211      QCSI: 00000004: 0004001e 0024001c 00000003 00000001 00000028 00000000
336
MODM: 1841236665 000d0000: 00000001: 03000019 01000028 0101001c 53505041 00000061 5f696d71
337
MODM: 1841241411      QCSI: 00000004: 0004002a 0024001c 00000003 00000001 0000002b 00000000
338
MODM: 1841242246 000d0000: 00000001: 03000019 0100002b 0100001c 53505041 00000061 5f696d71
339
MODM: 1841243796      QCSI: 00000004: 0004002b 00660019 00000003 00000001 0000002b 00000000
340
MODM: 1841244286 000d0000: 00000001: 03000019 0100002b 01000019 53505041 00000061 5f696d71
341
APPS: 1841255456      QCCI: 00000005: 0004001e 00240015 00000003 00000003 00000019 00000000
342
MODM: 1841255335 000d0000: 00000002: 0100ffff 0300ffff 07000014 53505041 0000016c 74646d73
343
MODM: 1841255828 000d0000: 00000702: 00000001 00000028 00000007
344 1 laforge
APPS: 1841261430      QCCI: 00000005: 0004002a 00240015 00000003 00000003 00000019 00000000
345
</pre>
346 12 laforge
347
More information in @smem_log.h@
348 8 laforge
349
h2. rmnet
350
351
"remote network" ?
352
* consists of control channel and data channel
353
* data channel carries IP data
354
* control channel carries QMI messages
355
356
* drivers/net/ethernet/msm/msm_rmnet_bam.c
357
** ioctl() to set ethernet or rawip (RMNET_IOCTL_SET_LLP_ETHERNET, RMNET_IOCTL_SET_LLP_IP, RMNET_IOCTL_GET_LLP), initial boot time config is ETHERNET
358
** use msm_bam_dmux_open() to attach
359
** use RMNET_IOCTL_GET_EPID to get the BAM_DMUX endpoint id
360
361
h2. bam (Bus Access Manager/Module)
362
363
* The Bus Access Manager/Module (BAM) can be
364
  considered as a distributed data mover (DM)
365
* some kind of DMA controller/engine
366
* A number of the on-chip devices have their own BAM DMA controller
367
  and use it to move data between system memory and peripherals or
368
  between two peripherals.
369
370
Files:
371
<pre>
372
./drivers/dma/qcom_bam_dma.c
373
./drivers/net/ethernet/msm/msm_rmnet_bam.c
374
./drivers/platform/msm/sps/bam.c
375
./drivers/platform/msm/sps/sps_bam.c
376
./drivers/platform/msm/usb_bam.c
377
</pre>
378
379
* channels (BAM_DMUX_)
380
** RMNET_0...7
381
** USB_RMNET_0
382
** DATA_REV_RMNET_0..8
383
** USB_DPL
384
385
seem to be be based on dmux ./drivers/soc/qcom/bam_dmux.c
386
387
h2. IPA (Internet Packet Accelerator)
388
389
Internet Packet Accelerator (IPA) is a programmable protocol
390
processor HW block. It is designed to support generic HW processing
391
of UL/DL IP packets for various use cases independent of radio
392
technology.
393
394
See drivers/platform/msm/ipa/
395
396 11 laforge
http://www.sumobrain.com/patents/wipo/Accelerator/WO2013063791A1.pdf
397
398
399 8 laforge
h2. bam2bam
400
401
maybe soem kind of direct connection between two peripherals by means of the BAM?
402
403
h2. Android USB Gadget
404
405
see [[Android_USB_Gadget]]
406 9 laforge
407
h2. IPC Logging
408
409
see [[IPC_Logging]]
Add picture from clipboard (Maximum size: 48.8 MB)