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. 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 */ 51 typedefstruct _ERROR_LOG
{ 52 unsigned char ErrorLogEntry
[40];/* To be architected */ 55 typedefenum _BOOT_STATUS
{ 59 RestartFinished
=0x08, 60 PowerFailStarted
=0x10, 61 PowerFailFinished
=0x20, 63 ProcessorRunning
=0x80, 64 ProcessorStart
=0x0100 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 */ 75 unsigned long SaveAreaLength
; 78 typedefenum _OSAREA_USAGE
{ 83 typedefenum _PM_MODE
{ 84 Suspend
=0x80,/* Part of state is in memory */ 85 Normal
=0x00/* No power management in effect */ 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
; 102 ERROR_LOG ErrorLog
[2]; 104 /* Global Environment information */ 106 unsigned long GELength
; 108 /* Date&Time from RTC of last change to Global Environment */ 109 unsigned long GELastWriteDT
[2]; 111 /* Configuration information */ 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 */ 121 unsigned long OSAreaLength
; 123 /* Date&Time from RTC of last change to OSAreaArea */ 124 unsigned long OSAreaLastWriteDT
[2]; 127 /* Here is the whole map of the NVRAM */ 128 typedefstruct _NVRAM_MAP
{ 130 unsigned char GEArea
[NVSIZE
-CONFSIZE
-OSAREASIZE
-sizeof(HEADER
)]; 131 unsigned char OSArea
[OSAREASIZE
]; 132 unsigned char ConfigArea
[CONFSIZE
]; 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
, 146 #endif/* _PPC_PREP_NVRAM_H */