@web-font-path: "roboto-debian.css";
Loading...
Searching...
No Matches
structure.h
1/*
2 * Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#ifndef _PICO_BINARY_INFO_STRUCTURE_H
8#define _PICO_BINARY_INFO_STRUCTURE_H
9
10// NOTE: This file may be included by non SDK code, so does not use SDK includes
11
12// NOTE: ALL CHANGES MUST BE BACKWARDS COMPATIBLE
13
14#ifdef __cplusplus
15extern "C" {
16#endif
17
18#include <stdint.h>
19
20#ifndef __packed
21#define __packed __attribute__((packed))
22#endif
23
24#if !defined(le_uint16_t) || !defined(le_uint32_t) || !defined(le_int32_t)
25
26#if defined(_MSC_VER) || __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
27
28#ifndef le_uint16_t
29#define le_uint16_t uint16_t
30#endif
31#ifndef le_uint32_t
32#define le_uint32_t uint32_t
33#endif
34#ifndef le_int32_t
35#define le_int32_t int32_t
36#endif
37
38#else
39#error Must define le_uint16_t, le_uint32_t, and le_int32_t when compiling for big endian
40#endif
41
42#endif
43
44
45typedef struct _binary_info_core binary_info_t;
46
47#define BINARY_INFO_TYPE_RAW_DATA 1
48#define BINARY_INFO_TYPE_SIZED_DATA 2
49#define BINARY_INFO_TYPE_BINARY_INFO_LIST_ZERO_TERMINATED 3
50#define BINARY_INFO_TYPE_BSON 4
51#define BINARY_INFO_TYPE_ID_AND_INT 5
52#define BINARY_INFO_TYPE_ID_AND_STRING 6
53// traditional block device
54#define BINARY_INFO_TYPE_BLOCK_DEVICE 7
55#define BINARY_INFO_TYPE_PINS_WITH_FUNC 8
56#define BINARY_INFO_TYPE_PINS_WITH_NAME 9
57#define BINARY_INFO_TYPE_PINS_WITH_NAMES 9
58#define BINARY_INFO_TYPE_NAMED_GROUP 10
59
60// note plan is to reserve c1 = 0->31 for "collision tags"; i.e.
61// for which you should always use random IDs with the binary_info,
62// giving you 4 + 8 + 32 = 44 bits to avoid collisions
63#define BINARY_INFO_MAKE_TAG(c1, c2) ((((uint)c2&0xffu)<<8u)|((uint)c1&0xffu))
64
65// Raspberry Pi defined. do not use
66#define BINARY_INFO_TAG_RASPBERRY_PI BINARY_INFO_MAKE_TAG('R','P')
67
68#define BINARY_INFO_ID_RP_PROGRAM_NAME 0x02031c86
69#define BINARY_INFO_ID_RP_PROGRAM_VERSION_STRING 0x11a9bc3a
70#define BINARY_INFO_ID_RP_PROGRAM_BUILD_DATE_STRING 0x9da22254
71#define BINARY_INFO_ID_RP_BINARY_END 0x68f465de
72#define BINARY_INFO_ID_RP_PROGRAM_URL 0x1856239a
73#define BINARY_INFO_ID_RP_PROGRAM_DESCRIPTION 0xb6a07c19
74#define BINARY_INFO_ID_RP_PROGRAM_FEATURE 0xa1f4b453
75#define BINARY_INFO_ID_RP_PROGRAM_BUILD_ATTRIBUTE 0x4275f0d3
76#define BINARY_INFO_ID_RP_SDK_VERSION 0x5360b3ab
77#define BINARY_INFO_ID_RP_PICO_BOARD 0xb63cffbb
78#define BINARY_INFO_ID_RP_BOOT2_NAME 0x7f8882e1
79
80#if PICO_ON_DEVICE
81#define bi_ptr_of(x) x *
82#else
83#define bi_ptr_of(x) le_uint32_t
84#endif
85typedef struct __packed _binary_info_core {
86 le_uint16_t type;
87 le_uint16_t tag;
89
90typedef struct __packed _binary_info_raw_data {
91 struct _binary_info_core core;
92 uint8_t bytes[1];
94
95typedef struct __packed _binary_info_sized_data {
96 struct _binary_info_core core;
97 le_uint32_t length;
98 uint8_t bytes[1];
100
101typedef struct __packed _binary_info_list_zero_terminated {
102 struct _binary_info_core core;
103 bi_ptr_of(binary_info_t) list;
105
106typedef struct __packed _binary_info_id_and_int {
107 struct _binary_info_core core;
108 le_uint32_t id;
109 le_int32_t value;
111
112typedef struct __packed _binary_info_id_and_string {
113 struct _binary_info_core core;
114 le_uint32_t id;
115 bi_ptr_of(const char) value;
117
118typedef struct __packed _binary_info_block_device {
119 struct _binary_info_core core;
120 bi_ptr_of(const char) name; // optional static name (independent of what is formatted)
121 le_uint32_t address;
122 le_uint32_t size;
123 bi_ptr_of(binary_info_t) extra; // additional info
124 le_uint16_t flags;
126
127#define BI_PINS_ENCODING_RANGE 1
128#define BI_PINS_ENCODING_MULTI 2
129
130typedef struct __packed _binary_info_pins_with_func {
131 struct _binary_info_core core;
132 // p4_5 : p3_5 : p2_5 : p1_5 : p0_5 : func_4 : 010_3 //individual pins p0,p1,p2,p3,p4 ... if fewer than 5 then duplicate p
133 // phi_5 : plo_5 : func_4 : 001_3 // pin range plo-phi inclusive
134 le_uint32_t pin_encoding;
136
137typedef struct __packed _binary_info_pins_with_name {
138 struct _binary_info_core core;
139 le_uint32_t pin_mask;
140 bi_ptr_of(const char) label;
142
143#define BI_NAMED_GROUP_SHOW_IF_EMPTY 0x0001 // default is to hide
144#define BI_NAMED_GROUP_SEPARATE_COMMAS 0x0002 // default is newlines
145#define BI_NAMED_GROUP_SORT_ALPHA 0x0004 // default is no sort
146#define BI_NAMED_GROUP_ADVANCED 0x0008 // if set, then only shown in say info -a
147
148typedef struct __packed _binary_info_named_group {
149 struct _binary_info_core core;
150 le_uint32_t parent_id;
151 le_uint16_t flags;
152 le_uint16_t group_tag;
153 le_uint32_t group_id;
154 bi_ptr_of(const char) label;
156
157enum {
158 BINARY_INFO_BLOCK_DEV_FLAG_READ =
159 1 << 0, // if not readable, then it is basically hidden, but tools may choose to avoid overwriting it
160 BINARY_INFO_BLOCK_DEV_FLAG_WRITE = 1 << 1,
161 BINARY_INFO_BLOCK_DEV_FLAG_REFORMAT = 1 << 2, // may be reformatted..
162
163 BINARY_INFO_BLOCK_DEV_FLAG_PT_UNKNOWN = 0 << 4, // unknown free to look
164 BINARY_INFO_BLOCK_DEV_FLAG_PT_MBR = 1 << 4, // expect MBR
165 BINARY_INFO_BLOCK_DEV_FLAG_PT_GPT = 2 << 4, // expect GPT
166 BINARY_INFO_BLOCK_DEV_FLAG_PT_NONE = 3 << 4, // no partition table
167};
168
169#ifdef __cplusplus
170}
171#endif
172#endif
Definition structure.h:118
Definition structure.h:85
Definition structure.h:106
Definition structure.h:112
Definition structure.h:101
Definition structure.h:148
Definition structure.h:130
Definition structure.h:137
Definition structure.h:90
Definition structure.h:95