source: rtems/c/src/lib/libbsp/powerpc/shared/include/nvram.h @ e79a1947

4.104.114.84.95
Last change on this file since e79a1947 was f05b2ac, checked in by Ralf Corsepius <ralf.corsepius@…>, on Apr 21, 2004 at 4:01:48 PM

Remove duplicate white lines.

  • Property mode set to 100644
File size: 4.8 KB
Line 
1/*
2 * PreP compliant NVRAM access
3 *
4 * This file can be found in motorla or IBP PPC site.
5 *
6 * $Id$
7 */
8
9#ifndef _PPC_NVRAM_H
10#define _PPC_NVRAM_H
11
12#define NVRAM_AS0  0x74
13#define NVRAM_AS1  0x75
14#define NVRAM_DATA 0x77
15
16/* RTC Offsets */
17
18#define MOTO_RTC_SECONDS        0x1FF9
19#define MOTO_RTC_MINUTES        0x1FFA
20#define MOTO_RTC_HOURS          0x1FFB
21#define MOTO_RTC_DAY_OF_WEEK    0x1FFC
22#define MOTO_RTC_DAY_OF_MONTH   0x1FFD
23#define MOTO_RTC_MONTH          0x1FFE
24#define MOTO_RTC_YEAR           0x1FFF
25#define MOTO_RTC_CONTROLA       0x1FF8
26#define MOTO_RTC_CONTROLB       0x1FF9
27
28#ifndef BCD_TO_BIN
29#define BCD_TO_BIN(val) ((val)=((val)&15) + ((val)>>4)*10)
30#endif
31
32#ifndef BIN_TO_BCD
33#define BIN_TO_BCD(val) ((val)=(((val)/10)<<4) + (val)%10)
34#endif
35
36/* Structure map for NVRAM on PowerPC Reference Platform */
37/* All fields are either character/byte strings which are valid either
38  endian or they are big-endian numbers.
39
40  There are a number of Date and Time fields which are in RTC format,
41  big-endian. These are stored in UT (GMT).
42
43  For enum's: if given in hex then they are bit significant, i.e. only
44  one bit is on for each enum.
45*/
46
47#define NVSIZE          4096    /* size of NVRAM */
48#define OSAREASIZE      512     /* size of OSArea space */
49#define CONFSIZE        1024    /* guess at size of Configuration space */
50
51#ifndef ASM
52
53typedef struct _SECURITY {
54  unsigned long BootErrCnt;         /* Count of boot password errors */
55  unsigned long ConfigErrCnt;       /* Count of config password errors */
56  unsigned long BootErrorDT[2];     /* Date&Time from RTC of last error in pw */
57  unsigned long ConfigErrorDT[2];   /* Date&Time from RTC of last error in pw */
58  unsigned long BootCorrectDT[2];   /* Date&Time from RTC of last correct pw */
59  unsigned long ConfigCorrectDT[2]; /* Date&Time from RTC of last correct pw */
60  unsigned long BootSetDT[2];       /* Date&Time from RTC of last set of pw */
61  unsigned long ConfigSetDT[2];     /* Date&Time from RTC of last set of pw */
62  unsigned char Serial[16];         /* Box serial number */
63} SECURITY;
64
65typedef enum _OS_ID {
66  Unknown       = 0,
67  Firmware      = 1,
68  AIX           = 2,
69  NT            = 3,
70  MKOS2         = 4,
71  MKAIX         = 5,
72  Taligent      = 6,
73  Solaris       = 7,
74  MK            = 12
75} OS_ID;
76
77typedef struct _ERROR_LOG {
78  unsigned char ErrorLogEntry[40]; /* To be architected */
79} ERROR_LOG;
80
81typedef enum _BOOT_STATUS {
82  BootStarted           = 0x01,
83  BootFinished          = 0x02,
84  RestartStarted        = 0x04,
85  RestartFinished       = 0x08,
86  PowerFailStarted      = 0x10,
87  PowerFailFinished     = 0x20,
88  ProcessorReady        = 0x40,
89  ProcessorRunning      = 0x80,
90  ProcessorStart        = 0x0100
91} BOOT_STATUS;
92
93typedef struct _RESTART_BLOCK {
94  unsigned short                Version;
95  unsigned short                Revision;
96  unsigned long                 ResumeReserve1[2];
97  volatile unsigned long        BootStatus;
98  unsigned long                 CheckSum;               /* Checksum of RESTART_BLOCK */
99  void*                         RestartAddress;
100  void*                         SaveAreaAddr;
101  unsigned long                 SaveAreaLength;
102} RESTART_BLOCK;
103
104typedef enum _OSAREA_USAGE {
105  Empty = 0,
106  Used  = 1
107} OSAREA_USAGE;
108
109typedef enum _PM_MODE {
110  Suspend = 0x80, /* Part of state is in memory */
111  Normal  = 0x00  /* No power management in effect */
112} PMMode;
113
114typedef struct _HEADER {
115  unsigned short        Size;       /* NVRAM size in K(1024) */
116  unsigned char         Version;     /* Structure map different */
117  unsigned char         Revision;    /* Structure map the same -may
118                                        be new values in old fields
119                                        in other words old code still works */
120  unsigned short        Crc1;       /* check sum from beginning of nvram to OSArea */
121  unsigned short        Crc2;       /* check sum of config */
122  unsigned char         LastOS;     /* OS_ID */
123  unsigned char         Endian;     /* B if big endian, L if little endian */
124  unsigned char         OSAreaUsage;/* OSAREA_USAGE */
125  unsigned char         PMMode;     /* Shutdown mode */
126  RESTART_BLOCK         RestartBlock;
127  SECURITY              Security;
128  ERROR_LOG             ErrorLog[2];
129
130  /* Global Environment information */
131  void*                 GEAddress;
132  unsigned long         GELength;
133
134  /* Date&Time from RTC of last change to Global Environment */
135  unsigned long         GELastWriteDT[2];
136
137  /* Configuration information */
138  void*                 ConfigAddress;
139  unsigned long         ConfigLength;
140
141  /* Date&Time from RTC of last change to Configuration */
142  unsigned long         ConfigLastWriteDT[2];
143  unsigned long         ConfigCount; /* Count of entries in Configuration */
144
145  /* OS dependent temp area */
146  void*                 OSAreaAddress;
147  unsigned long         OSAreaLength;
148
149  /* Date&Time from RTC of last change to OSAreaArea */
150  unsigned long         OSAreaLastWriteDT[2];
151} HEADER;
152
153/* Here is the whole map of the NVRAM */
154typedef struct _NVRAM_MAP {
155  HEADER        Header;
156  unsigned char GEArea[NVSIZE-CONFSIZE-OSAREASIZE-sizeof(HEADER)];
157  unsigned char OSArea[OSAREASIZE];
158  unsigned char ConfigArea[CONFSIZE];
159} NVRAM_MAP;
160
161/* Routines to manipulate the NVRAM */
162void init_prep_nvram(void);
163char *prep_nvram_get_var(const char *name);
164char *prep_nvram_first_var(void);
165char *prep_nvram_next_var(char *name);
166
167#endif /* ASM */
168
169#endif /* _PPC_NVRAM_H */
Note: See TracBrowser for help on using the repository browser.