nvram.h 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. * NVRAM definitions and access functions.
  4. */
  5. #ifndef _ASM_POWERPC_NVRAM_H
  6. #define _ASM_POWERPC_NVRAM_H
  7. #include <linux/types.h>
  8. #include <linux/errno.h>
  9. #include <linux/list.h>
  10. #include <uapi/asm/nvram.h>
  11. /*
  12. * Set oops header version to distinguish between old and new format header.
  13. * lnx,oops-log partition max size is 4000, header version > 4000 will
  14. * help in identifying new header.
  15. */
  16. #define OOPS_HDR_VERSION 5000
  17. struct err_log_info {
  18. __be32 error_type;
  19. __be32 seq_num;
  20. };
  21. struct nvram_os_partition {
  22. const char *name;
  23. int req_size; /* desired size, in bytes */
  24. int min_size; /* minimum acceptable size (0 means req_size) */
  25. long size; /* size of data portion (excluding err_log_info) */
  26. long index; /* offset of data portion of partition */
  27. bool os_partition; /* partition initialized by OS, not FW */
  28. };
  29. struct oops_log_info {
  30. __be16 version;
  31. __be16 report_length;
  32. __be64 timestamp;
  33. } __attribute__((packed));
  34. extern struct nvram_os_partition oops_log_partition;
  35. #ifdef CONFIG_PPC_PSERIES
  36. extern struct nvram_os_partition rtas_log_partition;
  37. extern int nvram_write_error_log(char * buff, int length,
  38. unsigned int err_type, unsigned int err_seq);
  39. extern int nvram_read_error_log(char * buff, int length,
  40. unsigned int * err_type, unsigned int *err_seq);
  41. extern int nvram_clear_error_log(void);
  42. extern int pSeries_nvram_init(void);
  43. #endif /* CONFIG_PPC_PSERIES */
  44. #ifdef CONFIG_MMIO_NVRAM
  45. extern int mmio_nvram_init(void);
  46. #else
  47. static inline int mmio_nvram_init(void)
  48. {
  49. return -ENODEV;
  50. }
  51. #endif
  52. extern int __init nvram_scan_partitions(void);
  53. extern loff_t nvram_create_partition(const char *name, int sig,
  54. int req_size, int min_size);
  55. extern int nvram_remove_partition(const char *name, int sig,
  56. const char *exceptions[]);
  57. extern int nvram_get_partition_size(loff_t data_index);
  58. extern loff_t nvram_find_partition(const char *name, int sig, int *out_size);
  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. /* Initialize NVRAM OS partition */
  65. extern int __init nvram_init_os_partition(struct nvram_os_partition *part);
  66. /* Initialize NVRAM oops partition */
  67. extern void __init nvram_init_oops_partition(int rtas_partition_exists);
  68. /* Read a NVRAM partition */
  69. extern int nvram_read_partition(struct nvram_os_partition *part, char *buff,
  70. int length, unsigned int *err_type,
  71. unsigned int *error_log_cnt);
  72. /* Write to NVRAM OS partition */
  73. extern int nvram_write_os_partition(struct nvram_os_partition *part,
  74. char *buff, int length,
  75. unsigned int err_type,
  76. unsigned int error_log_cnt);
  77. #endif /* _ASM_POWERPC_NVRAM_H */