xref: /netbsd-src/usr.sbin/memswitch/memswitch.h (revision a3bd874609f474229440e3f932c61f54ed233782)
1*a3bd8746Schristos /*	$NetBSD: memswitch.h,v 1.5 2018/01/26 09:38:26 christos Exp $	*/
212769637Sminoura 
312769637Sminoura /*-
412769637Sminoura  * Copyright (c) 1999 The NetBSD Foundation, Inc.
512769637Sminoura  * All rights reserved.
612769637Sminoura  *
712769637Sminoura  * This code is derived from software contributed to The NetBSD Foundation
812769637Sminoura  * by Minoura Makoto.
912769637Sminoura  *
1012769637Sminoura  * Redistribution and use in source and binary forms, with or without
1112769637Sminoura  * modification, are permitted provided that the following conditions
1212769637Sminoura  * are met:
1312769637Sminoura  * 1. Redistributions of source code must retain the above copyright
1412769637Sminoura  *    notice, this list of conditions and the following disclaimer.
1512769637Sminoura  * 2. Redistributions in binary form must reproduce the above copyright
1612769637Sminoura  *    notice, this list of conditions and the following disclaimer in the
1712769637Sminoura  *    documentation and/or other materials provided with the distribution.
1812769637Sminoura  *
1912769637Sminoura  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
2012769637Sminoura  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
2112769637Sminoura  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
2212769637Sminoura  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
2312769637Sminoura  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
2412769637Sminoura  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
2512769637Sminoura  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
2612769637Sminoura  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
2712769637Sminoura  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
2812769637Sminoura  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
2912769637Sminoura  * POSSIBILITY OF SUCH DAMAGE.
3012769637Sminoura  */
3112769637Sminoura 
3212769637Sminoura /* memswitch.h */
3312769637Sminoura 
3412769637Sminoura #include <paths.h>
3512769637Sminoura 
3612769637Sminoura #ifndef _PATH_DEVSRAM
3712769637Sminoura #define _PATH_DEVSRAM "/dev/sram"
3812769637Sminoura #endif
3912769637Sminoura 
4012769637Sminoura #define PROP_MAGIC1 (0)
4112769637Sminoura #define PROP_MAGIC2 (1)
4212769637Sminoura #define MAGIC1	(0x82773638)
4312769637Sminoura #define MAGIC2	(0x30303057)
4412769637Sminoura #define MAXVALUELEN 100
4512769637Sminoura 
4612769637Sminoura struct property;
4712769637Sminoura 
48421949a3Ssevan typedef int (*parse_t)(struct property*, const char*);
49421949a3Ssevan typedef int (*print_t)(struct property*, char*);
50421949a3Ssevan typedef int (*fill_t)(struct property*);
51421949a3Ssevan typedef int (*flush_t)(struct property*);
5212769637Sminoura 
5312769637Sminoura struct property {
5412769637Sminoura 	const char *class;
5512769637Sminoura 	const char *node;
5612769637Sminoura 	int offset;
5712769637Sminoura 	int size;
5812769637Sminoura 	int value_valid;
5912769637Sminoura 	union value {
6012769637Sminoura 		unsigned char byte[4];
6112769637Sminoura 		unsigned short word[2];
6212769637Sminoura 		unsigned long longword;
6312769637Sminoura 		void *pointer;
6412769637Sminoura 	} current_value;
6512769637Sminoura 	int modified;
6612769637Sminoura 	union value modified_value;
6712769637Sminoura 	union value default_value;
6812769637Sminoura 	parse_t parse;
6912769637Sminoura 	int min, max;
7012769637Sminoura 	print_t print;
7112769637Sminoura 	fill_t fill;
7212769637Sminoura 	flush_t flush;
7312769637Sminoura 	const char *descr;
7412769637Sminoura };
7512769637Sminoura 
7612769637Sminoura extern int number_of_props;
7712769637Sminoura extern struct property properties[];
7812769637Sminoura extern char *progname;
7912769637Sminoura extern u_int8_t *current_values;
8012769637Sminoura extern u_int8_t *modified_values;
8112769637Sminoura 
82*a3bd8746Schristos void show_single(const char*);
83*a3bd8746Schristos void show_all(void);
84*a3bd8746Schristos void modify_single(const char*);
85*a3bd8746Schristos void help_single(const char*);
86*a3bd8746Schristos void alloc_current_values(void);
87*a3bd8746Schristos void alloc_modified_values(void);
88*a3bd8746Schristos void flush(void);
89*a3bd8746Schristos int save(const char*);
90*a3bd8746Schristos int restore(const char*);
91