summaryrefslogtreecommitdiff
path: root/utils/sbtools/dbparser.h
diff options
context:
space:
mode:
authorAmaury Pouly <pamaury@rockbox.org>2011-09-15 16:10:31 +0000
committerAmaury Pouly <pamaury@rockbox.org>2011-09-15 16:10:31 +0000
commit9d7df9ae4d829204856a19fc14fae166631389bf (patch)
treeb82178fd2b0c7b4f75735599d99ce7fabbd53261 /utils/sbtools/dbparser.h
parent64b46723591adc8b563a692c0e91681d2fcd4ad4 (diff)
downloadrockbox-9d7df9ae4d829204856a19fc14fae166631389bf.zip
rockbox-9d7df9ae4d829204856a19fc14fae166631389bf.tar.gz
rockbox-9d7df9ae4d829204856a19fc14fae166631389bf.tar.bz2
rockbox-9d7df9ae4d829204856a19fc14fae166631389bf.tar.xz
sbtools: move the db parse to its own file and improve error messages
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30557 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'utils/sbtools/dbparser.h')
-rw-r--r--utils/sbtools/dbparser.h94
1 files changed, 94 insertions, 0 deletions
diff --git a/utils/sbtools/dbparser.h b/utils/sbtools/dbparser.h
new file mode 100644
index 0000000..f1b7ffd
--- /dev/null
+++ b/utils/sbtools/dbparser.h
@@ -0,0 +1,94 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2011 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 __DBPARSER__
+#define __DBPARSER__
+
+/**
+ * Command file parsing
+ */
+#include "sb.h"
+#include "elf.h"
+
+enum cmd_source_type_t
+{
+ CMD_SRC_UNK,
+ CMD_SRC_ELF,
+ CMD_SRC_BIN
+};
+
+struct bin_param_t
+{
+ uint32_t size;
+ void *data;
+};
+
+struct cmd_source_t
+{
+ char *identifier;
+ char *filename;
+ struct cmd_source_t *next;
+ /* for later use */
+ enum cmd_source_type_t type;
+ bool loaded;
+ struct elf_params_t elf;
+ struct bin_param_t bin;
+};
+
+enum cmd_inst_type_t
+{
+ CMD_LOAD, /* load image */
+ CMD_JUMP, /* jump at image */
+ CMD_CALL, /* call image */
+ CMD_LOAD_AT, /* load binary at */
+ CMD_CALL_AT, /* call at address */
+ CMD_JUMP_AT, /* jump at address */
+ CMD_MODE, /* change boot mode */
+};
+
+struct cmd_inst_t
+{
+ enum cmd_inst_type_t type;
+ char *identifier;
+ uint32_t argument; // for jump, call, mode
+ uint32_t addr; // for 'at'
+ struct cmd_inst_t *next;
+};
+
+struct cmd_section_t
+{
+ uint32_t identifier;
+ struct cmd_inst_t *inst_list;
+ struct cmd_section_t *next;
+};
+
+struct cmd_file_t
+{
+ struct sb_version_t product_ver;
+ struct sb_version_t component_ver;
+ struct cmd_source_t *source_list;
+ struct cmd_section_t *section_list;
+};
+
+struct cmd_source_t *db_find_source_by_id(struct cmd_file_t *cmd_file, const char *id);
+bool db_parse_sb_version(struct sb_version_t *ver, char *str);
+struct cmd_file_t *db_parse_file(const char *file);
+
+#endif /* __DBPARSER__ */