nvram.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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. extern int nvram_get_partition_size(loff_t data_index);
  49. extern loff_t nvram_find_partition(const char *name, int sig, int *out_size);
  50. #endif /* __KERNEL__ */
  51. /* PowerMac specific nvram stuffs */
  52. enum {
  53. pmac_nvram_OF, /* Open Firmware partition */
  54. pmac_nvram_XPRAM, /* MacOS XPRAM partition */
  55. pmac_nvram_NR /* MacOS Name Registry partition */
  56. };
  57. #ifdef __KERNEL__
  58. /* Return partition offset in nvram */
  59. extern int pmac_get_partition(int partition);
  60. /* Direct access to XPRAM on PowerMacs */
  61. extern u8 pmac_xpram_read(int xpaddr);
  62. extern void pmac_xpram_write(int xpaddr, u8 data);
  63. /* Synchronize NVRAM */
  64. extern void nvram_sync(void);
  65. /* Determine NVRAM size */
  66. extern ssize_t nvram_get_size(void);
  67. /* Normal access to NVRAM */
  68. extern unsigned char nvram_read_byte(int i);
  69. extern void nvram_write_byte(unsigned char c, int i);
  70. #endif
  71. /* Some offsets in XPRAM */
  72. #define PMAC_XPRAM_MACHINE_LOC 0xe4
  73. #define PMAC_XPRAM_SOUND_VOLUME 0x08
  74. /* Machine location structure in PowerMac XPRAM */
  75. struct pmac_machine_location {
  76. unsigned int latitude; /* 2+30 bit Fractional number */
  77. unsigned int longitude; /* 2+30 bit Fractional number */
  78. unsigned int delta; /* mix of GMT delta and DLS */
  79. };
  80. /*
  81. * /dev/nvram ioctls
  82. *
  83. * Note that PMAC_NVRAM_GET_OFFSET is still supported, but is
  84. * definitely obsolete. Do not use it if you can avoid it
  85. */
  86. #define OBSOLETE_PMAC_NVRAM_GET_OFFSET \
  87. _IOWR('p', 0x40, int)
  88. #define IOC_NVRAM_GET_OFFSET _IOWR('p', 0x42, int) /* Get NVRAM partition offset */
  89. #define IOC_NVRAM_SYNC _IO('p', 0x43) /* Sync NVRAM image */
  90. #endif /* _ASM_POWERPC_NVRAM_H */