nvram.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. /*
  2. * PreP compliant NVRAM access
  3. * This needs to be updated for PPC64
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License
  7. * as published by the Free Software Foundation; either version
  8. * 2 of the License, or (at your option) any later version.
  9. */
  10. #ifndef _PPC64_NVRAM_H
  11. #define _PPC64_NVRAM_H
  12. #define NVRW_CNT 0x20
  13. #define NVRAM_HEADER_LEN 16 /* sizeof(struct nvram_header) */
  14. #define NVRAM_BLOCK_LEN 16
  15. #define NVRAM_MAX_REQ (2080/NVRAM_BLOCK_LEN)
  16. #define NVRAM_MIN_REQ (1056/NVRAM_BLOCK_LEN)
  17. #define NVRAM_AS0 0x74
  18. #define NVRAM_AS1 0x75
  19. #define NVRAM_DATA 0x77
  20. /* RTC Offsets */
  21. #define MOTO_RTC_SECONDS 0x1FF9
  22. #define MOTO_RTC_MINUTES 0x1FFA
  23. #define MOTO_RTC_HOURS 0x1FFB
  24. #define MOTO_RTC_DAY_OF_WEEK 0x1FFC
  25. #define MOTO_RTC_DAY_OF_MONTH 0x1FFD
  26. #define MOTO_RTC_MONTH 0x1FFE
  27. #define MOTO_RTC_YEAR 0x1FFF
  28. #define MOTO_RTC_CONTROLA 0x1FF8
  29. #define MOTO_RTC_CONTROLB 0x1FF9
  30. #define NVRAM_SIG_SP 0x02 /* support processor */
  31. #define NVRAM_SIG_OF 0x50 /* open firmware config */
  32. #define NVRAM_SIG_FW 0x51 /* general firmware */
  33. #define NVRAM_SIG_HW 0x52 /* hardware (VPD) */
  34. #define NVRAM_SIG_FLIP 0x5a /* Apple flip/flop header */
  35. #define NVRAM_SIG_APPL 0x5f /* Apple "system" (???) */
  36. #define NVRAM_SIG_SYS 0x70 /* system env vars */
  37. #define NVRAM_SIG_CFG 0x71 /* config data */
  38. #define NVRAM_SIG_ELOG 0x72 /* error log */
  39. #define NVRAM_SIG_VEND 0x7e /* vendor defined */
  40. #define NVRAM_SIG_FREE 0x7f /* Free space */
  41. #define NVRAM_SIG_OS 0xa0 /* OS defined */
  42. #define NVRAM_SIG_PANIC 0xa1 /* Apple OSX "panic" */
  43. /* If change this size, then change the size of NVNAME_LEN */
  44. struct nvram_header {
  45. unsigned char signature;
  46. unsigned char checksum;
  47. unsigned short length;
  48. char name[12];
  49. };
  50. struct nvram_partition {
  51. struct list_head partition;
  52. struct nvram_header header;
  53. unsigned int index;
  54. };
  55. extern int nvram_write_error_log(char * buff, int length, unsigned int err_type);
  56. extern int nvram_read_error_log(char * buff, int length, unsigned int * err_type);
  57. extern int nvram_clear_error_log(void);
  58. extern struct nvram_partition *nvram_find_partition(int sig, const char *name);
  59. extern int pSeries_nvram_init(void);
  60. extern int pmac_nvram_init(void);
  61. extern int bpa_nvram_init(void);
  62. /* PowerMac specific nvram stuffs */
  63. enum {
  64. pmac_nvram_OF, /* Open Firmware partition */
  65. pmac_nvram_XPRAM, /* MacOS XPRAM partition */
  66. pmac_nvram_NR /* MacOS Name Registry partition */
  67. };
  68. /* Return partition offset in nvram */
  69. extern int pmac_get_partition(int partition);
  70. /* Direct access to XPRAM on PowerMacs */
  71. extern u8 pmac_xpram_read(int xpaddr);
  72. extern void pmac_xpram_write(int xpaddr, u8 data);
  73. /* Synchronize NVRAM */
  74. extern int nvram_sync(void);
  75. /* Some offsets in XPRAM */
  76. #define PMAC_XPRAM_MACHINE_LOC 0xe4
  77. #define PMAC_XPRAM_SOUND_VOLUME 0x08
  78. /* Machine location structure in PowerMac XPRAM */
  79. struct pmac_machine_location {
  80. unsigned int latitude; /* 2+30 bit Fractional number */
  81. unsigned int longitude; /* 2+30 bit Fractional number */
  82. unsigned int delta; /* mix of GMT delta and DLS */
  83. };
  84. /*
  85. * /dev/nvram ioctls
  86. *
  87. * Note that PMAC_NVRAM_GET_OFFSET is still supported, but is
  88. * definitely obsolete. Do not use it if you can avoid it
  89. */
  90. #define OBSOLETE_PMAC_NVRAM_GET_OFFSET \
  91. _IOWR('p', 0x40, int)
  92. #define IOC_NVRAM_GET_OFFSET _IOWR('p', 0x42, int) /* Get NVRAM partition offset */
  93. #endif /* _PPC64_NVRAM_H */