blob: fdc2339f8d35582ae8ee9c7b3c1f476ff1a85f9c [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 Chen3a834ed2011-03-04 09:30:05 -080068 token_sdram,
69
70 token_memory_type,
71 token_pllm_charge_pump_setup_ctrl,
72 token_pllm_loop_filter_setup_ctrl,
73 token_pllm_input_divider,
74 token_pllm_feedback_divider,
75 token_pllm_post_divider,
76 token_pllm_stable_time,
77 token_emc_clock_divider,
78 token_emc_auto_cal_interval,
79 token_emc_auto_cal_config,
80 token_emc_auto_cal_wait,
81 token_emc_pin_program_wait,
82 token_emc_rc,
83 token_emc_rfc,
84 token_emc_ras,
85 token_emc_rp,
86 token_emc_r2w,
87 token_emc_w2r,
88 token_emc_r2p,
89 token_emc_w2p,
90 token_emc_rd_rcd,
91 token_emc_wr_rcd,
92 token_emc_rrd,
93 token_emc_rext,
94 token_emc_wdv,
95 token_emc_quse,
96 token_emc_qrst,
97 token_emc_qsafe,
98 token_emc_rdv,
99 token_emc_refresh,
100 token_emc_burst_refresh_num,
101 token_emc_pdex2wr,
102 token_emc_pdex2rd,
103 token_emc_pchg2pden,
104 token_emc_act2pden,
105 token_emc_ar2pden,
106 token_emc_rw2pden,
107 token_emc_txsr,
108 token_emc_tcke,
109 token_emc_tfaw,
110 token_emc_trpab,
111 token_emc_tclkstable,
112 token_emc_tclkstop,
113 token_emc_trefbw,
114 token_emc_quse_extra,
115 token_emc_fbio_cfg1,
116 token_emc_fbio_dqsib_dly,
117 token_emc_fbio_dqsib_dly_msb,
118 token_emc_fbio_quse_dly,
119 token_emc_fbio_quse_dly_msb,
120 token_emc_fbio_cfg5,
121 token_emc_fbio_cfg6,
122 token_emc_fbio_spare,
123 token_emc_mrs,
124 token_emc_emrs,
125 token_emc_mrw1,
126 token_emc_mrw2,
127 token_emc_mrw3,
128 token_emc_mrw_reset_command,
129 token_emc_mrw_reset_ninit_wait,
130 token_emc_adr_cfg,
131 token_emc_adr_cfg1,
132 token_mc_emem_Cfg,
133 token_mc_lowlatency_config,
134 token_emc_cfg,
135 token_emc_cfg2,
136 token_emc_dbg,
137 token_ahb_arbitration_xbar_ctrl,
138 token_emc_cfg_dig_dll,
139 token_emc_dll_xform_dqs,
140 token_emc_dll_xform_quse,
141 token_warm_boot_wait,
142 token_emc_ctt_term_ctrl,
143 token_emc_odt_write,
144 token_emc_odt_read,
145 token_emc_zcal_ref_cnt,
146 token_emc_zcal_wait_cnt,
147 token_emc_zcal_mrw_cmd,
148 token_emc_mrs_reset_dll,
149 token_emc_mrw_zq_init_dev0,
150 token_emc_mrw_zq_init_dev1,
151 token_emc_mrw_zq_init_wait,
152 token_emc_mrs_reset_dll_wait,
153 token_emc_emrs_emr2,
154 token_emc_emrs_emr3,
155 token_emc_emrs_ddr2_dll_enable,
156 token_emc_mrs_ddr2_dll_reset,
157 token_emc_emrs_ddr2_ocd_calib,
158 token_emc_ddr2_wait,
159 token_emc_cfg_clktrim0,
160 token_emc_cfg_clktrim1,
161 token_emc_cfg_clktrim2,
162 token_pmc_ddr_pwr,
163 token_apb_misc_gp_xm2cfga_pad_ctrl,
164 token_apb_misc_gp_xm2cfgc_pad_ctrl,
165 token_apb_misc_gp_xm2cfgc_pad_ctrl2,
166 token_apb_misc_gp_xm2cfgd_pad_ctrl,
167 token_apb_misc_gp_xm2cfgd_pad_ctrl2,
168 token_apb_misc_gp_xm2clkcfg_Pad_ctrl,
169 token_apb_misc_gp_xm2comp_pad_ctrl,
170 token_apb_misc_gp_xm2vttgen_pad_ctrl,
Peer Chen8d782ee2011-01-18 21:34:18 -0500171
Peer Chen7557d9b2011-02-24 09:29:23 -0800172 token_force32 = 0x7fffffff
Peer Chen8d782ee2011-01-18 21:34:18 -0500173} parse_token;
174
Peer Chen7557d9b2011-02-24 09:29:23 -0800175typedef enum
176{
177 field_type_none = 0,
178 field_type_enum,
179 field_type_u32,
180 field_type_u8,
181 field_type_force32 = 0x7fffffff
182} field_type;
183
Peer Chen8d782ee2011-01-18 21:34:18 -0500184/* Forward declarations */
185typedef int (*process_function)(build_image_context *context,
186 parse_token token,
Peer Chen7557d9b2011-02-24 09:29:23 -0800187 char *remainder);
188
189typedef int (*process_subfield_function)(build_image_context *context,
190 u_int32_t index,
191 parse_token token,
192 u_int32_t value);
193
Peer Chen8d782ee2011-01-18 21:34:18 -0500194
195typedef struct
196{
Peer Chen7557d9b2011-02-24 09:29:23 -0800197 char *name;
198 u_int32_t value;
199} enum_item;
200
201typedef struct
202{
203 char *name;
204 u_int32_t token;
Anton Staafe517a4f2011-03-14 12:28:06 -0700205 u_int32_t enum_value;
Peer Chen7557d9b2011-02-24 09:29:23 -0800206 field_type type;
207 enum_item *enum_table;
208} field_item;
209
210typedef struct
211{
212 char *prefix;
213 parse_token token;
214 field_item *field_table;
215 process_subfield_function process;
216} parse_subfield_item;
217
218typedef struct
219{
220 char *prefix;
221 parse_token token;
222 process_function process;
Peer Chen8d782ee2011-01-18 21:34:18 -0500223} parse_item;
224
225/*
Anton Staafe517a4f2011-03-14 12:28:06 -0700226 * Provide access to enum and field tables. These tables are useful when
227 * pretty printing a BCT file using bct_dump.
228 */
229extern enum_item s_devtype_table[];
230extern enum_item s_sdmmc_data_width_table[];
231extern enum_item s_spi_clock_source_table[];
232extern enum_item s_nvboot_memory_type_table[];
233extern field_item s_sdram_field_table[];
234extern field_item s_nand_table[];
235extern field_item s_sdmmc_table[];
236extern field_item s_spiflash_table[];
237
238/*
Peer Chen8d782ee2011-01-18 21:34:18 -0500239 * Function prototypes
240 */
241void process_config_file(build_image_context *context);
242
243
244#endif /* #ifndef INCLUDED_PARSE_H */