summaryrefslogtreecommitdiff
path: root/rbutil/mkamsboot/mkamsboot.h
diff options
context:
space:
mode:
Diffstat (limited to 'rbutil/mkamsboot/mkamsboot.h')
-rw-r--r--rbutil/mkamsboot/mkamsboot.h124
1 files changed, 124 insertions, 0 deletions
diff --git a/rbutil/mkamsboot/mkamsboot.h b/rbutil/mkamsboot/mkamsboot.h
new file mode 100644
index 0000000000..e2de46c9b8
--- /dev/null
+++ b/rbutil/mkamsboot/mkamsboot.h
@@ -0,0 +1,124 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * mkamsboot.h - a tool for merging bootloader code into an Sansa V2
11 * (AMS) firmware file
12 *
13 * Copyright (C) 2008 Dave Chapman
14 *
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.
19 *
20 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
21 * KIND, either express or implied.
22 *
23 ****************************************************************************/
24
25#ifndef MKAMSBOOT_H
26#define MKAMSBOOT_H
27
28#include <stdint.h>
29#include <sys/types.h>
30
31
32/* load_rockbox_file()
33 *
34 * Loads a rockbox bootloader file into memory
35 *
36 * ARGUMENTS
37 *
38 * filename : bootloader file to load
39 * model : a 4 characters string representing the Sansa model
40 * ("fuze", "clip", "e2v2", "m2v4", or "c2v2")
41 * bootloader_size : set to the uncompressed bootloader size
42 * rb_packed_size : set to the size of compressed bootloader
43 * errstr : provided buffer to store an eventual error
44 * errstrsize : size of provided error buffer
45 *
46 * RETURN VALUE
47 * pointer to allocated memory containing the content of compressed bootloader
48 * or NULL in case of error (errstr will hold a description of the error)
49 */
50
51unsigned char* load_rockbox_file(
52 char* filename, int model, int* bootloader_size, int* rb_packedsize,
53 char* errstr, int errstrsize);
54
55
56/* load_of_file()
57 *
58 * Loads a Sansa AMS Original Firmware file into memory
59 *
60 * ARGUMENTS
61 *
62 * filename : firmware file to load
63 * bufsize : set to firmware file size
64 * md5sum : set to file md5sum, must be at least 33 bytes long
65 * model : set to firmware model (MODEL_XXX)
66 * fw_version : set to firmware format version (1 or 2)
67 * firmware_size : set to firmware block's size
68 * of_packed : pointer to allocated memory containing the compressed
69 * original firmware block
70 * of_packedsize : size of compressed original firmware block
71 * errstr : provided buffer to store an eventual error
72 * errstrsize : size of provided error buffer
73 *
74 * RETURN VALUE
75 * pointer to allocated memory containing the content of Original Firmware
76 * or NULL in case of error (errstr will hold a description of the error)
77 */
78
79unsigned char* load_of_file(
80 char* filename, off_t* bufsize, char* md5sum, int* model,
81 int* fw_version, int* firmware_size, unsigned char** of_packed,
82 int* of_packedsize, char* errstr, int errstrsize);
83
84
85/* patch_firmware()
86 *
87 * Patches a Sansa AMS Original Firmware file
88 *
89 * ARGUMENTS
90 *
91 * model : firmware model (MODEL_XXX)
92 * fw_version : firmware format version (1 or 2)
93 * firmware_size : size of uncompressed original firmware block
94 * buf : pointer to original firmware file
95 * len : size of original firmware file
96 * of_packed : pointer to compressed original firmware block
97 * of_packedsize : size of compressed original firmware block
98 * rb_packed : pointer to compressed rockbox bootloader
99 * rb_packed_size : size of compressed rockbox bootloader
100 */
101
102void patch_firmware(
103 int model, int fw_version, int firmware_size, unsigned char* buf,
104 int len, unsigned char* of_packed, int of_packedsize,
105 unsigned char* rb_packed, int rb_packedsize);
106
107
108/* total_size()
109 *
110 * Calculates the size of the new firmware block
111 *
112 * ARGUMENTS
113 *
114 * model : firmware model (MODEL_XXX)
115 * rb_packed_size : size of compressed rockbox bootloader
116 * of_packedsize : size of compressed original firmware block
117 *
118 * RETURN VALUE
119 * Size of new firmware block
120*/
121
122int total_size(int model, int rb_packedsize, int of_packedsize);
123
124#endif