2 * PreP compliant NVRAM access
5 /* Corey Minyard (minyard@acm.org) - Stolen from PReP book. Per the
7 (C) Copyright (Corey Minyard), (1998). All rights reserved
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.
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 */
57 typedef struct _ERROR_LOG
{
58 unsigned char ErrorLogEntry
[40]; /* To be architected */
61 typedef enum _BOOT_STATUS
{
64 RestartStarted
= 0x04,
65 RestartFinished
= 0x08,
66 PowerFailStarted
= 0x10,
67 PowerFailFinished
= 0x20,
68 ProcessorReady
= 0x40,
69 ProcessorRunning
= 0x80,
70 ProcessorStart
= 0x0100
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
;
81 unsigned long SaveAreaLength
;
84 typedef enum _OSAREA_USAGE
{
89 typedef enum _PM_MODE
{
90 Suspend
= 0x80, /* Part of state is in memory */
91 Normal
= 0x00 /* No power management in effect */
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
;
108 ERROR_LOG ErrorLog
[2];
110 /* Global Environment information */
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];
133 /* Here is the whole map of the NVRAM */
134 typedef struct _NVRAM_MAP
{
136 unsigned char GEArea
[NVSIZE
-CONFSIZE
-OSAREASIZE
-sizeof(HEADER
)];
137 unsigned char OSArea
[OSAREASIZE
];
138 unsigned char ConfigArea
[CONFSIZE
];
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
,
152 #endif /* _PPC_PREP_NVRAM_H */
153 #endif /* __KERNEL__ */