nvram.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /*
  2. * NVRAM definitions and access functions.
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License
  6. * as published by the Free Software Foundation; either version
  7. * 2 of the License, or (at your option) any later version.
  8. */
  9. #ifndef _ASM_POWERPC_NVRAM_H
  10. #define _ASM_POWERPC_NVRAM_H
  11. /* Signatures for nvram partitions */
  12. #define NVRAM_SIG_SP 0x02 /* support processor */
  13. #define NVRAM_SIG_OF 0x50 /* open firmware config */
  14. #define NVRAM_SIG_FW 0x51 /* general firmware */
  15. #define NVRAM_SIG_HW 0x52 /* hardware (VPD) */
  16. #define NVRAM_SIG_FLIP 0x5a /* Apple flip/flop header */
  17. #define NVRAM_SIG_APPL 0x5f /* Apple "system" (???) */
  18. #define NVRAM_SIG_SYS 0x70 /* system env vars */
  19. #define NVRAM_SIG_CFG 0x71 /* config data */
  20. #define NVRAM_SIG_ELOG 0x72 /* error log */
  21. #define NVRAM_SIG_VEND 0x7e /* vendor defined */
  22. #define NVRAM_SIG_FREE 0x7f /* Free space */
  23. #define NVRAM_SIG_OS 0xa0 /* OS defined */
  24. #define NVRAM_SIG_PANIC 0xa1 /* Apple OSX "panic" */
  25. #ifdef __KERNEL__
  26. #include <linux/errno.h>
  27. #include <linux/list.h>
  28. extern int nvram_write_error_log(char * buff, int length,
  29. unsigned int err_type, unsigned int err_seq);
  30. extern int nvram_read_error_log(char * buff, int length,
  31. unsigned int * err_type, unsigned int *err_seq);
  32. extern int nvram_clear_error_log(void);
  33. extern int pSeries_nvram_init(void);
  34. #ifdef CONFIG_MMIO_NVRAM
  35. extern int mmio_nvram_init(void);
  36. #else
  37. static inline int mmio_nvram_init(void)
  38. {
  39. return -ENODEV;
  40. }
  41. #endif
  42. #endif /* __KERNEL__ */
  43. /* PowerMac specific nvram stuffs */
  44. enum {
  45. pmac_nvram_OF, /* Open Firmware partition */
  46. pmac_nvram_XPRAM, /* MacOS XPRAM partition */
  47. pmac_nvram_NR /* MacOS Name Registry partition */
  48. };
  49. #ifdef __KERNEL__
  50. /* Return partition offset in nvram */
  51. extern int pmac_get_partition(int partition);
  52. /* Direct access to XPRAM on PowerMacs */
  53. extern u8 pmac_xpram_read(int xpaddr);
  54. extern void pmac_xpram_write(int xpaddr, u8 data);
  55. /* Synchronize NVRAM */
  56. extern void nvram_sync(void);
  57. /* Determine NVRAM size */
  58. extern ssize_t nvram_get_size(void);
  59. /* Normal access to NVRAM */
  60. extern unsigned char nvram_read_byte(int i);
  61. extern void nvram_write_byte(unsigned char c, int i);
  62. #endif
  63. /* Some offsets in XPRAM */
  64. #define PMAC_XPRAM_MACHINE_LOC 0xe4
  65. #define PMAC_XPRAM_SOUND_VOLUME 0x08
  66. /* Machine location structure in PowerMac XPRAM */
  67. struct pmac_machine_location {
  68. unsigned int latitude; /* 2+30 bit Fractional number */
  69. unsigned int longitude; /* 2+30 bit Fractional number */
  70. unsigned int delta; /* mix of GMT delta and DLS */
  71. };
  72. /*
  73. * /dev/nvram ioctls
  74. *
  75. * Note that PMAC_NVRAM_GET_OFFSET is still supported, but is
  76. * definitely obsolete. Do not use it if you can avoid it
  77. */
  78. #define OBSOLETE_PMAC_NVRAM_GET_OFFSET \
  79. _IOWR('p', 0x40, int)
  80. #define IOC_NVRAM_GET_OFFSET _IOWR('p', 0x42, int) /* Get NVRAM partition offset */
  81. #define IOC_NVRAM_SYNC _IO('p', 0x43) /* Sync NVRAM image */
  82. #endif /* _ASM_POWERPC_NVRAM_H */