]> git.sur5r.net Git - u-boot/blobdiff - lib/tiny-printf.c
mx6slevk: Avoid hardcoded RAM size
[u-boot] / lib / tiny-printf.c
index 4b70263df7d73992c2a858205f45370d31f7056a..b334f053cc0ee2645aa3669701f0ec22419bb572 100644 (file)
 #include <stdarg.h>
 #include <serial.h>
 
-static char *bf;
-static char zs;
+/*
+ * This code in here may execute before the DRAM is initialised, so
+ * we should make sure that it doesn't touch BSS, which some boards
+ * put in DRAM.
+ */
+static char *bf __attribute__ ((section(".data")));
+static char zs __attribute__ ((section(".data")));
 
 /* Current position in sprintf() output string */
-static char *outstr;
+static char *outstr __attribute__ ((section(".data")));
 
 static void out(char c)
 {
@@ -130,6 +135,11 @@ abort:
        return 0;
 }
 
+int vprintf(const char *fmt, va_list va)
+{
+       return _vprintf(fmt, va, putc);
+}
+
 int printf(const char *fmt, ...)
 {
        va_list va;
@@ -147,6 +157,20 @@ static void putc_outstr(char ch)
        *outstr++ = ch;
 }
 
+int sprintf(char *buf, const char *fmt, ...)
+{
+       va_list va;
+       int ret;
+
+       va_start(va, fmt);
+       outstr = buf;
+       ret = _vprintf(fmt, va, putc_outstr);
+       va_end(va);
+       *outstr = '\0';
+
+       return ret;
+}
+
 /* Note that size is ignored */
 int snprintf(char *buf, size_t size, const char *fmt, ...)
 {