2 * Copyright (C) Paul Mackerras 1997.
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version
7 * 2 of the License, or (at your option) any later version.
12 extern int strlen(const char *s);
13 extern void boot(int a1, int a2, void *prom);
19 void printk(char *fmt, ...);
22 start(int a1, int a2, void *promptr)
25 if (ofstdio(&stdin, &stdout, &stderr))
28 boot(a1, a2, promptr);
33 int writestring(void *f, char *ptr, int nb)
38 for (i = 0; i < nb; ++i) {
41 write(f, ptr + w, i - w);
48 write(f, ptr + w, nb - w);
57 return writestring(f, &ch, 1) == 1? c: -1;
63 return putc(c, stdout);
67 fputs(char *str, void *f)
71 return writestring(f, str, n) == n? 0: -1;
80 switch (read(stdin, &ch, 1)) {
84 printk("read(stdin) returned -1\n");
90 static char line[256];
103 if (c == -1 || c == 4)
105 if (c == '\r' || c == '\n') {
113 if (lineptr > line) {
121 while (lineptr > line) {
129 if (lineptr >= &line[sizeof(line) - 1])
137 lineleft = lineptr - line;
146 extern int vsprintf(char *buf, const char *fmt, va_list args);
147 static char sprint_buf[1024];
150 printk(char *fmt, ...)
156 n = vsprintf(sprint_buf, fmt, args);
158 writestring(stdout, sprint_buf, n);
162 printf(char *fmt, ...)
168 n = vsprintf(sprint_buf, fmt, args);
170 writestring(stdout, sprint_buf, n);