2 * Copyright (C) 1996-2005 Paul Mackerras.
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.
9 #include <linux/string.h>
15 static int xmon_write(const void *ptr
, int nb
)
17 return udbg_write(ptr
, nb
);
20 static int xmon_readchar(void)
27 int xmon_putchar(int c
)
33 return xmon_write(&ch
, 1) == 1? c
: -1;
36 static char line
[256];
40 static int xmon_getchar(void)
48 if (c
== -1 || c
== 4)
50 if (c
== '\r' || c
== '\n') {
66 while (lineptr
> line
) {
74 if (lineptr
>= &line
[sizeof(line
) - 1])
82 lineleft
= lineptr
- line
;
91 char *xmon_gets(char *str
, int nb
)
96 for (p
= str
; p
< str
+ nb
- 1; ) {
111 void xmon_printf(const char *format
, ...)
114 static char xmon_outbuf
[1024];
117 va_start(args
, format
);
118 n
= vsnprintf(xmon_outbuf
, sizeof(xmon_outbuf
), format
, args
);
121 rc
= xmon_write(xmon_outbuf
, n
);
124 /* No udbg hooks, fallback to printk() - dangerous */
129 void xmon_puts(const char *str
)
131 xmon_write(str
, strlen(str
));