diff options
author | Paul Mackerras <paulus@samba.org> | 2005-10-26 03:05:24 -0400 |
---|---|---|
committer | Paul Mackerras <paulus@samba.org> | 2005-10-26 03:05:24 -0400 |
commit | 033ef338b6e007dc081c6282a4f2a9dd761f8cd2 (patch) | |
tree | 3c77fad71c3d9ba04ddcdaea33063aaf7520ddb0 /arch/powerpc | |
parent | f9bd170a87948a9e077149b70fb192c563770fdf (diff) |
powerpc: Merge rtas.c into arch/powerpc/kernel
This splits arch/ppc64/kernel/rtas.c into arch/powerpc/kernel/rtas.c,
which contains generic RTAS functions useful on any CHRP platform,
and arch/powerpc/platforms/pseries/rtas-fw.[ch], which contain
some pSeries-specific firmware flashing bits. The parts of rtas.c
that are to do with pSeries-specific error logging are protected
by a new CONFIG_RTAS_ERROR_LOGGING symbol. The inclusion of rtas.o
is controlled by the CONFIG_PPC_RTAS symbol, and the relevant
platforms select that.
Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'arch/powerpc')
-rw-r--r-- | arch/powerpc/Kconfig | 13 | ||||
-rw-r--r-- | arch/powerpc/kernel/Makefile | 1 | ||||
-rw-r--r-- | arch/powerpc/kernel/asm-offsets.c | 6 | ||||
-rw-r--r-- | arch/powerpc/kernel/entry_32.S | 12 | ||||
-rw-r--r-- | arch/powerpc/kernel/prom.c | 3 | ||||
-rw-r--r-- | arch/powerpc/kernel/rtas.c | 680 | ||||
-rw-r--r-- | arch/powerpc/platforms/pseries/Kconfig | 5 | ||||
-rw-r--r-- | arch/powerpc/platforms/pseries/Makefile | 2 | ||||
-rw-r--r-- | arch/powerpc/platforms/pseries/rtas-fw.c | 138 | ||||
-rw-r--r-- | arch/powerpc/platforms/pseries/rtas-fw.h | 3 | ||||
-rw-r--r-- | arch/powerpc/platforms/pseries/setup.c | 10 |
11 files changed, 850 insertions, 23 deletions
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig index 9f279e0d84f2..ce5100cadd34 100644 --- a/arch/powerpc/Kconfig +++ b/arch/powerpc/Kconfig | |||
@@ -276,6 +276,8 @@ config PPC_PSERIES | |||
276 | depends on PPC_MULTIPLATFORM && PPC64 | 276 | depends on PPC_MULTIPLATFORM && PPC64 |
277 | bool " IBM pSeries & new (POWER5-based) iSeries" | 277 | bool " IBM pSeries & new (POWER5-based) iSeries" |
278 | select PPC_I8259 | 278 | select PPC_I8259 |
279 | select PPC_RTAS | ||
280 | select RTAS_ERROR_LOGGING | ||
279 | default y | 281 | default y |
280 | 282 | ||
281 | config PPC_CHRP | 283 | config PPC_CHRP |
@@ -283,6 +285,7 @@ config PPC_CHRP | |||
283 | depends on PPC_MULTIPLATFORM && PPC32 | 285 | depends on PPC_MULTIPLATFORM && PPC32 |
284 | select PPC_I8259 | 286 | select PPC_I8259 |
285 | select PPC_INDIRECT_PCI | 287 | select PPC_INDIRECT_PCI |
288 | select PPC_RTAS | ||
286 | default y | 289 | default y |
287 | 290 | ||
288 | config PPC_PMAC | 291 | config PPC_PMAC |
@@ -317,6 +320,7 @@ config PPC_MAPLE | |||
317 | config PPC_BPA | 320 | config PPC_BPA |
318 | bool " Broadband Processor Architecture" | 321 | bool " Broadband Processor Architecture" |
319 | depends on PPC_MULTIPLATFORM && PPC64 | 322 | depends on PPC_MULTIPLATFORM && PPC64 |
323 | select PPC_RTAS | ||
320 | 324 | ||
321 | config PPC_OF | 325 | config PPC_OF |
322 | bool | 326 | bool |
@@ -338,6 +342,15 @@ config MPIC | |||
338 | bool | 342 | bool |
339 | default y | 343 | default y |
340 | 344 | ||
345 | config PPC_RTAS | ||
346 | bool | ||
347 | default n | ||
348 | |||
349 | config RTAS_ERROR_LOGGING | ||
350 | bool | ||
351 | depends on PPC_RTAS | ||
352 | default n | ||
353 | |||
341 | config MPIC_BROKEN_U3 | 354 | config MPIC_BROKEN_U3 |
342 | bool | 355 | bool |
343 | depends on PPC_MAPLE | 356 | depends on PPC_MAPLE |
diff --git a/arch/powerpc/kernel/Makefile b/arch/powerpc/kernel/Makefile index f5d8038fed52..eaedb7e63315 100644 --- a/arch/powerpc/kernel/Makefile +++ b/arch/powerpc/kernel/Makefile | |||
@@ -16,6 +16,7 @@ obj-$(CONFIG_PPC64) += binfmt_elf32.o sys_ppc32.o ptrace32.o | |||
16 | obj-$(CONFIG_ALTIVEC) += vecemu.o vector.o | 16 | obj-$(CONFIG_ALTIVEC) += vecemu.o vector.o |
17 | obj-$(CONFIG_POWER4) += idle_power4.o | 17 | obj-$(CONFIG_POWER4) += idle_power4.o |
18 | obj-$(CONFIG_PPC_OF) += of_device.o | 18 | obj-$(CONFIG_PPC_OF) += of_device.o |
19 | obj-$(CONFIG_PPC_RTAS) += rtas.o | ||
19 | obj-$(CONFIG_IBMVIO) += vio.o | 20 | obj-$(CONFIG_IBMVIO) += vio.o |
20 | 21 | ||
21 | ifeq ($(CONFIG_PPC_MERGE),y) | 22 | ifeq ($(CONFIG_PPC_MERGE),y) |
diff --git a/arch/powerpc/kernel/asm-offsets.c b/arch/powerpc/kernel/asm-offsets.c index 1c83abd9f37c..710336a9f0fd 100644 --- a/arch/powerpc/kernel/asm-offsets.c +++ b/arch/powerpc/kernel/asm-offsets.c | |||
@@ -36,11 +36,11 @@ | |||
36 | #include <asm/processor.h> | 36 | #include <asm/processor.h> |
37 | #include <asm/cputable.h> | 37 | #include <asm/cputable.h> |
38 | #include <asm/thread_info.h> | 38 | #include <asm/thread_info.h> |
39 | #include <asm/rtas.h> | ||
39 | #ifdef CONFIG_PPC64 | 40 | #ifdef CONFIG_PPC64 |
40 | #include <asm/paca.h> | 41 | #include <asm/paca.h> |
41 | #include <asm/lppaca.h> | 42 | #include <asm/lppaca.h> |
42 | #include <asm/iSeries/HvLpEvent.h> | 43 | #include <asm/iSeries/HvLpEvent.h> |
43 | #include <asm/rtas.h> | ||
44 | #include <asm/cache.h> | 44 | #include <asm/cache.h> |
45 | #include <asm/systemcfg.h> | 45 | #include <asm/systemcfg.h> |
46 | #include <asm/compat.h> | 46 | #include <asm/compat.h> |
@@ -97,7 +97,7 @@ int main(void) | |||
97 | DEFINE(TI_TASK, offsetof(struct thread_info, task)); | 97 | DEFINE(TI_TASK, offsetof(struct thread_info, task)); |
98 | DEFINE(TI_EXECDOMAIN, offsetof(struct thread_info, exec_domain)); | 98 | DEFINE(TI_EXECDOMAIN, offsetof(struct thread_info, exec_domain)); |
99 | DEFINE(TI_CPU, offsetof(struct thread_info, cpu)); | 99 | DEFINE(TI_CPU, offsetof(struct thread_info, cpu)); |
100 | #endif /* CONFIG_PPC64 */ | 100 | #endif /* CONFIG_PPC32 */ |
101 | 101 | ||
102 | #ifdef CONFIG_PPC64 | 102 | #ifdef CONFIG_PPC64 |
103 | DEFINE(DCACHEL1LINESIZE, offsetof(struct ppc64_caches, dline_size)); | 103 | DEFINE(DCACHEL1LINESIZE, offsetof(struct ppc64_caches, dline_size)); |
@@ -142,11 +142,11 @@ int main(void) | |||
142 | DEFINE(LPPACASRR1, offsetof(struct lppaca, saved_srr1)); | 142 | DEFINE(LPPACASRR1, offsetof(struct lppaca, saved_srr1)); |
143 | DEFINE(LPPACAANYINT, offsetof(struct lppaca, int_dword.any_int)); | 143 | DEFINE(LPPACAANYINT, offsetof(struct lppaca, int_dword.any_int)); |
144 | DEFINE(LPPACADECRINT, offsetof(struct lppaca, int_dword.fields.decr_int)); | 144 | DEFINE(LPPACADECRINT, offsetof(struct lppaca, int_dword.fields.decr_int)); |
145 | #endif /* CONFIG_PPC64 */ | ||
145 | 146 | ||
146 | /* RTAS */ | 147 | /* RTAS */ |
147 | DEFINE(RTASBASE, offsetof(struct rtas_t, base)); | 148 | DEFINE(RTASBASE, offsetof(struct rtas_t, base)); |
148 | DEFINE(RTASENTRY, offsetof(struct rtas_t, entry)); | 149 | DEFINE(RTASENTRY, offsetof(struct rtas_t, entry)); |
149 | #endif /* CONFIG_PPC64 */ | ||
150 | 150 | ||
151 | /* Interrupt register frame */ | 151 | /* Interrupt register frame */ |
152 | DEFINE(STACK_FRAME_OVERHEAD, STACK_FRAME_OVERHEAD); | 152 | DEFINE(STACK_FRAME_OVERHEAD, STACK_FRAME_OVERHEAD); |
diff --git a/arch/powerpc/kernel/entry_32.S b/arch/powerpc/kernel/entry_32.S index 37b4396ca978..960da7bea043 100644 --- a/arch/powerpc/kernel/entry_32.S +++ b/arch/powerpc/kernel/entry_32.S | |||
@@ -954,7 +954,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_601) | |||
954 | * here so it's easy to add arch-specific sections later. | 954 | * here so it's easy to add arch-specific sections later. |
955 | * -- Cort | 955 | * -- Cort |
956 | */ | 956 | */ |
957 | #ifdef CONFIG_PPC_OF | 957 | #ifdef CONFIG_PPC_RTAS |
958 | /* | 958 | /* |
959 | * On CHRP, the Run-Time Abstraction Services (RTAS) have to be | 959 | * On CHRP, the Run-Time Abstraction Services (RTAS) have to be |
960 | * called with the MMU off. | 960 | * called with the MMU off. |
@@ -963,14 +963,13 @@ _GLOBAL(enter_rtas) | |||
963 | stwu r1,-INT_FRAME_SIZE(r1) | 963 | stwu r1,-INT_FRAME_SIZE(r1) |
964 | mflr r0 | 964 | mflr r0 |
965 | stw r0,INT_FRAME_SIZE+4(r1) | 965 | stw r0,INT_FRAME_SIZE+4(r1) |
966 | lis r4,rtas_data@ha | 966 | LOADADDR(r4, rtas) |
967 | lwz r4,rtas_data@l(r4) | ||
968 | lis r6,1f@ha /* physical return address for rtas */ | 967 | lis r6,1f@ha /* physical return address for rtas */ |
969 | addi r6,r6,1f@l | 968 | addi r6,r6,1f@l |
970 | tophys(r6,r6) | 969 | tophys(r6,r6) |
971 | tophys(r7,r1) | 970 | tophys(r7,r1) |
972 | lis r8,rtas_entry@ha | 971 | lwz r8,RTASENTRY(r4) |
973 | lwz r8,rtas_entry@l(r8) | 972 | lwz r4,RTASBASE(r4) |
974 | mfmsr r9 | 973 | mfmsr r9 |
975 | stw r9,8(r1) | 974 | stw r9,8(r1) |
976 | LOAD_MSR_KERNEL(r0,MSR_KERNEL) | 975 | LOAD_MSR_KERNEL(r0,MSR_KERNEL) |
@@ -978,7 +977,6 @@ _GLOBAL(enter_rtas) | |||
978 | MTMSRD(r0) /* don't get trashed */ | 977 | MTMSRD(r0) /* don't get trashed */ |
979 | li r9,MSR_KERNEL & ~(MSR_IR|MSR_DR) | 978 | li r9,MSR_KERNEL & ~(MSR_IR|MSR_DR) |
980 | mtlr r6 | 979 | mtlr r6 |
981 | CLR_TOP32(r7) | ||
982 | mtspr SPRN_SPRG2,r7 | 980 | mtspr SPRN_SPRG2,r7 |
983 | mtspr SPRN_SRR0,r8 | 981 | mtspr SPRN_SRR0,r8 |
984 | mtspr SPRN_SRR1,r9 | 982 | mtspr SPRN_SRR1,r9 |
@@ -999,4 +997,4 @@ machine_check_in_rtas: | |||
999 | twi 31,0,0 | 997 | twi 31,0,0 |
1000 | /* XXX load up BATs and panic */ | 998 | /* XXX load up BATs and panic */ |
1001 | 999 | ||
1002 | #endif /* CONFIG_PPC_OF */ | 1000 | #endif /* CONFIG_PPC_RTAS */ |
diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c index 8d0c78cbc0bc..16ac15e73b44 100644 --- a/arch/powerpc/kernel/prom.c +++ b/arch/powerpc/kernel/prom.c | |||
@@ -110,9 +110,6 @@ struct device_node *of_chosen; | |||
110 | struct device_node *dflt_interrupt_controller; | 110 | struct device_node *dflt_interrupt_controller; |
111 | int num_interrupt_controllers; | 111 | int num_interrupt_controllers; |
112 | 112 | ||
113 | u32 rtas_data; | ||
114 | u32 rtas_entry; | ||
115 | |||
116 | /* | 113 | /* |
117 | * Wrapper for allocating memory for various data that needs to be | 114 | * Wrapper for allocating memory for various data that needs to be |
118 | * attached to device nodes as they are processed at boot or when | 115 | * attached to device nodes as they are processed at boot or when |
diff --git a/arch/powerpc/kernel/rtas.c b/arch/powerpc/kernel/rtas.c new file mode 100644 index 000000000000..4d22eeeeb91d --- /dev/null +++ b/arch/powerpc/kernel/rtas.c | |||
@@ -0,0 +1,680 @@ | |||
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/delay.h> | ||
29 | #include <asm/uaccess.h> | ||
30 | #include <asm/lmb.h> | ||
31 | #ifdef CONFIG_PPC64 | ||
32 | #include <asm/systemcfg.h> | ||
33 | #endif | ||
34 | |||
35 | struct rtas_t rtas = { | ||
36 | .lock = SPIN_LOCK_UNLOCKED | ||
37 | }; | ||
38 | |||
39 | EXPORT_SYMBOL(rtas); | ||
40 | |||
41 | DEFINE_SPINLOCK(rtas_data_buf_lock); | ||
42 | char rtas_data_buf[RTAS_DATA_BUF_SIZE] __cacheline_aligned; | ||
43 | unsigned long rtas_rmo_buf; | ||
44 | |||
45 | /* | ||
46 | * call_rtas_display_status and call_rtas_display_status_delay | ||
47 | * are designed only for very early low-level debugging, which | ||
48 | * is why the token is hard-coded to 10. | ||
49 | */ | ||
50 | void call_rtas_display_status(unsigned char c) | ||
51 | { | ||
52 | struct rtas_args *args = &rtas.args; | ||
53 | unsigned long s; | ||
54 | |||
55 | if (!rtas.base) | ||
56 | return; | ||
57 | spin_lock_irqsave(&rtas.lock, s); | ||
58 | |||
59 | args->token = 10; | ||
60 | args->nargs = 1; | ||
61 | args->nret = 1; | ||
62 | args->rets = (rtas_arg_t *)&(args->args[1]); | ||
63 | args->args[0] = (int)c; | ||
64 | |||
65 | enter_rtas(__pa(args)); | ||
66 | |||
67 | spin_unlock_irqrestore(&rtas.lock, s); | ||
68 | } | ||
69 | |||
70 | void 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 rtas_progress(char *s, unsigned short hex) | ||
95 | { | ||
96 | struct device_node *root; | ||
97 | int width, *p; | ||
98 | char *os; | ||
99 | static int display_character, set_indicator; | ||
100 | static int display_width, display_lines, *row_width, form_feed; | ||
101 | static DEFINE_SPINLOCK(progress_lock); | ||
102 | static int current_line; | ||
103 | static int pending_newline = 0; /* did last write end with unprinted newline? */ | ||
104 | |||
105 | if (!rtas.base) | ||
106 | return; | ||
107 | |||
108 | if (display_width == 0) { | ||
109 | display_width = 0x10; | ||
110 | if ((root = find_path_device("/rtas"))) { | ||
111 | if ((p = (unsigned int *)get_property(root, | ||
112 | "ibm,display-line-length", NULL))) | ||
113 | display_width = *p; | ||
114 | if ((p = (unsigned int *)get_property(root, | ||
115 | "ibm,form-feed", NULL))) | ||
116 | form_feed = *p; | ||
117 | if ((p = (unsigned int *)get_property(root, | ||
118 | "ibm,display-number-of-lines", NULL))) | ||
119 | display_lines = *p; | ||
120 | row_width = (unsigned int *)get_property(root, | ||
121 | "ibm,display-truncation-length", NULL); | ||
122 | } | ||
123 | display_character = rtas_token("display-character"); | ||
124 | set_indicator = rtas_token("set-indicator"); | ||
125 | } | ||
126 | |||
127 | if (display_character == RTAS_UNKNOWN_SERVICE) { | ||
128 | /* use hex display if available */ | ||
129 | if (set_indicator != RTAS_UNKNOWN_SERVICE) | ||
130 | rtas_call(set_indicator, 3, 1, NULL, 6, 0, hex); | ||
131 | return; | ||
132 | } | ||
133 | |||
134 | spin_lock(&progress_lock); | ||
135 | |||
136 | /* | ||
137 | * Last write ended with newline, but we didn't print it since | ||
138 | * it would just clear the bottom line of output. Print it now | ||
139 | * instead. | ||
140 | * | ||
141 | * If no newline is pending and form feed is supported, clear the | ||
142 | * display with a form feed; otherwise, print a CR to start output | ||
143 | * at the beginning of the line. | ||
144 | */ | ||
145 | if (pending_newline) { | ||
146 | rtas_call(display_character, 1, 1, NULL, '\r'); | ||
147 | rtas_call(display_character, 1, 1, NULL, '\n'); | ||
148 | pending_newline = 0; | ||
149 | } else { | ||
150 | current_line = 0; | ||
151 | if (form_feed) | ||
152 | rtas_call(display_character, 1, 1, NULL, | ||
153 | (char)form_feed); | ||
154 | else | ||
155 | rtas_call(display_character, 1, 1, NULL, '\r'); | ||
156 | } | ||
157 | |||
158 | if (row_width) | ||
159 | width = row_width[current_line]; | ||
160 | else | ||
161 | width = display_width; | ||
162 | os = s; | ||
163 | while (*os) { | ||
164 | if (*os == '\n' || *os == '\r') { | ||
165 | /* If newline is the last character, save it | ||
166 | * until next call to avoid bumping up the | ||
167 | * display output. | ||
168 | */ | ||
169 | if (*os == '\n' && !os[1]) { | ||
170 | pending_newline = 1; | ||
171 | current_line++; | ||
172 | if (current_line > display_lines-1) | ||
173 | current_line = display_lines-1; | ||
174 | spin_unlock(&progress_lock); | ||
175 | return; | ||
176 | } | ||
177 | |||
178 | /* RTAS wants CR-LF, not just LF */ | ||
179 | |||
180 | if (*os == '\n') { | ||
181 | rtas_call(display_character, 1, 1, NULL, '\r'); | ||
182 | rtas_call(display_character, 1, 1, NULL, '\n'); | ||
183 | } else { | ||
184 | /* CR might be used to re-draw a line, so we'll | ||
185 | * leave it alone and not add LF. | ||
186 | */ | ||
187 | rtas_call(display_character, 1, 1, NULL, *os); | ||
188 | } | ||
189 | |||
190 | if (row_width) | ||
191 | width = row_width[current_line]; | ||
192 | else | ||
193 | width = display_width; | ||
194 | } else { | ||
195 | width--; | ||
196 | rtas_call(display_character, 1, 1, NULL, *os); | ||
197 | } | ||
198 | |||
199 | os++; | ||
200 | |||
201 | /* if we overwrite the screen length */ | ||
202 | if (width <= 0) | ||
203 | while ((*os != 0) && (*os != '\n') && (*os != '\r')) | ||
204 | os++; | ||
205 | } | ||
206 | |||
207 | spin_unlock(&progress_lock); | ||
208 | } | ||
209 | |||
210 | int rtas_token(const char *service) | ||
211 | { | ||
212 | int *tokp; | ||
213 | if (rtas.dev == NULL) | ||
214 | return RTAS_UNKNOWN_SERVICE; | ||
215 | tokp = (int *) get_property(rtas.dev, service, NULL); | ||
216 | return tokp ? *tokp : RTAS_UNKNOWN_SERVICE; | ||
217 | } | ||
218 | |||
219 | #ifdef CONFIG_RTAS_ERROR_LOGGING | ||
220 | /* | ||
221 | * Return the firmware-specified size of the error log buffer | ||
222 | * for all rtas calls that require an error buffer argument. | ||
223 | * This includes 'check-exception' and 'rtas-last-error'. | ||
224 | */ | ||
225 | int rtas_get_error_log_max(void) | ||
226 | { | ||
227 | static int rtas_error_log_max; | ||
228 | if (rtas_error_log_max) | ||
229 | return rtas_error_log_max; | ||
230 | |||
231 | rtas_error_log_max = rtas_token ("rtas-error-log-max"); | ||
232 | if ((rtas_error_log_max == RTAS_UNKNOWN_SERVICE) || | ||
233 | (rtas_error_log_max > RTAS_ERROR_LOG_MAX)) { | ||
234 | printk (KERN_WARNING "RTAS: bad log buffer size %d\n", | ||
235 | rtas_error_log_max); | ||
236 | rtas_error_log_max = RTAS_ERROR_LOG_MAX; | ||
237 | } | ||
238 | return rtas_error_log_max; | ||
239 | } | ||
240 | EXPORT_SYMBOL(rtas_get_error_log_max); | ||
241 | |||
242 | |||
243 | char rtas_err_buf[RTAS_ERROR_LOG_MAX]; | ||
244 | int rtas_last_error_token; | ||
245 | |||
246 | /** Return a copy of the detailed error text associated with the | ||
247 | * most recent failed call to rtas. Because the error text | ||
248 | * might go stale if there are any other intervening rtas calls, | ||
249 | * this routine must be called atomically with whatever produced | ||
250 | * the error (i.e. with rtas.lock still held from the previous call). | ||
251 | */ | ||
252 | static char *__fetch_rtas_last_error(char *altbuf) | ||
253 | { | ||
254 | struct rtas_args err_args, save_args; | ||
255 | u32 bufsz; | ||
256 | char *buf = NULL; | ||
257 | |||
258 | if (rtas_last_error_token == -1) | ||
259 | return NULL; | ||
260 | |||
261 | bufsz = rtas_get_error_log_max(); | ||
262 | |||
263 | err_args.token = rtas_last_error_token; | ||
264 | err_args.nargs = 2; | ||
265 | err_args.nret = 1; | ||
266 | err_args.args[0] = (rtas_arg_t)__pa(rtas_err_buf); | ||
267 | err_args.args[1] = bufsz; | ||
268 | err_args.args[2] = 0; | ||
269 | |||
270 | save_args = rtas.args; | ||
271 | rtas.args = err_args; | ||
272 | |||
273 | enter_rtas(__pa(&rtas.args)); | ||
274 | |||
275 | err_args = rtas.args; | ||
276 | rtas.args = save_args; | ||
277 | |||
278 | /* Log the error in the unlikely case that there was one. */ | ||
279 | if (unlikely(err_args.args[2] == 0)) { | ||
280 | if (altbuf) { | ||
281 | buf = altbuf; | ||
282 | } else { | ||
283 | buf = rtas_err_buf; | ||
284 | if (mem_init_done) | ||
285 | buf = kmalloc(RTAS_ERROR_LOG_MAX, GFP_ATOMIC); | ||
286 | } | ||
287 | if (buf) | ||
288 | memcpy(buf, rtas_err_buf, RTAS_ERROR_LOG_MAX); | ||
289 | } | ||
290 | |||
291 | return buf; | ||
292 | } | ||
293 | |||
294 | #define get_errorlog_buffer() kmalloc(RTAS_ERROR_LOG_MAX, GFP_KERNEL) | ||
295 | |||
296 | #else /* CONFIG_RTAS_ERROR_LOGGING */ | ||
297 | #define __fetch_rtas_last_error(x) NULL | ||
298 | #define get_errorlog_buffer() NULL | ||
299 | #endif | ||
300 | |||
301 | int rtas_call(int token, int nargs, int nret, int *outputs, ...) | ||
302 | { | ||
303 | va_list list; | ||
304 | int i; | ||
305 | unsigned long s; | ||
306 | struct rtas_args *rtas_args; | ||
307 | char *buff_copy = NULL; | ||
308 | int ret; | ||
309 | |||
310 | if (token == RTAS_UNKNOWN_SERVICE) | ||
311 | return -1; | ||
312 | |||
313 | /* Gotta do something different here, use global lock for now... */ | ||
314 | spin_lock_irqsave(&rtas.lock, s); | ||
315 | rtas_args = &rtas.args; | ||
316 | |||
317 | rtas_args->token = token; | ||
318 | rtas_args->nargs = nargs; | ||
319 | rtas_args->nret = nret; | ||
320 | rtas_args->rets = (rtas_arg_t *)&(rtas_args->args[nargs]); | ||
321 | va_start(list, outputs); | ||
322 | for (i = 0; i < nargs; ++i) | ||
323 | rtas_args->args[i] = va_arg(list, rtas_arg_t); | ||
324 | va_end(list); | ||
325 | |||
326 | for (i = 0; i < nret; ++i) | ||
327 | rtas_args->rets[i] = 0; | ||
328 | |||
329 | enter_rtas(__pa(rtas_args)); | ||
330 | |||
331 | /* A -1 return code indicates that the last command couldn't | ||
332 | be completed due to a hardware error. */ | ||
333 | if (rtas_args->rets[0] == -1) | ||
334 | buff_copy = __fetch_rtas_last_error(NULL); | ||
335 | |||
336 | if (nret > 1 && outputs != NULL) | ||
337 | for (i = 0; i < nret-1; ++i) | ||
338 | outputs[i] = rtas_args->rets[i+1]; | ||
339 | ret = (nret > 0)? rtas_args->rets[0]: 0; | ||
340 | |||
341 | /* Gotta do something different here, use global lock for now... */ | ||
342 | spin_unlock_irqrestore(&rtas.lock, s); | ||
343 | |||
344 | if (buff_copy) { | ||
345 | log_error(buff_copy, ERR_TYPE_RTAS_LOG, 0); | ||
346 | if (mem_init_done) | ||
347 | kfree(buff_copy); | ||
348 | } | ||
349 | return ret; | ||
350 | } | ||
351 | |||
352 | /* Given an RTAS status code of 990n compute the hinted delay of 10^n | ||
353 | * (last digit) milliseconds. For now we bound at n=5 (100 sec). | ||
354 | */ | ||
355 | unsigned int rtas_extended_busy_delay_time(int status) | ||
356 | { | ||
357 | int order = status - 9900; | ||
358 | unsigned long ms; | ||
359 | |||
360 | if (order < 0) | ||
361 | order = 0; /* RTC depends on this for -2 clock busy */ | ||
362 | else if (order > 5) | ||
363 | order = 5; /* bound */ | ||
364 | |||
365 | /* Use microseconds for reasonable accuracy */ | ||
366 | for (ms = 1; order > 0; order--) | ||
367 | ms *= 10; | ||
368 | |||
369 | return ms; | ||
370 | } | ||
371 | |||
372 | int rtas_error_rc(int rtas_rc) | ||
373 | { | ||
374 | int rc; | ||
375 | |||
376 | switch (rtas_rc) { | ||
377 | case -1: /* Hardware Error */ | ||
378 | rc = -EIO; | ||
379 | break; | ||
380 | case -3: /* Bad indicator/domain/etc */ | ||
381 | rc = -EINVAL; | ||
382 | break; | ||
383 | case -9000: /* Isolation error */ | ||
384 | rc = -EFAULT; | ||
385 | break; | ||
386 | case -9001: /* Outstanding TCE/PTE */ | ||
387 | rc = -EEXIST; | ||
388 | break; | ||
389 | case -9002: /* No usable slot */ | ||
390 | rc = -ENODEV; | ||
391 | break; | ||
392 | default: | ||
393 | printk(KERN_ERR "%s: unexpected RTAS error %d\n", | ||
394 | __FUNCTION__, rtas_rc); | ||
395 | rc = -ERANGE; | ||
396 | break; | ||
397 | } | ||
398 | return rc; | ||
399 | } | ||
400 | |||
401 | int rtas_get_power_level(int powerdomain, int *level) | ||
402 | { | ||
403 | int token = rtas_token("get-power-level"); | ||
404 | int rc; | ||
405 | |||
406 | if (token == RTAS_UNKNOWN_SERVICE) | ||
407 | return -ENOENT; | ||
408 | |||
409 | while ((rc = rtas_call(token, 1, 2, level, powerdomain)) == RTAS_BUSY) | ||
410 | udelay(1); | ||
411 | |||
412 | if (rc < 0) | ||
413 | return rtas_error_rc(rc); | ||
414 | return rc; | ||
415 | } | ||
416 | |||
417 | int rtas_set_power_level(int powerdomain, int level, int *setlevel) | ||
418 | { | ||
419 | int token = rtas_token("set-power-level"); | ||
420 | unsigned int wait_time; | ||
421 | int rc; | ||
422 | |||
423 | if (token == RTAS_UNKNOWN_SERVICE) | ||
424 | return -ENOENT; | ||
425 | |||
426 | while (1) { | ||
427 | rc = rtas_call(token, 2, 2, setlevel, powerdomain, level); | ||
428 | if (rc == RTAS_BUSY) | ||
429 | udelay(1); | ||
430 | else if (rtas_is_extended_busy(rc)) { | ||
431 | wait_time = rtas_extended_busy_delay_time(rc); | ||
432 | udelay(wait_time * 1000); | ||
433 | } else | ||
434 | break; | ||
435 | } | ||
436 | |||
437 | if (rc < 0) | ||
438 | return rtas_error_rc(rc); | ||
439 | return rc; | ||
440 | } | ||
441 | |||
442 | int rtas_get_sensor(int sensor, int index, int *state) | ||
443 | { | ||
444 | int token = rtas_token("get-sensor-state"); | ||
445 | unsigned int wait_time; | ||
446 | int rc; | ||
447 | |||
448 | if (token == RTAS_UNKNOWN_SERVICE) | ||
449 | return -ENOENT; | ||
450 | |||
451 | while (1) { | ||
452 | rc = rtas_call(token, 2, 2, state, sensor, index); | ||
453 | if (rc == RTAS_BUSY) | ||
454 | udelay(1); | ||
455 | else if (rtas_is_extended_busy(rc)) { | ||
456 | wait_time = rtas_extended_busy_delay_time(rc); | ||
457 | udelay(wait_time * 1000); | ||
458 | } else | ||
459 | break; | ||
460 | } | ||
461 | |||
462 | if (rc < 0) | ||
463 | return rtas_error_rc(rc); | ||
464 | return rc; | ||
465 | } | ||
466 | |||
467 | int rtas_set_indicator(int indicator, int index, int new_value) | ||
468 | { | ||
469 | int token = rtas_token("set-indicator"); | ||
470 | unsigned int wait_time; | ||
471 | int rc; | ||
472 | |||
473 | if (token == RTAS_UNKNOWN_SERVICE) | ||
474 | return -ENOENT; | ||
475 | |||
476 | while (1) { | ||
477 | rc = rtas_call(token, 3, 1, NULL, indicator, index, new_value); | ||
478 | if (rc == RTAS_BUSY) | ||
479 | udelay(1); | ||
480 | else if (rtas_is_extended_busy(rc)) { | ||
481 | wait_time = rtas_extended_busy_delay_time(rc); | ||
482 | udelay(wait_time * 1000); | ||
483 | } | ||
484 | else | ||
485 | break; | ||
486 | } | ||
487 | |||
488 | if (rc < 0) | ||
489 | return rtas_error_rc(rc); | ||
490 | return rc; | ||
491 | } | ||
492 | |||
493 | void rtas_restart(char *cmd) | ||
494 | { | ||
495 | printk("RTAS system-reboot returned %d\n", | ||
496 | rtas_call(rtas_token("system-reboot"), 0, 1, NULL)); | ||
497 | for (;;); | ||
498 | } | ||
499 | |||
500 | void rtas_power_off(void) | ||
501 | { | ||
502 | /* allow power on only with power button press */ | ||
503 | printk("RTAS power-off returned %d\n", | ||
504 | rtas_call(rtas_token("power-off"), 2, 1, NULL, -1, -1)); | ||
505 | for (;;); | ||
506 | } | ||
507 | |||
508 | void rtas_halt(void) | ||
509 | { | ||
510 | rtas_power_off(); | ||
511 | } | ||
512 | |||
513 | /* Must be in the RMO region, so we place it here */ | ||
514 | static char rtas_os_term_buf[2048]; | ||
515 | |||
516 | void rtas_os_term(char *str) | ||
517 | { | ||
518 | int status; | ||
519 | |||
520 | if (RTAS_UNKNOWN_SERVICE == rtas_token("ibm,os-term")) | ||
521 | return; | ||
522 | |||
523 | snprintf(rtas_os_term_buf, 2048, "OS panic: %s", str); | ||
524 | |||
525 | do { | ||
526 | status = rtas_call(rtas_token("ibm,os-term"), 1, 1, NULL, | ||
527 | __pa(rtas_os_term_buf)); | ||
528 | |||
529 | if (status == RTAS_BUSY) | ||
530 | udelay(1); | ||
531 | else if (status != 0) | ||
532 | printk(KERN_EMERG "ibm,os-term call failed %d\n", | ||
533 | status); | ||
534 | } while (status == RTAS_BUSY); | ||
535 | } | ||
536 | |||
537 | |||
538 | asmlinkage int ppc_rtas(struct rtas_args __user *uargs) | ||
539 | { | ||
540 | struct rtas_args args; | ||
541 | unsigned long flags; | ||
542 | char *buff_copy, *errbuf = NULL; | ||
543 | int nargs; | ||
544 | |||
545 | if (!capable(CAP_SYS_ADMIN)) | ||
546 | return -EPERM; | ||
547 | |||
548 | if (copy_from_user(&args, uargs, 3 * sizeof(u32)) != 0) | ||
549 | return -EFAULT; | ||
550 | |||
551 | nargs = args.nargs; | ||
552 | if (nargs > ARRAY_SIZE(args.args) | ||
553 | || args.nret > ARRAY_SIZE(args.args) | ||
554 | || nargs + args.nret > ARRAY_SIZE(args.args)) | ||
555 | return -EINVAL; | ||
556 | |||
557 | /* Copy in args. */ | ||
558 | if (copy_from_user(args.args, uargs->args, | ||
559 | nargs * sizeof(rtas_arg_t)) != 0) | ||
560 | return -EFAULT; | ||
561 | |||
562 | buff_copy = get_errorlog_buffer(); | ||
563 | |||
564 | spin_lock_irqsave(&rtas.lock, flags); | ||
565 | |||
566 | rtas.args = args; | ||
567 | enter_rtas(__pa(&rtas.args)); | ||
568 | args = rtas.args; | ||
569 | |||
570 | args.rets = &args.args[nargs]; | ||
571 | |||
572 | /* A -1 return code indicates that the last command couldn't | ||
573 | be completed due to a hardware error. */ | ||
574 | if (args.rets[0] == -1) | ||
575 | errbuf = __fetch_rtas_last_error(buff_copy); | ||
576 | |||
577 | spin_unlock_irqrestore(&rtas.lock, flags); | ||
578 | |||
579 | if (buff_copy) { | ||
580 | if (errbuf) | ||
581 | log_error(errbuf, ERR_TYPE_RTAS_LOG, 0); | ||
582 | kfree(buff_copy); | ||
583 | } | ||
584 | |||
585 | /* Copy out args. */ | ||
586 | if (copy_to_user(uargs->args + nargs, | ||
587 | args.args + nargs, | ||
588 | args.nret * sizeof(rtas_arg_t)) != 0) | ||
589 | return -EFAULT; | ||
590 | |||
591 | return 0; | ||
592 | } | ||
593 | |||
594 | #ifdef CONFIG_SMP | ||
595 | /* This version can't take the spinlock, because it never returns */ | ||
596 | |||
597 | struct rtas_args rtas_stop_self_args = { | ||
598 | /* The token is initialized for real in setup_system() */ | ||
599 | .token = RTAS_UNKNOWN_SERVICE, | ||
600 | .nargs = 0, | ||
601 | .nret = 1, | ||
602 | .rets = &rtas_stop_self_args.args[0], | ||
603 | }; | ||
604 | |||
605 | void rtas_stop_self(void) | ||
606 | { | ||
607 | struct rtas_args *rtas_args = &rtas_stop_self_args; | ||
608 | |||
609 | local_irq_disable(); | ||
610 | |||
611 | BUG_ON(rtas_args->token == RTAS_UNKNOWN_SERVICE); | ||
612 | |||
613 | printk("cpu %u (hwid %u) Ready to die...\n", | ||
614 | smp_processor_id(), hard_smp_processor_id()); | ||
615 | enter_rtas(__pa(rtas_args)); | ||
616 | |||
617 | panic("Alas, I survived.\n"); | ||
618 | } | ||
619 | #endif | ||
620 | |||
621 | /* | ||
622 | * Call early during boot, before mem init or bootmem, to retreive the RTAS | ||
623 | * informations from the device-tree and allocate the RMO buffer for userland | ||
624 | * accesses. | ||
625 | */ | ||
626 | void __init rtas_initialize(void) | ||
627 | { | ||
628 | unsigned long rtas_region = RTAS_INSTANTIATE_MAX; | ||
629 | |||
630 | /* Get RTAS dev node and fill up our "rtas" structure with infos | ||
631 | * about it. | ||
632 | */ | ||
633 | rtas.dev = of_find_node_by_name(NULL, "rtas"); | ||
634 | if (rtas.dev) { | ||
635 | u32 *basep, *entryp; | ||
636 | u32 *sizep; | ||
637 | |||
638 | basep = (u32 *)get_property(rtas.dev, "linux,rtas-base", NULL); | ||
639 | sizep = (u32 *)get_property(rtas.dev, "rtas-size", NULL); | ||
640 | if (basep != NULL && sizep != NULL) { | ||
641 | rtas.base = *basep; | ||
642 | rtas.size = *sizep; | ||
643 | entryp = (u32 *)get_property(rtas.dev, "linux,rtas-entry", NULL); | ||
644 | if (entryp == NULL) /* Ugh */ | ||
645 | rtas.entry = rtas.base; | ||
646 | else | ||
647 | rtas.entry = *entryp; | ||
648 | } else | ||
649 | rtas.dev = NULL; | ||
650 | } | ||
651 | if (!rtas.dev) | ||
652 | return; | ||
653 | |||
654 | /* If RTAS was found, allocate the RMO buffer for it and look for | ||
655 | * the stop-self token if any | ||
656 | */ | ||
657 | #ifdef CONFIG_PPC64 | ||
658 | if (systemcfg->platform == PLATFORM_PSERIES_LPAR) | ||
659 | rtas_region = min(lmb.rmo_size, RTAS_INSTANTIATE_MAX); | ||
660 | #endif | ||
661 | rtas_rmo_buf = lmb_alloc_base(RTAS_RMOBUF_MAX, PAGE_SIZE, rtas_region); | ||
662 | |||
663 | #ifdef CONFIG_HOTPLUG_CPU | ||
664 | rtas_stop_self_args.token = rtas_token("stop-self"); | ||
665 | #endif /* CONFIG_HOTPLUG_CPU */ | ||
666 | #ifdef CONFIG_RTAS_ERROR_LOGGING | ||
667 | rtas_last_error_token = rtas_token("rtas-last-error"); | ||
668 | #endif | ||
669 | } | ||
670 | |||
671 | |||
672 | EXPORT_SYMBOL(rtas_token); | ||
673 | EXPORT_SYMBOL(rtas_call); | ||
674 | EXPORT_SYMBOL(rtas_data_buf); | ||
675 | EXPORT_SYMBOL(rtas_data_buf_lock); | ||
676 | EXPORT_SYMBOL(rtas_extended_busy_delay_time); | ||
677 | EXPORT_SYMBOL(rtas_get_sensor); | ||
678 | EXPORT_SYMBOL(rtas_get_power_level); | ||
679 | EXPORT_SYMBOL(rtas_set_power_level); | ||
680 | EXPORT_SYMBOL(rtas_set_indicator); | ||
diff --git a/arch/powerpc/platforms/pseries/Kconfig b/arch/powerpc/platforms/pseries/Kconfig index 7a3b6fc4d976..2d57f588151d 100644 --- a/arch/powerpc/platforms/pseries/Kconfig +++ b/arch/powerpc/platforms/pseries/Kconfig | |||
@@ -21,11 +21,6 @@ config EEH | |||
21 | depends on PPC_PSERIES | 21 | depends on PPC_PSERIES |
22 | default y if !EMBEDDED | 22 | default y if !EMBEDDED |
23 | 23 | ||
24 | config PPC_RTAS | ||
25 | bool | ||
26 | depends on PPC_PSERIES || PPC_BPA | ||
27 | default y | ||
28 | |||
29 | config RTAS_PROC | 24 | config RTAS_PROC |
30 | bool "Proc interface to RTAS" | 25 | bool "Proc interface to RTAS" |
31 | depends on PPC_RTAS | 26 | depends on PPC_RTAS |
diff --git a/arch/powerpc/platforms/pseries/Makefile b/arch/powerpc/platforms/pseries/Makefile index 4c817304fc21..d5c160b789e3 100644 --- a/arch/powerpc/platforms/pseries/Makefile +++ b/arch/powerpc/platforms/pseries/Makefile | |||
@@ -1,4 +1,4 @@ | |||
1 | obj-y := pci.o lpar.o hvCall.o nvram.o reconfig.o \ | 1 | obj-y := pci.o lpar.o hvCall.o nvram.o reconfig.o \ |
2 | setup.o iommu.o ras.o | 2 | setup.o iommu.o rtas-fw.o ras.o |
3 | obj-$(CONFIG_SMP) += smp.o | 3 | obj-$(CONFIG_SMP) += smp.o |
4 | obj-$(CONFIG_IBMVIO) += vio.o | 4 | obj-$(CONFIG_IBMVIO) += vio.o |
diff --git a/arch/powerpc/platforms/pseries/rtas-fw.c b/arch/powerpc/platforms/pseries/rtas-fw.c new file mode 100644 index 000000000000..15d81d758ca0 --- /dev/null +++ b/arch/powerpc/platforms/pseries/rtas-fw.c | |||
@@ -0,0 +1,138 @@ | |||
1 | /* | ||
2 | * | ||
3 | * Procedures for firmware flash updates on pSeries systems. | ||
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 | #include "rtas-fw.h" | ||
35 | |||
36 | struct flash_block_list_header rtas_firmware_flash_list = {0, NULL}; | ||
37 | |||
38 | #define FLASH_BLOCK_LIST_VERSION (1UL) | ||
39 | |||
40 | static void rtas_flash_firmware(void) | ||
41 | { | ||
42 | unsigned long image_size; | ||
43 | struct flash_block_list *f, *next, *flist; | ||
44 | unsigned long rtas_block_list; | ||
45 | int i, status, update_token; | ||
46 | |||
47 | update_token = rtas_token("ibm,update-flash-64-and-reboot"); | ||
48 | if (update_token == RTAS_UNKNOWN_SERVICE) { | ||
49 | printk(KERN_ALERT "FLASH: ibm,update-flash-64-and-reboot is not available -- not a service partition?\n"); | ||
50 | printk(KERN_ALERT "FLASH: firmware will not be flashed\n"); | ||
51 | return; | ||
52 | } | ||
53 | |||
54 | /* NOTE: the "first" block list is a global var with no data | ||
55 | * blocks in the kernel data segment. We do this because | ||
56 | * we want to ensure this block_list addr is under 4GB. | ||
57 | */ | ||
58 | rtas_firmware_flash_list.num_blocks = 0; | ||
59 | flist = (struct flash_block_list *)&rtas_firmware_flash_list; | ||
60 | rtas_block_list = virt_to_abs(flist); | ||
61 | if (rtas_block_list >= 4UL*1024*1024*1024) { | ||
62 | printk(KERN_ALERT "FLASH: kernel bug...flash list header addr above 4GB\n"); | ||
63 | return; | ||
64 | } | ||
65 | |||
66 | printk(KERN_ALERT "FLASH: preparing saved firmware image for flash\n"); | ||
67 | /* Update the block_list in place. */ | ||
68 | image_size = 0; | ||
69 | for (f = flist; f; f = next) { | ||
70 | /* Translate data addrs to absolute */ | ||
71 | for (i = 0; i < f->num_blocks; i++) { | ||
72 | f->blocks[i].data = (char *)virt_to_abs(f->blocks[i].data); | ||
73 | image_size += f->blocks[i].length; | ||
74 | } | ||
75 | next = f->next; | ||
76 | /* Don't translate NULL pointer for last entry */ | ||
77 | if (f->next) | ||
78 | f->next = (struct flash_block_list *)virt_to_abs(f->next); | ||
79 | else | ||
80 | f->next = NULL; | ||
81 | /* make num_blocks into the version/length field */ | ||
82 | f->num_blocks = (FLASH_BLOCK_LIST_VERSION << 56) | ((f->num_blocks+1)*16); | ||
83 | } | ||
84 | |||
85 | printk(KERN_ALERT "FLASH: flash image is %ld bytes\n", image_size); | ||
86 | printk(KERN_ALERT "FLASH: performing flash and reboot\n"); | ||
87 | rtas_progress("Flashing \n", 0x0); | ||
88 | rtas_progress("Please Wait... ", 0x0); | ||
89 | printk(KERN_ALERT "FLASH: this will take several minutes. Do not power off!\n"); | ||
90 | status = rtas_call(update_token, 1, 1, NULL, rtas_block_list); | ||
91 | switch (status) { /* should only get "bad" status */ | ||
92 | case 0: | ||
93 | printk(KERN_ALERT "FLASH: success\n"); | ||
94 | break; | ||
95 | case -1: | ||
96 | printk(KERN_ALERT "FLASH: hardware error. Firmware may not be not flashed\n"); | ||
97 | break; | ||
98 | case -3: | ||
99 | printk(KERN_ALERT "FLASH: image is corrupt or not correct for this platform. Firmware not flashed\n"); | ||
100 | break; | ||
101 | case -4: | ||
102 | printk(KERN_ALERT "FLASH: flash failed when partially complete. System may not reboot\n"); | ||
103 | break; | ||
104 | default: | ||
105 | printk(KERN_ALERT "FLASH: unknown flash return code %d\n", status); | ||
106 | break; | ||
107 | } | ||
108 | } | ||
109 | |||
110 | void rtas_flash_bypass_warning(void) | ||
111 | { | ||
112 | printk(KERN_ALERT "FLASH: firmware flash requires a reboot\n"); | ||
113 | printk(KERN_ALERT "FLASH: the firmware image will NOT be flashed\n"); | ||
114 | } | ||
115 | |||
116 | |||
117 | void rtas_fw_restart(char *cmd) | ||
118 | { | ||
119 | if (rtas_firmware_flash_list.next) | ||
120 | rtas_flash_firmware(); | ||
121 | rtas_restart(cmd); | ||
122 | } | ||
123 | |||
124 | void rtas_fw_power_off(void) | ||
125 | { | ||
126 | if (rtas_firmware_flash_list.next) | ||
127 | rtas_flash_bypass_warning(); | ||
128 | rtas_power_off(); | ||
129 | } | ||
130 | |||
131 | void rtas_fw_halt(void) | ||
132 | { | ||
133 | if (rtas_firmware_flash_list.next) | ||
134 | rtas_flash_bypass_warning(); | ||
135 | rtas_halt(); | ||
136 | } | ||
137 | |||
138 | EXPORT_SYMBOL(rtas_firmware_flash_list); | ||
diff --git a/arch/powerpc/platforms/pseries/rtas-fw.h b/arch/powerpc/platforms/pseries/rtas-fw.h new file mode 100644 index 000000000000..e70fa69974a3 --- /dev/null +++ b/arch/powerpc/platforms/pseries/rtas-fw.h | |||
@@ -0,0 +1,3 @@ | |||
1 | void rtas_fw_restart(char *cmd); | ||
2 | void rtas_fw_power_off(void); | ||
3 | void rtas_fw_halt(void); | ||
diff --git a/arch/powerpc/platforms/pseries/setup.c b/arch/powerpc/platforms/pseries/setup.c index 0fa5beae6d1b..7e7e556e6b48 100644 --- a/arch/powerpc/platforms/pseries/setup.c +++ b/arch/powerpc/platforms/pseries/setup.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * linux/arch/ppc/kernel/setup.c | 2 | * 64-bit pSeries and RS/6000 setup code. |
3 | * | 3 | * |
4 | * Copyright (C) 1995 Linus Torvalds | 4 | * Copyright (C) 1995 Linus Torvalds |
5 | * Adapted from 'alpha' version by Gary Thomas | 5 | * Adapted from 'alpha' version by Gary Thomas |
@@ -67,6 +67,8 @@ | |||
67 | #include <asm/i8259.h> | 67 | #include <asm/i8259.h> |
68 | #include <asm/udbg.h> | 68 | #include <asm/udbg.h> |
69 | 69 | ||
70 | #include "rtas-fw.h" | ||
71 | |||
70 | #ifdef DEBUG | 72 | #ifdef DEBUG |
71 | #define DBG(fmt...) udbg_printf(fmt) | 73 | #define DBG(fmt...) udbg_printf(fmt) |
72 | #else | 74 | #else |
@@ -589,9 +591,9 @@ struct machdep_calls __initdata pSeries_md = { | |||
589 | .pcibios_fixup = pSeries_final_fixup, | 591 | .pcibios_fixup = pSeries_final_fixup, |
590 | .pci_probe_mode = pSeries_pci_probe_mode, | 592 | .pci_probe_mode = pSeries_pci_probe_mode, |
591 | .irq_bus_setup = pSeries_irq_bus_setup, | 593 | .irq_bus_setup = pSeries_irq_bus_setup, |
592 | .restart = rtas_restart, | 594 | .restart = rtas_fw_restart, |
593 | .power_off = rtas_power_off, | 595 | .power_off = rtas_fw_power_off, |
594 | .halt = rtas_halt, | 596 | .halt = rtas_fw_halt, |
595 | .panic = rtas_os_term, | 597 | .panic = rtas_os_term, |
596 | .cpu_die = pSeries_mach_cpu_die, | 598 | .cpu_die = pSeries_mach_cpu_die, |
597 | .get_boot_time = rtas_get_boot_time, | 599 | .get_boot_time = rtas_get_boot_time, |