1235537Sgber/*- 2235537Sgber * Copyright (C) 2009-2012 Semihalf 3235537Sgber * All rights reserved. 4235537Sgber * 5235537Sgber * Redistribution and use in source and binary forms, with or without 6235537Sgber * modification, are permitted provided that the following conditions 7235537Sgber * are met: 8235537Sgber * 1. Redistributions of source code must retain the above copyright 9235537Sgber * notice, this list of conditions and the following disclaimer. 10235537Sgber * 2. Redistributions in binary form must reproduce the above copyright 11235537Sgber * notice, this list of conditions and the following disclaimer in the 12235537Sgber * documentation and/or other materials provided with the distribution. 13235537Sgber * 14235537Sgber * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15235537Sgber * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16235537Sgber * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17235537Sgber * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE 18235537Sgber * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19235537Sgber * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20235537Sgber * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21235537Sgber * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22235537Sgber * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23235537Sgber * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24235537Sgber * SUCH DAMAGE. 25235537Sgber * 26235537Sgber * $FreeBSD$ 27235537Sgber */ 28235537Sgber 29235537Sgber#ifndef _NANDSIM_CONFPARSER_H_ 30235537Sgber#define _NANDSIM_CONFPARSER_H_ 31235537Sgber 32235537Sgber#define VALUE_UINT 0x08 33235537Sgber#define VALUE_INT 0x10 34235537Sgber#define VALUE_UINTARRAY 0x18 35235537Sgber#define VALUE_INTARRAY 0x20 36235537Sgber#define VALUE_STRING 0x28 37235537Sgber#define VALUE_CHAR 0x40 38235537Sgber#define VALUE_BOOL 0x48 39235537Sgber 40235537Sgber#define SIZE_8 0x01 41235537Sgber#define SIZE_16 0x02 42235537Sgber#define SIZE_32 0x04 43235537Sgber 44235537Sgber#include "nandsim_rcfile.h" 45235537Sgber 46235537Sgber/* 47235537Sgber * keyname = name of a key, 48235537Sgber * mandatory = is key mandatory in section belonging to, 0=false 1=true 49235537Sgber * valuetype = what kind of value is assigned to that key, e.g. 50235537Sgber * VALUE_UINT | SIZE_8 -- unsigned uint size 8 bits; 51235537Sgber * VALUE_UINTARRAY | SIZE_8 -- array of uints 8-bit long; 52235537Sgber * VALUE_BOOL -- 'on', 'off','true','false','yes' or 'no' 53235537Sgber * literals; 54235537Sgber * VALUE_STRING -- strings 55235537Sgber * field = ptr to the field that should hold value for parsed value 56235537Sgber * maxlength = contains maximum length of an array (used only with either 57235537Sgber * VALUE_STRING or VALUE_(U)INTARRAY value types. 58235537Sgber */ 59235537Sgberstruct nandsim_key { 60235537Sgber const char *keyname; 61235537Sgber uint8_t mandatory; 62235537Sgber uint8_t valuetype; 63235537Sgber void *field; 64235537Sgber uint32_t maxlength; 65235537Sgber}; 66235537Sgberstruct nandsim_section { 67235537Sgber const char *name; 68235537Sgber struct nandsim_key *keys; 69235537Sgber}; 70235537Sgber 71235537Sgberstruct nandsim_config { 72235537Sgber struct sim_param **simparams; 73235537Sgber struct sim_chip **simchips; 74235537Sgber struct sim_ctrl **simctrls; 75235537Sgber int chipcnt; 76235537Sgber int ctrlcnt; 77235537Sgber}; 78235537Sgber 79235537Sgberint parse_intarray(char *, int **); 80235537Sgberint parse_config(char *, const char *); 81235537Sgberint parse_section(struct rcfile *, const char *, int); 82235537Sgberint compare_configs(struct nandsim_config *, struct nandsim_config *); 83235537Sgberint convert_argint(char *, int *); 84235537Sgberint convert_arguint(char *, unsigned int *); 85235537Sgber 86235537Sgber#endif /* _NANDSIM_CONFPARSER_H_ */ 87