Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:23:54

0001 /*
0002  * PreP compliant NVRAM access
0003  *
0004  * This file can be found in motorla or IBP PPC site.
0005  */
0006 
0007 #ifndef _PPC_NVRAM_H
0008 #define _PPC_NVRAM_H
0009 
0010 #define NVRAM_AS0  0x74
0011 #define NVRAM_AS1  0x75
0012 #define NVRAM_DATA 0x77
0013 
0014 /* RTC Offsets */
0015 
0016 #define MOTO_RTC_SECONDS    0x1FF9
0017 #define MOTO_RTC_MINUTES    0x1FFA
0018 #define MOTO_RTC_HOURS      0x1FFB
0019 #define MOTO_RTC_DAY_OF_WEEK    0x1FFC
0020 #define MOTO_RTC_DAY_OF_MONTH   0x1FFD
0021 #define MOTO_RTC_MONTH      0x1FFE
0022 #define MOTO_RTC_YEAR       0x1FFF
0023 #define MOTO_RTC_CONTROLA       0x1FF8
0024 #define MOTO_RTC_CONTROLB       0x1FF9
0025 
0026 #ifndef BCD_TO_BIN
0027 #define BCD_TO_BIN(val) ((val)=((val)&15) + ((val)>>4)*10)
0028 #endif
0029 
0030 #ifndef BIN_TO_BCD
0031 #define BIN_TO_BCD(val) ((val)=(((val)/10)<<4) + (val)%10)
0032 #endif
0033 
0034 /* Structure map for NVRAM on PowerPC Reference Platform */
0035 /* All fields are either character/byte strings which are valid either
0036   endian or they are big-endian numbers.
0037 
0038   There are a number of Date and Time fields which are in RTC format,
0039   big-endian. These are stored in UT (GMT).
0040 
0041   For enum's: if given in hex then they are bit significant, i.e. only
0042   one bit is on for each enum.
0043 */
0044 
0045 #define NVSIZE      4096    /* size of NVRAM */
0046 #define OSAREASIZE  512 /* size of OSArea space */
0047 #define CONFSIZE    1024    /* guess at size of Configuration space */
0048 
0049 #ifndef ASM
0050 
0051 typedef struct _SECURITY {
0052   unsigned long BootErrCnt;     /* Count of boot password errors */
0053   unsigned long ConfigErrCnt;       /* Count of config password errors */
0054   unsigned long BootErrorDT[2];     /* Date&Time from RTC of last error in pw */
0055   unsigned long ConfigErrorDT[2];   /* Date&Time from RTC of last error in pw */
0056   unsigned long BootCorrectDT[2];   /* Date&Time from RTC of last correct pw */
0057   unsigned long ConfigCorrectDT[2]; /* Date&Time from RTC of last correct pw */
0058   unsigned long BootSetDT[2];       /* Date&Time from RTC of last set of pw */
0059   unsigned long ConfigSetDT[2];     /* Date&Time from RTC of last set of pw */
0060   unsigned char Serial[16];     /* Box serial number */
0061 } SECURITY;
0062 
0063 typedef enum _OS_ID {
0064   Unknown   = 0,
0065   Firmware  = 1,
0066   AIX       = 2,
0067   NT        = 3,
0068   MKOS2     = 4,
0069   MKAIX     = 5,
0070   Taligent  = 6,
0071   Solaris   = 7,
0072   MK        = 12
0073 } OS_ID;
0074 
0075 typedef struct _ERROR_LOG {
0076   unsigned char ErrorLogEntry[40]; /* To be architected */
0077 } ERROR_LOG;
0078 
0079 typedef enum _BOOT_STATUS {
0080   BootStarted       = 0x01,
0081   BootFinished      = 0x02,
0082   RestartStarted    = 0x04,
0083   RestartFinished   = 0x08,
0084   PowerFailStarted  = 0x10,
0085   PowerFailFinished     = 0x20,
0086   ProcessorReady    = 0x40,
0087   ProcessorRunning  = 0x80,
0088   ProcessorStart    = 0x0100
0089 } BOOT_STATUS;
0090 
0091 typedef struct _RESTART_BLOCK {
0092   unsigned short        Version;
0093   unsigned short        Revision;
0094   unsigned long         ResumeReserve1[2];
0095   volatile unsigned long    BootStatus;
0096   unsigned long         CheckSum;       /* Checksum of RESTART_BLOCK */
0097   void*             RestartAddress;
0098   void*             SaveAreaAddr;
0099   unsigned long         SaveAreaLength;
0100 } RESTART_BLOCK;
0101 
0102 typedef enum _OSAREA_USAGE {
0103   Empty = 0,
0104   Used  = 1
0105 } OSAREA_USAGE;
0106 
0107 typedef enum _PM_MODE {
0108   Suspend = 0x80, /* Part of state is in memory */
0109   Normal  = 0x00  /* No power management in effect */
0110 } PMMode;
0111 
0112 typedef struct _HEADER {
0113   unsigned short    Size;       /* NVRAM size in K(1024) */
0114   unsigned char     Version;     /* Structure map different */
0115   unsigned char     Revision;    /* Structure map the same -may
0116                     be new values in old fields
0117                     in other words old code still works */
0118   unsigned short    Crc1;       /* check sum from beginning of nvram to OSArea */
0119   unsigned short    Crc2;       /* check sum of config */
0120   unsigned char     LastOS;     /* OS_ID */
0121   unsigned char     Endian;     /* B if big endian, L if little endian */
0122   unsigned char     OSAreaUsage;/* OSAREA_USAGE */
0123   unsigned char     PMMode;     /* Shutdown mode */
0124   RESTART_BLOCK     RestartBlock;
0125   SECURITY      Security;
0126   ERROR_LOG         ErrorLog[2];
0127 
0128   /* Global Environment information */
0129   void*         GEAddress;
0130   unsigned long     GELength;
0131 
0132   /* Date&Time from RTC of last change to Global Environment */
0133   unsigned long     GELastWriteDT[2];
0134 
0135   /* Configuration information */
0136   void*         ConfigAddress;
0137   unsigned long     ConfigLength;
0138 
0139   /* Date&Time from RTC of last change to Configuration */
0140   unsigned long     ConfigLastWriteDT[2];
0141   unsigned long     ConfigCount; /* Count of entries in Configuration */
0142 
0143   /* OS dependent temp area */
0144   void*         OSAreaAddress;
0145   unsigned long     OSAreaLength;
0146 
0147   /* Date&Time from RTC of last change to OSArea */
0148   unsigned long     OSAreaLastWriteDT[2];
0149 } HEADER;
0150 
0151 /* Here is the whole map of the NVRAM */
0152 typedef struct _NVRAM_MAP {
0153   HEADER    Header;
0154   unsigned char GEArea[NVSIZE-CONFSIZE-OSAREASIZE-sizeof(HEADER)];
0155   unsigned char OSArea[OSAREASIZE];
0156   unsigned char ConfigArea[CONFSIZE];
0157 } NVRAM_MAP;
0158 
0159 /* Routines to manipulate the NVRAM */
0160 void init_prep_nvram(void);
0161 char *prep_nvram_get_var(const char *name);
0162 char *prep_nvram_first_var(void);
0163 char *prep_nvram_next_var(char *name);
0164 
0165 #endif /* ASM */
0166 
0167 #endif /* _PPC_NVRAM_H */