xref: /netbsd-src/usr.sbin/memswitch/memswitch.h (revision a3bd874609f474229440e3f932c61f54ed233782)
1 /*	$NetBSD: memswitch.h,v 1.5 2018/01/26 09:38:26 christos Exp $	*/
2 
3 /*-
4  * Copyright (c) 1999 The NetBSD Foundation, Inc.
5  * All rights reserved.
6  *
7  * This code is derived from software contributed to The NetBSD Foundation
8  * by Minoura Makoto.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  * 1. Redistributions of source code must retain the above copyright
14  *    notice, this list of conditions and the following disclaimer.
15  * 2. Redistributions in binary form must reproduce the above copyright
16  *    notice, this list of conditions and the following disclaimer in the
17  *    documentation and/or other materials provided with the distribution.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29  * POSSIBILITY OF SUCH DAMAGE.
30  */
31 
32 /* memswitch.h */
33 
34 #include <paths.h>
35 
36 #ifndef _PATH_DEVSRAM
37 #define _PATH_DEVSRAM "/dev/sram"
38 #endif
39 
40 #define PROP_MAGIC1 (0)
41 #define PROP_MAGIC2 (1)
42 #define MAGIC1	(0x82773638)
43 #define MAGIC2	(0x30303057)
44 #define MAXVALUELEN 100
45 
46 struct property;
47 
48 typedef int (*parse_t)(struct property*, const char*);
49 typedef int (*print_t)(struct property*, char*);
50 typedef int (*fill_t)(struct property*);
51 typedef int (*flush_t)(struct property*);
52 
53 struct property {
54 	const char *class;
55 	const char *node;
56 	int offset;
57 	int size;
58 	int value_valid;
59 	union value {
60 		unsigned char byte[4];
61 		unsigned short word[2];
62 		unsigned long longword;
63 		void *pointer;
64 	} current_value;
65 	int modified;
66 	union value modified_value;
67 	union value default_value;
68 	parse_t parse;
69 	int min, max;
70 	print_t print;
71 	fill_t fill;
72 	flush_t flush;
73 	const char *descr;
74 };
75 
76 extern int number_of_props;
77 extern struct property properties[];
78 extern char *progname;
79 extern u_int8_t *current_values;
80 extern u_int8_t *modified_values;
81 
82 void show_single(const char*);
83 void show_all(void);
84 void modify_single(const char*);
85 void help_single(const char*);
86 void alloc_current_values(void);
87 void alloc_modified_values(void);
88 void flush(void);
89 int save(const char*);
90 int restore(const char*);
91