aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarius Strobl <marius@FreeBSD.org>2012-01-27 22:29:29 +0000
committerMarius Strobl <marius@FreeBSD.org>2012-01-27 22:29:29 +0000
commit1cbb2a240865343a3f6956a643c377b6d4965eb3 (patch)
tree642957e354cdf5ffccd4ac7d31bed4a081a7fd91
parent21bbe2ac13e3f0bda1bdae7e0a2e1a56fd480eb7 (diff)
downloadsrc-1cbb2a240865343a3f6956a643c377b6d4965eb3.tar.gz
src-1cbb2a240865343a3f6956a643c377b6d4965eb3.zip
Implement OF_printf() using kvprintf() directly, avoiding to use a
buffer and allowing to handle newlines properly
Notes
Notes: svn path=/head/; revision=230631
-rw-r--r--sys/dev/ofw/openfirm.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/sys/dev/ofw/openfirm.c b/sys/dev/ofw/openfirm.c
index af6ee80695e5..4be2d2bc119b 100644
--- a/sys/dev/ofw/openfirm.c
+++ b/sys/dev/ofw/openfirm.c
@@ -72,6 +72,8 @@ __FBSDID("$FreeBSD$");
#include "ofw_if.h"
+static void OF_putchar(int c, void *arg);
+
MALLOC_DEFINE(M_OFWPROP, "openfirm", "Open Firmware properties");
static ihandle_t stdout;
@@ -82,7 +84,7 @@ static struct ofw_kobj ofw_kernel_obj;
static struct kobj_ops ofw_kernel_kops;
/*
- * OFW install routines. Highest priority wins, equal priority also
+ * OFW install routines. Highest priority wins, equal priority also
* overrides allowing last-set to win.
*/
SET_DECLARE(ofw_set, ofw_def_t);
@@ -138,15 +140,27 @@ OF_init(void *cookie)
return (rv);
}
+static void
+OF_putchar(int c, void *arg __unused)
+{
+ char cbuf;
+
+ if (c == '\n') {
+ cbuf = '\r';
+ OF_write(stdout, &cbuf, 1);
+ }
+
+ cbuf = c;
+ OF_write(stdout, &cbuf, 1);
+}
+
void
OF_printf(const char *fmt, ...)
{
va_list va;
- char buf[1024];
va_start(va, fmt);
- vsprintf(buf, fmt, va);
- OF_write(stdout, buf, strlen(buf));
+ (void)kvprintf(fmt, OF_putchar, NULL, 10, va);
va_end(va);
}