Import 2.3.18pre1
[davej-history.git] / include / asm-ppc / prep_nvram.h
blob2f0f80b5cb241be231474ba69c89f6cc84b8ebfb
1 /*
2 * PreP compliant NVRAM access
3 */
5 /* Corey Minyard (minyard@acm.org) - Stolen from PReP book. Per the
6 license I must say:
7 (C) Copyright (Corey Minyard), (1998). All rights reserved
8 */
10 /* Structure map for NVRAM on PowerPC Reference Platform */
11 /* All fields are either character/byte strings which are valid either
12 endian or they are big-endian numbers.
14 There are a number of Date and Time fields which are in RTC format,
15 big-endian. These are stored in UT (GMT).
17 For enum's: if given in hex then they are bit significant, i.e. only
18 one bit is on for each enum.
20 #ifndef _PPC_PREP_NVRAM_H
21 #define _PPC_PREP_NVRAM_H
23 #define NVSIZE 4096/* size of NVRAM */
24 #define OSAREASIZE 512/* size of OSArea space */
25 #define CONFSIZE 1024/* guess at size of Configuration space */
27 typedefstruct _SECURITY {
28 unsigned long BootErrCnt;/* Count of boot password errors */
29 unsigned long ConfigErrCnt;/* Count of config password errors */
30 unsigned long BootErrorDT[2];/* Date&Time from RTC of last error in pw */
31 unsigned long ConfigErrorDT[2];/* Date&Time from RTC of last error in pw */
32 unsigned long BootCorrectDT[2];/* Date&Time from RTC of last correct pw */
33 unsigned long ConfigCorrectDT[2];/* Date&Time from RTC of last correct pw */
34 unsigned long BootSetDT[2];/* Date&Time from RTC of last set of pw */
35 unsigned long ConfigSetDT[2];/* Date&Time from RTC of last set of pw */
36 unsigned char Serial[16];/* Box serial number */
37 } SECURITY;
39 typedefenum _OS_ID {
40 Unknown =0,
41 Firmware =1,
42 AIX =2,
43 NT =3,
44 MKOS2 =4,
45 MKAIX =5,
46 Taligent =6,
47 Solaris =7,
48 MK =12
49 } OS_ID;
51 typedefstruct _ERROR_LOG {
52 unsigned char ErrorLogEntry[40];/* To be architected */
53 } ERROR_LOG;
55 typedefenum _BOOT_STATUS {
56 BootStarted =0x01,
57 BootFinished =0x02,
58 RestartStarted =0x04,
59 RestartFinished =0x08,
60 PowerFailStarted =0x10,
61 PowerFailFinished =0x20,
62 ProcessorReady =0x40,
63 ProcessorRunning =0x80,
64 ProcessorStart =0x0100
65 } BOOT_STATUS;
67 typedefstruct _RESTART_BLOCK {
68 unsigned short Version;
69 unsigned short Revision;
70 unsigned long ResumeReserve1[2];
71 volatileunsigned long BootStatus;
72 unsigned long CheckSum;/* Checksum of RESTART_BLOCK */
73 void* RestartAddress;
74 void* SaveAreaAddr;
75 unsigned long SaveAreaLength;
76 } RESTART_BLOCK;
78 typedefenum _OSAREA_USAGE {
79 Empty =0,
80 Used =1
81 } OSAREA_USAGE;
83 typedefenum _PM_MODE {
84 Suspend =0x80,/* Part of state is in memory */
85 Normal =0x00/* No power management in effect */
86 } PMMode;
88 typedefstruct _HEADER {
89 unsigned short Size;/* NVRAM size in K(1024) */
90 unsigned char Version;/* Structure map different */
91 unsigned char Revision;/* Structure map the same -may
92 be new values in old fields
93 in other words old code still works */
94 unsigned short Crc1;/* check sum from beginning of nvram to OSArea */
95 unsigned short Crc2;/* check sum of config */
96 unsigned char LastOS;/* OS_ID */
97 unsigned char Endian;/* B if big endian, L if little endian */
98 unsigned char OSAreaUsage;/* OSAREA_USAGE */
99 unsigned char PMMode;/* Shutdown mode */
100 RESTART_BLOCK RestartBlock;
101 SECURITY Security;
102 ERROR_LOG ErrorLog[2];
104 /* Global Environment information */
105 void* GEAddress;
106 unsigned long GELength;
108 /* Date&Time from RTC of last change to Global Environment */
109 unsigned long GELastWriteDT[2];
111 /* Configuration information */
112 void* ConfigAddress;
113 unsigned long ConfigLength;
115 /* Date&Time from RTC of last change to Configuration */
116 unsigned long ConfigLastWriteDT[2];
117 unsigned long ConfigCount;/* Count of entries in Configuration */
119 /* OS dependent temp area */
120 void* OSAreaAddress;
121 unsigned long OSAreaLength;
123 /* Date&Time from RTC of last change to OSAreaArea */
124 unsigned long OSAreaLastWriteDT[2];
125 } HEADER;
127 /* Here is the whole map of the NVRAM */
128 typedefstruct _NVRAM_MAP {
129 HEADER Header;
130 unsigned char GEArea[NVSIZE-CONFSIZE-OSAREASIZE-sizeof(HEADER)];
131 unsigned char OSArea[OSAREASIZE];
132 unsigned char ConfigArea[CONFSIZE];
133 } NVRAM_MAP;
135 /* Routines to manipulate the NVRAM */
136 voidinit_prep_nvram(void);
137 char*prep_nvram_get_var(const char*name);
138 char*prep_nvram_first_var(void);
139 char*prep_nvram_next_var(char*name);
141 /* Routines to read and write directly to the NVRAM */
142 unsigned charprep_nvram_read_val(int addr);
143 voidprep_nvram_write_val(int addr,
144 unsigned char val);
146 #endif/* _PPC_PREP_NVRAM_H */
close