2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
4 * Copyright (C) 2009-2012 Semihalf
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 #ifndef _NANDSIM_CONFPARSER_H_
32 #define _NANDSIM_CONFPARSER_H_
34 #define VALUE_UINT 0x08
35 #define VALUE_INT 0x10
36 #define VALUE_UINTARRAY 0x18
37 #define VALUE_INTARRAY 0x20
38 #define VALUE_STRING 0x28
39 #define VALUE_CHAR 0x40
40 #define VALUE_BOOL 0x48
46 #include "nandsim_rcfile.h"
49 * keyname = name of a key,
50 * mandatory = is key mandatory in section belonging to, 0=false 1=true
51 * valuetype = what kind of value is assigned to that key, e.g.
52 * VALUE_UINT | SIZE_8 -- unsigned uint size 8 bits;
53 * VALUE_UINTARRAY | SIZE_8 -- array of uints 8-bit long;
54 * VALUE_BOOL -- 'on', 'off','true','false','yes' or 'no'
56 * VALUE_STRING -- strings
57 * field = ptr to the field that should hold value for parsed value
58 * maxlength = contains maximum length of an array (used only with either
59 * VALUE_STRING or VALUE_(U)INTARRAY value types.
68 struct nandsim_section {
70 struct nandsim_key *keys;
73 struct nandsim_config {
74 struct sim_param **simparams;
75 struct sim_chip **simchips;
76 struct sim_ctrl **simctrls;
81 int parse_intarray(char *, int **);
82 int parse_config(char *, const char *);
83 int parse_section(struct rcfile *, const char *, int);
84 int compare_configs(struct nandsim_config *, struct nandsim_config *);
85 int convert_argint(char *, int *);
86 int convert_arguint(char *, unsigned int *);
88 #endif /* _NANDSIM_CONFPARSER_H_ */