Linux 2.6.12-rc6
[cris-mirror.git] / include / asm-ppc / prep_nvram.h
blob6dbc36a84df23215b80e1907638f0cae1f021fbd
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 #ifdef __KERNEL__
21 #ifndef _PPC_PREP_NVRAM_H
22 #define _PPC_PREP_NVRAM_H
24 #define MAX_PREP_NVRAM 0x8000
25 #define PREP_NVRAM_AS0 0x74
26 #define PREP_NVRAM_AS1 0x75
27 #define PREP_NVRAM_DATA 0x77
29 #define NVSIZE 4096 /* size of NVRAM */
30 #define OSAREASIZE 512 /* size of OSArea space */
31 #define CONFSIZE 1024 /* guess at size of Configuration space */
33 typedef struct _SECURITY {
34 unsigned long BootErrCnt; /* Count of boot password errors */
35 unsigned long ConfigErrCnt; /* Count of config password errors */
36 unsigned long BootErrorDT[2]; /* Date&Time from RTC of last error in pw */
37 unsigned long ConfigErrorDT[2]; /* Date&Time from RTC of last error in pw */
38 unsigned long BootCorrectDT[2]; /* Date&Time from RTC of last correct pw */
39 unsigned long ConfigCorrectDT[2]; /* Date&Time from RTC of last correct pw */
40 unsigned long BootSetDT[2]; /* Date&Time from RTC of last set of pw */
41 unsigned long ConfigSetDT[2]; /* Date&Time from RTC of last set of pw */
42 unsigned char Serial[16]; /* Box serial number */
43 } SECURITY;
45 typedef enum _OS_ID {
46 Unknown = 0,
47 Firmware = 1,
48 AIX = 2,
49 NT = 3,
50 MKOS2 = 4,
51 MKAIX = 5,
52 Taligent = 6,
53 Solaris = 7,
54 MK = 12
55 } OS_ID;
57 typedef struct _ERROR_LOG {
58 unsigned char ErrorLogEntry[40]; /* To be architected */
59 } ERROR_LOG;
61 typedef enum _BOOT_STATUS {
62 BootStarted = 0x01,
63 BootFinished = 0x02,
64 RestartStarted = 0x04,
65 RestartFinished = 0x08,
66 PowerFailStarted = 0x10,
67 PowerFailFinished = 0x20,
68 ProcessorReady = 0x40,
69 ProcessorRunning = 0x80,
70 ProcessorStart = 0x0100
71 } BOOT_STATUS;
73 typedef struct _RESTART_BLOCK {
74 unsigned short Version;
75 unsigned short Revision;
76 unsigned long ResumeReserve1[2];
77 volatile unsigned long BootStatus;
78 unsigned long CheckSum; /* Checksum of RESTART_BLOCK */
79 void * RestartAddress;
80 void * SaveAreaAddr;
81 unsigned long SaveAreaLength;
82 } RESTART_BLOCK;
84 typedef enum _OSAREA_USAGE {
85 Empty = 0,
86 Used = 1
87 } OSAREA_USAGE;
89 typedef enum _PM_MODE {
90 Suspend = 0x80, /* Part of state is in memory */
91 Normal = 0x00 /* No power management in effect */
92 } PMMODE;
94 typedef struct _HEADER {
95 unsigned short Size; /* NVRAM size in K(1024) */
96 unsigned char Version; /* Structure map different */
97 unsigned char Revision; /* Structure map the same -may
98 be new values in old fields
99 in other words old code still works */
100 unsigned short Crc1; /* check sum from beginning of nvram to OSArea */
101 unsigned short Crc2; /* check sum of config */
102 unsigned char LastOS; /* OS_ID */
103 unsigned char Endian; /* B if big endian, L if little endian */
104 unsigned char OSAreaUsage; /* OSAREA_USAGE */
105 unsigned char PMMode; /* Shutdown mode */
106 RESTART_BLOCK RestartBlock;
107 SECURITY Security;
108 ERROR_LOG ErrorLog[2];
110 /* Global Environment information */
111 void * GEAddress;
112 unsigned long GELength;
114 /* Date&Time from RTC of last change to Global Environment */
115 unsigned long GELastWriteDT[2];
117 /* Configuration information */
118 void * ConfigAddress;
119 unsigned long ConfigLength;
121 /* Date&Time from RTC of last change to Configuration */
122 unsigned long ConfigLastWriteDT[2];
123 unsigned long ConfigCount; /* Count of entries in Configuration */
125 /* OS dependent temp area */
126 void * OSAreaAddress;
127 unsigned long OSAreaLength;
129 /* Date&Time from RTC of last change to OSAreaArea */
130 unsigned long OSAreaLastWriteDT[2];
131 } HEADER;
133 /* Here is the whole map of the NVRAM */
134 typedef struct _NVRAM_MAP {
135 HEADER Header;
136 unsigned char GEArea[NVSIZE-CONFSIZE-OSAREASIZE-sizeof(HEADER)];
137 unsigned char OSArea[OSAREASIZE];
138 unsigned char ConfigArea[CONFSIZE];
139 } NVRAM_MAP;
141 /* Routines to manipulate the NVRAM */
142 void init_prep_nvram(void);
143 char *prep_nvram_get_var(const char *name);
144 char *prep_nvram_first_var(void);
145 char *prep_nvram_next_var(char *name);
147 /* Routines to read and write directly to the NVRAM */
148 unsigned char prep_nvram_read_val(int addr);
149 void prep_nvram_write_val(int addr,
150 unsigned char val);
152 #endif /* _PPC_PREP_NVRAM_H */
153 #endif /* __KERNEL__ */