1/*	$NetBSD: defs.h,v 1.14 2013/03/15 20:22:44 nakayama 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 *
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#ifdef USE_OPENFIRM
33#include <dev/ofw/openfirmio.h>
34#endif
35
36#ifdef USE_PREPNVRAM
37#include <machine/nvram.h>
38#endif
39
40#undef BUFSIZE
41#define BUFSIZE		1024
42
43#define IO_READ		0
44#define IO_WRITE	1
45
46#define MAXIMUM(a, b)	((a) > (b) ? (a) : (b))
47
48/*
49 * Misc. location declarations.
50 */
51#define EE_SIZE			0x500
52#define EE_WC_LOC		0x04
53#define EE_CKSUM_LOC		0x0c
54#define EE_HWUPDATE_LOC		0x10
55#define EE_BANNER_ENABLE_LOC	0x20
56
57/*
58 * Keyword table entry.  Contains a pointer to the keyword, the
59 * offset into the prom where the value lives, and a pointer to
60 * the function that handles that value.
61 */
62struct	keytabent {
63	const char *kt_keyword;		/* keyword for this entry */
64	u_int	kt_offset;		/* offset into prom of value */
65	void	(*kt_handler) (const struct keytabent *, char *);
66					/* handler function for this entry */
67};
68
69/*
70 * String-value table entry.  Maps a string to a numeric value and
71 * vice-versa.
72 */
73struct	strvaltabent {
74	const char *sv_str;		/* the string ... */
75	u_char	sv_val;			/* ... and the value */
76};
77
78#ifdef USE_OPENPROM
79struct	opiocdesc;
80/*
81 * This is an entry in a table which describes a set of `exceptions'.
82 * In other words, these are Openprom fields that we either can't
83 * `just print' or don't know how to deal with.
84 */
85struct	extabent {
86	const char *ex_keyword;		/* keyword for this entry */
87	void	(*ex_handler) (const struct extabent *,
88		    struct opiocdesc *, char *);
89					/* handler function for this entry */
90};
91#endif
92
93#ifdef USE_OPENFIRM
94struct	extabent {
95	const char *ex_keyword;		/* keyword for this entry */
96	void	(*ex_handler) (const struct extabent *,
97		    struct ofiocdesc *, char *);
98					/* handler function for this entry */
99};
100#endif
101
102#ifdef USE_PREPNVRAM
103struct	extabent {
104	const char *ex_keyword;		/* keyword for this entry */
105	void	(*ex_handler) (const struct extabent *,
106		    struct pnviocdesc *, char *);
107					/* handler function for this entry */
108};
109#endif
110
111
112/* Sun 3/4 EEPROM handlers. */
113void	ee_action(char *, char *);
114void	ee_dump(void);
115
116/* Sun 3/4 EEPROM checksum routines. */
117void	ee_updatechecksums(void);
118void	ee_verifychecksums(void);
119
120/* Sparc Openprom handlers. */
121char	*op_handler(char *, char *);
122void	op_action(char *, char *);
123void	op_dump(void);
124int	check_for_openprom(void);
125
126/* OpenFirmware handlers. */
127char	*of_handler(char *, char *);
128void	of_action(char *, char *);
129void	of_dump(void);
130
131/* PReP nvram handlers. */
132char	*prep_handler(char *, char *);
133void	prep_action(char *, char *);
134void	prep_dump(void);
135