diff options
author | Amaury Pouly <pamaury@rockbox.org> | 2011-09-15 16:10:31 +0000 |
---|---|---|
committer | Amaury Pouly <pamaury@rockbox.org> | 2011-09-15 16:10:31 +0000 |
commit | 9d7df9ae4d829204856a19fc14fae166631389bf (patch) | |
tree | b82178fd2b0c7b4f75735599d99ce7fabbd53261 /utils/sbtools/dbparser.h | |
parent | 64b46723591adc8b563a692c0e91681d2fcd4ad4 (diff) | |
download | rockbox-9d7df9ae4d829204856a19fc14fae166631389bf.tar.gz rockbox-9d7df9ae4d829204856a19fc14fae166631389bf.zip |
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.h | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/utils/sbtools/dbparser.h b/utils/sbtools/dbparser.h new file mode 100644 index 0000000000..f1b7ffd77e --- /dev/null +++ b/utils/sbtools/dbparser.h | |||
@@ -0,0 +1,94 @@ | |||
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 | #ifndef __DBPARSER__ | ||
22 | #define __DBPARSER__ | ||
23 | |||
24 | /** | ||
25 | * Command file parsing | ||
26 | */ | ||
27 | #include "sb.h" | ||
28 | #include "elf.h" | ||
29 | |||
30 | enum cmd_source_type_t | ||
31 | { | ||
32 | CMD_SRC_UNK, | ||
33 | CMD_SRC_ELF, | ||
34 | CMD_SRC_BIN | ||
35 | }; | ||
36 | |||
37 | struct bin_param_t | ||
38 | { | ||
39 | uint32_t size; | ||
40 | void *data; | ||
41 | }; | ||
42 | |||
43 | struct cmd_source_t | ||
44 | { | ||
45 | char *identifier; | ||
46 | char *filename; | ||
47 | struct cmd_source_t *next; | ||
48 | /* for later use */ | ||
49 | enum cmd_source_type_t type; | ||
50 | bool loaded; | ||
51 | struct elf_params_t elf; | ||
52 | struct bin_param_t bin; | ||
53 | }; | ||
54 | |||
55 | enum cmd_inst_type_t | ||
56 | { | ||
57 | CMD_LOAD, /* load image */ | ||
58 | CMD_JUMP, /* jump at image */ | ||
59 | CMD_CALL, /* call image */ | ||
60 | CMD_LOAD_AT, /* load binary at */ | ||
61 | CMD_CALL_AT, /* call at address */ | ||
62 | CMD_JUMP_AT, /* jump at address */ | ||
63 | CMD_MODE, /* change boot mode */ | ||
64 | }; | ||
65 | |||
66 | struct cmd_inst_t | ||
67 | { | ||
68 | enum cmd_inst_type_t type; | ||
69 | char *identifier; | ||
70 | uint32_t argument; // for jump, call, mode | ||
71 | uint32_t addr; // for 'at' | ||
72 | struct cmd_inst_t *next; | ||
73 | }; | ||
74 | |||
75 | struct cmd_section_t | ||
76 | { | ||
77 | uint32_t identifier; | ||
78 | struct cmd_inst_t *inst_list; | ||
79 | struct cmd_section_t *next; | ||
80 | }; | ||
81 | |||
82 | struct cmd_file_t | ||
83 | { | ||
84 | struct sb_version_t product_ver; | ||
85 | struct sb_version_t component_ver; | ||
86 | struct cmd_source_t *source_list; | ||
87 | struct cmd_section_t *section_list; | ||
88 | }; | ||
89 | |||
90 | struct cmd_source_t *db_find_source_by_id(struct cmd_file_t *cmd_file, const char *id); | ||
91 | bool db_parse_sb_version(struct sb_version_t *ver, char *str); | ||
92 | struct cmd_file_t *db_parse_file(const char *file); | ||
93 | |||
94 | #endif /* __DBPARSER__ */ | ||