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