summaryrefslogtreecommitdiffstats
path: root/utils/imxtools/sbtools/rsrc.h
diff options
context:
space:
mode:
authorAmaury Pouly <amaury.pouly@gmail.com>2012-11-29 17:27:34 +0100
committerAmaury Pouly <amaury.pouly@gmail.com>2012-11-29 17:30:54 +0100
commitee36a396cd1619585a83803630db2d79b6cbefbd (patch)
treed24e9737433147ef3e57f00f8734f0e54123b810 /utils/imxtools/sbtools/rsrc.h
parent0ee512ca04e52b62550bd06532ffa67bdeab3d04 (diff)
downloadrockbox-ee36a396cd1619585a83803630db2d79b6cbefbd.tar.gz
rockbox-ee36a396cd1619585a83803630db2d79b6cbefbd.tar.bz2
rockbox-ee36a396cd1619585a83803630db2d79b6cbefbd.zip
imxtools: introduce rsrctool to manipulate rsrc sections
This tool is very preliminary but could be use for whatever purpose since the format of the rsrc sections is now known. By the way it appears that this format is the same as the one use by the stmp36xx for its resources. Change-Id: Idd7057f5cdce5af9726904169bb100c8bacb0981
Diffstat (limited to 'utils/imxtools/sbtools/rsrc.h')
-rw-r--r--utils/imxtools/sbtools/rsrc.h76
1 files changed, 76 insertions, 0 deletions
diff --git a/utils/imxtools/sbtools/rsrc.h b/utils/imxtools/sbtools/rsrc.h
new file mode 100644
index 0000000000..fc310e348d
--- /dev/null
+++ b/utils/imxtools/sbtools/rsrc.h
@@ -0,0 +1,76 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2012 Amaury Pouly
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+#ifndef __RSRC_H__
+#define __RSRC_H__
+
+#include <stdint.h>
+#include <stdbool.h>
+
+#include "misc.h"
+
+#define RSRC_SECTOR_SIZE 2048
+
+#define RSRC_TABLE_ENTRY_TYPE(e) ((e) >> 28)
+#define RSRC_TABLE_ENTRY_OFFSET(e) ((e) & 0xfffffff)
+
+#define RSRC_TYPE_NONE 0 /* empty entry */
+#define RSRC_TYPE_NESTED 1 /* nested entry: points to a sub-table */
+#define RSRC_TYPE_IMAGE 2 /* image entry */
+#define RSRC_TYPE_VALUE 3 /* value stored on 28-bits */
+#define RSRC_TYPE_AUDIO 4 /* audio entry */
+#define RSRC_TYPE_DATA 5 /* data entry */
+
+struct rsrc_file_t
+{
+ void *data;
+ int size;
+};
+
+enum rsrc_error_t
+{
+ RSRC_SUCCESS = 0,
+ RSRC_ERROR = -1,
+ RSRC_OPEN_ERROR = -2,
+ RSRC_READ_ERROR = -3,
+ RSRC_WRITE_ERROR = -4,
+ RSRC_FORMAT_ERROR = -5,
+ RSRC_CHECKSUM_ERROR = -6,
+ RSRC_NO_VALID_KEY = -7,
+ RSRC_FIRST_CRYPTO_ERROR = -8,
+ RSRC_LAST_CRYPTO_ERROR = RSRC_FIRST_CRYPTO_ERROR - CRYPTO_NUM_ERRORS,
+};
+
+enum rsrc_error_t rsrc_write_file(struct rsrc_file_t *rsrc, const char *filename);
+
+typedef void (*rsrc_color_printf)(void *u, bool err, color_t c, const char *f, ...);
+struct rsrc_file_t *rsrc_read_file(const char *filename, void *u,
+ rsrc_color_printf printf, enum rsrc_error_t *err);
+/* use size_t(-1) to use maximum size */
+struct rsrc_file_t *rsrc_read_file_ex(const char *filename, size_t offset, size_t size, void *u,
+ rsrc_color_printf printf, enum rsrc_error_t *err);
+struct rsrc_file_t *rsrc_read_memory(void *buffer, size_t size, void *u,
+ rsrc_color_printf printf, enum rsrc_error_t *err);
+
+void rsrc_dump(struct rsrc_file_t *file, void *u, rsrc_color_printf printf);
+void rsrc_free(struct rsrc_file_t *file);
+
+#endif /* __RSRC_H__ */
+