blob: e755c607e4cbbbf8cb331525241ca2359b879d11 [file] [log] [blame]
Peer Chen8d782ee2011-01-18 21:34:18 -05001/**
2 * Copyright (c) 2011 NVIDIA Corporation. All rights reserved.
3 *
4 * See file CREDITS for list of people who contributed to this
5 * project.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 2 of
10 * the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
20 * MA 02111-1307 USA
21 */
22
23/*
24 * parse.h - Definitions for the cbootimage parsing code.
25 */
26
27/*
28 * TODO / Notes
29 * - Add doxygen commentary
30 */
31
32#ifndef INCLUDED_PARSE_H
33#define INCLUDED_PARSE_H
34
35#include "cbootimage.h"
36
37
38/*
39 * Enums
40 */
41
42typedef enum
43{
Peer Chen7557d9b2011-02-24 09:29:23 -080044 token_none = 0,
45 token_attribute,
46 token_bootloader,
47 token_block_size,
48 token_page_size,
49 token_partition_size,
50 token_dev_type,
51 token_dev_param,
52 token_redundancy,
53 token_version,
54 token_bct_file,
55 token_addon,
Peer Chen053d5782011-03-03 10:12:58 -080056 token_nand_params,
Peer Chen7557d9b2011-02-24 09:29:23 -080057 token_sdmmc_params,
58 token_spiflash_params,
59 token_data_width,
60 token_clock_divider,
61 token_clock_source,
62 token_read_command_type_fast,
63 token_max_power_class_supported,
Peer Chen053d5782011-03-03 10:12:58 -080064 token_nand_timing2,
65 token_nand_timing,
66 token_block_size_log2,
67 token_page_size_log2,
Peer Chen8d782ee2011-01-18 21:34:18 -050068
Peer Chen7557d9b2011-02-24 09:29:23 -080069 token_force32 = 0x7fffffff
Peer Chen8d782ee2011-01-18 21:34:18 -050070} parse_token;
71
Peer Chen7557d9b2011-02-24 09:29:23 -080072typedef enum
73{
74 field_type_none = 0,
75 field_type_enum,
76 field_type_u32,
77 field_type_u8,
78 field_type_force32 = 0x7fffffff
79} field_type;
80
Peer Chen8d782ee2011-01-18 21:34:18 -050081/* Forward declarations */
82typedef int (*process_function)(build_image_context *context,
83 parse_token token,
Peer Chen7557d9b2011-02-24 09:29:23 -080084 char *remainder);
85
86typedef int (*process_subfield_function)(build_image_context *context,
87 u_int32_t index,
88 parse_token token,
89 u_int32_t value);
90
Peer Chen8d782ee2011-01-18 21:34:18 -050091
92typedef struct
93{
Peer Chen7557d9b2011-02-24 09:29:23 -080094 char *name;
95 u_int32_t value;
96} enum_item;
97
98typedef struct
99{
100 char *name;
101 u_int32_t token;
102 field_type type;
103 enum_item *enum_table;
104} field_item;
105
106typedef struct
107{
108 char *prefix;
109 parse_token token;
110 field_item *field_table;
111 process_subfield_function process;
112} parse_subfield_item;
113
114typedef struct
115{
116 char *prefix;
117 parse_token token;
118 process_function process;
Peer Chen8d782ee2011-01-18 21:34:18 -0500119} parse_item;
120
121/*
122 * Function prototypes
123 */
124void process_config_file(build_image_context *context);
125
126
127#endif /* #ifndef INCLUDED_PARSE_H */