[PATCH] ppc64: pSeries_progress -> rtas_progress
[linux-2.6] / arch / ppc64 / kernel / rtas.c
1 /*
2  *
3  * Procedures for interfacing to the RTAS on CHRP machines.
4  *
5  * Peter Bergner, IBM   March 2001.
6  * Copyright (C) 2001 IBM.
7  *
8  *      This program is free software; you can redistribute it and/or
9  *      modify it under the terms of the GNU General Public License
10  *      as published by the Free Software Foundation; either version
11  *      2 of the License, or (at your option) any later version.
12  */
13
14 #include <stdarg.h>
15 #include <linux/kernel.h>
16 #include <linux/types.h>
17 #include <linux/spinlock.h>
18 #include <linux/module.h>
19 #include <linux/init.h>
20
21 #include <asm/prom.h>
22 #include <asm/rtas.h>
23 #include <asm/semaphore.h>
24 #include <asm/machdep.h>
25 #include <asm/page.h>
26 #include <asm/param.h>
27 #include <asm/system.h>
28 #include <asm/abs_addr.h>
29 #include <asm/udbg.h>
30 #include <asm/delay.h>
31 #include <asm/uaccess.h>
32 #include <asm/systemcfg.h>
33
34 struct flash_block_list_header rtas_firmware_flash_list = {0, NULL};
35
36 struct rtas_t rtas = { 
37         .lock = SPIN_LOCK_UNLOCKED
38 };
39
40 EXPORT_SYMBOL(rtas);
41
42 char rtas_err_buf[RTAS_ERROR_LOG_MAX];
43
44 DEFINE_SPINLOCK(rtas_data_buf_lock);
45 char rtas_data_buf[RTAS_DATA_BUF_SIZE]__page_aligned;
46 unsigned long rtas_rmo_buf;
47
48 void
49 call_rtas_display_status(unsigned char c)
50 {
51         struct rtas_args *args = &rtas.args;
52         unsigned long s;
53
54         if (!rtas.base)
55                 return;
56         spin_lock_irqsave(&rtas.lock, s);
57
58         args->token = 10;
59         args->nargs = 1;
60         args->nret  = 1;
61         args->rets  = (rtas_arg_t *)&(args->args[1]);
62         args->args[0] = (int)c;
63
64         enter_rtas(__pa(args));
65
66         spin_unlock_irqrestore(&rtas.lock, s);
67 }
68
69 void
70 call_rtas_display_status_delay(unsigned char c)
71 {
72         static int pending_newline = 0;  /* did last write end with unprinted newline? */
73         static int width = 16;
74
75         if (c == '\n') {        
76                 while (width-- > 0)
77                         call_rtas_display_status(' ');
78                 width = 16;
79                 udelay(500000);
80                 pending_newline = 1;
81         } else {
82                 if (pending_newline) {
83                         call_rtas_display_status('\r');
84                         call_rtas_display_status('\n');
85                 } 
86                 pending_newline = 0;
87                 if (width--) {
88                         call_rtas_display_status(c);
89                         udelay(10000);
90                 }
91         }
92 }
93
94 void
95 rtas_progress(char *s, unsigned short hex)
96 {
97         struct device_node *root;
98         int width, *p;
99         char *os;
100         static int display_character, set_indicator;
101         static int max_width;
102         static DEFINE_SPINLOCK(progress_lock);
103         static int pending_newline = 0;  /* did last write end with unprinted newline? */
104
105         if (!rtas.base)
106                 return;
107
108         if (max_width == 0) {
109                 if ((root = find_path_device("/rtas")) &&
110                      (p = (unsigned int *)get_property(root,
111                                                        "ibm,display-line-length",
112                                                        NULL)))
113                         max_width = *p;
114                 else
115                         max_width = 0x10;
116                 display_character = rtas_token("display-character");
117                 set_indicator = rtas_token("set-indicator");
118         }
119
120         if (display_character == RTAS_UNKNOWN_SERVICE) {
121                 /* use hex display if available */
122                 if (set_indicator != RTAS_UNKNOWN_SERVICE)
123                         rtas_call(set_indicator, 3, 1, NULL, 6, 0, hex);
124                 return;
125         }
126
127         spin_lock(&progress_lock);
128
129         /*
130          * Last write ended with newline, but we didn't print it since
131          * it would just clear the bottom line of output. Print it now
132          * instead.
133          *
134          * If no newline is pending, print a CR to start output at the
135          * beginning of the line.
136          */
137         if (pending_newline) {
138                 rtas_call(display_character, 1, 1, NULL, '\r');
139                 rtas_call(display_character, 1, 1, NULL, '\n');
140                 pending_newline = 0;
141         } else {
142                 rtas_call(display_character, 1, 1, NULL, '\r');
143         }
144  
145         width = max_width;
146         os = s;
147         while (*os) {
148                 if (*os == '\n' || *os == '\r') {
149                         /* Blank to end of line. */
150                         while (width-- > 0)
151                                 rtas_call(display_character, 1, 1, NULL, ' ');
152  
153                         /* If newline is the last character, save it
154                          * until next call to avoid bumping up the
155                          * display output.
156                          */
157                         if (*os == '\n' && !os[1]) {
158                                 pending_newline = 1;
159                                 spin_unlock(&progress_lock);
160                                 return;
161                         }
162  
163                         /* RTAS wants CR-LF, not just LF */
164  
165                         if (*os == '\n') {
166                                 rtas_call(display_character, 1, 1, NULL, '\r');
167                                 rtas_call(display_character, 1, 1, NULL, '\n');
168                         } else {
169                                 /* CR might be used to re-draw a line, so we'll
170                                  * leave it alone and not add LF.
171                                  */
172                                 rtas_call(display_character, 1, 1, NULL, *os);
173                         }
174  
175                         width = max_width;
176                 } else {
177                         width--;
178                         rtas_call(display_character, 1, 1, NULL, *os);
179                 }
180  
181                 os++;
182  
183                 /* if we overwrite the screen length */
184                 if (width <= 0)
185                         while ((*os != 0) && (*os != '\n') && (*os != '\r'))
186                                 os++;
187         }
188  
189         /* Blank to end of line. */
190         while (width-- > 0)
191                 rtas_call(display_character, 1, 1, NULL, ' ');
192
193         spin_unlock(&progress_lock);
194 }
195
196 int
197 rtas_token(const char *service)
198 {
199         int *tokp;
200         if (rtas.dev == NULL) {
201                 PPCDBG(PPCDBG_RTAS,"\tNo rtas device in device-tree...\n");
202                 return RTAS_UNKNOWN_SERVICE;
203         }
204         tokp = (int *) get_property(rtas.dev, service, NULL);
205         return tokp ? *tokp : RTAS_UNKNOWN_SERVICE;
206 }
207
208 /*
209  * Return the firmware-specified size of the error log buffer
210  *  for all rtas calls that require an error buffer argument.
211  *  This includes 'check-exception' and 'rtas-last-error'.
212  */
213 int rtas_get_error_log_max(void)
214 {
215         static int rtas_error_log_max;
216         if (rtas_error_log_max)
217                 return rtas_error_log_max;
218
219         rtas_error_log_max = rtas_token ("rtas-error-log-max");
220         if ((rtas_error_log_max == RTAS_UNKNOWN_SERVICE) ||
221             (rtas_error_log_max > RTAS_ERROR_LOG_MAX)) {
222                 printk (KERN_WARNING "RTAS: bad log buffer size %d\n", rtas_error_log_max);
223                 rtas_error_log_max = RTAS_ERROR_LOG_MAX;
224         }
225         return rtas_error_log_max;
226 }
227
228
229 /** Return a copy of the detailed error text associated with the
230  *  most recent failed call to rtas.  Because the error text
231  *  might go stale if there are any other intervening rtas calls,
232  *  this routine must be called atomically with whatever produced
233  *  the error (i.e. with rtas.lock still held from the previous call).
234  */
235 static int
236 __fetch_rtas_last_error(void)
237 {
238         struct rtas_args err_args, save_args;
239         u32 bufsz;
240
241         bufsz = rtas_get_error_log_max();
242
243         err_args.token = rtas_token("rtas-last-error");
244         err_args.nargs = 2;
245         err_args.nret = 1;
246
247         err_args.args[0] = (rtas_arg_t)__pa(rtas_err_buf);
248         err_args.args[1] = bufsz;
249         err_args.args[2] = 0;
250
251         save_args = rtas.args;
252         rtas.args = err_args;
253
254         enter_rtas(__pa(&rtas.args));
255
256         err_args = rtas.args;
257         rtas.args = save_args;
258
259         return err_args.args[2];
260 }
261
262 int rtas_call(int token, int nargs, int nret, int *outputs, ...)
263 {
264         va_list list;
265         int i, logit = 0;
266         unsigned long s;
267         struct rtas_args *rtas_args;
268         char * buff_copy = NULL;
269         int ret;
270
271         PPCDBG(PPCDBG_RTAS, "Entering rtas_call\n");
272         PPCDBG(PPCDBG_RTAS, "\ttoken    = 0x%x\n", token);
273         PPCDBG(PPCDBG_RTAS, "\tnargs    = %d\n", nargs);
274         PPCDBG(PPCDBG_RTAS, "\tnret     = %d\n", nret);
275         PPCDBG(PPCDBG_RTAS, "\t&outputs = 0x%lx\n", outputs);
276         if (token == RTAS_UNKNOWN_SERVICE)
277                 return -1;
278
279         /* Gotta do something different here, use global lock for now... */
280         spin_lock_irqsave(&rtas.lock, s);
281         rtas_args = &rtas.args;
282
283         rtas_args->token = token;
284         rtas_args->nargs = nargs;
285         rtas_args->nret  = nret;
286         rtas_args->rets  = (rtas_arg_t *)&(rtas_args->args[nargs]);
287         va_start(list, outputs);
288         for (i = 0; i < nargs; ++i) {
289                 rtas_args->args[i] = va_arg(list, rtas_arg_t);
290                 PPCDBG(PPCDBG_RTAS, "\tnarg[%d] = 0x%x\n", i, rtas_args->args[i]);
291         }
292         va_end(list);
293
294         for (i = 0; i < nret; ++i)
295                 rtas_args->rets[i] = 0;
296
297         PPCDBG(PPCDBG_RTAS, "\tentering rtas with 0x%lx\n",
298                 __pa(rtas_args));
299         enter_rtas(__pa(rtas_args));
300         PPCDBG(PPCDBG_RTAS, "\treturned from rtas ...\n");
301
302         /* A -1 return code indicates that the last command couldn't
303            be completed due to a hardware error. */
304         if (rtas_args->rets[0] == -1)
305                 logit = (__fetch_rtas_last_error() == 0);
306
307         ifppcdebug(PPCDBG_RTAS) {
308                 for(i=0; i < nret ;i++)
309                         udbg_printf("\tnret[%d] = 0x%lx\n", i, (ulong)rtas_args->rets[i]);
310         }
311
312         if (nret > 1 && outputs != NULL)
313                 for (i = 0; i < nret-1; ++i)
314                         outputs[i] = rtas_args->rets[i+1];
315         ret = (nret > 0)? rtas_args->rets[0]: 0;
316
317         /* Log the error in the unlikely case that there was one. */
318         if (unlikely(logit)) {
319                 buff_copy = rtas_err_buf;
320                 if (mem_init_done) {
321                         buff_copy = kmalloc(RTAS_ERROR_LOG_MAX, GFP_ATOMIC);
322                         if (buff_copy)
323                                 memcpy(buff_copy, rtas_err_buf,
324                                        RTAS_ERROR_LOG_MAX);
325                 }
326         }
327
328         /* Gotta do something different here, use global lock for now... */
329         spin_unlock_irqrestore(&rtas.lock, s);
330
331         if (buff_copy) {
332                 log_error(buff_copy, ERR_TYPE_RTAS_LOG, 0);
333                 if (mem_init_done)
334                         kfree(buff_copy);
335         }
336         return ret;
337 }
338
339 /* Given an RTAS status code of 990n compute the hinted delay of 10^n
340  * (last digit) milliseconds.  For now we bound at n=5 (100 sec).
341  */
342 unsigned int
343 rtas_extended_busy_delay_time(int status)
344 {
345         int order = status - 9900;
346         unsigned long ms;
347
348         if (order < 0)
349                 order = 0;      /* RTC depends on this for -2 clock busy */
350         else if (order > 5)
351                 order = 5;      /* bound */
352
353         /* Use microseconds for reasonable accuracy */
354         for (ms=1; order > 0; order--)
355                 ms *= 10;
356
357         return ms; 
358 }
359
360 int rtas_error_rc(int rtas_rc)
361 {
362         int rc;
363
364         switch (rtas_rc) {
365                 case -1:                /* Hardware Error */
366                         rc = -EIO;
367                         break;
368                 case -3:                /* Bad indicator/domain/etc */
369                         rc = -EINVAL;
370                         break;
371                 case -9000:             /* Isolation error */
372                         rc = -EFAULT;
373                         break;
374                 case -9001:             /* Outstanding TCE/PTE */
375                         rc = -EEXIST;
376                         break;
377                 case -9002:             /* No usable slot */
378                         rc = -ENODEV;
379                         break;
380                 default:
381                         printk(KERN_ERR "%s: unexpected RTAS error %d\n",
382                                         __FUNCTION__, rtas_rc);
383                         rc = -ERANGE;
384                         break;
385         }
386         return rc;
387 }
388
389 int rtas_get_power_level(int powerdomain, int *level)
390 {
391         int token = rtas_token("get-power-level");
392         int rc;
393
394         if (token == RTAS_UNKNOWN_SERVICE)
395                 return -ENOENT;
396
397         while ((rc = rtas_call(token, 1, 2, level, powerdomain)) == RTAS_BUSY)
398                 udelay(1);
399
400         if (rc < 0)
401                 return rtas_error_rc(rc);
402         return rc;
403 }
404
405 int rtas_set_power_level(int powerdomain, int level, int *setlevel)
406 {
407         int token = rtas_token("set-power-level");
408         unsigned int wait_time;
409         int rc;
410
411         if (token == RTAS_UNKNOWN_SERVICE)
412                 return -ENOENT;
413
414         while (1) {
415                 rc = rtas_call(token, 2, 2, setlevel, powerdomain, level);
416                 if (rc == RTAS_BUSY)
417                         udelay(1);
418                 else if (rtas_is_extended_busy(rc)) {
419                         wait_time = rtas_extended_busy_delay_time(rc);
420                         udelay(wait_time * 1000);
421                 } else
422                         break;
423         }
424
425         if (rc < 0)
426                 return rtas_error_rc(rc);
427         return rc;
428 }
429
430 int rtas_get_sensor(int sensor, int index, int *state)
431 {
432         int token = rtas_token("get-sensor-state");
433         unsigned int wait_time;
434         int rc;
435
436         if (token == RTAS_UNKNOWN_SERVICE)
437                 return -ENOENT;
438
439         while (1) {
440                 rc = rtas_call(token, 2, 2, state, sensor, index);
441                 if (rc == RTAS_BUSY)
442                         udelay(1);
443                 else if (rtas_is_extended_busy(rc)) {
444                         wait_time = rtas_extended_busy_delay_time(rc);
445                         udelay(wait_time * 1000);
446                 } else
447                         break;
448         }
449
450         if (rc < 0)
451                 return rtas_error_rc(rc);
452         return rc;
453 }
454
455 int rtas_set_indicator(int indicator, int index, int new_value)
456 {
457         int token = rtas_token("set-indicator");
458         unsigned int wait_time;
459         int rc;
460
461         if (token == RTAS_UNKNOWN_SERVICE)
462                 return -ENOENT;
463
464         while (1) {
465                 rc = rtas_call(token, 3, 1, NULL, indicator, index, new_value);
466                 if (rc == RTAS_BUSY)
467                         udelay(1);
468                 else if (rtas_is_extended_busy(rc)) {
469                         wait_time = rtas_extended_busy_delay_time(rc);
470                         udelay(wait_time * 1000);
471                 }
472                 else
473                         break;
474         }
475
476         if (rc < 0)
477                 return rtas_error_rc(rc);
478         return rc;
479 }
480
481 #define FLASH_BLOCK_LIST_VERSION (1UL)
482 static void
483 rtas_flash_firmware(void)
484 {
485         unsigned long image_size;
486         struct flash_block_list *f, *next, *flist;
487         unsigned long rtas_block_list;
488         int i, status, update_token;
489
490         update_token = rtas_token("ibm,update-flash-64-and-reboot");
491         if (update_token == RTAS_UNKNOWN_SERVICE) {
492                 printk(KERN_ALERT "FLASH: ibm,update-flash-64-and-reboot is not available -- not a service partition?\n");
493                 printk(KERN_ALERT "FLASH: firmware will not be flashed\n");
494                 return;
495         }
496
497         /* NOTE: the "first" block list is a global var with no data
498          * blocks in the kernel data segment.  We do this because
499          * we want to ensure this block_list addr is under 4GB.
500          */
501         rtas_firmware_flash_list.num_blocks = 0;
502         flist = (struct flash_block_list *)&rtas_firmware_flash_list;
503         rtas_block_list = virt_to_abs(flist);
504         if (rtas_block_list >= 4UL*1024*1024*1024) {
505                 printk(KERN_ALERT "FLASH: kernel bug...flash list header addr above 4GB\n");
506                 return;
507         }
508
509         printk(KERN_ALERT "FLASH: preparing saved firmware image for flash\n");
510         /* Update the block_list in place. */
511         image_size = 0;
512         for (f = flist; f; f = next) {
513                 /* Translate data addrs to absolute */
514                 for (i = 0; i < f->num_blocks; i++) {
515                         f->blocks[i].data = (char *)virt_to_abs(f->blocks[i].data);
516                         image_size += f->blocks[i].length;
517                 }
518                 next = f->next;
519                 /* Don't translate NULL pointer for last entry */
520                 if (f->next)
521                         f->next = (struct flash_block_list *)virt_to_abs(f->next);
522                 else
523                         f->next = NULL;
524                 /* make num_blocks into the version/length field */
525                 f->num_blocks = (FLASH_BLOCK_LIST_VERSION << 56) | ((f->num_blocks+1)*16);
526         }
527
528         printk(KERN_ALERT "FLASH: flash image is %ld bytes\n", image_size);
529         printk(KERN_ALERT "FLASH: performing flash and reboot\n");
530         rtas_progress("Flashing        \n", 0x0);
531         rtas_progress("Please Wait...  ", 0x0);
532         printk(KERN_ALERT "FLASH: this will take several minutes.  Do not power off!\n");
533         status = rtas_call(update_token, 1, 1, NULL, rtas_block_list);
534         switch (status) {       /* should only get "bad" status */
535             case 0:
536                 printk(KERN_ALERT "FLASH: success\n");
537                 break;
538             case -1:
539                 printk(KERN_ALERT "FLASH: hardware error.  Firmware may not be not flashed\n");
540                 break;
541             case -3:
542                 printk(KERN_ALERT "FLASH: image is corrupt or not correct for this platform.  Firmware not flashed\n");
543                 break;
544             case -4:
545                 printk(KERN_ALERT "FLASH: flash failed when partially complete.  System may not reboot\n");
546                 break;
547             default:
548                 printk(KERN_ALERT "FLASH: unknown flash return code %d\n", status);
549                 break;
550         }
551 }
552
553 void rtas_flash_bypass_warning(void)
554 {
555         printk(KERN_ALERT "FLASH: firmware flash requires a reboot\n");
556         printk(KERN_ALERT "FLASH: the firmware image will NOT be flashed\n");
557 }
558
559
560 void
561 rtas_restart(char *cmd)
562 {
563         if (rtas_firmware_flash_list.next)
564                 rtas_flash_firmware();
565
566         printk("RTAS system-reboot returned %d\n",
567                rtas_call(rtas_token("system-reboot"), 0, 1, NULL));
568         for (;;);
569 }
570
571 void
572 rtas_power_off(void)
573 {
574         if (rtas_firmware_flash_list.next)
575                 rtas_flash_bypass_warning();
576         /* allow power on only with power button press */
577         printk("RTAS power-off returned %d\n",
578                rtas_call(rtas_token("power-off"), 2, 1, NULL, -1, -1));
579         for (;;);
580 }
581
582 void
583 rtas_halt(void)
584 {
585         if (rtas_firmware_flash_list.next)
586                 rtas_flash_bypass_warning();
587         rtas_power_off();
588 }
589
590 /* Must be in the RMO region, so we place it here */
591 static char rtas_os_term_buf[2048];
592
593 void rtas_os_term(char *str)
594 {
595         int status;
596
597         if (RTAS_UNKNOWN_SERVICE == rtas_token("ibm,os-term"))
598                 return;
599
600         snprintf(rtas_os_term_buf, 2048, "OS panic: %s", str);
601
602         do {
603                 status = rtas_call(rtas_token("ibm,os-term"), 1, 1, NULL,
604                                    __pa(rtas_os_term_buf));
605
606                 if (status == RTAS_BUSY)
607                         udelay(1);
608                 else if (status != 0)
609                         printk(KERN_EMERG "ibm,os-term call failed %d\n",
610                                status);
611         } while (status == RTAS_BUSY);
612 }
613
614
615 asmlinkage int ppc_rtas(struct rtas_args __user *uargs)
616 {
617         struct rtas_args args;
618         unsigned long flags;
619         char * buff_copy;
620         int nargs;
621         int err_rc = 0;
622
623         if (!capable(CAP_SYS_ADMIN))
624                 return -EPERM;
625
626         if (copy_from_user(&args, uargs, 3 * sizeof(u32)) != 0)
627                 return -EFAULT;
628
629         nargs = args.nargs;
630         if (nargs > ARRAY_SIZE(args.args)
631             || args.nret > ARRAY_SIZE(args.args)
632             || nargs + args.nret > ARRAY_SIZE(args.args))
633                 return -EINVAL;
634
635         /* Copy in args. */
636         if (copy_from_user(args.args, uargs->args,
637                            nargs * sizeof(rtas_arg_t)) != 0)
638                 return -EFAULT;
639
640         buff_copy = kmalloc(RTAS_ERROR_LOG_MAX, GFP_KERNEL);
641
642         spin_lock_irqsave(&rtas.lock, flags);
643
644         rtas.args = args;
645         enter_rtas(__pa(&rtas.args));
646         args = rtas.args;
647
648         args.rets = &args.args[nargs];
649
650         /* A -1 return code indicates that the last command couldn't
651            be completed due to a hardware error. */
652         if (args.rets[0] == -1) {
653                 err_rc = __fetch_rtas_last_error();
654                 if ((err_rc == 0) && buff_copy) {
655                         memcpy(buff_copy, rtas_err_buf, RTAS_ERROR_LOG_MAX);
656                 }
657         }
658
659         spin_unlock_irqrestore(&rtas.lock, flags);
660
661         if (buff_copy) {
662                 if ((args.rets[0] == -1) && (err_rc == 0)) {
663                         log_error(buff_copy, ERR_TYPE_RTAS_LOG, 0);
664                 }
665                 kfree(buff_copy);
666         }
667
668         /* Copy out args. */
669         if (copy_to_user(uargs->args + nargs,
670                          args.args + nargs,
671                          args.nret * sizeof(rtas_arg_t)) != 0)
672                 return -EFAULT;
673
674         return 0;
675 }
676
677 /* This version can't take the spinlock, because it never returns */
678
679 struct rtas_args rtas_stop_self_args = {
680         /* The token is initialized for real in setup_system() */
681         .token = RTAS_UNKNOWN_SERVICE,
682         .nargs = 0,
683         .nret = 1,
684         .rets = &rtas_stop_self_args.args[0],
685 };
686
687 void rtas_stop_self(void)
688 {
689         struct rtas_args *rtas_args = &rtas_stop_self_args;
690
691         local_irq_disable();
692
693         BUG_ON(rtas_args->token == RTAS_UNKNOWN_SERVICE);
694
695         printk("cpu %u (hwid %u) Ready to die...\n",
696                smp_processor_id(), hard_smp_processor_id());
697         enter_rtas(__pa(rtas_args));
698
699         panic("Alas, I survived.\n");
700 }
701
702 /*
703  * Call early during boot, before mem init or bootmem, to retreive the RTAS
704  * informations from the device-tree and allocate the RMO buffer for userland
705  * accesses.
706  */
707 void __init rtas_initialize(void)
708 {
709         /* Get RTAS dev node and fill up our "rtas" structure with infos
710          * about it.
711          */
712         rtas.dev = of_find_node_by_name(NULL, "rtas");
713         if (rtas.dev) {
714                 u32 *basep, *entryp;
715                 u32 *sizep;
716
717                 basep = (u32 *)get_property(rtas.dev, "linux,rtas-base", NULL);
718                 sizep = (u32 *)get_property(rtas.dev, "rtas-size", NULL);
719                 if (basep != NULL && sizep != NULL) {
720                         rtas.base = *basep;
721                         rtas.size = *sizep;
722                         entryp = (u32 *)get_property(rtas.dev, "linux,rtas-entry", NULL);
723                         if (entryp == NULL) /* Ugh */
724                                 rtas.entry = rtas.base;
725                         else
726                                 rtas.entry = *entryp;
727                 } else
728                         rtas.dev = NULL;
729         }
730         /* If RTAS was found, allocate the RMO buffer for it and look for
731          * the stop-self token if any
732          */
733         if (rtas.dev) {
734                 unsigned long rtas_region = RTAS_INSTANTIATE_MAX;
735                 if (systemcfg->platform == PLATFORM_PSERIES_LPAR)
736                         rtas_region = min(lmb.rmo_size, RTAS_INSTANTIATE_MAX);
737
738                 rtas_rmo_buf = lmb_alloc_base(RTAS_RMOBUF_MAX, PAGE_SIZE,
739                                                         rtas_region);
740
741 #ifdef CONFIG_HOTPLUG_CPU
742                 rtas_stop_self_args.token = rtas_token("stop-self");
743 #endif /* CONFIG_HOTPLUG_CPU */
744         }
745
746 }
747
748
749 EXPORT_SYMBOL(rtas_firmware_flash_list);
750 EXPORT_SYMBOL(rtas_token);
751 EXPORT_SYMBOL(rtas_call);
752 EXPORT_SYMBOL(rtas_data_buf);
753 EXPORT_SYMBOL(rtas_data_buf_lock);
754 EXPORT_SYMBOL(rtas_extended_busy_delay_time);
755 EXPORT_SYMBOL(rtas_get_sensor);
756 EXPORT_SYMBOL(rtas_get_power_level);
757 EXPORT_SYMBOL(rtas_set_power_level);
758 EXPORT_SYMBOL(rtas_set_indicator);
759 EXPORT_SYMBOL(rtas_get_error_log_max);