1
6
7
8
9
10
11
12
13
19
20
21
22
23
24
25
26
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
122
123
129
130
131
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
169
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
214
215
216
217
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
263
264
265
266
267
268
269
270
271
272
273
274
275
276
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
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
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
394
395
396
397
398
399
400
401
402
403
404
405
406
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
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
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
516
517
518
519
520
521
522
523
524
525
529
530
531
532
533
534
535
536
537
538
539
540
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
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
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
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
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
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
960
961
974
975
985
986
996
997
998
999
1000
1001
1002
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
/* ... */
#ifndef _PICO_BOOTROM_H
#define _PICO_BOOTROM_H
#include "pico.h"
#include "pico/bootrom_constants.h"
/* ... */
#ifndef __ASSEMBLER__
#include <string.h>
#include "pico/bootrom/lock.h"
#if PICO_RP2040
typedef uint32_t (*rom_popcount32_fn)(uint32_t);
typedef uint32_t (*rom_reverse32_fn)(uint32_t);
typedef uint32_t (*rom_clz32_fn)(uint32_t);
typedef uint32_t (*rom_ctz32_fn)(uint32_t);
typedef uint8_t *(*rom_memset_fn)(uint8_t *, uint8_t, uint32_t);
typedef uint32_t *(*rom_memset4_fn)(uint32_t *, uint8_t, uint32_t);
typedef uint32_t *(*rom_memcpy_fn)(uint8_t *, const uint8_t *, uint32_t);
typedef uint32_t *(*rom_memcpy44_fn)(uint32_t *, const uint32_t *, uint32_t);/* ... */
#endif
typedef void __attribute__((noreturn)) (*rom_reset_usb_boot_fn)(uint32_t, uint32_t);
typedef int (*rom_reboot_fn)(uint32_t flags, uint32_t delay_ms, uint32_t p0, uint32_t p1);
typedef rom_reset_usb_boot_fn reset_usb_boot_fn;
typedef void (*rom_connect_internal_flash_fn)(void);
typedef void (*rom_flash_exit_xip_fn)(void);
typedef void (*rom_flash_range_erase_fn)(uint32_t, size_t, uint32_t, uint8_t);
typedef void (*rom_flash_range_program_fn)(uint32_t, const uint8_t*, size_t);
typedef void (*rom_flash_flush_cache_fn)(void);
typedef void (*rom_flash_enter_cmd_xip_fn)(void);
#if !PICO_RP2040
typedef void (*rom_bootrom_state_reset_fn)(uint32_t flags);
typedef void (*rom_flash_reset_address_trans_fn)(void);
typedef void (*rom_flash_select_xip_read_mode_fn)(bootrom_xip_mode_t mode, uint8_t clkdiv);
typedef int (*rom_get_sys_info_fn)(uint32_t *out_buffer, uint32_t out_buffer_word_size, uint32_t flags);
typedef int (*rom_get_partition_table_info_fn)(uint32_t *out_buffer, uint32_t out_buffer_word_size, uint32_t partition_and_flags);
typedef int (*rom_explicit_buy_fn)(uint8_t *buffer, uint32_t buffer_size);
typedef void* (*rom_validate_ns_buffer_fn)(const void *addr, uint32_t size, uint32_t write, uint32_t *ok);
/* ... */
typedef intptr_t (*rom_set_rom_callback_fn)(uint callback_num, bootrom_api_callback_generic_t funcptr);
typedef int (*rom_chain_image_fn)(uint8_t *workarea_base, uint32_t workarea_size, uint32_t window_base, uint32_t window_size);
typedef int (*rom_load_partition_table_fn)(uint8_t *workarea_base, uint32_t workarea_size, bool force_reload);
typedef int (*rom_pick_ab_partition_fn)(uint8_t *workarea_base, uint32_t workarea_size, uint partition_a_num, uint32_t flash_update_boot_window_base);
typedef int (*rom_get_b_partition_fn)(uint pi_a);
typedef int (*rom_get_uf2_target_partition_fn)(uint8_t *workarea_base, uint32_t workarea_size, uint32_t family_id, resident_partition_t *partition_out);
typedef int (*rom_func_otp_access_fn)(uint8_t *buf, uint32_t buf_len, otp_cmd_t cmd);
typedef intptr_t (*rom_flash_runtime_to_storage_addr_fn)(uintptr_t flash_runtime_addr);
typedef int (*rom_flash_op_fn)(cflash_flags_t flags, uintptr_t addr, uint32_t size_bytes, uint8_t *buf);
#ifndef __riscv
typedef int (*rom_set_ns_api_permission_fn)(uint ns_api_num, bool allowed);
/* ... */
typedef int (*rom_func_secure_call)(uintptr_t a0, ...);/* ... */
#endif
#ifdef __riscv
typedef struct {
uint32_t *base;
uint32_t size;
...} bootrom_stack_t;
typedef int (*rom_set_bootrom_stack_fn)(bootrom_stack_t *stack);/* ... */
#endif/* ... */
#endif
#ifdef __cplusplus
extern "C" {
#endif
/* ... */
static inline uint32_t rom_table_code(uint8_t c1, uint8_t c2) {
return ROM_TABLE_CODE((uint32_t) c1, (uint32_t) c2);
}{ ... }
/* ... */
void *rom_func_lookup(uint32_t code);
/* ... */
void *rom_data_lookup(uint32_t code);
/* ... */
bool rom_funcs_lookup(uint32_t *table, unsigned int count);
#if PICO_RP2040
typedef void *(*rom_table_lookup_fn)(uint16_t *table, uint32_t code);
#else
typedef void *(*rom_table_lookup_fn)(uint32_t code, uint32_t mask);
#endif
#if PICO_C_COMPILER_IS_GNU && (__GNUC__ >= 12)
__force_inline static void *rom_hword_as_ptr(uint16_t rom_address) {
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Warray-bounds"
return (void *)(uintptr_t)*(uint16_t *)(uintptr_t)rom_address;
#pragma GCC diagnostic pop
}rom_hword_as_ptr (uint16_t rom_address) { ... }
/* ... */#else
#define rom_hword_as_ptr(rom_address) (void *)(uintptr_t)(*(uint16_t *)(uintptr_t)(rom_address))
/* ... */#endif
#ifdef __riscv
static __force_inline bool rom_size_is_64k(void) {
#ifdef RASPBERRYPI_AMETHYST_FPGA
uint result;
pico_default_asm_volatile (
"li %0, 0\n"
"csrr t2, mstatus\n"
"csrci mstatus, 0x8\n"
"la t0, 1f\n"
"csrrw t0, mtvec, t0\n"
"li t1, 32 * 1024\n"
"lw t1, (t1)\n"
"li %0, 1\n"
".p2align 2\n"
"1:\n"
"csrw mtvec, t0\n"
"csrw mstatus, t2\n"
: "=r" (result)
:
: "t0", "t1", "t2"
);
return result;/* ... */
#else
return false;
#endif
}rom_size_is_64k (void) { ... }
/* ... */#endif
/* ... */
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Warray-bounds"
static __force_inline void *rom_func_lookup_inline(uint32_t code) {
#if PICO_RP2040
rom_table_lookup_fn rom_table_lookup = (rom_table_lookup_fn) rom_hword_as_ptr(BOOTROM_TABLE_LOOKUP_OFFSET);
uint16_t *func_table = (uint16_t *) rom_hword_as_ptr(BOOTROM_FUNC_TABLE_OFFSET);
return rom_table_lookup(func_table, code);/* ... */
#else
#ifdef __riscv
uint32_t rom_offset_adjust = rom_size_is_64k() ? 32 * 1024 : 0;
rom_table_lookup_fn rom_table_lookup = (rom_table_lookup_fn) (uintptr_t)*(uint16_t*)(BOOTROM_TABLE_LOOKUP_ENTRY_OFFSET + rom_offset_adjust);
return rom_table_lookup(code, RT_FLAG_FUNC_RISCV);/* ... */
#else
rom_table_lookup_fn rom_table_lookup = (rom_table_lookup_fn) (uintptr_t)*(uint16_t*)(BOOTROM_TABLE_LOOKUP_OFFSET);
if (pico_processor_state_is_nonsecure()) {
return rom_table_lookup(code, RT_FLAG_FUNC_ARM_NONSEC);
}if (pico_processor_state_is_nonsecure()) { ... } else {
return rom_table_lookup(code, RT_FLAG_FUNC_ARM_SEC);
}else { ... }
/* ... */#endif/* ... */
#endif
}{ ... }
#pragma GCC diagnostic pop
/* ... */
void __attribute__((noreturn)) rom_reset_usb_boot(uint32_t usb_activity_gpio_pin_mask, uint32_t disable_interface_mask);
static inline void __attribute__((noreturn)) reset_usb_boot(uint32_t usb_activity_gpio_pin_mask, uint32_t disable_interface_mask) {
rom_reset_usb_boot(usb_activity_gpio_pin_mask, disable_interface_mask);
}{ ... }
/* ... */
static inline void rom_connect_internal_flash() {
rom_connect_internal_flash_fn func = (rom_connect_internal_flash_fn) rom_func_lookup_inline(ROM_FUNC_CONNECT_INTERNAL_FLASH);
func();
}{ ... }
/* ... */
static inline void rom_flash_exit_xip() {
rom_flash_exit_xip_fn func = (rom_flash_exit_xip_fn) rom_func_lookup_inline(ROM_FUNC_FLASH_EXIT_XIP);
func();
}{ ... }
/* ... */
static inline void rom_flash_range_erase(uint32_t addr, size_t count, uint32_t block_size, uint8_t block_cmd) {
rom_flash_range_erase_fn func = (rom_flash_range_erase_fn) rom_func_lookup_inline(ROM_FUNC_FLASH_RANGE_ERASE);
func(addr, count, block_size, block_cmd);
}{ ... }
/* ... */
static inline void rom_flash_range_program(uint32_t addr, const uint8_t *data, size_t count) {
rom_flash_range_program_fn func = (rom_flash_range_program_fn) rom_func_lookup_inline(ROM_FUNC_FLASH_RANGE_PROGRAM);
func(addr, data, count);
}{ ... }
/* ... */
static inline void rom_flash_flush_cache() {
rom_flash_flush_cache_fn func = (rom_flash_flush_cache_fn) rom_func_lookup_inline(ROM_FUNC_FLASH_FLUSH_CACHE);
func();
}{ ... }
/* ... */
static inline void rom_flash_enter_cmd_xip() {
rom_flash_enter_cmd_xip_fn func = (rom_flash_enter_cmd_xip_fn) rom_func_lookup_inline(ROM_FUNC_FLASH_ENTER_CMD_XIP);
func();
}{ ... }
#if !PICO_RP2040
#ifdef __riscv
/* ... */
static inline int rom_set_bootrom_stack(bootrom_stack_t *stack) {
rom_set_bootrom_stack_fn func = (rom_set_bootrom_stack_fn) rom_func_lookup_inline(ROM_FUNC_SET_BOOTROM_STACK);
return func(stack);
}rom_set_bootrom_stack (bootrom_stack_t *stack) { ... }
/* ... */#endif
/* ... */
static inline int rom_reboot(uint32_t flags, uint32_t delay_ms, uint32_t p0, uint32_t p1) {
rom_reboot_fn func = (rom_reboot_fn) rom_func_lookup_inline(ROM_FUNC_REBOOT);
return func(flags, delay_ms, p0, p1);
}{ ... }
bool rom_get_boot_random(uint32_t out[4]);
/* ... */
static inline void rom_bootrom_state_reset(uint32_t flags) {
rom_bootrom_state_reset_fn func = (rom_bootrom_state_reset_fn) rom_func_lookup_inline(ROM_FUNC_BOOTROM_STATE_RESET);
return func(flags);
}{ ... }
/* ... */
static inline void rom_flash_reset_address_trans(void) {
rom_flash_reset_address_trans_fn func = (rom_flash_reset_address_trans_fn) rom_func_lookup_inline(ROM_FUNC_FLASH_RESET_ADDRESS_TRANS);
func();
}{ ... }
/* ... */
static inline void rom_flash_select_xip_read_mode(bootrom_xip_mode_t mode, uint8_t clkdiv) {
rom_flash_select_xip_read_mode_fn func = (rom_flash_select_xip_read_mode_fn) rom_func_lookup_inline(ROM_FUNC_FLASH_SELECT_XIP_READ_MODE);
func(mode, clkdiv);
}{ ... }
/* ... */
static inline int rom_flash_op(cflash_flags_t flags, uintptr_t addr, uint32_t size_bytes, uint8_t *buf) {
rom_flash_op_fn func = (rom_flash_op_fn) rom_func_lookup_inline(ROM_FUNC_FLASH_OP);
if (!bootrom_try_acquire_lock(BOOTROM_LOCK_FLASH_OP))
return BOOTROM_ERROR_LOCK_REQUIRED;
int rc = func(flags, addr, size_bytes, buf);
bootrom_release_lock(BOOTROM_LOCK_FLASH_OP);
return rc;
}{ ... }
/* ... */
static inline int rom_func_otp_access(uint8_t *buf, uint32_t buf_len, otp_cmd_t cmd) {
rom_func_otp_access_fn func = (rom_func_otp_access_fn) rom_func_lookup_inline(ROM_FUNC_OTP_ACCESS);
if (!bootrom_try_acquire_lock(BOOTROM_LOCK_OTP))
return BOOTROM_ERROR_LOCK_REQUIRED;
int rc = func(buf, buf_len, cmd);
bootrom_release_lock(BOOTROM_LOCK_OTP);
return rc;
}{ ... }
/* ... */
static inline int rom_get_partition_table_info(uint32_t *out_buffer, uint32_t out_buffer_word_size, uint32_t partition_and_flags) {
rom_get_partition_table_info_fn func = (rom_get_partition_table_info_fn) rom_func_lookup_inline(ROM_FUNC_GET_PARTITION_TABLE_INFO);
if (!bootrom_try_acquire_lock(BOOTROM_LOCK_SHA_256))
return BOOTROM_ERROR_LOCK_REQUIRED;
int rc = func(out_buffer, out_buffer_word_size, partition_and_flags);
bootrom_release_lock(BOOTROM_LOCK_SHA_256);
return rc;
}{ ... }
/* ... */
static inline int rom_load_partition_table(uint8_t *workarea_base, uint32_t workarea_size, bool force_reload) {
rom_load_partition_table_fn func = (rom_load_partition_table_fn) rom_func_lookup_inline(ROM_FUNC_LOAD_PARTITION_TABLE);
if (!bootrom_try_acquire_lock(BOOTROM_LOCK_SHA_256))
return BOOTROM_ERROR_LOCK_REQUIRED;
int rc = func(workarea_base, workarea_size, force_reload);
bootrom_release_lock(BOOTROM_LOCK_SHA_256);
return rc;
}{ ... }
/* ... */
static inline int rom_pick_ab_partition(uint8_t *workarea_base, uint32_t workarea_size, uint partition_a_num, uint32_t flash_update_boot_window_base) {
rom_pick_ab_partition_fn func = (rom_pick_ab_partition_fn) rom_func_lookup_inline(ROM_FUNC_PICK_AB_PARTITION);
if (!bootrom_try_acquire_lock(BOOTROM_LOCK_SHA_256))
return BOOTROM_ERROR_LOCK_REQUIRED;
int rc = func(workarea_base, workarea_size, partition_a_num, flash_update_boot_window_base);
bootrom_release_lock(BOOTROM_LOCK_SHA_256);
return rc;
}{ ... }
/* ... */
static inline int rom_get_b_partition(uint pi_a) {
rom_get_b_partition_fn func = (rom_get_b_partition_fn) rom_func_lookup_inline(ROM_FUNC_GET_B_PARTITION);
return func(pi_a);
}{ ... }
/* ... */
static inline int rom_get_uf2_target_partition(uint8_t *workarea_base, uint32_t workarea_size, uint32_t family_id, resident_partition_t *partition_out) {
rom_get_uf2_target_partition_fn func = (rom_get_uf2_target_partition_fn) rom_func_lookup_inline(ROM_FUNC_GET_UF2_TARGET_PARTITION);
if (!bootrom_try_acquire_lock(BOOTROM_LOCK_SHA_256))
return BOOTROM_ERROR_LOCK_REQUIRED;
int rc = func(workarea_base, workarea_size, family_id, partition_out);
bootrom_release_lock(BOOTROM_LOCK_SHA_256);
return rc;
}{ ... }
/* ... */
static inline intptr_t rom_flash_runtime_to_storage_addr(uintptr_t flash_runtime_addr) {
rom_flash_runtime_to_storage_addr_fn func = (rom_flash_runtime_to_storage_addr_fn) rom_func_lookup_inline(ROM_FUNC_FLASH_RUNTIME_TO_STORAGE_ADDR);
return func(flash_runtime_addr);
}{ ... }
/* ... */
static inline int rom_chain_image(uint8_t *workarea_base, uint32_t workarea_size, uint32_t region_base, uint32_t region_size) {
rom_chain_image_fn func = (rom_chain_image_fn) rom_func_lookup_inline(ROM_FUNC_CHAIN_IMAGE);
bootrom_release_lock(BOOTROM_LOCK_ENABLE);
int rc = func(workarea_base, workarea_size, region_base, region_size);
bootrom_acquire_lock_blocking(BOOTROM_LOCK_ENABLE);
return rc;
}{ ... }
/* ... */
static inline int rom_explicit_buy(uint8_t *buffer, uint32_t buffer_size) {
rom_explicit_buy_fn func = (rom_explicit_buy_fn) rom_func_lookup_inline(ROM_FUNC_EXPLICIT_BUY);
return func(buffer, buffer_size);
}{ ... }
#ifndef __riscv
/* ... */
static inline int rom_set_ns_api_permission(uint ns_api_num, bool allowed) {
rom_set_ns_api_permission_fn func = (rom_set_ns_api_permission_fn) rom_func_lookup_inline(ROM_FUNC_SET_NS_API_PERMISSION);
return func(ns_api_num, allowed);
}{ ... }
#endif/* ... */
/* ... */
static inline void* rom_validate_ns_buffer(const void *addr, uint32_t size, uint32_t write, uint32_t *ok) {
rom_validate_ns_buffer_fn func = (rom_validate_ns_buffer_fn) rom_func_lookup_inline(ROM_FUNC_VALIDATE_NS_BUFFER);
return func(addr, size, write, ok);
}{ ... }
/* ... */
static inline intptr_t rom_set_rom_callback(uint callback_num, bootrom_api_callback_generic_t funcptr) {
rom_set_rom_callback_fn func = (rom_set_rom_callback_fn) rom_func_lookup_inline(ROM_FUNC_SET_ROM_CALLBACK);
return func(callback_num, funcptr);
}{ ... }
#define BOOT_TYPE_NORMAL 0
#define BOOT_TYPE_BOOTSEL 2
#define BOOT_TYPE_RAM_IMAGE 3
#define BOOT_TYPE_FLASH_UPDATE 4
#define BOOT_TYPE_PC_SP 0xd
#define BOOT_TYPE_CHAINED_FLAG 0x80
6 defines
/* ... */
static inline int rom_get_sys_info(uint32_t *out_buffer, uint32_t out_buffer_word_size, uint32_t flags) {
rom_get_sys_info_fn func = (rom_get_sys_info_fn)rom_func_lookup_inline(ROM_FUNC_GET_SYS_INFO);
return func(out_buffer, out_buffer_word_size, flags);
}{ ... }
typedef struct {
union {
struct __packed {
int8_t diagnostic_partition_index;
uint8_t boot_type;
int8_t partition;
uint8_t tbyb_and_update_info;
...};
uint32_t boot_word;
...};
uint32_t boot_diagnostic;
uint32_t reboot_params[2];
...} boot_info_t;
static inline int rom_get_boot_info(boot_info_t *info) {
uint32_t result[5];
int words_returned = rom_get_sys_info(result, 5, SYS_INFO_BOOT_INFO);
if (words_returned == (sizeof(result)/sizeof(result[0])) && result[0] == SYS_INFO_BOOT_INFO) {
memcpy(info, &result[1], sizeof(boot_info_t));
return true;
}if (words_returned == (sizeof(result)/sizeof(result[0])) && result[0] == SYS_INFO_BOOT_INFO) { ... } else {
return false;
}else { ... }
}{ ... }
static inline int rom_get_last_boot_type_with_chained_flag(void) {
uint32_t result[5];
int words_returned = rom_get_sys_info(result, 5, SYS_INFO_BOOT_INFO);
if (words_returned == count_of(result) && result[0] == SYS_INFO_BOOT_INFO) {
return (int)((result[1] & 0xff00u) >> 8);
}if (words_returned == count_of(result) && result[0] == SYS_INFO_BOOT_INFO) { ... } else {
return PICO_ERROR_INVALID_DATA;
}else { ... }
}{ ... }
static inline int rom_get_last_boot_type(void) {
int rc = rom_get_last_boot_type_with_chained_flag();
if (rc >= 0) rc &= ~BOOT_TYPE_CHAINED_FLAG;
return rc;
}{ ... }
/* ... */
int rom_add_flash_runtime_partition(uint32_t start_offset, uint32_t size, uint32_t permissions);
/* ... */
#endif
#ifdef __cplusplus
}extern "C" { ... }
#endif
/* ... */
#endif /* ... */
#endif