defs.h revision 1.10 1 /* $NetBSD: defs.h,v 1.10 2007/03/01 16:49:48 garbled Exp $ */
2
3 /*-
4 * Copyright (c) 1996 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Jason R. Thorpe.
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 * 3. All advertising materials mentioning features or use of this software
19 * must display the following acknowledgement:
20 * This product includes software developed by the NetBSD
21 * Foundation, Inc. and its contributors.
22 * 4. Neither the name of The NetBSD Foundation nor the names of its
23 * contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 * POSSIBILITY OF SUCH DAMAGE.
37 */
38
39 #ifdef USE_OPENFIRM
40 #include <dev/ofw/openfirmio.h>
41 #endif
42
43 #ifdef USE_PREPNVRAM
44 #include <machine/nvram.h>
45 #endif
46
47 #undef BUFSIZE
48 #define BUFSIZE 1024
49
50 #define IO_READ 0
51 #define IO_WRITE 1
52
53 #define MAXIMUM(a, b) ((a) > (b) ? (a) : (b))
54
55 /*
56 * Misc. location declarations.
57 */
58 #define EE_SIZE 0x500
59 #define EE_WC_LOC 0x04
60 #define EE_CKSUM_LOC 0x0c
61 #define EE_HWUPDATE_LOC 0x10
62 #define EE_BANNER_ENABLE_LOC 0x20
63
64 /*
65 * Keyword table entry. Contains a pointer to the keyword, the
66 * offset into the prom where the value lives, and a pointer to
67 * the function that handles that value.
68 */
69 struct keytabent {
70 char *kt_keyword; /* keyword for this entry */
71 u_int kt_offset; /* offset into prom of value */
72 void (*kt_handler) (struct keytabent *, char *);
73 /* handler function for this entry */
74 };
75
76 /*
77 * String-value table entry. Maps a string to a numeric value and
78 * vice-versa.
79 */
80 struct strvaltabent {
81 char *sv_str; /* the string ... */
82 u_char sv_val; /* ... and the value */
83 };
84
85 #ifdef __sparc__
86 struct opiocdesc;
87 /*
88 * This is an entry in a table which describes a set of `exceptions'.
89 * In other words, these are Openprom fields that we either can't
90 * `just print' or don't know how to deal with.
91 */
92 struct extabent {
93 char *ex_keyword; /* keyword for this entry */
94 void (*ex_handler) (struct extabent *,
95 struct opiocdesc *, char *);
96 /* handler function for this entry */
97 };
98 #endif /* __sparc__ */
99
100 #ifdef USE_OPENFIRM
101 struct extabent {
102 char *ex_keyword; /* keyword for this entry */
103 void (*ex_handler) (struct extabent *,
104 struct ofiocdesc *, char *);
105 /* handler function for this entry */
106 };
107 #endif
108
109 #ifdef USE_PREPNVRAM
110 struct extabent {
111 char *ex_keyword; /* keyword for this entry */
112 void (*ex_handler) (struct extabent *,
113 struct pnviocdesc *, char *);
114 /* handler function for this entry */
115 };
116 #endif
117
118
119 /* Sun 3/4 EEPROM handlers. */
120 void ee_action (char *, char *);
121 void ee_dump (void);
122 void ee_hwupdate (struct keytabent *, char *);
123 void ee_num8 (struct keytabent *, char *);
124 void ee_num16 (struct keytabent *, char *);
125 void ee_screensize (struct keytabent *, char *);
126 void ee_truefalse (struct keytabent *, char *);
127 void ee_bootdev (struct keytabent *, char *);
128 void ee_kbdtype (struct keytabent *, char *);
129 void ee_constype (struct keytabent *, char *);
130 void ee_diagpath (struct keytabent *, char *);
131 void ee_banner (struct keytabent *, char *);
132 void ee_notsupp (struct keytabent *, char *);
133
134 /* Sun 3/4 EEPROM checksum routines. */
135 u_char ee_checksum (u_char *, size_t);
136 void ee_updatechecksums (void);
137 void ee_verifychecksums (void);
138
139 #ifdef __sparc__
140 /* Sparc Openprom handlers. */
141 char *op_handler (char *, char *);
142 void op_action (char *, char *);
143 void op_dump (void);
144 int check_for_openprom (void);
145 #endif /* __sparc__ */
146
147 /* OpenFirmware handlers. */
148 char *of_handler (char *, char *);
149 void of_action (char *, char *);
150 void of_dump (void);
151
152 /* PReP nvram handlers. */
153 char *prep_handler (char *, char *);
154 void prep_action (char *, char *);
155 void prep_dump (void);
156