nvram.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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. #include <linux/types.h>
  12. #include <linux/errno.h>
  13. #include <linux/list.h>
  14. #include <uapi/asm/nvram.h>
  15. /*
  16. * Set oops header version to distinguish between old and new format header.
  17. * lnx,oops-log partition max size is 4000, header version > 4000 will
  18. * help in identifying new header.
  19. */
  20. #define OOPS_HDR_VERSION 5000
  21. struct err_log_info {
  22. __be32 error_type;
  23. __be32 seq_num;
  24. };
  25. struct nvram_os_partition {
  26. const char *name;
  27. int req_size; /* desired size, in bytes */
  28. int min_size; /* minimum acceptable size (0 means req_size) */
  29. long size; /* size of data portion (excluding err_log_info) */
  30. long index; /* offset of data portion of partition */
  31. bool os_partition; /* partition initialized by OS, not FW */
  32. };
  33. struct oops_log_info {
  34. __be16 version;
  35. __be16 report_length;
  36. __be64 timestamp;
  37. } __attribute__((packed));
  38. extern struct nvram_os_partition oops_log_partition;
  39. #ifdef CONFIG_PPC_PSERIES
  40. extern struct nvram_os_partition rtas_log_partition;
  41. extern int nvram_write_error_log(char * buff, int length,
  42. unsigned int err_type, unsigned int err_seq);
  43. extern int nvram_read_error_log(char * buff, int length,
  44. unsigned int * err_type, unsigned int *err_seq);
  45. extern int nvram_clear_error_log(void);
  46. extern int pSeries_nvram_init(void);
  47. #endif /* CONFIG_PPC_PSERIES */
  48. #ifdef CONFIG_MMIO_NVRAM
  49. extern int mmio_nvram_init(void);
  50. #else
  51. static inline int mmio_nvram_init(void)
  52. {
  53. return -ENODEV;
  54. }
  55. #endif
  56. extern int __init nvram_scan_partitions(void);
  57. extern loff_t nvram_create_partition(const char *name, int sig,
  58. int req_size, int min_size);
  59. extern int nvram_remove_partition(const char *name, int sig,
  60. const char *exceptions[]);
  61. extern int nvram_get_partition_size(loff_t data_index);
  62. extern loff_t nvram_find_partition(const char *name, int sig, int *out_size);
  63. /* Return partition offset in nvram */
  64. extern int pmac_get_partition(int partition);
  65. /* Direct access to XPRAM on PowerMacs */
  66. extern u8 pmac_xpram_read(int xpaddr);
  67. extern void pmac_xpram_write(int xpaddr, u8 data);
  68. /* Synchronize NVRAM */
  69. extern void nvram_sync(void);
  70. /* Initialize NVRAM OS partition */
  71. extern int __init nvram_init_os_partition(struct nvram_os_partition *part);
  72. /* Initialize NVRAM oops partition */
  73. extern void __init nvram_init_oops_partition(int rtas_partition_exists);
  74. /* Read a NVRAM partition */
  75. extern int nvram_read_partition(struct nvram_os_partition *part, char *buff,
  76. int length, unsigned int *err_type,
  77. unsigned int *error_log_cnt);
  78. /* Write to NVRAM OS partition */
  79. extern int nvram_write_os_partition(struct nvram_os_partition *part,
  80. char *buff, int length,
  81. unsigned int err_type,
  82. unsigned int error_log_cnt);
  83. /* Determine NVRAM size */
  84. extern ssize_t nvram_get_size(void);
  85. /* Normal access to NVRAM */
  86. extern unsigned char nvram_read_byte(int i);
  87. extern void nvram_write_byte(unsigned char c, int i);
  88. #endif /* _ASM_POWERPC_NVRAM_H */