[SeaBIOS] [PATCH v2 1/6] output: add 64bit hex print support

Gerd Hoffmann kraxel at redhat.com
Wed Feb 29 12:45:05 CET 2012


---
 src/output.c |   23 +++++++++++++++++++++--
 1 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/src/output.c b/src/output.c
index bdde7cc..32cbcaa 100644
--- a/src/output.c
+++ b/src/output.c
@@ -249,6 +249,7 @@ bvprintf(struct putcinfo *action, const char *fmt, va_list args)
         const char *n = s+1;
         int field_width = 0;
         int spacepad = 1;
+        int is64 = 0;
         for (;;) {
             c = GET_GLOBAL(*(u8*)n);
             if (!isdigit(c))
@@ -264,6 +265,11 @@ bvprintf(struct putcinfo *action, const char *fmt, va_list args)
             n++;
             c = GET_GLOBAL(*(u8*)n);
         }
+        if (c == 'l') {
+            is64 = 1;
+            n++;
+            c = GET_GLOBAL(*(u8*)n);
+        }
         s32 val;
         const char *sarg;
         switch (c) {
@@ -289,8 +295,21 @@ bvprintf(struct putcinfo *action, const char *fmt, va_list args)
             field_width = 8;
             spacepad = 0;
         case 'x':
-            val = va_arg(args, s32);
-            puthex(action, val, field_width, spacepad);
+            if (is64) {
+                val = va_arg(args, s32);
+                u32 upper = va_arg(args, s32);
+                if (upper) {
+                    if (field_width < 8)
+                        field_width = 8;
+                    puthex(action, upper, field_width - 8, spacepad);
+                    puthex(action, val, 8, 0);
+                } else {
+                    puthex(action, val, field_width, spacepad);
+                }
+            } else {
+                val = va_arg(args, s32);
+                puthex(action, val, field_width, spacepad);
+            }
             break;
         case 'c':
             val = va_arg(args, int);
-- 
1.7.1




More information about the SeaBIOS mailing list