Fix EFI and IEEE1275

This commit is contained in:
Vladimir 'phcoder' Serbinenko 2010-03-16 00:23:49 +01:00
parent 023e3a5ca7
commit 9a3355cfde
2 changed files with 30 additions and 61 deletions

View file

@ -85,29 +85,35 @@ map_char (grub_uint32_t c)
} }
static void static void
grub_console_putchar (grub_uint32_t c) grub_console_putchar (const struct grub_unicode_glyph *c)
{ {
grub_efi_char16_t str[2]; grub_efi_char16_t str[2 + c->ncomb];
grub_efi_simple_text_output_interface_t *o; grub_efi_simple_text_output_interface_t *o;
unsigned i, j;
o = grub_efi_system_table->con_out; o = grub_efi_system_table->con_out;
/* For now, do not try to use a surrogate pair. */ /* For now, do not try to use a surrogate pair. */
if (c > 0xffff) if (c->base > 0xffff)
c = '?'; str[0] = '?';
else
str[0] = (grub_efi_char16_t) map_char (c & 0xffff); str[0] = (grub_efi_char16_t) map_char (c->base & 0xffff);
str[1] = 0; j = 1;
for (i = 0; i < c->ncomb; i++)
if (c->base < 0xffff)
str[j++] = c->combining[i].code;
str[j] = 0;
/* Should this test be cached? */ /* Should this test be cached? */
if (c > 0x7f && efi_call_2 (o->test_string, o, str) != GRUB_EFI_SUCCESS) if ((c->base > 0x7f || c->ncomb)
&& efi_call_2 (o->test_string, o, str) != GRUB_EFI_SUCCESS)
return; return;
efi_call_2 (o->output_string, o, str); efi_call_2 (o->output_string, o, str);
} }
static grub_ssize_t static grub_ssize_t
grub_console_getcharwidth (grub_uint32_t c __attribute__ ((unused))) grub_console_getcharwidth (const struct grub_unicode_glyph *c __attribute__ ((unused)))
{ {
/* For now, every printable character has the width 1. */ /* For now, every printable character has the width 1. */
return 1; return 1;
@ -351,7 +357,8 @@ static struct grub_term_output grub_console_term_output =
.setcolorstate = grub_console_setcolorstate, .setcolorstate = grub_console_setcolorstate,
.setcolor = grub_console_setcolor, .setcolor = grub_console_setcolor,
.getcolor = grub_console_getcolor, .getcolor = grub_console_getcolor,
.setcursor = grub_console_setcursor .setcursor = grub_console_setcursor,
.flags = GRUB_TERM_CODE_TYPE_UCS4_VISUAL
}; };
void void

View file

@ -76,60 +76,18 @@ grub_ofconsole_writeesc (const char *str)
} }
static void static void
grub_ofconsole_putchar (grub_uint32_t c) grub_ofconsole_putchar (const struct grub_unicode_glyph *c)
{ {
char chr; char chr;
if (c > 0x7F) chr = c->base;
{
/* Better than nothing. */
switch (c)
{
case GRUB_TERM_DISP_LEFT:
c = '<';
break;
case GRUB_TERM_DISP_UP:
c = '^';
break;
case GRUB_TERM_DISP_RIGHT: if (chr == '\n')
c = '>';
break;
case GRUB_TERM_DISP_DOWN:
c = 'v';
break;
case GRUB_TERM_DISP_HLINE:
c = '-';
break;
case GRUB_TERM_DISP_VLINE:
c = '|';
break;
case GRUB_TERM_DISP_UL:
case GRUB_TERM_DISP_UR:
case GRUB_TERM_DISP_LL:
case GRUB_TERM_DISP_LR:
c = '+';
break;
default:
c = '?';
break;
}
}
chr = c;
if (c == '\n')
{ {
grub_curr_y++; grub_curr_y++;
grub_curr_x = 0; grub_curr_x = 0;
} }
else if (c == '\r') else if (chr == '\r')
{ {
grub_curr_x = 0; grub_curr_x = 0;
} }
@ -138,16 +96,19 @@ grub_ofconsole_putchar (grub_uint32_t c)
grub_curr_x++; grub_curr_x++;
if (grub_curr_x >= grub_ofconsole_width) if (grub_curr_x >= grub_ofconsole_width)
{ {
grub_ofconsole_putchar ('\n'); chr = '\n';
grub_ofconsole_putchar ('\r'); grub_ieee1275_write (stdout_ihandle, &chr, 1, 0);
grub_curr_x++; chr = '\r';
grub_ieee1275_write (stdout_ihandle, &chr, 1, 0);
grub_curr_y++;
grub_curr_x = 1;
} }
} }
grub_ieee1275_write (stdout_ihandle, &chr, 1, 0); grub_ieee1275_write (stdout_ihandle, &chr, 1, 0);
} }
static grub_ssize_t static grub_ssize_t
grub_ofconsole_getcharwidth (grub_uint32_t c __attribute__((unused))) grub_ofconsole_getcharwidth (const struct grub_unicode_glyph *c __attribute__((unused)))
{ {
return 1; return 1;
} }
@ -497,7 +458,8 @@ static struct grub_term_output grub_ofconsole_term_output =
.setcolor = grub_ofconsole_setcolor, .setcolor = grub_ofconsole_setcolor,
.getcolor = grub_ofconsole_getcolor, .getcolor = grub_ofconsole_getcolor,
.setcursor = grub_ofconsole_setcursor, .setcursor = grub_ofconsole_setcursor,
.refresh = grub_ofconsole_refresh .refresh = grub_ofconsole_refresh,
.flags = GRUB_TERM_CODE_TYPE_ASCII
}; };
void void