24
24
#include <grub/efi/api.h>
25
25
#include <grub/efi/console.h>
27
static const grub_uint8_t
28
28
grub_console_standard_color = GRUB_EFI_TEXT_ATTR (GRUB_EFI_YELLOW,
29
29
GRUB_EFI_BACKGROUND_BLACK);
31
grub_console_normal_color = GRUB_EFI_TEXT_ATTR (GRUB_EFI_LIGHTGRAY,
32
GRUB_EFI_BACKGROUND_BLACK);
34
grub_console_highlight_color = GRUB_EFI_TEXT_ATTR (GRUB_EFI_BLACK,
35
GRUB_EFI_BACKGROUND_LIGHTGRAY);
37
31
static int read_key = -1;
39
33
static grub_uint32_t
40
34
map_char (grub_uint32_t c)
36
/* Map some unicode characters to the EFI character. */
44
/* Map some unicode characters to the EFI character. */
47
case 0x2190: /* left arrow */
50
case 0x2191: /* up arrow */
53
case 0x2192: /* right arrow */
56
case 0x2193: /* down arrow */
59
case 0x2501: /* horizontal line */
62
case 0x2503: /* vertical line */
65
case 0x250F: /* upper-left corner */
68
case 0x2513: /* upper-right corner */
71
case 0x2517: /* lower-left corner */
74
case 0x251B: /* lower-right corner */
39
case GRUB_UNICODE_LEFTARROW:
40
c = GRUB_UNICODE_BLACK_LEFT_TRIANGLE;
42
case GRUB_UNICODE_UPARROW:
43
c = GRUB_UNICODE_BLACK_UP_TRIANGLE;
45
case GRUB_UNICODE_RIGHTARROW:
46
c = GRUB_UNICODE_BLACK_RIGHT_TRIANGLE;
48
case GRUB_UNICODE_DOWNARROW:
49
c = GRUB_UNICODE_BLACK_DOWN_TRIANGLE;
51
case GRUB_UNICODE_HLINE:
52
c = GRUB_UNICODE_LIGHT_HLINE;
54
case GRUB_UNICODE_VLINE:
55
c = GRUB_UNICODE_LIGHT_VLINE;
57
case GRUB_UNICODE_CORNER_UL:
58
c = GRUB_UNICODE_LIGHT_CORNER_UL;
60
case GRUB_UNICODE_CORNER_UR:
61
c = GRUB_UNICODE_LIGHT_CORNER_UR;
63
case GRUB_UNICODE_CORNER_LL:
64
c = GRUB_UNICODE_LIGHT_CORNER_LL;
66
case GRUB_UNICODE_CORNER_LR:
67
c = GRUB_UNICODE_LIGHT_CORNER_LR;
88
grub_console_putchar (grub_uint32_t c)
75
grub_console_putchar (struct grub_term_output *term __attribute__ ((unused)),
76
const struct grub_unicode_glyph *c)
90
grub_efi_char16_t str[2];
78
grub_efi_char16_t str[2 + c->ncomb];
91
79
grub_efi_simple_text_output_interface_t *o;
93
82
o = grub_efi_system_table->con_out;
95
84
/* For now, do not try to use a surrogate pair. */
99
str[0] = (grub_efi_char16_t) map_char (c & 0xffff);
88
str[0] = (grub_efi_char16_t) map_char (c->base & 0xffff);
90
for (i = 0; i < c->ncomb; i++)
92
str[j++] = c->combining[i].code;
102
95
/* Should this test be cached? */
103
if (c > 0x7f && efi_call_2 (o->test_string, o, str) != GRUB_EFI_SUCCESS)
96
if ((c->base > 0x7f || c->ncomb)
97
&& efi_call_2 (o->test_string, o, str) != GRUB_EFI_SUCCESS)
106
100
efi_call_2 (o->output_string, o, str);
110
grub_console_getcharwidth (grub_uint32_t c __attribute__ ((unused)))
112
/* For now, every printable character has the width 1. */
117
grub_console_checkkey (void)
104
grub_console_checkkey (struct grub_term_input *term __attribute__ ((unused)))
119
106
grub_efi_simple_input_interface_t *i;
120
107
grub_efi_input_key_t key;
302
291
efi_call_2 (o->set_attributes, o, grub_console_standard_color);
304
293
case GRUB_TERM_COLOR_NORMAL:
305
efi_call_2 (o->set_attributes, o, grub_console_normal_color);
294
efi_call_2 (o->set_attributes, o, term->normal_color);
307
296
case GRUB_TERM_COLOR_HIGHLIGHT:
308
efi_call_2 (o->set_attributes, o, grub_console_highlight_color);
297
efi_call_2 (o->set_attributes, o, term->highlight_color);
316
grub_console_setcolor (grub_uint8_t normal_color, grub_uint8_t highlight_color)
318
grub_console_normal_color = normal_color;
319
grub_console_highlight_color = highlight_color;
323
grub_console_getcolor (grub_uint8_t *normal_color, grub_uint8_t *highlight_color)
325
*normal_color = grub_console_normal_color;
326
*highlight_color = grub_console_highlight_color;
330
grub_console_setcursor (int on)
305
grub_console_setcursor (struct grub_term_output *term __attribute__ ((unused)),
332
308
grub_efi_simple_text_output_interface_t *o;
347
323
.name = "console",
348
324
.putchar = grub_console_putchar,
349
.getcharwidth = grub_console_getcharwidth,
350
325
.getwh = grub_console_getwh,
351
326
.getxy = grub_console_getxy,
352
327
.gotoxy = grub_console_gotoxy,
353
328
.cls = grub_console_cls,
354
329
.setcolorstate = grub_console_setcolorstate,
355
.setcolor = grub_console_setcolor,
356
.getcolor = grub_console_getcolor,
357
.setcursor = grub_console_setcursor
330
.setcursor = grub_console_setcursor,
331
.normal_color = GRUB_EFI_TEXT_ATTR (GRUB_EFI_LIGHTGRAY,
332
GRUB_EFI_BACKGROUND_BLACK),
333
.highlight_color = GRUB_EFI_TEXT_ATTR (GRUB_EFI_BLACK,
334
GRUB_EFI_BACKGROUND_LIGHTGRAY),
335
.flags = GRUB_TERM_CODE_TYPE_VISUAL_GLYPHS