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 | 8d782ee | 2011-01-18 21:34:18 -0500 | [diff] [blame] | 68 | |
Peer Chen | 7557d9b | 2011-02-24 09:29:23 -0800 | [diff] [blame] | 69 | token_force32 = 0x7fffffff |
Peer Chen | 8d782ee | 2011-01-18 21:34:18 -0500 | [diff] [blame] | 70 | } parse_token; |
| 71 | |
Peer Chen | 7557d9b | 2011-02-24 09:29:23 -0800 | [diff] [blame] | 72 | typedef 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 Chen | 8d782ee | 2011-01-18 21:34:18 -0500 | [diff] [blame] | 81 | /* Forward declarations */ |
| 82 | typedef int (*process_function)(build_image_context *context, |
| 83 | parse_token token, |
Peer Chen | 7557d9b | 2011-02-24 09:29:23 -0800 | [diff] [blame] | 84 | char *remainder); |
| 85 | |
| 86 | typedef int (*process_subfield_function)(build_image_context *context, |
| 87 | u_int32_t index, |
| 88 | parse_token token, |
| 89 | u_int32_t value); |
| 90 | |
Peer Chen | 8d782ee | 2011-01-18 21:34:18 -0500 | [diff] [blame] | 91 | |
| 92 | typedef struct |
| 93 | { |
Peer Chen | 7557d9b | 2011-02-24 09:29:23 -0800 | [diff] [blame] | 94 | char *name; |
| 95 | u_int32_t value; |
| 96 | } enum_item; |
| 97 | |
| 98 | typedef struct |
| 99 | { |
| 100 | char *name; |
| 101 | u_int32_t token; |
| 102 | field_type type; |
| 103 | enum_item *enum_table; |
| 104 | } field_item; |
| 105 | |
| 106 | typedef struct |
| 107 | { |
| 108 | char *prefix; |
| 109 | parse_token token; |
| 110 | field_item *field_table; |
| 111 | process_subfield_function process; |
| 112 | } parse_subfield_item; |
| 113 | |
| 114 | typedef struct |
| 115 | { |
| 116 | char *prefix; |
| 117 | parse_token token; |
| 118 | process_function process; |
Peer Chen | 8d782ee | 2011-01-18 21:34:18 -0500 | [diff] [blame] | 119 | } parse_item; |
| 120 | |
| 121 | /* |
| 122 | * Function prototypes |
| 123 | */ |
| 124 | void process_config_file(build_image_context *context); |
| 125 | |
| 126 | |
| 127 | #endif /* #ifndef INCLUDED_PARSE_H */ |