diff options
Diffstat (limited to 'utils/sbtools/sb.h')
-rw-r--r-- | utils/sbtools/sb.h | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/utils/sbtools/sb.h b/utils/sbtools/sb.h index 0a8fad10af..27f5668d2e 100644 --- a/utils/sbtools/sb.h +++ b/utils/sbtools/sb.h | |||
@@ -22,6 +22,7 @@ | |||
22 | #define __SB_H__ | 22 | #define __SB_H__ |
23 | 23 | ||
24 | #include <stdint.h> | 24 | #include <stdint.h> |
25 | #include <stdbool.h> | ||
25 | 26 | ||
26 | #define BLOCK_SIZE 16 | 27 | #define BLOCK_SIZE 16 |
27 | 28 | ||
@@ -150,4 +151,56 @@ struct sb_instruction_tag_t | |||
150 | uint32_t flags; /* section flags */ | 151 | uint32_t flags; /* section flags */ |
151 | } __attribute__((packed)); | 152 | } __attribute__((packed)); |
152 | 153 | ||
154 | /******* | ||
155 | * API * | ||
156 | *******/ | ||
157 | |||
158 | #define SB_INST_DATA 0xff | ||
159 | |||
160 | struct sb_inst_t | ||
161 | { | ||
162 | uint8_t inst; /* SB_INST_* */ | ||
163 | uint32_t size; | ||
164 | // <union> | ||
165 | void *data; | ||
166 | uint32_t pattern; | ||
167 | uint32_t addr; | ||
168 | // </union> | ||
169 | uint32_t argument; // for call and jump | ||
170 | /* for production use */ | ||
171 | uint32_t padding_size; | ||
172 | uint8_t *padding; | ||
173 | }; | ||
174 | |||
175 | struct sb_section_t | ||
176 | { | ||
177 | uint32_t identifier; | ||
178 | bool is_data; | ||
179 | bool is_cleartext; | ||
180 | uint32_t alignment; | ||
181 | // data sections are handled as one or more SB_INST_DATA virtual instruction | ||
182 | int nr_insts; | ||
183 | struct sb_inst_t *insts; | ||
184 | /* for production use */ | ||
185 | uint32_t file_offset; /* in blocks */ | ||
186 | uint32_t sec_size; /* in blocks */ | ||
187 | }; | ||
188 | |||
189 | struct sb_file_t | ||
190 | { | ||
191 | /* override real, otherwise it is randomly generated */ | ||
192 | uint8_t (*real_key)[16]; | ||
193 | /* override crypto IV, use with caution ! Use NULL to generate it */ | ||
194 | uint8_t (*crypto_iv)[16]; | ||
195 | |||
196 | int nr_sections; | ||
197 | struct sb_section_t *sections; | ||
198 | struct sb_version_t product_ver; | ||
199 | struct sb_version_t component_ver; | ||
200 | /* for production use */ | ||
201 | uint32_t image_size; /* in blocks */ | ||
202 | }; | ||
203 | |||
204 | void sb_produce_file(struct sb_file_t *sb, const char *filename); | ||
205 | |||
153 | #endif /* __SB_H__ */ | 206 | #endif /* __SB_H__ */ |