summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAmaury Pouly <pamaury@rockbox.org>2011-04-16 18:22:37 +0000
committerAmaury Pouly <pamaury@rockbox.org>2011-04-16 18:22:37 +0000
commitd9b050ee2b069d65a57e2a65638a6ff1bf63ff17 (patch)
tree4625b39d0949c9846053211489de3d7cd4030983
parentff1f2e24156bc8a34eccfa9e0af4dcebdc6cf1d2 (diff)
downloadrockbox-d9b050ee2b069d65a57e2a65638a6ff1bf63ff17.tar.gz
rockbox-d9b050ee2b069d65a57e2a65638a6ff1bf63ff17.zip
sbinfo: move sb specific bits of its own header
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29722 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--utils/sbinfo/sb.h99
-rw-r--r--utils/sbinfo/sbinfo.c43
2 files changed, 100 insertions, 42 deletions
diff --git a/utils/sbinfo/sb.h b/utils/sbinfo/sb.h
new file mode 100644
index 0000000000..c4d705c14b
--- /dev/null
+++ b/utils/sbinfo/sb.h
@@ -0,0 +1,99 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2011 Amaury Pouly
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22#define _ISOC99_SOURCE /* snprintf() */
23#include <sys/types.h>
24#include <sys/stat.h>
25
26struct sb_version_t
27{
28 uint16_t major;
29 uint16_t pad0;
30 uint16_t minor;
31 uint16_t pad1;
32 uint16_t revision;
33 uint16_t pad2;
34};
35
36struct sb_header_t
37{
38 uint8_t sha1_header[20]; /* SHA-1 of the rest of the header */
39 uint8_t signature[4]; /* Signature "STMP" */
40 uint8_t major_ver; /* Should be 1 */
41 uint8_t minor_ver; /* Should be 1 */
42 uint16_t flags;
43 uint32_t image_size; /* In blocks (=16bytes) */
44 uint32_t first_boot_tag_off; /* Offset in blocks */
45 uint32_t first_boot_sec_id; /* First bootable section ID */
46 uint16_t nr_keys; /* Number of encryption keys */
47 uint16_t key_dict_off; /* Offset to key dictionary (in blocks) */
48 uint16_t header_size; /* In blocks */
49 uint16_t nr_sections; /* Number of sections */
50 uint16_t sec_hdr_size; /* Section header size (in blocks) */
51 uint8_t rand_pad0[6]; /* Random padding */
52 uint64_t timestamp; /* In microseconds since 2000/1/1 00:00:00 */
53 struct sb_version_t product_ver;
54 struct sb_version_t component_ver;
55 uint16_t drive_tag; /* Unknown meaning */
56 uint8_t rand_pad1[6]; /* Random padding */
57} __attribute__((packed));
58
59#define SB_INST_NOP 0x0
60#define SB_INST_TAG 0x1
61#define SB_INST_LOAD 0x2
62#define SB_INST_FILL 0x3
63#define SB_INST_JUMP 0x4
64#define SB_INST_CALL 0x5
65#define SB_INST_MODE 0x6
66
67#define ROM_SECTION_BOOTABLE (1 << 0)
68#define ROM_SECTION_CLEARTEXT (1 << 1)
69
70struct sb_instruction_header_t
71{
72 uint8_t checksum;
73 uint8_t opcode;
74 uint16_t zero_except_for_tag;
75} __attribute__((packed));
76
77struct sb_instruction_load_t
78{
79 struct sb_instruction_header_t hdr;
80 uint32_t addr;
81 uint32_t len;
82 uint32_t crc;
83} __attribute__((packed));
84
85struct sb_instruction_fill_t
86{
87 struct sb_instruction_header_t hdr;
88 uint32_t addr;
89 uint32_t len;
90 uint32_t pattern;
91} __attribute__((packed));
92
93struct sb_instruction_call_t
94{
95 struct sb_instruction_header_t hdr;
96 uint32_t addr;
97 uint32_t zero;
98 uint32_t arg;
99} __attribute__((packed));
diff --git a/utils/sbinfo/sbinfo.c b/utils/sbinfo/sbinfo.c
index 351847f19b..d6bab4addc 100644
--- a/utils/sbinfo/sbinfo.c
+++ b/utils/sbinfo/sbinfo.c
@@ -41,6 +41,7 @@
41 41
42#include "crypto.h" 42#include "crypto.h"
43#include "elf.h" 43#include "elf.h"
44#include "sb.h"
44 45
45#if 1 /* ANSI colors */ 46#if 1 /* ANSI colors */
46 47
@@ -80,48 +81,6 @@ uint8_t *g_buf; /* file content */
80char out_prefix[PREFIX_SIZE]; 81char out_prefix[PREFIX_SIZE];
81const char *key_file; 82const char *key_file;
82 83
83#define SB_INST_NOP 0x0
84#define SB_INST_TAG 0x1
85#define SB_INST_LOAD 0x2
86#define SB_INST_FILL 0x3
87#define SB_INST_JUMP 0x4
88#define SB_INST_CALL 0x5
89#define SB_INST_MODE 0x6
90
91#define ROM_SECTION_BOOTABLE (1 << 0)
92#define ROM_SECTION_CLEARTEXT (1 << 1)
93
94struct sb_instruction_header_t
95{
96 uint8_t checksum;
97 uint8_t opcode;
98 uint16_t zero_except_for_tag;
99} __attribute__((packed));
100
101struct sb_instruction_load_t
102{
103 struct sb_instruction_header_t hdr;
104 uint32_t addr;
105 uint32_t len;
106 uint32_t crc;
107} __attribute__((packed));
108
109struct sb_instruction_fill_t
110{
111 struct sb_instruction_header_t hdr;
112 uint32_t addr;
113 uint32_t len;
114 uint32_t pattern;
115} __attribute__((packed));
116
117struct sb_instruction_call_t
118{
119 struct sb_instruction_header_t hdr;
120 uint32_t addr;
121 uint32_t zero;
122 uint32_t arg;
123} __attribute__((packed));
124
125void *xmalloc(size_t s) /* malloc helper, used in elf.c */ 84void *xmalloc(size_t s) /* malloc helper, used in elf.c */
126{ 85{
127 void * r = malloc(s); 86 void * r = malloc(s);