1 /*
2 * PreP compliant NVRAM access
3 */
4
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 */
9
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.
13
14 There are a number of Date and Time fields which are in RTC format,
15 big-endian. These are stored in UT (GMT).
16
17 For enum's: if given in hex then they are bit significant, i.e. only
18 one bit is on for each enum.
19 */
20 #ifdef __KERNEL__
21 #ifndef _PPC_PREP_NVRAM_H
22 #define _PPC_PREP_NVRAM_H
23
24 #define NVSIZE 4096 /* size of NVRAM */
25 #define OSAREASIZE 512 /* size of OSArea space */
26 #define CONFSIZE 1024 /* guess at size of Configuration space */
27
28 typedef struct _SECURITY {
29 unsigned long BootErrCnt; /* Count of boot password errors */
30 unsigned long ConfigErrCnt; /* Count of config password errors */
31 unsigned long BootErrorDT[2]; /* Date&Time from RTC of last error in pw */
32 unsigned long ConfigErrorDT[2]; /* Date&Time from RTC of last error in pw */
33 unsigned long BootCorrectDT[2]; /* Date&Time from RTC of last correct pw */
34 unsigned long ConfigCorrectDT[2]; /* Date&Time from RTC of last correct pw */
35 unsigned long BootSetDT[2]; /* Date&Time from RTC of last set of pw */
36 unsigned long ConfigSetDT[2]; /* Date&Time from RTC of last set of pw */
37 unsigned char Serial[16]; /* Box serial number */
38 } SECURITY;
39
40 typedef enum _OS_ID {
41 Unknown = 0,
42 Firmware = 1,
43 AIX = 2,
44 NT = 3,
45 MKOS2 = 4,
46 MKAIX = 5,
47 Taligent = 6,
48 Solaris = 7,
49 MK = 12
50 } OS_ID;
51
52 typedef struct _ERROR_LOG {
53 unsigned char ErrorLogEntry[40]; /* To be architected */
54 } ERROR_LOG;
55
56 typedef enum _BOOT_STATUS {
57 BootStarted = 0x01,
58 BootFinished = 0x02,
59 RestartStarted = 0x04,
60 RestartFinished = 0x08,
61 PowerFailStarted = 0x10,
62 PowerFailFinished = 0x20,
63 ProcessorReady = 0x40,
64 ProcessorRunning = 0x80,
65 ProcessorStart = 0x0100
66 } BOOT_STATUS;
67
68 typedef struct _RESTART_BLOCK {
69 unsigned short Version;
70 unsigned short Revision;
71 unsigned long ResumeReserve1[2];
72 volatile unsigned long BootStatus;
73 unsigned long CheckSum; /* Checksum of RESTART_BLOCK */
74 void * RestartAddress;
75 void * SaveAreaAddr;
76 unsigned long SaveAreaLength;
77 } RESTART_BLOCK;
78
79 typedef enum _OSAREA_USAGE {
80 Empty = 0,
81 Used = 1
82 } OSAREA_USAGE;
83
84 typedef enum _PM_MODE {
85 Suspend = 0x80, /* Part of state is in memory */
86 Normal = 0x00 /* No power management in effect */
87 } PMMode;
88
89 typedef struct _HEADER {
90 unsigned short Size; /* NVRAM size in K(1024) */
91 unsigned char Version; /* Structure map different */
92 unsigned char Revision; /* Structure map the same -may
93 be new values in old fields
94 in other words old code still works */
95 unsigned short Crc1; /* check sum from beginning of nvram to OSArea */
96 unsigned short Crc2; /* check sum of config */
97 unsigned char LastOS; /* OS_ID */
98 unsigned char Endian; /* B if big endian, L if little endian */
99 unsigned char OSAreaUsage; /* OSAREA_USAGE */
100 unsigned char PMMode; /* Shutdown mode */
101 RESTART_BLOCK RestartBlock;
102 SECURITY Security;
103 ERROR_LOG ErrorLog[2];
104
105 /* Global Environment information */
106 void * GEAddress;
107 unsigned long GELength;
108
109 /* Date&Time from RTC of last change to Global Environment */
110 unsigned long GELastWriteDT[2];
111
112 /* Configuration information */
113 void * ConfigAddress;
114 unsigned long ConfigLength;
115
116 /* Date&Time from RTC of last change to Configuration */
117 unsigned long ConfigLastWriteDT[2];
118 unsigned long ConfigCount; /* Count of entries in Configuration */
119
120 /* OS dependent temp area */
121 void * OSAreaAddress;
122 unsigned long OSAreaLength;
123
124 /* Date&Time from RTC of last change to OSAreaArea */
125 unsigned long OSAreaLastWriteDT[2];
126 } HEADER;
127
128 /* Here is the whole map of the NVRAM */
129 typedef struct _NVRAM_MAP {
130 HEADER Header;
131 unsigned char GEArea[NVSIZE-CONFSIZE-OSAREASIZE-sizeof(HEADER)];
132 unsigned char OSArea[OSAREASIZE];
133 unsigned char ConfigArea[CONFSIZE];
134 } NVRAM_MAP;
135
136 /* Routines to manipulate the NVRAM */
137 void init_prep_nvram(void);
138 char *prep_nvram_get_var(const char *name);
139 char *prep_nvram_first_var(void);
140 char *prep_nvram_next_var(char *name);
141
142 /* Routines to read and write directly to the NVRAM */
143 unsigned char prep_nvram_read_val(int addr);
144 void prep_nvram_write_val(int addr,
145 unsigned char val);
146
147 #endif /* _PPC_PREP_NVRAM_H */
148 #endif /* __KERNEL__ */
149
This page was automatically generated by the
LXR engine.
Visit the LXR main site for more
information.