1*ca1a6f97Sjoerg /* $NetBSD: defs.h,v 1.15 2013/07/02 11:59:46 joerg Exp $ */ 2da9b1f76Sthorpej 3c479d69aSthorpej /*- 4c479d69aSthorpej * Copyright (c) 1996 The NetBSD Foundation, Inc. 5da9b1f76Sthorpej * All rights reserved. 6da9b1f76Sthorpej * 7c479d69aSthorpej * This code is derived from software contributed to The NetBSD Foundation 8c479d69aSthorpej * by Jason R. Thorpe. 9c479d69aSthorpej * 10da9b1f76Sthorpej * Redistribution and use in source and binary forms, with or without 11da9b1f76Sthorpej * modification, are permitted provided that the following conditions 12da9b1f76Sthorpej * are met: 13da9b1f76Sthorpej * 1. Redistributions of source code must retain the above copyright 14da9b1f76Sthorpej * notice, this list of conditions and the following disclaimer. 15da9b1f76Sthorpej * 2. Redistributions in binary form must reproduce the above copyright 16da9b1f76Sthorpej * notice, this list of conditions and the following disclaimer in the 17da9b1f76Sthorpej * documentation and/or other materials provided with the distribution. 18da9b1f76Sthorpej * 19c479d69aSthorpej * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 20c479d69aSthorpej * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21c479d69aSthorpej * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 2287f4ccd4Sjtc * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 2387f4ccd4Sjtc * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24c479d69aSthorpej * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25c479d69aSthorpej * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26c479d69aSthorpej * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27c479d69aSthorpej * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28c479d69aSthorpej * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29c479d69aSthorpej * POSSIBILITY OF SUCH DAMAGE. 30da9b1f76Sthorpej */ 31da9b1f76Sthorpej 324c36dff3Smacallan #ifdef USE_OPENFIRM 334c36dff3Smacallan #include <dev/ofw/openfirmio.h> 344c36dff3Smacallan #endif 354c36dff3Smacallan 369cc2c6c4Sgarbled #ifdef USE_PREPNVRAM 379cc2c6c4Sgarbled #include <machine/nvram.h> 389cc2c6c4Sgarbled #endif 399cc2c6c4Sgarbled 40da9b1f76Sthorpej #undef BUFSIZE 41da9b1f76Sthorpej #define BUFSIZE 1024 42da9b1f76Sthorpej 43da9b1f76Sthorpej #define IO_READ 0 44da9b1f76Sthorpej #define IO_WRITE 1 45da9b1f76Sthorpej 46da9b1f76Sthorpej #define MAXIMUM(a, b) ((a) > (b) ? (a) : (b)) 47da9b1f76Sthorpej 48da9b1f76Sthorpej /* 49da9b1f76Sthorpej * Misc. location declarations. 50da9b1f76Sthorpej */ 51da9b1f76Sthorpej #define EE_SIZE 0x500 52da9b1f76Sthorpej #define EE_WC_LOC 0x04 53da9b1f76Sthorpej #define EE_CKSUM_LOC 0x0c 54da9b1f76Sthorpej #define EE_HWUPDATE_LOC 0x10 55da9b1f76Sthorpej #define EE_BANNER_ENABLE_LOC 0x20 56da9b1f76Sthorpej 57da9b1f76Sthorpej /* 58da9b1f76Sthorpej * Keyword table entry. Contains a pointer to the keyword, the 59da9b1f76Sthorpej * offset into the prom where the value lives, and a pointer to 60da9b1f76Sthorpej * the function that handles that value. 61da9b1f76Sthorpej */ 62da9b1f76Sthorpej struct keytabent { 631d09b9bbSnakayama const char *kt_keyword; /* keyword for this entry */ 64da9b1f76Sthorpej u_int kt_offset; /* offset into prom of value */ 65*ca1a6f97Sjoerg void (*kt_handler) (const struct keytabent *, char *); 66da9b1f76Sthorpej /* handler function for this entry */ 67da9b1f76Sthorpej }; 68da9b1f76Sthorpej 69da9b1f76Sthorpej /* 70da9b1f76Sthorpej * String-value table entry. Maps a string to a numeric value and 71da9b1f76Sthorpej * vice-versa. 72da9b1f76Sthorpej */ 73da9b1f76Sthorpej struct strvaltabent { 741d09b9bbSnakayama const char *sv_str; /* the string ... */ 75da9b1f76Sthorpej u_char sv_val; /* ... and the value */ 76da9b1f76Sthorpej }; 77da9b1f76Sthorpej 7861db04d3Snakayama #ifdef USE_OPENPROM 792434f068Sthorpej struct opiocdesc; 80da9b1f76Sthorpej /* 81da9b1f76Sthorpej * This is an entry in a table which describes a set of `exceptions'. 82da9b1f76Sthorpej * In other words, these are Openprom fields that we either can't 83da9b1f76Sthorpej * `just print' or don't know how to deal with. 84da9b1f76Sthorpej */ 85da9b1f76Sthorpej struct extabent { 867a4c7e7fSlukem const char *ex_keyword; /* keyword for this entry */ 87*ca1a6f97Sjoerg void (*ex_handler) (const struct extabent *, 887996c8deSmrg struct opiocdesc *, char *); 89da9b1f76Sthorpej /* handler function for this entry */ 90da9b1f76Sthorpej }; 9161db04d3Snakayama #endif 92da9b1f76Sthorpej 93ad53a0a5Smacallan #ifdef USE_OPENFIRM 94ad53a0a5Smacallan struct extabent { 957a4c7e7fSlukem const char *ex_keyword; /* keyword for this entry */ 96*ca1a6f97Sjoerg void (*ex_handler) (const struct extabent *, 97ad53a0a5Smacallan struct ofiocdesc *, char *); 98ad53a0a5Smacallan /* handler function for this entry */ 99ad53a0a5Smacallan }; 100ad53a0a5Smacallan #endif 101ad53a0a5Smacallan 1029cc2c6c4Sgarbled #ifdef USE_PREPNVRAM 1039cc2c6c4Sgarbled struct extabent { 1047a4c7e7fSlukem const char *ex_keyword; /* keyword for this entry */ 105*ca1a6f97Sjoerg void (*ex_handler) (const struct extabent *, 1069cc2c6c4Sgarbled struct pnviocdesc *, char *); 1079cc2c6c4Sgarbled /* handler function for this entry */ 1089cc2c6c4Sgarbled }; 1099cc2c6c4Sgarbled #endif 1109cc2c6c4Sgarbled 1119cc2c6c4Sgarbled 112da9b1f76Sthorpej /* Sun 3/4 EEPROM handlers. */ 1136ce96c99Smrg void ee_action(char *, char *); 1146ce96c99Smrg void ee_dump(void); 115da9b1f76Sthorpej 116da9b1f76Sthorpej /* Sun 3/4 EEPROM checksum routines. */ 1177996c8deSmrg void ee_updatechecksums(void); 1187996c8deSmrg void ee_verifychecksums(void); 119da9b1f76Sthorpej 120da9b1f76Sthorpej /* Sparc Openprom handlers. */ 1217996c8deSmrg char *op_handler(char *, char *); 1226ce96c99Smrg void op_action(char *, char *); 1237996c8deSmrg void op_dump(void); 1246ce96c99Smrg int check_for_openprom(void); 125ad53a0a5Smacallan 126ad53a0a5Smacallan /* OpenFirmware handlers. */ 127ad53a0a5Smacallan char *of_handler(char *, char *); 128ad53a0a5Smacallan void of_action(char *, char *); 129ad53a0a5Smacallan void of_dump(void); 1309cc2c6c4Sgarbled 1319cc2c6c4Sgarbled /* PReP nvram handlers. */ 1329cc2c6c4Sgarbled char *prep_handler(char *, char *); 1339cc2c6c4Sgarbled void prep_action(char *, char *); 1349cc2c6c4Sgarbled void prep_dump(void); 135