summaryrefslogtreecommitdiffstats
path: root/Replicant_contributors_meeting_27_28_July_2019_Paris_France/modems/Replicant_and_modems_Samsung-ipc.tex
blob: 704d123b2563d5f7fa34128b916e67c67efdc966 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
\documentclass{beamer}
\usepackage[english]{babel}
\usepackage{color}
\usepackage{graphicx}
\usepackage{ifthen}
\usepackage[utf8]{inputenc}
\usepackage{listings}
\usepackage{pdfpages}

\lstdefinestyle{terminal}{
  backgroundcolor=\color{black},
  basicstyle=\scriptsize\color{green},
}

%% Based on:
%% https://tex.stackexchange.com/questions/136900/insert-a-full-page-image
\newcommand{\pictureframe}[1] {
  {
    \begin{frame}
      \noindent
      \resizebox{\textwidth}{\textheight}
                {\includegraphics{#1}}
                \hspace*{-\textwidth}
    \end{frame}
  }
}

\usetheme{Singapore}

\title{Samsung-ipc compatible modems in Replicant}
\author{Denis 'GNUtoo' Carikli}
\date{\today}

\begin{document}

\maketitle

%% TODO: Using \itemize{} fails to compile
%% TODO: convert \center frames to chapter title

\begin{frame}
  \center{Samsung IPC}
\end{frame}

\begin{frame}
  \center{Samsung IPC: Hardware part}
\end{frame}

\begin{frame}
  \center{XMM626 $\leftarrow$RAM$\rightarrow$SOC }
  \begin{itemize}
  \item Galaxy S           (I9100)
  \item Nexus S            (I902x)
  \item Galaxy Tab   (unsupported)
  \end{itemize}
\end{frame}

\begin{frame}
  \center{XMM626 $\leftarrow$RAM$\rightarrow$SOC: Isolation }
  \begin{itemize}
    \item Nexus S: The modem kernel driver shows that part of a RAM chip is shared between the modem and the SOC
    \item No hardware guarantees that the modem cannot take control of the SOC
    \item IOMMU:
      \begin{itemize}
      \item Requires a mainline kernel to trust the code
      \item And the SOC documentation on that...
      \item And people having analyzed its security...
      \item And to be setup before the RAM is even initialized...
      \item But the bootloader is not free software...
      \end{itemize}
  \end{itemize}
\end{frame}

\begin{frame}
  \center{XMM626 $\leftarrow$MIPI$\rightarrow$SOC }
  \begin{itemize}
  \item Galaxy Nexus       (I9250)
  \item Galaxy Tab II 7.0  (P3100)
  \item Galaxy Tab II 10.1 (P5100)
  \end{itemize}
\end{frame}

\begin{frame}
  \center{XMM626 $\leftarrow$MIPI$\rightarrow$SOC: Isolation }
  \begin{itemize}
    \item Not analyzed in depth but probably ok
    \item Same interface than camera and screens
  \end{itemize}
\end{frame}

\begin{frame}
  \center{XMM626 $\leftarrow$HSIC$\rightarrow$SOC }
  \begin{itemize}
  \item Galaxy S2          (I9100)
  \item Galaxy SIII        (I9300)
  \item Galaxy Note        (N7000)
  \item Galaxy Note II     (N7100)
  \item Galaxy Note 8.0    (N5100)
  \end{itemize}
\end{frame}

\begin{frame}
  \center{XMM626 $\leftarrow$HSIC$\rightarrow$SOC: Isolation }
  \begin{itemize}
  \item No DMA to the SOC RAM
  \item USB-like bus: USB without the PHY
  \item The host need to reset the bus to get the devices re-enumerated
  \item $\rightarrow$ More complicated for the modem to become a keyboard
  \item Ideally (not looked into yet):
  \begin{itemize}
  \item usbguard
  \item USB peripherals whitelist
  \item $\rightarrow$ re-usable for USB modems (GTA04, PinePhone, Librem5, etc).
  \end{itemize}
  \end{itemize}
\end{frame}

\begin{frame}
  \center{Samsung IPC}
  \begin{itemize}
  \item We will look more specifically at the case with the XMM626 connected through HSIC.
  \item Other transports are similar: transports are abstracted by the kernel driver and libsamsung-ipc transport drivers.
  \end{itemize}
\end{frame}

\pictureframe{output/xmm626_hsic.png}

\begin{frame}
  \center{The samsung-ipc protocol}
  \begin{itemize}
  \item Asyncronous
  \item $\rightarrow$ You get asyncronous responses from the modem
  \item $\rightarrow$ You match with the request (sequence numbers)
  \item $\rightarrow$ libsamsung-ril needs receive asyncronous responses too
  \item $\rightarrow$ More complex design with callbacks
  \end{itemize}
\end{frame}

\begin{frame}
  \center{libsamsung-ril}
\end{frame}

\begin{frame}
  \center{The initialization not very different from the reference-ril}
\end{frame}
\lstset{language=C}
\begin{lstlisting}
  RIL_RadioFunctions ril_radio_functions = {
    RIL_VERSION,
    ril_on_request,
    ril_on_state_request,
    ril_supports,
    ril_on_cancel,
    ril_get_version
  };
  ...

  const RIL_RadioFunctions *RIL_Init(
            const struct RIL_Env *env, int argc,
            char **argv) {
        ...
        return radio_functions;
  }
\end{lstlisting}

\begin{frame}
  \center{The interface with rild is not that different either}
\end{frame}
\lstset{language=C}
\begin{lstlisting}
  void ril_on_request(int request, void *data,
                   size_t size, RIL_Token token) {
  ...
  ril_request_register(request, data, size, token);
  ...
}
\end{lstlisting}

\begin{frame}
\center{ril\_request\_register}
\end{frame}
\lstset{language=C}
\begin{lstlisting}
  int ril_request_register(int request, void *data,
                   size_t size, RIL_Token token) {
  ...
  list_end = ril_data->requests;
  ...
  list = list_head_alloc(list_end, NULL,
                        (void *) ril_request);
  ...
  ril_data->requests = list;
}
\end{lstlisting}

\begin{frame}
  \center{Global ril\_Data variable}
\end{frame}

\lstset{language=bash}
\begin{lstlisting}[style=terminal]
$ git grep "extern.*ril_data;"
samsung-ril.h:extern struct ril_data *ril_data;
\end{lstlisting}

\begin{frame}
  \center{Why?}
  \begin{itemize}
  \item Asyncronous design $\rightarrow$ Faster
  \item Enqueue the request and continue serving new requests.
  \item We will see how getting the response works in a second time
  \end{itemize}
\end{frame}

\begin{frame}
  \begin{itemize}
  \item We got a request to power on the phone from the RIL
  \item We got rid of it by adding it to a list
  \item Now what happens to it?
  \end{itemize}
\end{frame}

\begin{frame}
  \center{RIL\_Init}
\end{frame}
\lstset{language=C}
\begin{lstlisting}
  const RIL_RadioFunctions *RIL_Init(
           const struct RIL_Env *env, int argc,
           char **argv) {
  ...
  rc = pthread_create(&ril_data->request_thread,
                 &attr, ril_request_loop, NULL);
  ...
}
\end{lstlisting}

\begin{frame}
  \center{ril\_request\_loop}
\end{frame}
\lstset{language=C}
\begin{lstlisting}

void *ril_request_loop(void *data) { ...
  while (1) {
    do {
      request = ril_request_find_status(
                           RIL_REQUEST_UNHANDLED);
      ...
      request->status = RIL_REQUEST_PENDING;
    } while (request != NULL);
    do {
      ...
      request = ril_request_find_status(
                             RIL_REQUEST_PENDING);
      ...
      rc = ril_request_dispatch(request);
    } while (request != NULL);
  }
\end{lstlisting}

\begin{frame}
  \center{ril\_request\_dispatch}
\end{frame}

\lstset{language=C}
\begin{lstlisting}
  int ril_request_dispatch(
  struct ril_request *request) {
    ...
    for (i = 0; i < ril_request_handlers_count;
    i++) {
      ...
      if (ril_request_handlers[i].request ==
                              request->request) {
        status = ril_request_handlers[i].handler(
                      quest->data, request->size,
                      request->token);
        ...
        request->status = status; ...
      } ...
    } ...
    return 0;
  }
\end{lstlisting}

\begin{frame}
  \center{ril\_request\_handler}
\end{frame}

\lstset{language=C}
\begin{lstlisting}
  struct ril_request_handler
                        ril_request_handlers[] = {
    /* Power */
    {
      .request = RIL_REQUEST_RADIO_POWER,
      .handler = ril_request_radio_power,
    }, ...
  }
\end{lstlisting}

\begin{frame}
  \center{ril\_request\_radio\_power}
\end{frame}
\lstset{language=C}
\begin{lstlisting}
  int ril_request_radio_power(void *data,
  size_t size, RIL_Token token) {
    ...
    power_state = *((int *)data);
    ...
    if (power_state > 0) {
      request_data.state =
           IPC_PWR_PHONE_STATE_REQUEST_NORMAL; ...
    } else {
      request_data.state =
              IPC_PWR_PHONE_STATE_REQUEST_LPM; ...
    } ...
    rc = ipc_fmt_send(ipc_fmt_request_seq(token),
              IPC_PWR_PHONE_STATE, IPC_TYPE_EXEC,
              (void *) &request_data,
              sizeof(request_data)); ...
  }
\end{lstlisting}

\begin{frame}
  \center{ipc\_fmt\_send}
\end{frame}
\lstset{language=C}
\begin{lstlisting}
  int ipc_fmt_send(unsigned char mseq,
  unsigned short command, unsigned char type,
  const void *data, size_t size) {
    ...
    ipc_fmt_data = (struct ipc_fmt_data *)
                                     client->data;
    ...
    rc = ipc_client_send(ipc_fmt_data->ipc_client,
                 mseq, command, type, data, size);
    ...
}

\end{lstlisting}

\begin{frame}
  \center{The rest happens in libsamsung-ipc}
\end{frame}

\lstset{language=bash}
\begin{lstlisting}[style=terminal]
$ git grep IPC_PWR_PHONE_STATE_REQUEST_NORMAL
  include/pwr.h:
  #define IPC_PWR_PHONE_STATE_REQUEST_NORMAL 0x0202
$ git grep ipc_client_send
  include/samsung-ipc.h:
  int ipc_client_send(struct ipc_client *client, ...
  samsung-ipc/ipc.c:
  int ipc_client_send(struct ipc_client *client, ...
\end{lstlisting}


\begin{frame}
  \center{Now what happens with notifications from the modem?}
\end{frame}

\begin{frame}
  \center{Again RIL\_Init}
\end{frame}

\lstset{language=C}
\begin{lstlisting}
  const RIL_RadioFunctions *RIL_Init(
  const struct RIL_Env *env,
  __attribute__((unused)) int argc,
  __attribute__((unused)) char **argv) {
    ...
    rc = ril_client_loop(ril_clients[i]);
    ...
  }
\end{lstlisting}

\begin{frame}
  \center{ril\_clients[i]?}
\end{frame}

\begin{frame}
  \center{ril\_clients}
\end{frame}
\lstset{language=C}
\begin{lstlisting}
struct ril_client *ril_clients[] = {
        &ipc_fmt_client,
        &ipc_rfs_client,
        &srs_client,
};
\end{lstlisting}

\begin{frame}
  \center{IPC and RFS}
  \begin{itemize}
  \item RFS: Modem's remote filesystem (EFS)
  \item SRS: For the audio part
  \item IPC: The rest of the protocol
  \end{itemize}
\end{frame}

\lstset{language=bash}
\begin{lstlisting}[style=terminal]
$ git grep XMM626_SEC_MODEM_IPC0_DEVICE
  modems/xmm626/xmm626_sec_modem.c:
  fd = open(XMM626_SEC_MODEM_IPC0_DEVICE,
                  O_RDWR | O_NOCTTY | O_NONBLOCK);
  modems/xmm626/xmm626_sec_modem.h:
  #define XMM626_SEC_MODEM_IPC0_DEVICE
                                  "/dev/umts_ipc0"
  $ git grep XMM626_SEC_MODEM_RFS0_DEVICE
  modems/xmm626/xmm626_sec_modem.c:
  fd = open(XMM626_SEC_MODEM_RFS0_DEVICE,
                  O_RDWR | O_NOCTTY | O_NONBLOCK);
  modems/xmm626/xmm626_sec_modem.h:
  #define XMM626_SEC_MODEM_RFS0_DEVICE
                                  "/dev/umts_rfs0"
\end{lstlisting}

\begin{frame}
  \center{ril\_client\_loop}
\end{frame}
\lstset{language=C}
\begin{lstlisting}
  int ril_client_loop(struct ril_client *client) {
    ...
    rc = pthread_create(&client->thread, &attr,
               ril_client_thread, (void *) client);
    ...
  }

\end{lstlisting}

\begin{frame}
  \center{ril\_client\_thread}
\end{frame}
\lstset{language=C}
\begin{lstlisting}
  void *ril_client_thread(void *data) {
    ...
    client = (struct ril_client *) data;
    ...
    rc = client->handlers->loop(client);
    ...
  }
\end{lstlisting}

\begin{frame}
  \center{ril\_client}
\end{frame}
\lstset{language=C}
\begin{lstlisting}
struct ril_client ipc_fmt_client = {
        .id = RIL_CLIENT_IPC_FMT,
        .name = "IPC FMT",
        .handlers = &ipc_fmt_handlers,
        .callbacks = &ipc_fmt_callbacks,
};
\end{lstlisting}

\begin{frame}
  \center{ipc\_fmt\_handers}
\end{frame}
\lstset{language=C}
\begin{lstlisting}
struct ril_client_handlers ipc_fmt_handlers = {
        .create = ipc_fmt_create,
        .destroy = ipc_fmt_destroy,
        .open = ipc_fmt_open,
        .close = ipc_fmt_close,
        .loop = ipc_fmt_loop,
};
\end{lstlisting}

\begin{frame}
  \center{ipc\_fmt\_loop}
\end{frame}

\lstset{language=C}
\begin{lstlisting}
  int ipc_fmt_loop(struct ril_client *client) {
    ...
    rc = ipc_client_recv(data->ipc_client,
                                        &message);
    ...
    rc = ipc_fmt_dispatch(client, &message);
    ...
  }
\end{lstlisting}

\begin{frame}
  \center{ipc\_fmt\_dispatch}
\end{frame}
\lstset{language=C}
\begin{lstlisting}
  int ipc_fmt_dispatch(struct ril_client *client,
                   struct ipc_message *message) {
    ...
    for (i = 0;
      i < ipc_fmt_dispatch_handlers_count; i++) {
    ...
    if (ipc_fmt_dispatch_handlers[i].command ==
                              message->command) {
    ...
    rc = ipc_fmt_dispatch_handlers[i].handler(
                                        message);
    ...
    }
  }
  ...
}
\end{lstlisting}

\begin{frame}
  \center{ipc\_fmt\_dispatch\_handlers}
\end{frame}
\lstset{language=C}
\begin{lstlisting}
  struct ipc_dispatch_handler
                  ipc_fmt_dispatch_handlers[] = {
    /* Power */
    {
      .command = IPC_PWR_PHONE_PWR_UP,
      .handler = ipc_pwr_phone_pwr_up,
    },
\end{lstlisting}

\begin{frame}
  \center{ipc\_pwr\_phone\_pwr\_up}
\end{frame}
\lstset{language=C}
\begin{lstlisting}
  int ipc_pwr_phone_pwr_up(__attribute__((unused))
                    struct ipc_message *message) {
    ril_radio_state_update(RADIO_STATE_OFF);

    return 0;
  }
\end{lstlisting}

\begin{frame}
  \center{libsamsung-ipc}
\end{frame}

\begin{frame}
  \center{ipc\_client\_send}
\end{frame}
\lstset{language=C}
\begin{lstlisting}
  int ipc_client_send(struct ipc_client *client,
  unsigned char mseq, unsigned short command,
  unsigned char type, const void *data,
                                 size_t size) {
    ...
    memset(&message, 0, sizeof(message));
    message.mseq = mseq;
    message.aseq = 0xff;
    message.command = command;
    message.type = type;
    message.data = (void *) data;
    message.size = size;

    return client->ops->send(client, &message);
}
\end{lstlisting}

\begin{frame}
  \center{client$\rightarrow$ops$\rightarrow$send}
\end{frame}


\begin{frame}
  \center{ipc\_client\_create}
\end{frame}
\lstset{language=C}
\begin{lstlisting}
struct ipc_client *ipc_client_create(int type) {
  ...
  rc = ipc_device_detect();
  ...
  switch (type) {
    ...
    case IPC_CLIENT_TYPE_FMT:
      client->ops =
               ipc_devices[device_index].fmt_ops;
      break;
      ...
  }
  ...
}
\end{lstlisting}

\begin{frame}
  \center{ipc\_device\_detect}
\end{frame}
\lstset{language=C}
\begin{lstlisting}
  int ipc_device_detect(void) {
    ...
    fd = open("/proc/cpuinfo", O_RDONLY);
    ...
    if (strncmp(line, "Hardware", 8) == 8) {
    ...
    if (...  && strcmp(kernel_version,
              ipc_devices[i].kernel_version) != 0)
    ...
}

\end{lstlisting}

\begin{frame}
  \center{ipc\_devices}
\end{frame}
\lstset{language=C}
\begin{lstlisting}
struct ipc_device_desc ipc_devices[] = {
  ...
  {
        .name = "i9300",
        .board_name = "smdk4x12",
        .kernel_version = NULL,
        .fmt_ops = &i9300_fmt_ops,
        .rfs_ops = &i9300_rfs_ops,
        .handlers = &i9300_handlers,
        .gprs_specs = &i9300_gprs_specs,
        .nv_data_specs = &i9300_nv_data_specs,
    },
\end{lstlisting}

\begin{frame}
  \center{ipc\_client\_ops}
\end{frame}
\lstset{language=C}
\begin{lstlisting}
struct ipc_client_ops i9300_fmt_ops = {
    .boot = i9300_boot,
    .send = xmm626_sec_modem_fmt_send,
    .recv = xmm626_sec_modem_fmt_recv,
};
\end{lstlisting}

\begin{frame}
  \center{xmm626\_sec\_modem\_fmt\_send}
\end{frame}
\lstset{language=C}
\begin{lstlisting}
  int xmm626_sec_modem_fmt_send(
                    struct ipc_client *client,
                  struct ipc_message *message) {
    ...
    rc = client->handlers->write(
                client->handlers->transport_data,
                              p, length - count);
  }
\end{lstlisting}


\begin{frame}
  \center{i9300\_handlers}
\end{frame}
\lstset{language=C}
\begin{lstlisting}
  struct ipc_client_handlers i9300_handlers = {
    .read = i9300_read,
    .write = i9300_write,
    .open = i9300_open,
    .close = i9300_close,
    .poll = i9300_poll,
    .transport_data = NULL,
    .power_on = i9300_power_on,
    .power_off = i9300_power_off,
    .power_data = NULL,
    .gprs_activate = i9300_gprs_activate,
    .gprs_deactivate = i9300_gprs_deactivate,
    .gprs_data = NULL,
    .data_create = i9300_data_create,
    .data_destroy = i9300_data_destroy,
  };
\end{lstlisting}

\begin{frame}
  \center{i9300\_open}
\end{frame}
\lstset{language=C}
\begin{lstlisting}
int i9300_open(void *data, int type)
{
  ...
  transport_data->fd =
                     xmm626_sec_modem_open(type);
  ...
  return 0;
}
\end{lstlisting}

\begin{frame}
  \center{xmm626\_sec\_modem\_open}
\end{frame}
\lstset{language=C}
\begin{lstlisting}
int xmm626_sec_modem_open(int type) {
    switch (type) {
      case IPC_CLIENT_TYPE_FMT:
        fd = open(XMM626_SEC_MODEM_IPC0_DEVICE,
                 O_RDWR | O_NOCTTY | O_NONBLOCK);
          break;
      case IPC_CLIENT_TYPE_RFS:
        fd = open(XMM626_SEC_MODEM_RFS0_DEVICE,
                 O_RDWR | O_NOCTTY | O_NONBLOCK);
          break;
      default:
          return -1;
    }
    ...
}
\end{lstlisting}

\begin{frame}
  \center{xmm626\_sec\_modem\_fmt\_send}
\end{frame}
\lstset{language=bash}
\begin{lstlisting}[style=terminal]
  $ git grep XMM626_SEC_MODEM_IPC0_DEVICE
  devices/xmm626/xmm626_sec_modem.h:
  #define XMM626_SEC_MODEM_IPC0_DEVICE "/dev/umts_ipc0"
  $ git grep XMM626_SEC_MODEM_RFS0_DEVICE
  devices/xmm626/xmm626_sec_modem.h:
  #define XMM626_SEC_MODEM_RFS0_DEVICE "/dev/umts_rfs0"
\end{lstlisting}

\begin{frame}
  \center{i9300\_write}
\end{frame}
\lstset{language=C}
\begin{lstlisting}
  int i9300_write(void *data,
       const void *buffer, size_t length) {
  ...
  rc = xmm626_sec_modem_write(
       transport_data->fd, buffer, length);

  return rc;
}
\end{lstlisting}

\begin{frame}
  \center{xmm626\_modem\_write}
\end{frame}
\lstset{language=C}
\begin{lstlisting}
  int xmm626_sec_modem_write(int fd,
            const void *buffer, size_t length) {
    ...
    status = ioctl(fd, IOCTL_MODEM_STATUS, 0);
    if (status != STATE_ONLINE &&
                        status != STATE_BOOTING)
       return -1;

    rc = write(fd, buffer, length);

    return rc;
}
\end{lstlisting}

\begin{frame}
  \center{Sharing the work with other Android distributions}
  \begin{itemize}
  \item Not complete enough to be merged in LineageOS
  \end{itemize}
\end{frame}

\begin{frame}
  \center{Sharing the work with GNU/Linux distributions}
  \begin{itemize}
  \item Freesmartphone.org
  \item Ofono + rild + libamsung-ril + libsamsung-ipc
  \item Ofono + libsamsung-ipc
  \item PostmarketOS?
  \item PureOS, Parabola?
  \end{itemize}
\end{frame}

\begin{frame}
  \center{Discussions:}
  \begin{itemize}
  \item Sharing code with other distributions?
  \item USB Guard?
  \item Device requirements: Require modem to be isolated ?
  \item Other modems and GNU/Linux stack (PinePhone, GTA04)?
  \item Using GNU/Linux modem stack as much as possible?
  \item Automatic testing infrastructure and ofono?
  \item GNU/Linux and testing?
  \end{itemize}
\end{frame}

\begin{thebibliography}{99}
\end{thebibliography}

\end{document}