Peer Chen | 8d782ee | 2011-01-18 21:34:18 -0500 | [diff] [blame] | 1 | /** |
| 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 | |
| 42 | typedef enum |
| 43 | { |
Peer Chen | 7557d9b | 2011-02-24 09:29:23 -0800 | [diff] [blame] | 44 | 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 Chen | 053d578 | 2011-03-03 10:12:58 -0800 | [diff] [blame] | 56 | token_nand_params, |
Peer Chen | 7557d9b | 2011-02-24 09:29:23 -0800 | [diff] [blame] | 57 | 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 Chen | 053d578 | 2011-03-03 10:12:58 -0800 | [diff] [blame] | 64 | token_nand_timing2, |
| 65 | token_nand_timing, |
| 66 | token_block_size_log2, |
| 67 | token_page_size_log2, |
Peer Chen | 3a834ed | 2011-03-04 09:30:05 -0800 | [diff] [blame] | 68 | 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 Chen | 8d782ee | 2011-01-18 21:34:18 -0500 | [diff] [blame] | 171 | |
Peer Chen | 7557d9b | 2011-02-24 09:29:23 -0800 | [diff] [blame] | 172 | token_force32 = 0x7fffffff |
Peer Chen | 8d782ee | 2011-01-18 21:34:18 -0500 | [diff] [blame] | 173 | } parse_token; |
| 174 | |
Peer Chen | 7557d9b | 2011-02-24 09:29:23 -0800 | [diff] [blame] | 175 | typedef 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 Chen | 8d782ee | 2011-01-18 21:34:18 -0500 | [diff] [blame] | 184 | /* Forward declarations */ |
| 185 | typedef int (*process_function)(build_image_context *context, |
| 186 | parse_token token, |
Peer Chen | 7557d9b | 2011-02-24 09:29:23 -0800 | [diff] [blame] | 187 | char *remainder); |
| 188 | |
| 189 | typedef int (*process_subfield_function)(build_image_context *context, |
| 190 | u_int32_t index, |
| 191 | parse_token token, |
| 192 | u_int32_t value); |
| 193 | |
Peer Chen | 8d782ee | 2011-01-18 21:34:18 -0500 | [diff] [blame] | 194 | |
| 195 | typedef struct |
| 196 | { |
Peer Chen | 7557d9b | 2011-02-24 09:29:23 -0800 | [diff] [blame] | 197 | char *name; |
| 198 | u_int32_t value; |
| 199 | } enum_item; |
| 200 | |
| 201 | typedef struct |
| 202 | { |
| 203 | char *name; |
| 204 | u_int32_t token; |
| 205 | field_type type; |
| 206 | enum_item *enum_table; |
| 207 | } field_item; |
| 208 | |
| 209 | typedef struct |
| 210 | { |
| 211 | char *prefix; |
| 212 | parse_token token; |
| 213 | field_item *field_table; |
| 214 | process_subfield_function process; |
| 215 | } parse_subfield_item; |
| 216 | |
| 217 | typedef struct |
| 218 | { |
| 219 | char *prefix; |
| 220 | parse_token token; |
| 221 | process_function process; |
Peer Chen | 8d782ee | 2011-01-18 21:34:18 -0500 | [diff] [blame] | 222 | } parse_item; |
| 223 | |
| 224 | /* |
| 225 | * Function prototypes |
| 226 | */ |
| 227 | void process_config_file(build_image_context *context); |
| 228 | |
| 229 | |
| 230 | #endif /* #ifndef INCLUDED_PARSE_H */ |