nvram.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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. #ifdef CONFIG_PPC_PSERIES
  29. extern int nvram_write_error_log(char * buff, int length,
  30. unsigned int err_type, unsigned int err_seq);
  31. extern int nvram_read_error_log(char * buff, int length,
  32. unsigned int * err_type, unsigned int *err_seq);
  33. extern int nvram_clear_error_log(void);
  34. extern int pSeries_nvram_init(void);
  35. #endif /* CONFIG_PPC_PSERIES */
  36. #ifdef CONFIG_MMIO_NVRAM
  37. extern int mmio_nvram_init(void);
  38. #else
  39. static inline int mmio_nvram_init(void)
  40. {
  41. return -ENODEV;
  42. }
  43. #endif
  44. extern int __init nvram_scan_partitions(void);
  45. extern loff_t nvram_create_partition(const char *name, int sig,
  46. int req_size, int min_size);
  47. extern int nvram_remove_partition(const char *name, int sig,
  48. const char *exceptions[]);
  49. extern int nvram_get_partition_size(loff_t data_index);
  50. extern loff_t nvram_find_partition(const char *name, int sig, int *out_size);
  51. #endif /* __KERNEL__ */
  52. /* PowerMac specific nvram stuffs */
  53. enum {
  54. pmac_nvram_OF, /* Open Firmware partition */
  55. pmac_nvram_XPRAM, /* MacOS XPRAM partition */
  56. pmac_nvram_NR /* MacOS Name Registry partition */
  57. };
  58. #ifdef __KERNEL__
  59. /* Return partition offset in nvram */
  60. extern int pmac_get_partition(int partition);
  61. /* Direct access to XPRAM on PowerMacs */
  62. extern u8 pmac_xpram_read(int xpaddr);
  63. extern void pmac_xpram_write(int xpaddr, u8 data);
  64. /* Synchronize NVRAM */
  65. extern void nvram_sync(void);
  66. /* Determine NVRAM size */
  67. extern ssize_t nvram_get_size(void);
  68. /* Normal access to NVRAM */
  69. extern unsigned char nvram_read_byte(int i);
  70. extern void nvram_write_byte(unsigned char c, int i);
  71. #endif
  72. /* Some offsets in XPRAM */
  73. #define PMAC_XPRAM_MACHINE_LOC 0xe4
  74. #define PMAC_XPRAM_SOUND_VOLUME 0x08
  75. /* Machine location structure in PowerMac XPRAM */
  76. struct pmac_machine_location {
  77. unsigned int latitude; /* 2+30 bit Fractional number */
  78. unsigned int longitude; /* 2+30 bit Fractional number */
  79. unsigned int delta; /* mix of GMT delta and DLS */
  80. };
  81. /*
  82. * /dev/nvram ioctls
  83. *
  84. * Note that PMAC_NVRAM_GET_OFFSET is still supported, but is
  85. * definitely obsolete. Do not use it if you can avoid it
  86. */
  87. #define OBSOLETE_PMAC_NVRAM_GET_OFFSET \
  88. _IOWR('p', 0x40, int)
  89. #define IOC_NVRAM_GET_OFFSET _IOWR('p', 0x42, int) /* Get NVRAM partition offset */
  90. #define IOC_NVRAM_SYNC _IO('p', 0x43) /* Sync NVRAM image */
  91. #endif /* _ASM_POWERPC_NVRAM_H */