Commit 228ab0bd authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] ppc64: NVRAM error logging/buffering patch, from Jake Moilanen

From: Anton Blanchard <anton@samba.org>

This is a port of the nvram buffering/error logging code from 2.4 to 2.6.  It
includes moving /proc/rtas to /proc/ppc64/rtas and making /proc/rtas a
symlink to /proc/ppc64/rtas.  It also splits up the /dev/nvram device
read/write functions from the basic nvram access functions, and adds ppc_md
fields for the nvram access functions.
parent a0f52f9e
......@@ -130,18 +130,18 @@ config MSCHUNKS
depends on PPC_ISERIES
default y
config RTAS_FLASH
tristate "Firmware flash interface"
depends on !PPC_ISERIES
config SCANLOG
tristate "Scanlog dump interface"
depends on !PPC_ISERIES
config PPC_RTAS
bool "Proc interface to RTAS"
depends on !PPC_ISERIES
config RTAS_FLASH
tristate "Firmware flash interface"
depends on PPC_RTAS
config SCANLOG
tristate "Scanlog dump interface"
depends on PPC_RTAS
endmenu
......
......@@ -20,7 +20,7 @@ obj-$(CONFIG_PPC_ISERIES) += iSeries_pci.o iSeries_pci_reset.o \
mf.o HvLpEvent.o iSeries_proc.o
obj-$(CONFIG_PPC_PSERIES) += pSeries_pci.o pSeries_lpar.o pSeries_hvCall.o \
eeh.o rtasd.o nvram.o ras.o
eeh.o nvram.o rtasd.o ras.o
# Change this to pSeries only once we've got iSeries up to date
obj-y += open_pic.o xics.o pSeries_htab.o rtas.o \
......
......@@ -57,6 +57,7 @@
#include <asm/irq.h>
#include <asm/naca.h>
#include <asm/time.h>
#include <asm/nvram.h>
#include "i8259.h"
#include "open_pic.h"
......@@ -273,6 +274,9 @@ chrp_init(unsigned long r3, unsigned long r4, unsigned long r5,
ppc_md.progress = chrp_progress;
ppc_md.nvram_read = pSeries_nvram_read;
ppc_md.nvram_write = pSeries_nvram_write;
/* Build up the firmware_features bitmask field
* using contents of device-tree/ibm,hypertas-functions.
* Ultimately this functionality may be moved into prom.c prom_init().
......
This diff is collapsed.
......@@ -39,6 +39,7 @@
#include <asm/hw_irq.h>
#include <asm/abs_addr.h>
#include <asm/cacheflush.h>
#include <asm/proc_fs.h>
#ifdef CONFIG_PPC_ISERIES
#include <asm/iSeries/iSeries_pci.h>
#include <asm/iSeries/iSeries_proc.h>
......@@ -222,3 +223,4 @@ EXPORT_SYMBOL(debugger_fault_handler);
EXPORT_SYMBOL(tb_ticks_per_usec);
EXPORT_SYMBOL(paca);
EXPORT_SYMBOL(proc_ppc64);
......@@ -95,15 +95,21 @@ void proc_ppc64_init(void)
* /proc/ppc64/pmc/cpu0
*/
spin_lock(&proc_ppc64_lock);
proc_ppc64_root = proc_mkdir("ppc64", 0);
if (!proc_ppc64_root) return;
if (proc_ppc64.root == NULL) {
proc_ppc64_init();
if (!proc_ppc64.root) {
spin_unlock(&proc_ppc64_lock);
return;
}
}
spin_unlock(&proc_ppc64_lock);
/* Placeholder for rtas interfaces. */
rtas_proc_dir = proc_mkdir("rtas", proc_ppc64_root);
if (proc_ppc64.rtas == NULL) {
return;
}
proc_ppc64_pmc_root = proc_mkdir("pmc", proc_ppc64_root);
proc_ppc64_pmc_root = proc_mkdir("pmc", proc_ppc64.root);
proc_ppc64_pmc_system_root = proc_mkdir("system", proc_ppc64_pmc_root);
for (i = 0; i < NR_CPUS; i++) {
......@@ -114,7 +120,6 @@ void proc_ppc64_init(void)
}
}
/* Create directories for the software counters. */
for (i = 0; i < NR_CPUS; i++) {
if (!cpu_online(i))
......
......@@ -67,14 +67,18 @@ static struct file_operations ofdt_fops = {
.write = ofdt_write
};
static int __init proc_ppc64_init(void)
int __init proc_ppc64_init(void)
{
printk(KERN_INFO "proc_ppc64: Creating /proc/ppc64/\n");
if (proc_ppc64.root == NULL) {
printk(KERN_INFO "proc_ppc64: Creating /proc/ppc64/\n");
proc_ppc64.root = proc_mkdir("ppc64", 0);
if (!proc_ppc64.root)
return 0;
} else {
return 0;
}
proc_ppc64.naca = create_proc_entry("naca", S_IRUSR, proc_ppc64.root);
if ( proc_ppc64.naca ) {
......@@ -105,8 +109,12 @@ static int __init proc_ppc64_init(void)
}
/* Placeholder for rtas interfaces. */
if (proc_ppc64.rtas == NULL)
proc_ppc64.rtas = proc_mkdir("rtas", proc_ppc64.root);
if (proc_ppc64.rtas)
proc_symlink("rtas", 0, "ppc64/rtas");
proc_ppc64_create_ofdt(proc_ppc64.root);
return 0;
......@@ -411,4 +419,3 @@ static void release_prop_list(const struct property *prop)
}
fs_initcall(proc_ppc64_init);
......@@ -122,6 +122,10 @@ ras_epow_interrupt(int irq, void *dev_id, struct pt_regs * regs)
*((unsigned long *)&log_entry), status);
printk(KERN_WARNING
"EPOW <0x%lx 0x%lx>\n",*((unsigned long *)&log_entry), status);
/* format and print the extended information */
log_error((char *)&log_entry, ERR_TYPE_RTAS_LOG, 0);
return IRQ_HANDLED;
}
......@@ -139,6 +143,7 @@ ras_error_interrupt(int irq, void *dev_id, struct pt_regs * regs)
struct rtas_error_log log_entry;
unsigned int size = sizeof(log_entry);
long status = 0xdeadbeef;
int fatal;
status = rtas_call(rtas_token("check-exception"), 6, 1, NULL,
0x500, irq,
......@@ -146,8 +151,15 @@ ras_error_interrupt(int irq, void *dev_id, struct pt_regs * regs)
1, /* Time Critical */
__pa(&log_entry), size);
if((status != 1) &&
(log_entry.severity >= SEVERITY_ERROR_SYNC)) {
if ((status == 0) && (log_entry.severity >= SEVERITY_ERROR_SYNC))
fatal = 1;
else
fatal = 0;
/* format and print the extended information */
log_error((char *)&log_entry, ERR_TYPE_RTAS_LOG, fatal);
if (fatal) {
udbg_printf("HW Error <0x%lx 0x%lx>\n",
*((unsigned long *)&log_entry), status);
printk(KERN_EMERG
......@@ -157,6 +169,7 @@ ras_error_interrupt(int irq, void *dev_id, struct pt_regs * regs)
#ifndef DEBUG
/* Don't actually power off when debugging so we can test
* without actually failing while injecting errors.
* Error data will not be logged to syslog.
*/
ppc_md.power_off();
#endif
......
......@@ -20,6 +20,7 @@
#include <linux/ctype.h>
#include <linux/time.h>
#include <linux/string.h>
#include <linux/init.h>
#include <asm/uaccess.h>
#include <asm/bitops.h>
......@@ -27,6 +28,7 @@
#include <asm/io.h>
#include <asm/prom.h>
#include <asm/rtas.h>
#include <asm/proc_fs.h>
#include <asm/machdep.h> /* for ppc_md */
#include <asm/time.h>
......@@ -211,36 +213,36 @@ void proc_rtas_init(void)
return;
}
if (proc_rtas == NULL) {
proc_rtas = proc_mkdir("rtas", 0);
if (proc_ppc64.rtas == NULL) {
proc_ppc64_init();
}
if (proc_rtas == NULL) {
if (proc_ppc64.rtas == NULL) {
printk(KERN_ERR "Failed to create /proc/rtas in proc_rtas_init\n");
return;
}
/* /proc/rtas entries */
entry = create_proc_entry("progress", S_IRUGO|S_IWUSR, proc_rtas);
entry = create_proc_entry("progress", S_IRUGO|S_IWUSR, proc_ppc64.rtas);
if (entry) entry->proc_fops = &ppc_rtas_progress_operations;
entry = create_proc_entry("clock", S_IRUGO|S_IWUSR, proc_rtas);
entry = create_proc_entry("clock", S_IRUGO|S_IWUSR, proc_ppc64.rtas);
if (entry) entry->proc_fops = &ppc_rtas_clock_operations;
entry = create_proc_entry("poweron", S_IWUSR|S_IRUGO, proc_rtas);
entry = create_proc_entry("poweron", S_IWUSR|S_IRUGO, proc_ppc64.rtas);
if (entry) entry->proc_fops = &ppc_rtas_poweron_operations;
create_proc_read_entry("sensors", S_IRUGO, proc_rtas,
create_proc_read_entry("sensors", S_IRUGO, proc_ppc64.rtas,
ppc_rtas_sensor_read, NULL);
entry = create_proc_entry("frequency", S_IWUSR|S_IRUGO, proc_rtas);
entry = create_proc_entry("frequency", S_IWUSR|S_IRUGO, proc_ppc64.rtas);
if (entry) entry->proc_fops = &ppc_rtas_tone_freq_operations;
entry = create_proc_entry("volume", S_IWUSR|S_IRUGO, proc_rtas);
entry = create_proc_entry("volume", S_IWUSR|S_IRUGO, proc_ppc64.rtas);
if (entry) entry->proc_fops = &ppc_rtas_tone_volume_operations;
entry = create_proc_entry("rmo_buffer", S_IRUSR, proc_rtas);
entry = create_proc_entry("rmo_buffer", S_IRUSR, proc_ppc64.rtas);
if (entry) entry->proc_fops = &ppc_rtas_rmo_buf_ops;
}
......
......@@ -16,6 +16,7 @@
#include <linux/types.h>
#include <linux/spinlock.h>
#include <linux/module.h>
#include <linux/init.h>
#include <asm/prom.h>
#include <asm/proc_fs.h>
......@@ -61,7 +62,7 @@ struct rtas_t rtas = {
extern unsigned long reloc_offset(void);
spinlock_t rtas_data_buf_lock = SPIN_LOCK_UNLOCKED;
char rtas_data_buf[RTAS_DATA_BUF_SIZE];
char rtas_data_buf[RTAS_DATA_BUF_SIZE]__page_aligned;
void
phys_call_rtas(int token, int nargs, int nret, ...)
......@@ -422,7 +423,7 @@ asmlinkage int ppc_rtas(struct rtas_args __user *uargs)
return 0;
}
EXPORT_SYMBOL(proc_ppc64);
EXPORT_SYMBOL(rtas_firmware_flash_list);
EXPORT_SYMBOL(rtas_token);
EXPORT_SYMBOL(rtas_call);
......
......@@ -17,11 +17,15 @@
#include <linux/proc_fs.h>
#include <linux/init.h>
#include <linux/vmalloc.h>
#include <linux/spinlock.h>
#include <asm/uaccess.h>
#include <asm/io.h>
#include <asm/rtas.h>
#include <asm/prom.h>
#include <asm/nvram.h>
#include <asm/atomic.h>
#include <asm/proc_fs.h>
#if 0
#define DEBUG(A...) printk(KERN_ERR A)
......@@ -29,13 +33,10 @@
#define DEBUG(A...)
#endif
static spinlock_t rtas_log_lock = SPIN_LOCK_UNLOCKED;
static spinlock_t log_lock = SPIN_LOCK_UNLOCKED;
DECLARE_WAIT_QUEUE_HEAD(rtas_log_wait);
#define LOG_NUMBER 64 /* must be a power of two */
#define LOG_NUMBER_MASK (LOG_NUMBER-1)
static char *rtas_log_buf;
static unsigned long rtas_log_start;
static unsigned long rtas_log_size;
......@@ -43,21 +44,173 @@ static unsigned long rtas_log_size;
static int surveillance_requested;
static unsigned int rtas_event_scan_rate;
static unsigned int rtas_error_log_max;
static unsigned int rtas_error_log_buffer_max;
#define SURVEILLANCE_TOKEN 9000
#define SURVEILLANCE_TIMEOUT 1
#define SURVEILLANCE_SCANRATE 1
extern spinlock_t proc_ppc64_lock;
extern volatile int no_more_logging;
struct proc_dir_entry *proc_rtas;
volatile int error_log_cnt = 0;
/*
* Since we use 32 bit RTAS, the physical address of this must be below
* 4G or else bad things happen. Allocate this in the kernel data and
* make it big enough.
*/
#define RTAS_ERROR_LOG_MAX 1024
static unsigned char logdata[RTAS_ERROR_LOG_MAX];
/* To see this info, grep RTAS /var/log/messages and each entry
* will be collected together with obvious begin/end.
* There will be a unique identifier on the begin and end lines.
* This will persist across reboots.
*
* format of error logs returned from RTAS:
* bytes (size) : contents
* --------------------------------------------------------
* 0-7 (8) : rtas_error_log
* 8-47 (40) : extended info
* 48-51 (4) : vendor id
* 52-1023 (vendor specific) : location code and debug data
*/
static void printk_log_rtas(char *buf, int len)
{
int i,j,n;
int perline = 16;
char buffer[64];
char * str = "RTAS event";
printk(RTAS_ERR "%d -------- %s begin --------\n", error_log_cnt, str);
/*
* Print perline bytes on each line, each line will start
* with RTAS and a changing number, so syslogd will
* print lines that are otherwise the same. Separate every
* 4 bytes with a space.
*/
for (i=0; i < len; i++) {
j = i % perline;
if (j == 0) {
memset(buffer, 0, sizeof(buffer));
n = sprintf(buffer, "RTAS %d:", i/perline);
}
if ((i % 4) == 0)
n += sprintf(buffer+n, " ");
n += sprintf(buffer+n, "%02x", (unsigned char)buf[i]);
if (j == (perline-1))
printk(KERN_ERR "%s\n", buffer);
}
if ((i % perline) != 0)
printk(KERN_ERR "%s\n", buffer);
printk(RTAS_ERR "%d -------- %s end ----------\n", error_log_cnt, str);
}
static int log_rtas_len(char * buf)
{
int len;
struct rtas_error_log *err;
/* rtas fixed header */
len = 8;
err = (struct rtas_error_log *)buf;
if (err->extended_log_length) {
/* extended header */
len += err->extended_log_length;
if (len > RTAS_ERROR_LOG_MAX)
len = RTAS_ERROR_LOG_MAX;
}
return len;
}
/*
* First write to nvram, if fatal error, that is the only
* place we log the info. The error will be picked up
* on the next reboot by rtasd. If not fatal, run the
* method for the type of error. Currently, only RTAS
* errors have methods implemented, but in the future
* there might be a need to store data in nvram before a
* call to panic().
*
* XXX We write to nvram periodically, to indicate error has
* been written and sync'd, but there is a possibility
* that if we don't shutdown correctly, a duplicate error
* record will be created on next reboot.
*/
void pSeries_log_error(char *buf, unsigned int err_type, int fatal)
{
unsigned long offset;
unsigned long s;
int len = 0;
DEBUG("logging event\n");
if (buf == NULL)
return;
spin_lock_irqsave(&log_lock, s);
/* get length and increase count */
switch (err_type & ERR_TYPE_MASK) {
case ERR_TYPE_RTAS_LOG:
len = log_rtas_len(buf);
if (!(err_type & ERR_FLAG_BOOT))
error_log_cnt++;
break;
case ERR_TYPE_KERNEL_PANIC:
default:
spin_unlock_irqrestore(&log_lock, s);
return;
}
/* Write error to NVRAM */
if (!no_more_logging && !(err_type & ERR_FLAG_BOOT))
nvram_write_error_log(buf, len, err_type);
/* Check to see if we need to or have stopped logging */
if (fatal || no_more_logging) {
no_more_logging = 1;
spin_unlock_irqrestore(&log_lock, s);
return;
}
/* call type specific method for error */
switch (err_type & ERR_TYPE_MASK) {
case ERR_TYPE_RTAS_LOG:
/* put into syslog and error_log file */
printk_log_rtas(buf, len);
offset = rtas_error_log_buffer_max *
((rtas_log_start+rtas_log_size) & LOG_NUMBER_MASK);
/* First copy over sequence number */
memcpy(&rtas_log_buf[offset], (void *) &error_log_cnt, sizeof(int));
/* Second copy over error log data */
offset += sizeof(int);
memcpy(&rtas_log_buf[offset], buf, len);
if (rtas_log_size < LOG_NUMBER)
rtas_log_size += 1;
else
rtas_log_start += 1;
spin_unlock_irqrestore(&log_lock, s);
wake_up_interruptible(&rtas_log_wait);
break;
case ERR_TYPE_KERNEL_PANIC:
default:
spin_unlock_irqrestore(&log_lock, s);
return;
}
}
static int rtas_log_open(struct inode * inode, struct file * file)
{
return 0;
......@@ -68,36 +221,50 @@ static int rtas_log_release(struct inode * inode, struct file * file)
return 0;
}
/* This will check if all events are logged, if they are then, we
* know that we can safely clear the events in NVRAM.
* Next we'll sit and wait for something else to log.
*/
static ssize_t rtas_log_read(struct file * file, char * buf,
size_t count, loff_t *ppos)
{
int error;
char *tmp;
unsigned long s;
unsigned long offset;
if (!buf || count < rtas_error_log_max)
if (!buf || count < rtas_error_log_buffer_max)
return -EINVAL;
count = rtas_error_log_max;
count = rtas_error_log_buffer_max;
error = verify_area(VERIFY_WRITE, buf, count);
if (error)
return -EINVAL;
return -EFAULT;
tmp = kmalloc(rtas_error_log_max, GFP_KERNEL);
tmp = kmalloc(count, GFP_KERNEL);
if (!tmp)
return -ENOMEM;
spin_lock_irqsave(&log_lock, s);
/* if it's 0, then we know we got the last one (the one in NVRAM) */
if (rtas_log_size == 0 && !no_more_logging)
nvram_clear_error_log();
spin_unlock_irqrestore(&log_lock, s);
error = wait_event_interruptible(rtas_log_wait, rtas_log_size);
if (error)
goto out;
spin_lock(&rtas_log_lock);
offset = rtas_error_log_max * (rtas_log_start & LOG_NUMBER_MASK);
spin_lock_irqsave(&log_lock, s);
offset = rtas_error_log_buffer_max * (rtas_log_start & LOG_NUMBER_MASK);
memcpy(tmp, &rtas_log_buf[offset], count);
rtas_log_start += 1;
rtas_log_size -= 1;
spin_unlock(&rtas_log_lock);
spin_unlock_irqrestore(&log_lock, s);
error = copy_to_user(buf, tmp, count) ? -EFAULT : count;
out:
......@@ -120,28 +287,6 @@ struct file_operations proc_rtas_log_operations = {
.release = rtas_log_release,
};
static void log_rtas(char *buf)
{
unsigned long offset;
DEBUG("logging rtas event\n");
spin_lock(&rtas_log_lock);
offset = rtas_error_log_max *
((rtas_log_start+rtas_log_size) & LOG_NUMBER_MASK);
memcpy(&rtas_log_buf[offset], buf, rtas_error_log_max);
if (rtas_log_size < LOG_NUMBER)
rtas_log_size += 1;
else
rtas_log_start += 1;
spin_unlock(&rtas_log_lock);
wake_up_interruptible(&rtas_log_wait);
}
static int enable_surveillance(void)
{
int error;
......@@ -197,10 +342,12 @@ extern long sys_sched_get_priority_max(int policy);
static int rtasd(void *unused)
{
unsigned int err_type;
int cpu = 0;
int error;
int first_pass = 1;
int event_scan = rtas_token("event-scan");
int rc;
if (event_scan == RTAS_UNKNOWN_SERVICE || get_eventscan_parms() == -1)
goto error;
......@@ -211,6 +358,9 @@ static int rtasd(void *unused)
goto error;
}
/* We can use rtas_log_buf now */
no_more_logging = 0;
DEBUG("will sleep for %d jiffies\n", (HZ*60/rtas_event_scan_rate) / 2);
daemonize("rtasd");
......@@ -221,6 +371,16 @@ static int rtasd(void *unused)
current->nice = sys_sched_get_priority_max(SCHED_FIFO) + 1;
#endif
/* See if we have any error stored in NVRAM */
memset(logdata, 0, rtas_error_log_max);
rc = nvram_read_error_log(logdata, rtas_error_log_max, &err_type);
if (!rc) {
if (err_type != ERR_FLAG_ALREADY_LOGGED) {
pSeries_log_error(logdata, err_type | ERR_FLAG_BOOT, 0);
}
}
repeat:
for (cpu = 0; cpu < NR_CPUS; cpu++) {
if (!cpu_online(cpu))
......@@ -241,7 +401,7 @@ static int rtasd(void *unused)
}
if (error == 0)
log_rtas(logdata);
pSeries_log_error(logdata, ERR_TYPE_RTAS_LOG, 0);
} while(error == 0);
......@@ -275,25 +435,29 @@ static int __init rtas_init(void)
{
struct proc_dir_entry *entry;
if (proc_rtas == NULL) {
proc_rtas = proc_mkdir("rtas", 0);
if (proc_ppc64.rtas == NULL) {
proc_ppc64_init();
}
if (proc_ppc64.rtas == NULL) {
printk(KERN_ERR "rtas_init: /proc/ppc64/rtas does not exist.");
return -EIO;
}
if (proc_rtas == NULL) {
printk(KERN_ERR "Failed to create /proc/rtas in rtas_init\n");
} else {
entry = create_proc_entry("error_log", S_IRUSR, proc_rtas);
entry = create_proc_entry("error_log", S_IRUSR, proc_ppc64.rtas);
if (entry)
entry->proc_fops = &proc_rtas_log_operations;
else
printk(KERN_ERR "Failed to create rtas/error_log proc entry\n");
}
if (kernel_thread(rtasd, 0, CLONE_FS) < 0)
printk(KERN_ERR "Failed to start RTAS daemon\n");
printk(KERN_ERR "RTAS daemon started\n");
/* Make room for the sequence number */
rtas_error_log_buffer_max = rtas_error_log_max + sizeof(int);
return 0;
}
......
......@@ -28,6 +28,7 @@
#include <asm/uaccess.h>
#include <asm/rtas.h>
#include <asm/prom.h>
#include <asm/proc_fs.h>
#define MODULE_VERSION "1.0"
#define MODULE_NAME "scanlog"
......@@ -43,9 +44,6 @@ static int scanlog_debug;
static unsigned int ibm_scan_log_dump; /* RTAS token */
static struct proc_dir_entry *proc_ppc64_scan_log_dump; /* The proc file */
extern struct proc_dir_entry *proc_rtas;
static ssize_t scanlog_read(struct file *file, char *buf,
size_t count, loff_t *ppos)
{
......@@ -214,15 +212,16 @@ int __init scanlog_init(void)
return -EIO;
}
if (proc_rtas == NULL)
proc_rtas = proc_mkdir("rtas", 0);
if (proc_ppc64.rtas == NULL) {
proc_ppc64_init();
}
if (proc_rtas == NULL) {
if (proc_ppc64.rtas == NULL) {
printk(KERN_ERR "Failed to create /proc/rtas in scanlog_init\n");
return -EIO;
}
ent = create_proc_entry("scan-log-dump", S_IRUSR, proc_rtas);
ent = create_proc_entry("scan-log-dump", S_IRUSR, proc_ppc64.rtas);
if (ent) {
ent->proc_fops = &scanlog_fops;
/* Ideally we could allocate a buffer < 4G */
......
......@@ -89,6 +89,12 @@ struct machdep_calls {
unsigned char (*udbg_getc)(void);
int (*udbg_getc_poll)(void);
/* Interface for platform error logging */
void (*log_error)(char *buf, unsigned int err_type, int fatal);
ssize_t (*nvram_write)(char *buf, size_t count, loff_t *index);
ssize_t (*nvram_read)(char *buf, size_t count, loff_t *index);
#ifdef CONFIG_SMP
/* functions for dealing with other cpus */
struct smp_ops_t smp_ops;
......@@ -113,5 +119,11 @@ void ppc64_attention_msg(unsigned int src, const char *msg);
/* Print a dump progress message. */
void ppc64_dump_msg(unsigned int src, const char *msg);
static inline void log_error(char *buf, unsigned int err_type, int fatal)
{
if (ppc_md.log_error)
ppc_md.log_error(buf, err_type, fatal);
}
#endif /* _PPC64_MACHDEP_H */
#endif /* __KERNEL__ */
......@@ -11,6 +11,12 @@
#ifndef _PPC64_NVRAM_H
#define _PPC64_NVRAM_H
#define NVRW_CNT 0x20
#define NVRAM_HEADER_LEN 16 /* sizeof(struct nvram_header) */
#define NVRAM_BLOCK_LEN 16
#define NVRAM_MAX_REQ (2080/NVRAM_BLOCK_LEN)
#define NVRAM_MIN_REQ (1056/NVRAM_BLOCK_LEN)
#define NVRAM_AS0 0x74
#define NVRAM_AS1 0x75
#define NVRAM_DATA 0x77
......@@ -28,4 +34,37 @@
#define MOTO_RTC_CONTROLA 0x1FF8
#define MOTO_RTC_CONTROLB 0x1FF9
#define NVRAM_SIG_SP 0x02 /* support processor */
#define NVRAM_SIG_OF 0x50 /* open firmware config */
#define NVRAM_SIG_FW 0x51 /* general firmware */
#define NVRAM_SIG_HW 0x52 /* hardware (VPD) */
#define NVRAM_SIG_SYS 0x70 /* system env vars */
#define NVRAM_SIG_CFG 0x71 /* config data */
#define NVRAM_SIG_ELOG 0x72 /* error log */
#define NVRAM_SIG_VEND 0x7e /* vendor defined */
#define NVRAM_SIG_FREE 0x7f /* Free space */
#define NVRAM_SIG_OS 0xa0 /* OS defined */
/* If change this size, then change the size of NVNAME_LEN */
struct nvram_header {
unsigned char signature;
unsigned char checksum;
unsigned short length;
char name[12];
};
struct nvram_partition {
struct list_head partition;
struct nvram_header header;
unsigned int index;
};
ssize_t pSeries_nvram_read(char *buf, size_t count, loff_t *index);
ssize_t pSeries_nvram_write(char *buf, size_t count, loff_t *index);
int nvram_write_error_log(char * buff, int length, unsigned int err_type);
int nvram_read_error_log(char * buff, int length, unsigned int * err_type);
int nvram_clear_error_log(void);
void nvram_print_partitions(char * label);
#endif /* _PPC64_NVRAM_H */
......@@ -34,5 +34,6 @@ struct proc_ppc64_t {
};
extern struct proc_ppc64_t proc_ppc64;
extern int proc_ppc64_init(void);
#endif /* _PPC64_PROC_FS_H */
......@@ -22,6 +22,13 @@
/* Buffer size for ppc_rtas system call. */
#define RTAS_RMOBUF_MAX (64 * 1024)
/* RTAS return codes */
#define RTAS_BUSY -2 /* RTAS Return Status - Busy */
#define RTAS_EXTENDED_DELAY_MIN 9900
#define RTAS_EXTENDED_DELAY_MAX 9905
#define RTAS_UNKNOWN_OP -1099 /* Return Status - Unknown RTAS Token */
/*
* In general to call RTAS use rtas_token("string") to lookup
* an RTAS token for the given string (e.g. "event-scan").
......@@ -179,16 +186,37 @@ static inline int rtas_is_extended_busy(int status)
return status >= 9900 && status <= 9909;
}
extern void pSeries_log_error(char *buf, unsigned int err_type, int fatal);
/* Error types logged. */
#define ERR_FLAG_ALREADY_LOGGED 0x0
#define ERR_FLAG_BOOT 0x1 /* log was pulled from NVRAM on boot */
#define ERR_TYPE_RTAS_LOG 0x2 /* from rtas event-scan */
#define ERR_TYPE_KERNEL_PANIC 0x4 /* from panic() */
/* All the types and not flags */
#define ERR_TYPE_MASK (ERR_TYPE_RTAS_LOG | ERR_TYPE_KERNEL_PANIC)
#define RTAS_ERR KERN_ERR "RTAS: "
#define RTAS_ERROR_LOG_MAX 2048
/* Event Scan Parameters */
#define EVENT_SCAN_ALL_EVENTS 0xf0000000
#define SURVEILLANCE_TOKEN 9000
#define SURVEILLANCE_TIMEOUT 1
#define SURVEILLANCE_SCANRATE 1
#define LOG_NUMBER 64 /* must be a power of two */
#define LOG_NUMBER_MASK (LOG_NUMBER-1)
/* Some RTAS ops require a data buffer and that buffer must be < 4G.
* Rather than having a memory allocator, just use this buffer
* (get the lock first), make the RTAS call. Copy the data instead
* of holding the buffer for long.
*/
#define RTAS_DATA_BUF_SIZE 1024
#define RTAS_UNKNOWN_OP -1099 /* Return Status - Unknown RTAS Token */
#define RTAS_BUSY -2 /* RTAS Return Status - Busy */
#define RTAS_DATA_BUF_SIZE 4096
extern spinlock_t rtas_data_buf_lock;
extern char rtas_data_buf[RTAS_DATA_BUF_SIZE];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment