aboutsummaryrefslogtreecommitdiffstats
path: root/arch/ppc64/kernel/rtas.c
diff options
context:
space:
mode:
authorArnd Bergmann <arnd@arndb.de>2005-06-22 19:43:28 -0400
committerPaul Mackerras <paulus@samba.org>2005-06-22 19:43:28 -0400
commit6566c6f1f18d42affe73ccdd403e290b64d10473 (patch)
tree9c9cdea21d05e52a60044abf339e9750c6760f0a /arch/ppc64/kernel/rtas.c
parentc5a3c2e52af1bcb118022ffac9a0fd1d42d43bd3 (diff)
[PATCH] ppc64: pSeries_progress -> rtas_progress
The pSeries_progress function is called from some places in the rtas code, which may also be used by non-pSeries platforms. Though pSeries is currently the only platform type that implements display-character, the code is actually generic enough to be part of the rtas subsystem. I hit a bug here because the generic rtas code tried calling ppc_md.progress, which points to an __init function on most platforms. We could also clear the ppc_md.progress pointer when freeing the init memory to make it more explicit that ppc_md.progress must not be called after bootup. Signed-off-by: Arnd Bergmann <arndb@de.ibm.com> Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'arch/ppc64/kernel/rtas.c')
-rw-r--r--arch/ppc64/kernel/rtas.c106
1 files changed, 104 insertions, 2 deletions
diff --git a/arch/ppc64/kernel/rtas.c b/arch/ppc64/kernel/rtas.c
index 5575603def27..43e1518653d5 100644
--- a/arch/ppc64/kernel/rtas.c
+++ b/arch/ppc64/kernel/rtas.c
@@ -91,6 +91,108 @@ call_rtas_display_status_delay(unsigned char c)
91 } 91 }
92} 92}
93 93
94void
95rtas_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
94int 196int
95rtas_token(const char *service) 197rtas_token(const char *service)
96{ 198{
@@ -425,8 +527,8 @@ rtas_flash_firmware(void)
425 527
426 printk(KERN_ALERT "FLASH: flash image is %ld bytes\n", image_size); 528 printk(KERN_ALERT "FLASH: flash image is %ld bytes\n", image_size);
427 printk(KERN_ALERT "FLASH: performing flash and reboot\n"); 529 printk(KERN_ALERT "FLASH: performing flash and reboot\n");
428 ppc_md.progress("Flashing \n", 0x0); 530 rtas_progress("Flashing \n", 0x0);
429 ppc_md.progress("Please Wait... ", 0x0); 531 rtas_progress("Please Wait... ", 0x0);
430 printk(KERN_ALERT "FLASH: this will take several minutes. Do not power off!\n"); 532 printk(KERN_ALERT "FLASH: this will take several minutes. Do not power off!\n");
431 status = rtas_call(update_token, 1, 1, NULL, rtas_block_list); 533 status = rtas_call(update_token, 1, 1, NULL, rtas_block_list);
432 switch (status) { /* should only get "bad" status */ 534 switch (status) { /* should only get "bad" status */