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
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
|
/*
ChibiOS - Copyright (C) 2006..2019 Giovanni Di Sirio.
This file is part of ChibiOS.
ChibiOS is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
ChibiOS is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* @file sb/host/sbhost.c
* @brief ARM sandbox host API code.
*
* @addtogroup ARM_SANDBOX_HOSTAPI
* @{
*/
#include "ch.h"
#include "sb.h"
#if defined(SB_INCLUDE_USERAPI)
#include "sbuserapi.h"
#endif
/*===========================================================================*/
/* Module local definitions. */
/*===========================================================================*/
/**
* @name Standard API handlers
* @{
*/
#define SB_SVC0_HANDLER sb_api_stdio
#define SB_SVC1_HANDLER sb_api_exit
#define SB_SVC2_HANDLER sb_api_get_systime
#define SB_SVC3_HANDLER sb_api_get_frequency
#define SB_SVC4_HANDLER sb_api_sleep
#define SB_SVC5_HANDLER sb_api_sleep_until_windowed
#define SB_SVC6_HANDLER sb_api_wait_message
#define SB_SVC7_HANDLER sb_api_reply_message
#define SB_SVC8_HANDLER sb_api_wait_one_timeout
#define SB_SVC9_HANDLER sb_api_wait_any_timeout
#define SB_SVC10_HANDLER sb_api_wait_all_timeout
#define SB_SVC11_HANDLER sb_api_broadcast_flags
/** @} */
#define __SVC(x) asm volatile ("svc " #x)
/*
* All handlers defaulted to a common function.
*/
#if !defined(SB_SVC0_HANDLER)
#define SB_SVC0_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC1_HANDLER)
#define SB_SVC1_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC2_HANDLER)
#define SB_SVC2_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC3_HANDLER)
#define SB_SVC3_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC4_HANDLER)
#define SB_SVC4_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC5_HANDLER)
#define SB_SVC5_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC6_HANDLER)
#define SB_SVC6_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC7_HANDLER)
#define SB_SVC7_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC8_HANDLER)
#define SB_SVC8_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC9_HANDLER)
#define SB_SVC9_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC10_HANDLER)
#define SB_SVC10_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC11_HANDLER)
#define SB_SVC11_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC12_HANDLER)
#define SB_SVC12_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC13_HANDLER)
#define SB_SVC13_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC14_HANDLER)
#define SB_SVC14_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC15_HANDLER)
#define SB_SVC15_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC16_HANDLER)
#define SB_SVC16_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC17_HANDLER)
#define SB_SVC17_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC18_HANDLER)
#define SB_SVC18_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC19_HANDLER)
#define SB_SVC19_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC20_HANDLER)
#define SB_SVC20_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC21_HANDLER)
#define SB_SVC21_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC22_HANDLER)
#define SB_SVC22_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC23_HANDLER)
#define SB_SVC23_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC24_HANDLER)
#define SB_SVC24_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC25_HANDLER)
#define SB_SVC25_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC26_HANDLER)
#define SB_SVC26_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC27_HANDLER)
#define SB_SVC27_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC28_HANDLER)
#define SB_SVC28_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC29_HANDLER)
#define SB_SVC29_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC30_HANDLER)
#define SB_SVC30_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC31_HANDLER)
#define SB_SVC31_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC32_HANDLER)
#define SB_SVC32_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC33_HANDLER)
#define SB_SVC33_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC34_HANDLER)
#define SB_SVC34_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC35_HANDLER)
#define SB_SVC35_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC36_HANDLER)
#define SB_SVC36_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC37_HANDLER)
#define SB_SVC37_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC38_HANDLER)
#define SB_SVC38_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC39_HANDLER)
#define SB_SVC39_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC40_HANDLER)
#define SB_SVC40_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC41_HANDLER)
#define SB_SVC41_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC42_HANDLER)
#define SB_SVC42_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC43_HANDLER)
#define SB_SVC43_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC44_HANDLER)
#define SB_SVC44_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC45_HANDLER)
#define SB_SVC45_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC46_HANDLER)
#define SB_SVC46_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC47_HANDLER)
#define SB_SVC47_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC48_HANDLER)
#define SB_SVC48_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC49_HANDLER)
#define SB_SVC49_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC50_HANDLER)
#define SB_SVC50_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC51_HANDLER)
#define SB_SVC51_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC52_HANDLER)
#define SB_SVC52_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC53_HANDLER)
#define SB_SVC53_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC54_HANDLER)
#define SB_SVC54_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC55_HANDLER)
#define SB_SVC55_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC56_HANDLER)
#define SB_SVC56_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC57_HANDLER)
#define SB_SVC57_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC58_HANDLER)
#define SB_SVC58_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC59_HANDLER)
#define SB_SVC59_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC60_HANDLER)
#define SB_SVC60_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC61_HANDLER)
#define SB_SVC61_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC62_HANDLER)
#define SB_SVC62_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC63_HANDLER)
#define SB_SVC63_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC64_HANDLER)
#define SB_SVC64_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC65_HANDLER)
#define SB_SVC65_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC66_HANDLER)
#define SB_SVC66_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC67_HANDLER)
#define SB_SVC67_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC68_HANDLER)
#define SB_SVC68_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC69_HANDLER)
#define SB_SVC69_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC70_HANDLER)
#define SB_SVC70_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC71_HANDLER)
#define SB_SVC71_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC72_HANDLER)
#define SB_SVC72_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC73_HANDLER)
#define SB_SVC73_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC74_HANDLER)
#define SB_SVC74_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC75_HANDLER)
#define SB_SVC75_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC76_HANDLER)
#define SB_SVC76_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC77_HANDLER)
#define SB_SVC77_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC78_HANDLER)
#define SB_SVC78_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC79_HANDLER)
#define SB_SVC79_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC80_HANDLER)
#define SB_SVC80_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC81_HANDLER)
#define SB_SVC81_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC82_HANDLER)
#define SB_SVC82_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC83_HANDLER)
#define SB_SVC83_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC84_HANDLER)
#define SB_SVC84_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC85_HANDLER)
#define SB_SVC85_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC86_HANDLER)
#define SB_SVC86_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC87_HANDLER)
#define SB_SVC87_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC88_HANDLER)
#define SB_SVC88_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC89_HANDLER)
#define SB_SVC89_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC90_HANDLER)
#define SB_SVC90_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC91_HANDLER)
#define SB_SVC91_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC92_HANDLER)
#define SB_SVC92_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC93_HANDLER)
#define SB_SVC93_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC94_HANDLER)
#define SB_SVC94_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC95_HANDLER)
#define SB_SVC95_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC96_HANDLER)
#define SB_SVC96_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC97_HANDLER)
#define SB_SVC97_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC98_HANDLER)
#define SB_SVC98_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC99_HANDLER)
#define SB_SVC99_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC100_HANDLER)
#define SB_SVC100_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC101_HANDLER)
#define SB_SVC101_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC102_HANDLER)
#define SB_SVC102_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC103_HANDLER)
#define SB_SVC103_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC104_HANDLER)
#define SB_SVC104_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC105_HANDLER)
#define SB_SVC105_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC106_HANDLER)
#define SB_SVC106_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC107_HANDLER)
#define SB_SVC107_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC108_HANDLER)
#define SB_SVC108_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC109_HANDLER)
#define SB_SVC109_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC110_HANDLER)
#define SB_SVC110_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC111_HANDLER)
#define SB_SVC111_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC112_HANDLER)
#define SB_SVC112_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC113_HANDLER)
#define SB_SVC113_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC114_HANDLER)
#define SB_SVC114_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC115_HANDLER)
#define SB_SVC115_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC116_HANDLER)
#define SB_SVC116_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC117_HANDLER)
#define SB_SVC117_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC118_HANDLER)
#define SB_SVC118_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC119_HANDLER)
#define SB_SVC119_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC120_HANDLER)
#define SB_SVC120_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC121_HANDLER)
#define SB_SVC121_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC122_HANDLER)
#define SB_SVC122_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC123_HANDLER)
#define SB_SVC123_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC124_HANDLER)
#define SB_SVC124_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC125_HANDLER)
#define SB_SVC125_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC126_HANDLER)
#define SB_SVC126_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC127_HANDLER)
#define SB_SVC127_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC128_HANDLER)
#define SB_SVC128_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC129_HANDLER)
#define SB_SVC129_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC130_HANDLER)
#define SB_SVC130_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC131_HANDLER)
#define SB_SVC131_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC132_HANDLER)
#define SB_SVC132_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC133_HANDLER)
#define SB_SVC133_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC134_HANDLER)
#define SB_SVC134_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC135_HANDLER)
#define SB_SVC135_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC136_HANDLER)
#define SB_SVC136_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC137_HANDLER)
#define SB_SVC137_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC138_HANDLER)
#define SB_SVC138_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC139_HANDLER)
#define SB_SVC139_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC140_HANDLER)
#define SB_SVC140_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC141_HANDLER)
#define SB_SVC141_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC142_HANDLER)
#define SB_SVC142_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC143_HANDLER)
#define SB_SVC143_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC144_HANDLER)
#define SB_SVC144_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC145_HANDLER)
#define SB_SVC145_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC146_HANDLER)
#define SB_SVC146_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC147_HANDLER)
#define SB_SVC147_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC148_HANDLER)
#define SB_SVC148_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC149_HANDLER)
#define SB_SVC149_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC150_HANDLER)
#define SB_SVC150_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC151_HANDLER)
#define SB_SVC151_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC152_HANDLER)
#define SB_SVC152_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC153_HANDLER)
#define SB_SVC153_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC154_HANDLER)
#define SB_SVC154_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC155_HANDLER)
#define SB_SVC155_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC156_HANDLER)
#define SB_SVC156_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC157_HANDLER)
#define SB_SVC157_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC158_HANDLER)
#define SB_SVC158_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC159_HANDLER)
#define SB_SVC159_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC160_HANDLER)
#define SB_SVC160_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC161_HANDLER)
#define SB_SVC161_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC162_HANDLER)
#define SB_SVC162_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC163_HANDLER)
#define SB_SVC163_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC164_HANDLER)
#define SB_SVC164_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC165_HANDLER)
#define SB_SVC165_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC166_HANDLER)
#define SB_SVC166_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC167_HANDLER)
#define SB_SVC167_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC168_HANDLER)
#define SB_SVC168_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC169_HANDLER)
#define SB_SVC169_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC170_HANDLER)
#define SB_SVC170_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC171_HANDLER)
#define SB_SVC171_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC172_HANDLER)
#define SB_SVC172_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC173_HANDLER)
#define SB_SVC173_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC174_HANDLER)
#define SB_SVC174_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC175_HANDLER)
#define SB_SVC175_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC176_HANDLER)
#define SB_SVC176_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC177_HANDLER)
#define SB_SVC177_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC178_HANDLER)
#define SB_SVC178_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC179_HANDLER)
#define SB_SVC179_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC180_HANDLER)
#define SB_SVC180_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC181_HANDLER)
#define SB_SVC181_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC182_HANDLER)
#define SB_SVC182_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC183_HANDLER)
#define SB_SVC183_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC184_HANDLER)
#define SB_SVC184_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC185_HANDLER)
#define SB_SVC185_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC186_HANDLER)
#define SB_SVC186_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC187_HANDLER)
#define SB_SVC187_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC188_HANDLER)
#define SB_SVC188_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC189_HANDLER)
#define SB_SVC189_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC190_HANDLER)
#define SB_SVC190_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC191_HANDLER)
#define SB_SVC191_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC192_HANDLER)
#define SB_SVC192_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC193_HANDLER)
#define SB_SVC193_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC194_HANDLER)
#define SB_SVC194_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC195_HANDLER)
#define SB_SVC195_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC196_HANDLER)
#define SB_SVC196_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC197_HANDLER)
#define SB_SVC197_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC198_HANDLER)
#define SB_SVC198_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC199_HANDLER)
#define SB_SVC199_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC200_HANDLER)
#define SB_SVC200_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC201_HANDLER)
#define SB_SVC201_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC202_HANDLER)
#define SB_SVC202_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC203_HANDLER)
#define SB_SVC203_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC204_HANDLER)
#define SB_SVC204_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC205_HANDLER)
#define SB_SVC205_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC206_HANDLER)
#define SB_SVC206_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC207_HANDLER)
#define SB_SVC207_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC208_HANDLER)
#define SB_SVC208_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC209_HANDLER)
#define SB_SVC209_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC210_HANDLER)
#define SB_SVC210_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC211_HANDLER)
#define SB_SVC211_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC212_HANDLER)
#define SB_SVC212_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC213_HANDLER)
#define SB_SVC213_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC214_HANDLER)
#define SB_SVC214_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC215_HANDLER)
#define SB_SVC215_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC216_HANDLER)
#define SB_SVC216_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC217_HANDLER)
#define SB_SVC217_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC218_HANDLER)
#define SB_SVC218_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC219_HANDLER)
#define SB_SVC219_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC220_HANDLER)
#define SB_SVC220_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC221_HANDLER)
#define SB_SVC221_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC222_HANDLER)
#define SB_SVC222_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC223_HANDLER)
#define SB_SVC223_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC224_HANDLER)
#define SB_SVC224_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC225_HANDLER)
#define SB_SVC225_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC226_HANDLER)
#define SB_SVC226_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC227_HANDLER)
#define SB_SVC227_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC228_HANDLER)
#define SB_SVC228_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC229_HANDLER)
#define SB_SVC229_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC230_HANDLER)
#define SB_SVC230_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC231_HANDLER)
#define SB_SVC231_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC232_HANDLER)
#define SB_SVC232_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC233_HANDLER)
#define SB_SVC233_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC234_HANDLER)
#define SB_SVC234_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC235_HANDLER)
#define SB_SVC235_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC236_HANDLER)
#define SB_SVC236_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC237_HANDLER)
#define SB_SVC237_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC238_HANDLER)
#define SB_SVC238_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC239_HANDLER)
#define SB_SVC239_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC240_HANDLER)
#define SB_SVC240_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC241_HANDLER)
#define SB_SVC241_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC242_HANDLER)
#define SB_SVC242_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC243_HANDLER)
#define SB_SVC243_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC244_HANDLER)
#define SB_SVC244_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC245_HANDLER)
#define SB_SVC245_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC246_HANDLER)
#define SB_SVC246_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC247_HANDLER)
#define SB_SVC247_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC248_HANDLER)
#define SB_SVC248_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC249_HANDLER)
#define SB_SVC249_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC250_HANDLER)
#define SB_SVC250_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC251_HANDLER)
#define SB_SVC251_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC252_HANDLER)
#define SB_SVC252_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC253_HANDLER)
#define SB_SVC253_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC254_HANDLER)
#define SB_SVC254_HANDLER sb_undef_handler
#endif
#if !defined(SB_SVC255_HANDLER)
#define SB_SVC255_HANDLER sb_undef_handler
#endif
/*===========================================================================*/
/* Module exported variables. */
/*===========================================================================*/
static void sb_undef_handler(struct port_extctx *ectxp);
const port_syscall_t sb_syscalls[256] = {
SB_SVC0_HANDLER, SB_SVC1_HANDLER, SB_SVC2_HANDLER, SB_SVC3_HANDLER,
SB_SVC4_HANDLER, SB_SVC5_HANDLER, SB_SVC6_HANDLER, SB_SVC7_HANDLER,
SB_SVC8_HANDLER, SB_SVC9_HANDLER, SB_SVC10_HANDLER, SB_SVC11_HANDLER,
SB_SVC12_HANDLER, SB_SVC13_HANDLER, SB_SVC14_HANDLER, SB_SVC15_HANDLER,
SB_SVC16_HANDLER, SB_SVC17_HANDLER, SB_SVC18_HANDLER, SB_SVC19_HANDLER,
SB_SVC20_HANDLER, SB_SVC21_HANDLER, SB_SVC22_HANDLER, SB_SVC23_HANDLER,
SB_SVC24_HANDLER, SB_SVC25_HANDLER, SB_SVC26_HANDLER, SB_SVC27_HANDLER,
SB_SVC28_HANDLER, SB_SVC29_HANDLER, SB_SVC30_HANDLER, SB_SVC31_HANDLER,
SB_SVC32_HANDLER, SB_SVC33_HANDLER, SB_SVC34_HANDLER, SB_SVC35_HANDLER,
SB_SVC36_HANDLER, SB_SVC37_HANDLER, SB_SVC38_HANDLER, SB_SVC39_HANDLER,
SB_SVC40_HANDLER, SB_SVC41_HANDLER, SB_SVC42_HANDLER, SB_SVC43_HANDLER,
SB_SVC44_HANDLER, SB_SVC45_HANDLER, SB_SVC46_HANDLER, SB_SVC47_HANDLER,
SB_SVC48_HANDLER, SB_SVC49_HANDLER, SB_SVC50_HANDLER, SB_SVC51_HANDLER,
SB_SVC52_HANDLER, SB_SVC53_HANDLER, SB_SVC54_HANDLER, SB_SVC55_HANDLER,
SB_SVC56_HANDLER, SB_SVC57_HANDLER, SB_SVC58_HANDLER, SB_SVC59_HANDLER,
SB_SVC60_HANDLER, SB_SVC61_HANDLER, SB_SVC62_HANDLER, SB_SVC63_HANDLER,
SB_SVC64_HANDLER, SB_SVC65_HANDLER, SB_SVC66_HANDLER, SB_SVC67_HANDLER,
SB_SVC68_HANDLER, SB_SVC69_HANDLER, SB_SVC70_HANDLER, SB_SVC71_HANDLER,
SB_SVC72_HANDLER, SB_SVC73_HANDLER, SB_SVC74_HANDLER, SB_SVC75_HANDLER,
SB_SVC76_HANDLER, SB_SVC77_HANDLER, SB_SVC78_HANDLER, SB_SVC79_HANDLER,
SB_SVC80_HANDLER, SB_SVC81_HANDLER, SB_SVC82_HANDLER, SB_SVC83_HANDLER,
SB_SVC84_HANDLER, SB_SVC85_HANDLER, SB_SVC86_HANDLER, SB_SVC87_HANDLER,
SB_SVC88_HANDLER, SB_SVC89_HANDLER, SB_SVC90_HANDLER, SB_SVC91_HANDLER,
SB_SVC92_HANDLER, SB_SVC93_HANDLER, SB_SVC94_HANDLER, SB_SVC95_HANDLER,
SB_SVC96_HANDLER, SB_SVC97_HANDLER, SB_SVC98_HANDLER, SB_SVC99_HANDLER,
SB_SVC100_HANDLER, SB_SVC101_HANDLER, SB_SVC102_HANDLER, SB_SVC103_HANDLER,
SB_SVC104_HANDLER, SB_SVC105_HANDLER, SB_SVC106_HANDLER, SB_SVC107_HANDLER,
SB_SVC108_HANDLER, SB_SVC109_HANDLER, SB_SVC110_HANDLER, SB_SVC111_HANDLER,
SB_SVC112_HANDLER, SB_SVC113_HANDLER, SB_SVC114_HANDLER, SB_SVC115_HANDLER,
SB_SVC116_HANDLER, SB_SVC117_HANDLER, SB_SVC118_HANDLER, SB_SVC119_HANDLER,
SB_SVC120_HANDLER, SB_SVC121_HANDLER, SB_SVC122_HANDLER, SB_SVC123_HANDLER,
SB_SVC124_HANDLER, SB_SVC125_HANDLER, SB_SVC126_HANDLER, SB_SVC127_HANDLER,
SB_SVC128_HANDLER, SB_SVC129_HANDLER, SB_SVC130_HANDLER, SB_SVC131_HANDLER,
SB_SVC132_HANDLER, SB_SVC133_HANDLER, SB_SVC134_HANDLER, SB_SVC135_HANDLER,
SB_SVC136_HANDLER, SB_SVC137_HANDLER, SB_SVC138_HANDLER, SB_SVC139_HANDLER,
SB_SVC140_HANDLER, SB_SVC141_HANDLER, SB_SVC142_HANDLER, SB_SVC143_HANDLER,
SB_SVC144_HANDLER, SB_SVC145_HANDLER, SB_SVC146_HANDLER, SB_SVC147_HANDLER,
SB_SVC148_HANDLER, SB_SVC149_HANDLER, SB_SVC150_HANDLER, SB_SVC151_HANDLER,
SB_SVC152_HANDLER, SB_SVC153_HANDLER, SB_SVC154_HANDLER, SB_SVC155_HANDLER,
SB_SVC156_HANDLER, SB_SVC157_HANDLER, SB_SVC158_HANDLER, SB_SVC159_HANDLER,
SB_SVC160_HANDLER, SB_SVC161_HANDLER, SB_SVC162_HANDLER, SB_SVC163_HANDLER,
SB_SVC164_HANDLER, SB_SVC165_HANDLER, SB_SVC166_HANDLER, SB_SVC167_HANDLER,
SB_SVC168_HANDLER, SB_SVC169_HANDLER, SB_SVC170_HANDLER, SB_SVC171_HANDLER,
SB_SVC172_HANDLER, SB_SVC173_HANDLER, SB_SVC174_HANDLER, SB_SVC175_HANDLER,
SB_SVC176_HANDLER, SB_SVC177_HANDLER, SB_SVC178_HANDLER, SB_SVC179_HANDLER,
SB_SVC180_HANDLER, SB_SVC181_HANDLER, SB_SVC182_HANDLER, SB_SVC183_HANDLER,
SB_SVC184_HANDLER, SB_SVC185_HANDLER, SB_SVC186_HANDLER, SB_SVC187_HANDLER,
SB_SVC188_HANDLER, SB_SVC189_HANDLER, SB_SVC190_HANDLER, SB_SVC191_HANDLER,
SB_SVC192_HANDLER, SB_SVC193_HANDLER, SB_SVC194_HANDLER, SB_SVC195_HANDLER,
SB_SVC196_HANDLER, SB_SVC197_HANDLER, SB_SVC198_HANDLER, SB_SVC199_HANDLER,
SB_SVC200_HANDLER, SB_SVC201_HANDLER, SB_SVC202_HANDLER, SB_SVC203_HANDLER,
SB_SVC204_HANDLER, SB_SVC205_HANDLER, SB_SVC206_HANDLER, SB_SVC207_HANDLER,
SB_SVC208_HANDLER, SB_SVC209_HANDLER, SB_SVC210_HANDLER, SB_SVC211_HANDLER,
SB_SVC212_HANDLER, SB_SVC213_HANDLER, SB_SVC214_HANDLER, SB_SVC215_HANDLER,
SB_SVC216_HANDLER, SB_SVC217_HANDLER, SB_SVC218_HANDLER, SB_SVC219_HANDLER,
SB_SVC220_HANDLER, SB_SVC221_HANDLER, SB_SVC222_HANDLER, SB_SVC223_HANDLER,
SB_SVC224_HANDLER, SB_SVC225_HANDLER, SB_SVC226_HANDLER, SB_SVC227_HANDLER,
SB_SVC228_HANDLER, SB_SVC229_HANDLER, SB_SVC230_HANDLER, SB_SVC231_HANDLER,
SB_SVC232_HANDLER, SB_SVC233_HANDLER, SB_SVC234_HANDLER, SB_SVC235_HANDLER,
SB_SVC236_HANDLER, SB_SVC237_HANDLER, SB_SVC238_HANDLER, SB_SVC239_HANDLER,
SB_SVC240_HANDLER, SB_SVC241_HANDLER, SB_SVC242_HANDLER, SB_SVC243_HANDLER,
SB_SVC244_HANDLER, SB_SVC245_HANDLER, SB_SVC246_HANDLER, SB_SVC247_HANDLER,
SB_SVC248_HANDLER, SB_SVC249_HANDLER, SB_SVC250_HANDLER, SB_SVC251_HANDLER,
SB_SVC252_HANDLER, SB_SVC253_HANDLER, SB_SVC254_HANDLER, SB_SVC255_HANDLER
};
/*===========================================================================*/
/* Module local types. */
/*===========================================================================*/
/*===========================================================================*/
/* Module local variables. */
/*===========================================================================*/
/*===========================================================================*/
/* Module local functions. */
/*===========================================================================*/
static void sb_undef_handler(struct port_extctx *ectxp) {
ectxp->r0 = SB_ERR_ENOSYS;
}
/*===========================================================================*/
/* Module exported functions. */
/*===========================================================================*/
void sb_api_stdio(struct port_extctx *ectxp) {
switch (ectxp->r0) {
case SB_POSIX_OPEN:
ectxp->r0 = sb_posix_open((const char *)ectxp->r1,
ectxp->r2);
break;
case SB_POSIX_CLOSE:
ectxp->r0 = sb_posix_close(ectxp->r1);
break;
case SB_POSIX_READ:
ectxp->r0 = sb_posix_read(ectxp->r1,
(void *)ectxp->r2,
(size_t)ectxp->r3);
break;
case SB_POSIX_WRITE:
ectxp->r0 = sb_posix_write(ectxp->r1,
(const void *)ectxp->r2,
(size_t)ectxp->r3);
break;
case SB_POSIX_LSEEK:
ectxp->r0 = sb_posix_lseek(ectxp->r1,
ectxp->r2,
ectxp->r3);
break;
default:
ectxp->r0 = SB_ERR_ENOSYS;
break;
}
}
void sb_api_exit(struct port_extctx *ectxp) {
chThdExit((msg_t )ectxp->r0);
/* Cannot get here.*/
ectxp->r0 = SB_ERR_ENOSYS;
}
void sb_api_get_systime(struct port_extctx *ectxp) {
ectxp->r0 = (uint32_t)chVTGetSystemTimeX();
}
void sb_api_get_frequency(struct port_extctx *ectxp) {
ectxp->r0 = (uint32_t)CH_CFG_ST_FREQUENCY;
}
void sb_api_sleep(struct port_extctx *ectxp) {
sysinterval_t interval = (sysinterval_t )ectxp->r0;
if (interval != TIME_IMMEDIATE) {
chThdSleep(interval);
}
ectxp->r0 = SB_ERR_NOERROR;
}
void sb_api_sleep_until_windowed(struct port_extctx *ectxp) {
chThdSleepUntilWindowed((systime_t )ectxp->r0, (systime_t )ectxp->r1);
ectxp->r0 = SB_ERR_NOERROR;
}
void sb_api_wait_message(struct port_extctx *ectxp) {
#if CH_CFG_USE_MESSAGES == TRUE
sb_class_t *sbcp = (sb_class_t *)chThdGetSelfX()->ctx.syscall.p;
if (sbcp->msg_tp == NULL) {
sbcp->msg_tp = chMsgWait();
ectxp->r0 = (uint32_t)chMsgGet(sbcp->msg_tp);
}
else {
chMsgRelease(sbcp->msg_tp, MSG_RESET);
sbcp->msg_tp = NULL;
ectxp->r0 = SB_ERR_EBUSY;
}
#else
ectxp->r0 = SB_ERR_NOT_IMPLEMENTED;
#endif
}
void sb_api_reply_message(struct port_extctx *ectxp) {
#if CH_CFG_USE_MESSAGES == TRUE
sb_class_t *sbcp = (sb_class_t *)chThdGetSelfX()->ctx.syscall.p;
if (sbcp->msg_tp != NULL) {
chMsgRelease(sbcp->msg_tp, (msg_t )ectxp->r0);
sbcp->msg_tp = NULL;
ectxp->r0 = SB_ERR_NOERROR;
}
else {
ectxp->r0 = SB_ERR_EBUSY;
}
#else
ectxp->r0 = SB_ERR_NOT_IMPLEMENTED;
#endif
}
void sb_api_wait_one_timeout(struct port_extctx *ectxp) {
#if CH_CFG_USE_EVENTS == TRUE
ectxp->r0 = (uint32_t)chEvtWaitOneTimeout((eventmask_t )ectxp->r0,
(sysinterval_t )ectxp->r1);
#else
ectxp->r0 = SB_ERR_NOT_IMPLEMENTED;
#endif
}
void sb_api_wait_any_timeout(struct port_extctx *ectxp) {
#if CH_CFG_USE_EVENTS == TRUE
ectxp->r0 = (uint32_t)chEvtWaitAnyTimeout((eventmask_t )ectxp->r0,
(sysinterval_t )ectxp->r1);
#else
ectxp->r0 = SB_ERR_NOT_IMPLEMENTED;
#endif
}
void sb_api_wait_all_timeout(struct port_extctx *ectxp) {
#if CH_CFG_USE_EVENTS == TRUE
ectxp->r0 = (uint32_t)chEvtWaitAllTimeout((eventmask_t )ectxp->r0,
(sysinterval_t )ectxp->r1);
#else
ectxp->r0 = SB_ERR_NOT_IMPLEMENTED;
#endif
}
void sb_api_broadcast_flags(struct port_extctx *ectxp) {
#if CH_CFG_USE_EVENTS == TRUE
sb_class_t *sbcp = (sb_class_t *)chThdGetSelfX()->ctx.syscall.p;
chEvtBroadcastFlags(&sbcp->es, (eventflags_t )ectxp->r0);
ectxp->r0 = SB_ERR_NOERROR;
#else
ectxp->r0 = SB_ERR_NOT_IMPLEMENTED;
#endif
}
/** @} */
|