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
This commit is contained in:
Warner Losh 2016-05-17 14:10:45 +00:00
parent c205f958b4
commit d4d32e5899
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=300056
3 changed files with 7 additions and 1 deletions

View File

@ -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 */

View File

@ -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 @@ printf(const char *fmt, ...)
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':

View File

@ -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,