summaryrefslogtreecommitdiffstats
path: root/utils/sbtools/sb.h
diff options
context:
space:
mode:
authorAmaury Pouly <pamaury@rockbox.org>2011-10-29 17:01:47 +0000
committerAmaury Pouly <pamaury@rockbox.org>2011-10-29 17:01:47 +0000
commitd2a58f3aadf33e11bcbc4743cac65d4464447db8 (patch)
treec800fee3b6598b86aa3ff3aaf971d4ad5d6e9d06 /utils/sbtools/sb.h
parent93c6c79e8d2ee39056afe7f8145b051d4a0e8d38 (diff)
downloadrockbox-d2a58f3aadf33e11bcbc4743cac65d4464447db8.tar.gz
rockbox-d2a58f3aadf33e11bcbc4743cac65d4464447db8.tar.bz2
rockbox-d2a58f3aadf33e11bcbc4743cac65d4464447db8.zip
sbtools: move sb file production to its own file with a clean api, factor key reading even more
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30851 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'utils/sbtools/sb.h')
-rw-r--r--utils/sbtools/sb.h53
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 @@
#define __SB_H__
#include <stdint.h>
+#include <stdbool.h>
#define BLOCK_SIZE 16
@@ -150,4 +151,56 @@ struct sb_instruction_tag_t
uint32_t flags; /* section flags */
} __attribute__((packed));
+/*******
+ * API *
+ *******/
+
+#define SB_INST_DATA 0xff
+
+struct sb_inst_t
+{
+ uint8_t inst; /* SB_INST_* */
+ uint32_t size;
+ // <union>
+ void *data;
+ uint32_t pattern;
+ uint32_t addr;
+ // </union>
+ uint32_t argument; // for call and jump
+ /* for production use */
+ uint32_t padding_size;
+ uint8_t *padding;
+};
+
+struct sb_section_t
+{
+ uint32_t identifier;
+ bool is_data;
+ bool is_cleartext;
+ uint32_t alignment;
+ // data sections are handled as one or more SB_INST_DATA virtual instruction
+ int nr_insts;
+ struct sb_inst_t *insts;
+ /* for production use */
+ uint32_t file_offset; /* in blocks */
+ uint32_t sec_size; /* in blocks */
+};
+
+struct sb_file_t
+{
+ /* override real, otherwise it is randomly generated */
+ uint8_t (*real_key)[16];
+ /* override crypto IV, use with caution ! Use NULL to generate it */
+ uint8_t (*crypto_iv)[16];
+
+ int nr_sections;
+ struct sb_section_t *sections;
+ struct sb_version_t product_ver;
+ struct sb_version_t component_ver;
+ /* for production use */
+ uint32_t image_size; /* in blocks */
+};
+
+void sb_produce_file(struct sb_file_t *sb, const char *filename);
+
#endif /* __SB_H__ */