Author: imp
Date: Tue May 17 14:10:45 2016
New Revision: 300056
URL: https://svnweb.freebsd.org/changeset/base/300056

Log:
  It sure would be nice to use printf with wide strings. Implement %S to
  do that. The C_WIDEOUT flag indicates that the console supports
  it. Mark the EFI console as supporting this.
  
  MFC After: 3 days

Modified:
  head/sys/boot/common/bootstrap.h
  head/sys/boot/common/util.c
  head/sys/boot/efi/libefi/efi_console.c

Modified: head/sys/boot/common/bootstrap.h
==============================================================================
--- head/sys/boot/common/bootstrap.h    Tue May 17 14:10:44 2016        
(r300055)
+++ head/sys/boot/common/bootstrap.h    Tue May 17 14:10:45 2016        
(r300056)
@@ -102,6 +102,7 @@ struct console 
 #define C_PRESENTOUT   (1<<1)      /* console can provide output */
 #define C_ACTIVEIN     (1<<2)      /* user wants input from console */
 #define C_ACTIVEOUT    (1<<3)      /* user wants output to console */
+#define        C_WIDEOUT       (1<<4)      /* c_out routine groks wide chars */
     void       (* c_probe)(struct console *cp);        /* set c_flags to match 
hardware */
     int                (* c_init)(int arg);                    /* reinit XXX 
may need more args */
     void       (* c_out)(int c);                       /* emit c */

Modified: head/sys/boot/common/util.c
==============================================================================
--- head/sys/boot/common/util.c Tue May 17 14:10:44 2016        (r300055)
+++ head/sys/boot/common/util.c Tue May 17 14:10:45 2016        (r300056)
@@ -120,6 +120,7 @@ printf(const char *fmt, ...)
        va_list ap;
        const char *hex = "0123456789abcdef";
        char buf[32], *s;
+       uint16_t *S;
        unsigned long long u;
        int c, l;
 
@@ -143,6 +144,10 @@ nextfmt:
                        for (s = va_arg(ap, char *); *s != '\0'; s++)
                                putchar(*s);
                        break;
+               case 'S':       /* Assume console can cope with wide chars */
+                       for (S = va_arg(ap, uint16_t *); *S != 0; S++)
+                               putchar(*S);
+                       break;
                case 'd':       /* A lie, always prints unsigned */
                case 'u':
                case 'x':

Modified: head/sys/boot/efi/libefi/efi_console.c
==============================================================================
--- head/sys/boot/efi/libefi/efi_console.c      Tue May 17 14:10:44 2016        
(r300055)
+++ head/sys/boot/efi/libefi/efi_console.c      Tue May 17 14:10:45 2016        
(r300056)
@@ -61,7 +61,7 @@ int efi_cons_poll(void);
 struct console efi_console = {
        "efi",
        "EFI console",
-       0,
+       C_WIDEOUT,
        efi_cons_probe,
        efi_cons_init,
        efi_cons_putchar,
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to