blob: f2e8ad6f873b00dc25f42882753007dcd38742d6 [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,
56 token_sdmmc_params,
57 token_spiflash_params,
58 token_data_width,
59 token_clock_divider,
60 token_clock_source,
61 token_read_command_type_fast,
62 token_max_power_class_supported,
Peer Chen8d782ee2011-01-18 21:34:18 -050063
Peer Chen7557d9b2011-02-24 09:29:23 -080064 token_force32 = 0x7fffffff
Peer Chen8d782ee2011-01-18 21:34:18 -050065} parse_token;
66
Peer Chen7557d9b2011-02-24 09:29:23 -080067typedef enum
68{
69 field_type_none = 0,
70 field_type_enum,
71 field_type_u32,
72 field_type_u8,
73 field_type_force32 = 0x7fffffff
74} field_type;
75
Peer Chen8d782ee2011-01-18 21:34:18 -050076/* Forward declarations */
77typedef int (*process_function)(build_image_context *context,
78 parse_token token,
Peer Chen7557d9b2011-02-24 09:29:23 -080079 char *remainder);
80
81typedef int (*process_subfield_function)(build_image_context *context,
82 u_int32_t index,
83 parse_token token,
84 u_int32_t value);
85
Peer Chen8d782ee2011-01-18 21:34:18 -050086
87typedef struct
88{
Peer Chen7557d9b2011-02-24 09:29:23 -080089 char *name;
90 u_int32_t value;
91} enum_item;
92
93typedef struct
94{
95 char *name;
96 u_int32_t token;
97 field_type type;
98 enum_item *enum_table;
99} field_item;
100
101typedef struct
102{
103 char *prefix;
104 parse_token token;
105 field_item *field_table;
106 process_subfield_function process;
107} parse_subfield_item;
108
109typedef struct
110{
111 char *prefix;
112 parse_token token;
113 process_function process;
Peer Chen8d782ee2011-01-18 21:34:18 -0500114} parse_item;
115
116/*
117 * Function prototypes
118 */
119void process_config_file(build_image_context *context);
120
121
122#endif /* #ifndef INCLUDED_PARSE_H */