Home | History | Annotate | Line # | Download | only in include
nvram.h revision 1.7.2.1
      1  1.7.2.1     yamt /* $NetBSD: nvram.h,v 1.7.2.1 2012/10/30 17:20:14 yamt Exp $ */
      2      1.1  garbled 
      3      1.1  garbled /*-
      4      1.1  garbled  * Copyright (c) 2006 The NetBSD Foundation, Inc.
      5      1.1  garbled  * All rights reserved.
      6      1.1  garbled  *
      7      1.1  garbled  * This code is derived from software contributed to The NetBSD Foundation
      8      1.1  garbled  * by Tim Rightnour
      9      1.1  garbled  *
     10      1.1  garbled  * Redistribution and use in source and binary forms, with or without
     11      1.1  garbled  * modification, are permitted provided that the following conditions
     12      1.1  garbled  * are met:
     13      1.1  garbled  * 1. Redistributions of source code must retain the above copyright
     14      1.1  garbled  *    notice, this list of conditions and the following disclaimer.
     15      1.1  garbled  * 2. Redistributions in binary form must reproduce the above copyright
     16      1.1  garbled  *    notice, this list of conditions and the following disclaimer in the
     17      1.1  garbled  *    documentation and/or other materials provided with the distribution.
     18      1.1  garbled  *
     19      1.1  garbled  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     20      1.1  garbled  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     21      1.1  garbled  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     22      1.1  garbled  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     23      1.1  garbled  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     24      1.1  garbled  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     25      1.1  garbled  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     26      1.1  garbled  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     27      1.1  garbled  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28      1.1  garbled  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     29      1.1  garbled  * POSSIBILITY OF SUCH DAMAGE.
     30      1.1  garbled  */
     31      1.1  garbled 
     32      1.1  garbled /*
     33      1.1  garbled  * Based on the PowerPC Reference Platform NVRAM Specification.
     34      1.1  garbled  * Document Number: PPS-AR-FW0002
     35      1.1  garbled  * Jan 22, 1996
     36      1.1  garbled  * Version 0.3
     37      1.1  garbled  */
     38      1.1  garbled 
     39      1.1  garbled #ifndef _MACHINE_NVRAM_H
     40      1.1  garbled #define _MACHINE_NVRAM_H
     41      1.1  garbled 
     42      1.3  garbled #if defined(_KERNEL)
     43      1.2  garbled /* for the motorola machines */
     44      1.2  garbled #include <dev/ic/mk48txxvar.h>
     45      1.3  garbled #endif
     46      1.2  garbled 
     47      1.1  garbled #define MAX_PREP_NVRAM 0x8000	/* maxmum size of the nvram */
     48      1.1  garbled 
     49      1.1  garbled #define NVSIZE 4096		/* standard nvram size */
     50      1.1  garbled #define OSAREASIZE 512		/* size of OSArea space */
     51      1.1  garbled #define CONFSIZE 1024		/* guess at size of configuration area */
     52      1.1  garbled 
     53      1.1  garbled /*
     54      1.1  garbled  * The security fields are maintained by the firmware, and should be
     55      1.1  garbled  * considered read-only.
     56      1.1  garbled  */
     57      1.1  garbled typedef struct _SECURITY {
     58      1.1  garbled 	uint32_t BootErrCnt;	/* count of boot password errors */
     59      1.1  garbled 	uint32_t ConfigErrCnt;	/* count of config password errors */
     60      1.1  garbled 	uint32_t BootErrorDT[2];/* Date&Time from RTC of last error in pw */
     61      1.1  garbled 	uint32_t ConfigErrorDT[2];	/* last config pw error */
     62      1.1  garbled 	uint32_t BootCorrectDT[2];	/* last correct boot pw */
     63      1.1  garbled 	uint32_t ConfigCorrectDT[2];	/* last correct config pw */
     64      1.1  garbled 	uint32_t BootSetDT[2];		/* last set of boot pw */
     65      1.1  garbled 	uint32_t ConfigSetDT[2];	/* last set of config pw */
     66      1.1  garbled 	uint8_t Serial[16];	/* Box serial number */
     67      1.1  garbled } SECURITY;
     68      1.1  garbled 
     69      1.1  garbled typedef enum _ERROR_STATUS {
     70      1.1  garbled 	Clear = 0,	/* empty entry */
     71      1.1  garbled 	Pending = 1,
     72      1.1  garbled 	DiagnosedOK = 2,
     73      1.1  garbled 	DiagnosedFail = 3,
     74      1.1  garbled 	Overrun = 4,
     75      1.1  garbled 	Logged = 5,
     76      1.1  garbled } ERROR_STATUS;
     77      1.1  garbled 
     78      1.1  garbled typedef enum _OS_ID {
     79      1.1  garbled 	Unknown = 0,
     80      1.1  garbled 	Firmware = 1,
     81      1.1  garbled 	AIX = 2,
     82      1.1  garbled 	NT = 3,
     83      1.1  garbled 	WPOS2 = 4,
     84      1.1  garbled 	WPX = 5,
     85      1.1  garbled 	Taligent = 6,
     86      1.1  garbled 	Solaris = 7,
     87      1.1  garbled 	Netware = 8,
     88      1.1  garbled 	USL = 9,
     89      1.1  garbled 	Low_End_Client = 10,
     90      1.1  garbled 	SCO = 11,
     91      1.1  garbled 	MK = 12, /* from linux ?? */
     92      1.1  garbled } OS_ID;
     93      1.1  garbled 
     94      1.1  garbled /*
     95      1.1  garbled  * According to IBM, if severity is severe, the OS should not boot.  It should
     96      1.1  garbled  * instead run diags.  Umm.. whatever.
     97      1.1  garbled  */
     98      1.1  garbled 
     99      1.1  garbled typedef struct _ERROR_LOG {
    100      1.1  garbled 	uint8_t Status;		/* ERROR_STATUS */
    101      1.1  garbled 	uint8_t Os;		/* OS_ID */
    102      1.1  garbled 	uint8_t Type;		/* H=hardware S=software */
    103      1.1  garbled 	uint8_t Severity;	/* S=servere E=Error */
    104      1.1  garbled 	uint32_t ErrDT[2];	/* date and time from RTC */
    105      1.1  garbled 	uint8_t code[8];	/* error code */
    106      1.1  garbled 	union {
    107      1.1  garbled 		uint8_t detail[20]; /* detail of error */
    108      1.1  garbled 	} data;
    109      1.1  garbled } ERROR_LOG;
    110      1.1  garbled 
    111      1.1  garbled typedef enum _BOOT_STATUS {
    112      1.1  garbled 	BootStarted = 0x01,
    113      1.1  garbled 	BootFinished = 0x02,
    114      1.1  garbled 	RestartStarted = 0x04,
    115      1.1  garbled 	RestartFinished = 0x08,
    116      1.1  garbled 	PowerFailStarted = 0x10,
    117      1.1  garbled 	PowerFailFinished = 0x20,
    118      1.1  garbled 	ProcessorReady = 0x40,
    119      1.1  garbled 	ProcessorRunning = 0x80,
    120      1.1  garbled 	ProcessorStart = 0x0100
    121      1.1  garbled } BOOT_STATUS;
    122      1.1  garbled 
    123      1.1  garbled /*
    124      1.1  garbled  * If the OS decided to store data in the os area of NVRAM, this tells us
    125      1.1  garbled  * the last user, so we can decide if we want to re-use it or nuke it.
    126      1.1  garbled  * I'm not sure what all of these do yet.
    127      1.1  garbled  */
    128      1.1  garbled typedef struct _RESTART_BLOCK {
    129      1.1  garbled 	uint16_t Version;
    130      1.1  garbled 	uint16_t Revision;
    131      1.1  garbled 	uint32_t BootMasterId;
    132      1.1  garbled 	uint32_t ProcessorId;
    133      1.1  garbled 	volatile uint32_t BootStatus;
    134      1.1  garbled 	uint32_t CheckSum; /* Checksum of RESTART_BLOCK */
    135      1.1  garbled 	void *RestartAddress;
    136      1.1  garbled 	void *SaveAreaAddr;
    137      1.1  garbled 	uint32_t SaveAreaLength;
    138      1.1  garbled } RESTART_BLOCK;
    139      1.1  garbled 
    140      1.1  garbled typedef enum _OSAREA_USAGE {
    141      1.1  garbled 	Empty = 0,
    142      1.1  garbled 	Used = 1,
    143      1.1  garbled } OSAREA_USAGE;
    144      1.1  garbled 
    145      1.1  garbled typedef enum _PM_MODE {
    146      1.1  garbled 	Suspend = 0x80, /* part of state is in memory */
    147      1.1  garbled 	DirtyBit = 0x01, /* used to decide if pushbutton needs to be checked */
    148      1.1  garbled 	Hibernate = 0, /* nothing is in memory */
    149      1.1  garbled } PMMODE;
    150      1.1  garbled 
    151      1.1  garbled typedef struct _HEADER {
    152      1.1  garbled 	uint16_t Size;		/* NVRAM size in K(1024) */
    153      1.1  garbled 	uint8_t Version;	/* Structure map different */
    154      1.1  garbled 	uint8_t Revision;	/* Structure map same */
    155      1.1  garbled 	uint16_t Crc1;		/* checksum from beginning of nvram to OSArea*/
    156      1.1  garbled 	uint16_t Crc2;		/* cksum of config */
    157      1.1  garbled 	uint8_t LastOS;		/* OS_ID */
    158      1.1  garbled 	uint8_t Endian;		/* B if BE L if LE */
    159      1.1  garbled 	uint8_t OSAreaUSage;	/* OSAREA_USAGE */
    160      1.1  garbled 	uint8_t PMMode;		/* Shutdown mode */
    161      1.1  garbled 	RESTART_BLOCK RestartBlock;
    162      1.1  garbled 	SECURITY Security;
    163      1.1  garbled 	ERROR_LOG ErrorLog[2];
    164      1.1  garbled 
    165      1.1  garbled 	/* Global Environment info */
    166      1.1  garbled 	void *GEAddress;
    167      1.1  garbled 	uint32_t GELength;
    168      1.1  garbled 	uint32_t GELastWRiteDT[2]; /* last change to GE area */
    169      1.1  garbled 
    170      1.1  garbled 	/* Configuration info */
    171      1.1  garbled 	void *ConfigAddress;
    172      1.1  garbled 	uint32_t ConfigLength;
    173      1.1  garbled 	uint32_t ConfigLastWriteDT[2]; /* last change to config area */
    174      1.1  garbled 	uint32_t ConfigCount;	/* count of entries in configuration */
    175      1.1  garbled 
    176      1.7      wiz 	/* OS Dependent temp area */
    177      1.1  garbled 	void *OSAreaAddress;
    178      1.1  garbled 	uint32_t OSAreaLength;
    179      1.1  garbled 	uint32_t OSAreaLastWriteDT[2]; /* last change to OSArea */
    180      1.1  garbled } HEADER;
    181      1.1  garbled 
    182      1.1  garbled typedef struct _NVRAM_MAP {
    183      1.1  garbled 	HEADER Header;
    184      1.1  garbled 	uint8_t GEArea[NVSIZE - CONFSIZE - OSAREASIZE - sizeof(HEADER)];
    185      1.1  garbled 	uint8_t OSArea[OSAREASIZE];
    186      1.1  garbled 	uint8_t ConfigArea[CONFSIZE];
    187      1.1  garbled } NVRAM_MAP;
    188      1.1  garbled 
    189      1.1  garbled struct pnviocdesc {
    190      1.1  garbled 	int	pnv_namelen;	/* len of pnv_name */
    191      1.1  garbled 	char	*pnv_name;	/* node name */
    192      1.1  garbled 	int	pnv_buflen;	/* len of pnv_bus */
    193      1.1  garbled 	char	*pnv_buf;	/* option value result */
    194      1.1  garbled 	int	pnv_num;	/* number of something */
    195      1.1  garbled };
    196      1.1  garbled 
    197      1.4  garbled #define DEV_NVRAM	0
    198      1.4  garbled #define DEV_RESIDUAL	1
    199      1.4  garbled 
    200      1.3  garbled #if defined(_KERNEL)
    201      1.2  garbled struct prep_mk48txx_softc {
    202      1.5  tsutsui 	device_t *sc_dev;
    203      1.2  garbled 	bus_space_tag_t sc_bst;	 /* bus tag & handle */
    204      1.2  garbled 	bus_space_handle_t sc_bsh;      /* */
    205      1.2  garbled 
    206      1.2  garbled 	struct todr_chip_handle sc_handle; /* TODR handle */
    207      1.2  garbled 	const char	*sc_model;	/* chip model name */
    208      1.2  garbled 	bus_size_t	sc_nvramsz;	/* Size of NVRAM on the chip */
    209      1.2  garbled 	bus_size_t	sc_clkoffset;	/* Offset in NVRAM to clock bits */
    210      1.2  garbled 	u_int		sc_year0;	/* What year is represented on
    211      1.2  garbled 					   the system by the chip's year
    212      1.2  garbled 					   counter at 0 */
    213      1.2  garbled 	u_int		sc_flag;
    214      1.2  garbled #define MK48TXX_NO_CENT_ADJUST  0x0001
    215      1.2  garbled 
    216      1.2  garbled 	mk48txx_nvrd_t	sc_nvrd;	/* NVRAM/RTC read function */
    217      1.2  garbled 	mk48txx_nvwr_t	sc_nvwr;	/* NVRAM/RTC write function */
    218      1.2  garbled 	bus_space_tag_t sc_data;
    219      1.2  garbled 	bus_space_handle_t sc_datah;
    220      1.2  garbled };
    221      1.2  garbled 
    222      1.1  garbled struct nvram_pnpbus_softc {
    223      1.1  garbled 	bus_space_tag_t sc_iot;		/* io space tag */
    224      1.1  garbled 	bus_space_tag_t sc_as;		/* addr line */
    225      1.1  garbled 	bus_space_handle_t sc_ash;
    226      1.1  garbled 	bus_space_handle_t sc_ashs[2];
    227      1.1  garbled 
    228      1.1  garbled 	bus_space_tag_t sc_data;	/* data line */
    229      1.1  garbled 	bus_space_handle_t sc_datah;
    230      1.2  garbled 
    231      1.2  garbled 	/* clock bits for mk48txx */
    232      1.2  garbled 	struct prep_mk48txx_softc sc_mksc; /* mk48txx softc */
    233      1.2  garbled 
    234      1.1  garbled 	u_char  sc_open;		/* single use device */
    235      1.1  garbled };
    236      1.1  garbled 
    237      1.3  garbled #endif /* _KERNEL */
    238      1.3  garbled 
    239      1.1  garbled #define PNVIOCGET	_IOWR('O', 1, struct pnviocdesc) /* get var contents */
    240      1.1  garbled #define PNVIOCGETNEXTNAME _IOWR('O', 2, struct pnviocdesc) /* get next var */
    241      1.3  garbled #define PNVIOCGETNUMGE	_IOWR('O', 3, struct pnviocdesc) /* get nrof vars */
    242      1.3  garbled #define PNVIOCSET	_IOW('O', 4, struct pnviocdesc) /* set nvram var */
    243      1.1  garbled 
    244      1.1  garbled #endif /* _MACHINE_NVRAM_H */
    245