Include dualboot.h in dualboot.c as an additional compile time sanity check
[kugel-rb.git] / rbutil / mkamsboot / mkamsboot.h
blob06fd329c8cc89ba700937b9adbbb7dd31a7557ec
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * mkamsboot.h - a tool for merging bootloader code into an Sansa V2
11 * (AMS) firmware file
13 * Copyright (C) 2008 Dave Chapman
15 * This program is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU General Public License
17 * as published by the Free Software Foundation; either version 2
18 * of the License, or (at your option) any later version.
20 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
21 * KIND, either express or implied.
23 ****************************************************************************/
25 #ifndef MKAMSBOOT_H
26 #define MKAMSBOOT_H
28 #include <stdint.h>
29 #include <sys/types.h>
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
35 /* Supported models */
36 enum {
37 MODEL_UNKNOWN = -1,
38 MODEL_FUZE = 0,
39 MODEL_CLIP,
40 MODEL_CLIPV2,
41 MODEL_E200V2,
42 MODEL_M200V4,
43 MODEL_C200V2,
44 MODEL_CLIPPLUS,
48 /* Holds info about the OF */
49 struct md5sums {
50 int model;
51 char *version;
52 char *md5;
55 extern const unsigned short hw_revisions[];
56 extern const unsigned short fw_revisions[];
57 extern const char* model_names[];
58 extern const int bootloader_sizes[];
60 /* load_rockbox_file()
62 * Loads a rockbox bootloader file into memory
64 * ARGUMENTS
66 * filename : bootloader file to load
67 * model : a 4 characters string representing the Sansa model
68 * ("fuze", "clip", "e2v2", "m2v4", or "c2v2")
69 * bootloader_size : set to the uncompressed bootloader size
70 * rb_packed_size : set to the size of compressed bootloader
71 * errstr : provided buffer to store an eventual error
72 * errstrsize : size of provided error buffer
74 * RETURN VALUE
75 * pointer to allocated memory containing the content of compressed bootloader
76 * or NULL in case of error (errstr will hold a description of the error)
79 unsigned char* load_rockbox_file(
80 char* filename, int model, int* bootloader_size, int* rb_packedsize,
81 char* errstr, int errstrsize);
84 /* load_of_file()
86 * Loads a Sansa AMS Original Firmware file into memory
88 * ARGUMENTS
90 * filename : firmware file to load
91 * bufsize : set to firmware file size
92 * md5sum : set to file md5sum, must be at least 33 bytes long
93 * model : set to firmware model (MODEL_XXX)
94 * fw_version : set to firmware format version (1 or 2)
95 * firmware_size : set to firmware block's size
96 * of_packed : pointer to allocated memory containing the compressed
97 * original firmware block
98 * of_packedsize : size of compressed original firmware block
99 * errstr : provided buffer to store an eventual error
100 * errstrsize : size of provided error buffer
102 * RETURN VALUE
103 * pointer to allocated memory containing the content of Original Firmware
104 * or NULL in case of error (errstr will hold a description of the error)
107 unsigned char* load_of_file(
108 char* filename, off_t* bufsize, struct md5sums *sum,
109 int* firmware_size, unsigned char** of_packed,
110 int* of_packedsize, char* errstr, int errstrsize);
113 /* patch_firmware()
115 * Patches a Sansa AMS Original Firmware file
117 * ARGUMENTS
119 * model : firmware model (MODEL_XXX)
120 * fw_version : firmware format version (1 or 2)
121 * firmware_size : size of uncompressed original firmware block
122 * buf : pointer to original firmware file
123 * len : size of original firmware file
124 * of_packed : pointer to compressed original firmware block
125 * of_packedsize : size of compressed original firmware block
126 * rb_packed : pointer to compressed rockbox bootloader
127 * rb_packed_size : size of compressed rockbox bootloader
130 void patch_firmware(
131 int model, int fw_version, int firmware_size, unsigned char* buf,
132 int len, unsigned char* of_packed, int of_packedsize,
133 unsigned char* rb_packed, int rb_packedsize);
136 /* total_size()
138 * Calculates the size of the new firmware block
140 * ARGUMENTS
142 * model : firmware model (MODEL_XXX)
143 * rb_packed_size : size of compressed rockbox bootloader
144 * of_packedsize : size of compressed original firmware block
146 * RETURN VALUE
147 * Size of new firmware block
150 int total_size(int model, int rb_packedsize, int of_packedsize);
152 /* firmware_revision()
154 * returns the firmware revision for a particular model
156 * ARGUMENTS
158 * model : firmware model (MODEL_XXX)
160 * RETURN VALUE
161 * firmware version
163 int firmware_revision(int model);
165 #ifdef __cplusplus
167 #endif
169 #endif