xref: /openbsd/usr.sbin/eeprom/defs.h (revision d89ec533)
1 /*	$OpenBSD: defs.h,v 1.7 2008/06/26 05:42:21 ray Exp $	*/
2 /*	$NetBSD: defs.h,v 1.2 1996/02/28 01:13:20 thorpej Exp $	*/
3 
4 /*-
5  * Copyright (c) 1996 The NetBSD Foundation, Inc.
6  * All rights reserved.
7  *
8  * This code is derived from software contributed to The NetBSD Foundation
9  * by Jason R. Thorpe.
10  *
11  * Redistribution and use in source and binary forms, with or without
12  * modification, are permitted provided that the following conditions
13  * are met:
14  * 1. Redistributions of source code must retain the above copyright
15  *    notice, this list of conditions and the following disclaimer.
16  * 2. Redistributions in binary form must reproduce the above copyright
17  *    notice, this list of conditions and the following disclaimer in the
18  *    documentation and/or other materials provided with the distribution.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
21  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
22  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
24  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30  * POSSIBILITY OF SUCH DAMAGE.
31  */
32 
33 #undef BUFSIZE
34 #define BUFSIZE		1024
35 
36 #define IO_READ		0
37 #define IO_WRITE	1
38 
39 #define MAXIMUM(a, b)	((a) > (b) ? (a) : (b))
40 
41 /*
42  * Misc. location declarations.
43  */
44 #define EE_SIZE			0x500
45 #define EE_WC_LOC		0x04
46 #define EE_CKSUM_LOC		0x0c
47 #define EE_HWUPDATE_LOC		0x10
48 #define EE_BANNER_ENABLE_LOC	0x20
49 
50 /*
51  * Keyword table entry.  Contains a pointer to the keyword, the
52  * offset into the prom where the value lives, and a pointer to
53  * the function that handles that value.
54  */
55 struct	keytabent {
56 	char	*kt_keyword;		/* keyword for this entry */
57 	u_int	kt_offset;		/* offset into prom of value */
58 	void	(*kt_handler)(struct keytabent *, char *);
59 					/* handler function for this entry */
60 };
61 
62 /*
63  * String-value table entry.  Maps a string to a numeric value and
64  * vice-versa.
65  */
66 struct	strvaltabent {
67 	char	*sv_str;		/* the string ... */
68 	u_char	sv_val;			/* ... and the value */
69 };
70 
71 /*
72  * This is an entry in a table which describes a set of `exceptions'.
73  * In other words, these are Openprom fields that we either can't
74  * `just print' or don't know how to deal with.
75  */
76 struct	extabent {
77 	char	*ex_keyword;		/* keyword for this entry */
78 	void	(*ex_handler)(struct extabent *, struct opiocdesc *, char *);
79 					/* handler function for this entry */
80 };
81 
82 /* Sun 3/4 EEPROM handlers. */
83 void	ee_hwupdate(struct keytabent *, char *);
84 void	ee_num8(struct keytabent *, char *);
85 void	ee_num16(struct keytabent *, char *);
86 void	ee_screensize(struct keytabent *, char *);
87 void	ee_truefalse(struct keytabent *, char *);
88 void	ee_bootdev(struct keytabent *, char *);
89 void	ee_kbdtype(struct keytabent *, char *);
90 void	ee_constype(struct keytabent *, char *);
91 void	ee_diagpath(struct keytabent *, char *);
92 void	ee_banner(struct keytabent *, char *);
93 void	ee_notsupp(struct keytabent *, char *);
94 
95 /* Sun 3/4 EEPROM checksum routines. */
96 u_char	ee_checksum(u_char *, size_t);
97 void	ee_updatechecksums(void);
98 void	ee_verifychecksums(void);
99 
100 /* OpenPROM handlers. */
101 char	*op_handler(char *, char *);
102 void	 op_dump(void);
103 void	 op_tree(void);
104