| OLD | NEW |
| 1 /** | 1 /** |
| 2 * Copyright (c) 2011 NVIDIA Corporation. All rights reserved. | 2 * Copyright (c) 2011 NVIDIA Corporation. All rights reserved. |
| 3 * | 3 * |
| 4 * See file CREDITS for list of people who contributed to this | 4 * See file CREDITS for list of people who contributed to this |
| 5 * project. | 5 * project. |
| 6 * | 6 * |
| 7 * This program is free software; you can redistribute it and/or | 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 | 8 * modify it under the terms of the GNU General Public License as |
| 9 * published by the Free Software Foundation; either version 2 of | 9 * published by the Free Software Foundation; either version 2 of |
| 10 * the License, or (at your option) any later version. | 10 * the License, or (at your option) any later version. |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 *parse_end_state(char *statement, char *uname, int chars_remaining); | 80 *parse_end_state(char *statement, char *uname, int chars_remaining); |
| 81 static int | 81 static int |
| 82 parse_dev_param(build_image_context *context, parse_token token, char *rest); | 82 parse_dev_param(build_image_context *context, parse_token token, char *rest); |
| 83 | 83 |
| 84 static int process_statement(build_image_context *context, char *statement); | 84 static int process_statement(build_image_context *context, char *statement); |
| 85 | 85 |
| 86 static enum_item s_devtype_table[] = | 86 static enum_item s_devtype_table[] = |
| 87 { | 87 { |
| 88 { "NvBootDevType_Sdmmc", nvbct_lib_id_dev_type_sdmmc }, | 88 { "NvBootDevType_Sdmmc", nvbct_lib_id_dev_type_sdmmc }, |
| 89 { "NvBootDevType_Spi", nvbct_lib_id_dev_type_spi }, | 89 { "NvBootDevType_Spi", nvbct_lib_id_dev_type_spi }, |
| 90 { "NvBootDevType_Nand", nvbct_lib_id_dev_type_nand }, |
| 90 { "Sdmmc", nvbct_lib_id_dev_type_sdmmc }, | 91 { "Sdmmc", nvbct_lib_id_dev_type_sdmmc }, |
| 91 { "Spi", nvbct_lib_id_dev_type_spi }, | 92 { "Spi", nvbct_lib_id_dev_type_spi }, |
| 93 { "Nand", nvbct_lib_id_dev_type_nand }, |
| 92 | 94 |
| 93 { NULL, 0 } | 95 { NULL, 0 } |
| 94 }; | 96 }; |
| 95 | 97 |
| 96 static enum_item s_sdmmc_data_width_table[] = | 98 static enum_item s_sdmmc_data_width_table[] = |
| 97 { | 99 { |
| 98 { | 100 { |
| 99 "NvBootSdmmcDataWidth_4Bit", | 101 "NvBootSdmmcDataWidth_4Bit", |
| 100 nvbct_lib_id_sdmmc_data_width_4bit | 102 nvbct_lib_id_sdmmc_data_width_4bit |
| 101 }, | 103 }, |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 | 136 |
| 135 | 137 |
| 136 { "PllPOut0", nvbct_lib_id_spi_clock_source_pllp_out0 }, | 138 { "PllPOut0", nvbct_lib_id_spi_clock_source_pllp_out0 }, |
| 137 { "PllCOut0", nvbct_lib_id_spi_clock_source_pllc_out0 }, | 139 { "PllCOut0", nvbct_lib_id_spi_clock_source_pllc_out0 }, |
| 138 { "PllMOut0", nvbct_lib_id_spi_clock_source_pllm_out0 }, | 140 { "PllMOut0", nvbct_lib_id_spi_clock_source_pllm_out0 }, |
| 139 { "ClockM", nvbct_lib_id_spi_clock_source_clockm }, | 141 { "ClockM", nvbct_lib_id_spi_clock_source_clockm }, |
| 140 | 142 |
| 141 { NULL, 0 } | 143 { NULL, 0 } |
| 142 }; | 144 }; |
| 143 | 145 |
| 146 static field_item s_nand_table[] = |
| 147 { |
| 148 { "ClockDivider", token_clock_divider, field_type_u32, NULL }, |
| 149 /* Note: NandTiming2 must appear before NandTiming, because NandTiming |
| 150 * is a prefix of NandTiming2 and would otherwise match first. |
| 151 */ |
| 152 { "NandTiming2", token_nand_timing2, field_type_u32, NULL }, |
| 153 { "NandTiming", token_nand_timing, field_type_u32, NULL }, |
| 154 { "BlockSizeLog2", token_block_size_log2, field_type_u32, NULL }, |
| 155 { "PageSizeLog2", token_page_size_log2, field_type_u32, NULL }, |
| 156 { NULL, 0, 0, NULL } |
| 157 }; |
| 158 |
| 144 static field_item s_sdmmc_table[] = | 159 static field_item s_sdmmc_table[] = |
| 145 { | 160 { |
| 146 { "ClockDivider", token_clock_divider, field_type_u32, NULL }, | 161 { "ClockDivider", token_clock_divider, field_type_u32, NULL }, |
| 147 { "DataWidth", token_data_width, | 162 { "DataWidth", token_data_width, |
| 148 field_type_enum, s_sdmmc_data_width_table }, | 163 field_type_enum, s_sdmmc_data_width_table }, |
| 149 { "MaxPowerClassSupported", token_max_power_class_supported, | 164 { "MaxPowerClassSupported", token_max_power_class_supported, |
| 150 field_type_u32, NULL }, | 165 field_type_u32, NULL }, |
| 151 | 166 |
| 152 { NULL, 0, 0, NULL } | 167 { NULL, 0, 0, NULL } |
| 153 }; | 168 }; |
| 154 | 169 |
| 155 static field_item s_spiflash_table[] = | 170 static field_item s_spiflash_table[] = |
| 156 { | 171 { |
| 157 { "ReadCommandTypeFast", token_read_command_type_fast, | 172 { "ReadCommandTypeFast", token_read_command_type_fast, |
| 158 field_type_u8, NULL }, | 173 field_type_u8, NULL }, |
| 159 { "ClockDivider", token_clock_divider, field_type_u8, NULL }, | 174 { "ClockDivider", token_clock_divider, field_type_u8, NULL }, |
| 160 { "ClockSource", token_clock_source, | 175 { "ClockSource", token_clock_source, |
| 161 field_type_enum, s_spi_clock_source_table }, | 176 field_type_enum, s_spi_clock_source_table }, |
| 162 | 177 |
| 163 { NULL, 0, 0, NULL } | 178 { NULL, 0, 0, NULL } |
| 164 }; | 179 }; |
| 165 | 180 |
| 166 static parse_subfield_item s_device_type_table[] = | 181 static parse_subfield_item s_device_type_table[] = |
| 167 { | 182 { |
| 183 { "NandParams.", token_nand_params, |
| 184 s_nand_table, set_nand_param }, |
| 168 { "SdmmcParams.", token_sdmmc_params, | 185 { "SdmmcParams.", token_sdmmc_params, |
| 169 s_sdmmc_table, set_sdmmc_param }, | 186 s_sdmmc_table, set_sdmmc_param }, |
| 170 { "SpiFlashParams.", token_spiflash_params, | 187 { "SpiFlashParams.", token_spiflash_params, |
| 171 s_spiflash_table, set_spiflash_param }, | 188 s_spiflash_table, set_spiflash_param }, |
| 172 | 189 |
| 173 { NULL, 0, NULL } | 190 { NULL, 0, NULL } |
| 174 }; | 191 }; |
| 175 | 192 |
| 176 static parse_item s_top_level_items[] = | 193 static parse_item s_top_level_items[] = |
| 177 { | 194 { |
| 178 » { "Bctfile=",» token_bct_file,»» parse_bct_file }, | 195 » { "Bctfile=", token_bct_file,» » parse_bct_file }, |
| 179 » { "Attribute=",»token_attribute,» » parse_value_u32 }, | 196 » { "Attribute=", token_attribute,» » parse_value_u32 }, |
| 180 » { "Attribute[",»token_attribute,» » parse_array }, | 197 » { "Attribute[", token_attribute,» » parse_array }, |
| 181 » { "PageSize=",» token_page_size,» » parse_value_u32 }, | 198 » { "PageSize=", token_page_size,» » parse_value_u32 }, |
| 182 » { "BlockSize=",»token_block_size,» » parse_value_u32 }, | 199 » { "BlockSize=", token_block_size,» » parse_value_u32 }, |
| 183 » { "PartitionSize=",» token_partition_size,» parse_value_u32 }, | 200 » { "PartitionSize=", token_partition_size,» parse_value_u32 }, |
| 184 » { "DevType[",» token_dev_type,»» parse_array }, | 201 » { "DevType[", token_dev_type,» » parse_array }, |
| 185 » { "DeviceParam[",» token_dev_param,» » parse_dev_param
}, | 202 » { "DeviceParam[", token_dev_param,» » parse_dev_param }, |
| 186 » { "BootLoader=",» token_bootloader,» » parse_bootloader
}, | 203 » { "BootLoader=", token_bootloader,» » parse_bootloader }, |
| 187 » { "Redundancy=",» token_redundancy,» » parse_value_u32
}, | 204 » { "Redundancy=", token_redundancy,» » parse_value_u32 }, |
| 188 » { "Version=",» token_version,» » parse_value_u32 }, | 205 » { "Version=", token_version,» » parse_value_u32 }, |
| 189 » { "AddOn[",» token_addon,» » parse_addon }, | 206 » { "AddOn[", token_addon,» » parse_addon }, |
| 190 { NULL, 0, NULL } /* Must be last */ | 207 { NULL, 0, NULL } /* Must be last */ |
| 191 }; | 208 }; |
| 192 | 209 |
| 193 /* Macro to simplify parser code a bit. */ | 210 /* Macro to simplify parser code a bit. */ |
| 194 #define PARSE_COMMA(x) if (*rest != ',') return (x); rest++ | 211 #define PARSE_COMMA(x) if (*rest != ',') return (x); rest++ |
| 195 | 212 |
| 196 /* This parsing code was initially borrowed from nvcamera_config_parse.c. */ | 213 /* This parsing code was initially borrowed from nvcamera_config_parse.c. */ |
| 197 /* Returns the address of the character after the parsed data. */ | 214 /* Returns the address of the character after the parsed data. */ |
| 198 static char * | 215 static char * |
| 199 parse_u32(char *statement, u_int32_t *val) | 216 parse_u32(char *statement, u_int32_t *val) |
| (...skipping 603 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 803 break; | 820 break; |
| 804 } | 821 } |
| 805 } | 822 } |
| 806 | 823 |
| 807 return; | 824 return; |
| 808 | 825 |
| 809 error: | 826 error: |
| 810 printf("Error parsing: %s\n", buffer); | 827 printf("Error parsing: %s\n", buffer); |
| 811 exit(1); | 828 exit(1); |
| 812 } | 829 } |
| OLD | NEW |