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