nvram.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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. /* PowerMac specific nvram stuffs */
  62. enum {
  63. pmac_nvram_OF, /* Open Firmware partition */
  64. pmac_nvram_XPRAM, /* MacOS XPRAM partition */
  65. pmac_nvram_NR /* MacOS Name Registry partition */
  66. };
  67. /* Return partition offset in nvram */
  68. extern int pmac_get_partition(int partition);
  69. /* Direct access to XPRAM on PowerMacs */
  70. extern u8 pmac_xpram_read(int xpaddr);
  71. extern void pmac_xpram_write(int xpaddr, u8 data);
  72. /* Synchronize NVRAM */
  73. extern int nvram_sync(void);
  74. /* Some offsets in XPRAM */
  75. #define PMAC_XPRAM_MACHINE_LOC 0xe4
  76. #define PMAC_XPRAM_SOUND_VOLUME 0x08
  77. /* Machine location structure in PowerMac XPRAM */
  78. struct pmac_machine_location {
  79. unsigned int latitude; /* 2+30 bit Fractional number */
  80. unsigned int longitude; /* 2+30 bit Fractional number */
  81. unsigned int delta; /* mix of GMT delta and DLS */
  82. };
  83. /*
  84. * /dev/nvram ioctls
  85. *
  86. * Note that PMAC_NVRAM_GET_OFFSET is still supported, but is
  87. * definitely obsolete. Do not use it if you can avoid it
  88. */
  89. #define OBSOLETE_PMAC_NVRAM_GET_OFFSET \
  90. _IOWR('p', 0x40, int)
  91. #define IOC_NVRAM_GET_OFFSET _IOWR('p', 0x42, int) /* Get NVRAM partition offset */
  92. #endif /* _PPC64_NVRAM_H */