1/* $NetBSD: defs.h,v 1.12 2009/04/26 01:51:07 lukem 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) (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 __sparc__ 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) (struct extabent *, 88 struct opiocdesc *, char *); 89 /* handler function for this entry */ 90}; 91#endif /* __sparc__ */ 92 93#ifdef USE_OPENFIRM 94struct extabent { 95 const char *ex_keyword; /* keyword for this entry */ 96 void (*ex_handler) (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) (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); 115void ee_hwupdate (struct keytabent *, char *); 116void ee_num8 (struct keytabent *, char *); 117void ee_num16 (struct keytabent *, char *); 118void ee_screensize (struct keytabent *, char *); 119void ee_truefalse (struct keytabent *, char *); 120void ee_bootdev (struct keytabent *, char *); 121void ee_kbdtype (struct keytabent *, char *); 122void ee_constype (struct keytabent *, char *); 123void ee_diagpath (struct keytabent *, char *); 124void ee_banner (struct keytabent *, char *); 125void ee_notsupp (struct keytabent *, char *); 126 127/* Sun 3/4 EEPROM checksum routines. */ 128u_char ee_checksum (u_char *, size_t); 129void ee_updatechecksums (void); 130void ee_verifychecksums (void); 131 132#ifdef __sparc__ 133/* Sparc Openprom handlers. */ 134char *op_handler (char *, char *); 135void op_action (char *, char *); 136void op_dump (void); 137int check_for_openprom (void); 138#endif /* __sparc__ */ 139 140/* OpenFirmware handlers. */ 141char *of_handler (char *, char *); 142void of_action (char *, char *); 143void of_dump (void); 144 145/* PReP nvram handlers. */ 146char *prep_handler (char *, char *); 147void prep_action (char *, char *); 148void prep_dump (void); 149