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