]> git.ipfire.org Git - people/ms/u-boot.git/blobdiff - lib/efi_selftest/efi_selftest_console.c
Merge tag 'xilinx-for-v2018.03' of git://git.denx.de/u-boot-microblaze
[people/ms/u-boot.git] / lib / efi_selftest / efi_selftest_console.c
index 6a7fd20da5c51b008fd0794b07c96345c50225cc..e1649f48bc4bc874add10169a4e0a6cf41eb127a 100644 (file)
@@ -130,22 +130,25 @@ static void int2dec(s32 value, u16 **buf)
 }
 
 /*
- * Print a formatted string to the EFI console
+ * Print a colored formatted string to the EFI console
  *
- * @fmt: format string
- * @...: optional arguments
+ * @color      color, see constants in efi_api.h, use -1 for no color
+ * @fmt                format string
+ * @...                optional arguments
  */
-void efi_st_printf(const char *fmt, ...)
+void efi_st_printc(int color, const char *fmt, ...)
 {
        va_list args;
        u16 buf[160];
        const char *c;
        u16 *pos = buf;
        const char *s;
-       const u16 *u;
+       u16 *u;
 
        va_start(args, fmt);
 
+       if (color >= 0)
+               con_out->set_attribute(con_out, (unsigned long)color);
        c = fmt;
        for (; *c; ++c) {
                switch (*c) {
@@ -188,9 +191,13 @@ void efi_st_printf(const char *fmt, ...)
                                /* u16 string */
                                case 's':
                                        u = va_arg(args, u16*);
-                                       /* Ensure string fits into buffer */
-                                       for (; *u && pos < buf + 120; ++u)
-                                               *pos++ = *u;
+                                       if (pos > buf) {
+                                               *pos = 0;
+                                               con_out->output_string(con_out,
+                                                                      buf);
+                                       }
+                                       con_out->output_string(con_out, u);
+                                       pos = buf;
                                        break;
                                default:
                                        --c;
@@ -216,6 +223,8 @@ void efi_st_printf(const char *fmt, ...)
        va_end(args);
        *pos = 0;
        con_out->output_string(con_out, buf);
+       if (color >= 0)
+               con_out->set_attribute(con_out, EFI_LIGHTGRAY);
 }
 
 /*