prep_nvram.h 4.6 KB

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