Add support to run SMM handler in TSEG instead of ASEG
[coreboot.git] / src / console / vtxprintf.c
index 3c75e3d7041d97bcbf5816fb52a05fb498627151..a370e5f21ddd591cef4c08fbc74e7117b47675b4 100644 (file)
@@ -6,6 +6,7 @@
 
 #include <string.h>
 #include <div64.h>
+#include <console/console.h>
 #include <console/vtxprintf.h>
 
 /* haha, don't need ctype.c */
@@ -30,7 +31,7 @@ static int skip_atoi(const char **s)
 #define SPECIAL        32              /* 0x */
 #define LARGE  64              /* use 'ABCDEF' instead of 'abcdef' */
 
-static int number(void (*tx_byte)(unsigned char byte), 
+static int number(void (*tx_byte)(unsigned char byte),
        unsigned long long num, int base, int size, int precision, int type)
 {
        char c,sign,tmp[66];
@@ -112,18 +113,23 @@ int vtxprintf(void (*tx_byte)(unsigned char byte), const char *fmt, va_list args
        int precision;          /* min. # of digits for integers; max
                                   number of chars for from string */
        int qualifier;          /* 'h', 'l', or 'L' for integer fields */
-       
+
        int count;
 
+#if defined(__SMM__) && CONFIG_SMM_TSEG
+       /* Fix pointer in TSEG */
+       tx_byte = console_tx_byte;
+#endif
+
        for (count=0; *fmt ; ++fmt) {
                if (*fmt != '%') {
                        tx_byte(*fmt), count++;
                        continue;
                }
-                       
+
                /* process flags */
                flags = 0;
-               repeat:
+repeat:
                        ++fmt;          /* this also skips first '%' */
                        switch (*fmt) {
                                case '-': flags |= LEFT; goto repeat;
@@ -132,7 +138,7 @@ int vtxprintf(void (*tx_byte)(unsigned char byte), const char *fmt, va_list args
                                case '#': flags |= SPECIAL; goto repeat;
                                case '0': flags |= ZEROPAD; goto repeat;
                                }
-               
+
                /* get field width */
                field_width = -1;
                if (is_digit(*fmt))
@@ -150,7 +156,7 @@ int vtxprintf(void (*tx_byte)(unsigned char byte), const char *fmt, va_list args
                /* get the precision */
                precision = -1;
                if (*fmt == '.') {
-                       ++fmt;  
+                       ++fmt;
                        if (is_digit(*fmt))
                                precision = skip_atoi(&fmt);
                        else if (*fmt == '*') {