#include <asm/rtas.h>
#include <asm/semaphore.h>
#include <asm/machdep.h>
-#include <asm/paca.h>
#include <asm/page.h>
#include <asm/param.h>
#include <asm/system.h>
.lock = SPIN_LOCK_UNLOCKED
};
+EXPORT_SYMBOL(rtas);
+
char rtas_err_buf[RTAS_ERROR_LOG_MAX];
spinlock_t rtas_data_buf_lock = SPIN_LOCK_UNLOCKED;
char rtas_data_buf[RTAS_DATA_BUF_SIZE]__page_aligned;
+unsigned long rtas_rmo_buf;
void
-call_rtas_display_status(char c)
+call_rtas_display_status(unsigned char c)
{
struct rtas_args *args = &rtas.args;
unsigned long s;
+ if (!rtas.base)
+ return;
spin_lock_irqsave(&rtas.lock, s);
args->token = 10;
spin_unlock_irqrestore(&rtas.lock, s);
}
+void
+call_rtas_display_status_delay(unsigned char c)
+{
+ static int pending_newline = 0; /* did last write end with unprinted newline? */
+ static int width = 16;
+
+ if (c == '\n') {
+ while (width-- > 0)
+ call_rtas_display_status(' ');
+ width = 16;
+ udelay(500000);
+ pending_newline = 1;
+ } else {
+ if (pending_newline) {
+ call_rtas_display_status('\r');
+ call_rtas_display_status('\n');
+ }
+ pending_newline = 0;
+ if (width--) {
+ call_rtas_display_status(c);
+ udelay(10000);
+ }
+ }
+}
+
int
rtas_token(const char *service)
{
return tokp ? *tokp : RTAS_UNKNOWN_SERVICE;
}
-
/** Return a copy of the detailed error text associated with the
* most recent failed call to rtas. Because the error text
* might go stale if there are any other intervening rtas calls,
__fetch_rtas_last_error(void)
{
struct rtas_args err_args, save_args;
+ u32 bufsz;
+
+ bufsz = rtas_token ("rtas-error-log-max");
+ if ((bufsz == RTAS_UNKNOWN_SERVICE) ||
+ (bufsz > RTAS_ERROR_LOG_MAX)) {
+ printk (KERN_WARNING "RTAS: bad log buffer size %d\n", bufsz);
+ bufsz = RTAS_ERROR_LOG_MAX;
+ }
err_args.token = rtas_token("rtas-last-error");
err_args.nargs = 2;
err_args.nret = 1;
- err_args.rets = (rtas_arg_t *)&(err_args.args[2]);
err_args.args[0] = (rtas_arg_t)__pa(rtas_err_buf);
- err_args.args[1] = RTAS_ERROR_LOG_MAX;
+ err_args.args[1] = bufsz;
err_args.args[2] = 0;
save_args = rtas.args;
rtas.args = err_args;
- PPCDBG(PPCDBG_RTAS, "\tentering rtas with 0x%lx\n",
- __pa(&err_args));
enter_rtas(__pa(&rtas.args));
- PPCDBG(PPCDBG_RTAS, "\treturned from rtas ...\n");
err_args = rtas.args;
rtas.args = save_args;
- return err_args.rets[0];
+ return err_args.args[2];
}
int rtas_call(int token, int nargs, int nret, int *outputs, ...)
/* Log the error in the unlikely case that there was one. */
if (unlikely(logit)) {
- buff_copy = kmalloc(RTAS_ERROR_LOG_MAX, GFP_ATOMIC);
- if (buff_copy) {
- memcpy(buff_copy, rtas_err_buf, RTAS_ERROR_LOG_MAX);
+ buff_copy = rtas_err_buf;
+ if (mem_init_done) {
+ buff_copy = kmalloc(RTAS_ERROR_LOG_MAX, GFP_ATOMIC);
+ if (buff_copy)
+ memcpy(buff_copy, rtas_err_buf,
+ RTAS_ERROR_LOG_MAX);
}
}
if (buff_copy) {
log_error(buff_copy, ERR_TYPE_RTAS_LOG, 0);
- kfree(buff_copy);
+ if (mem_init_done)
+ kfree(buff_copy);
}
return ret;
}
} while (status == RTAS_BUSY);
}
-unsigned long rtas_rmo_buf = 0;
asmlinkage int ppc_rtas(struct rtas_args __user *uargs)
{
}
#endif /* CONFIG_HOTPLUG_CPU */
+/*
+ * Return the firmware-specified size of the error log buffer
+ * for all rtas calls that require an error buffer argument.
+ * This includes 'check-exception' and 'rtas-last-error'.
+ */
+int rtas_get_error_log_max(void)
+{
+ static int rtas_error_log_max;
+ if (rtas_error_log_max)
+ return rtas_error_log_max;
+
+ rtas_error_log_max = rtas_token ("rtas-error-log-max");
+ if ((rtas_error_log_max == RTAS_UNKNOWN_SERVICE) ||
+ (rtas_error_log_max > RTAS_ERROR_LOG_MAX)) {
+ printk (KERN_WARNING "RTAS: bad log buffer size %d\n", rtas_error_log_max);
+ rtas_error_log_max = RTAS_ERROR_LOG_MAX;
+ }
+ return rtas_error_log_max;
+}
+
+/*
+ * Call early during boot, before mem init or bootmem, to retreive the RTAS
+ * informations from the device-tree and allocate the RMO buffer for userland
+ * accesses.
+ */
+void __init rtas_initialize(void)
+{
+ /* Get RTAS dev node and fill up our "rtas" structure with infos
+ * about it.
+ */
+ rtas.dev = of_find_node_by_name(NULL, "rtas");
+ if (rtas.dev) {
+ u64 *basep, *entryp;
+ u32 *sizep;
+
+ basep = (u64 *)get_property(of_chosen, "linux,rtas-base", NULL);
+ sizep = (u32 *)get_property(of_chosen, "linux,rtas-size", NULL);
+ if (basep != NULL && sizep != NULL) {
+ rtas.base = *basep;
+ rtas.size = *sizep;
+ entryp = (u64 *)get_property(of_chosen, "linux,rtas-entry", NULL);
+ if (entryp == NULL) /* Ugh */
+ rtas.entry = rtas.base;
+ else
+ rtas.entry = *entryp;
+ } else
+ rtas.dev = NULL;
+ }
+ /* If RTAS was found, allocate the RMO buffer for it and look for
+ * the stop-self token if any
+ */
+ if (rtas.dev) {
+ unsigned long rtas_region = RTAS_INSTANTIATE_MAX;
+ if (systemcfg->platform == PLATFORM_PSERIES_LPAR)
+ rtas_region = min(lmb.rmo_size, RTAS_INSTANTIATE_MAX);
+
+ rtas_rmo_buf = lmb_alloc_base(RTAS_RMOBUF_MAX, PAGE_SIZE,
+ rtas_region);
+
+#ifdef CONFIG_HOTPLUG_CPU
+ rtas_stop_self_args.token = rtas_token("stop-self");
+#endif /* CONFIG_HOTPLUG_CPU */
+ }
+
+}
+
+
EXPORT_SYMBOL(rtas_firmware_flash_list);
EXPORT_SYMBOL(rtas_token);
EXPORT_SYMBOL(rtas_call);
EXPORT_SYMBOL(rtas_get_power_level);
EXPORT_SYMBOL(rtas_set_power_level);
EXPORT_SYMBOL(rtas_set_indicator);
+EXPORT_SYMBOL(rtas_get_error_log_max);