2 * GRUB -- GRand Unified Bootloader
3 * Copyright (C) 2002,2003,2005,2007,2008,2009 Free Software Foundation, Inc.
5 * GRUB is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
10 * GRUB is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
19 #include <grub/machine/memory.h>
20 #include <grub/machine/console.h>
21 #include <grub/term.h>
22 #include <grub/types.h>
24 static const struct grub_machine_bios_data_area
*bios_data_area
=
25 (struct grub_machine_bios_data_area
*) GRUB_MEMORY_MACHINE_BIOS_DATA_AREA_ADDR
;
27 #define KEYBOARD_LEFT_SHIFT (1 << 0)
28 #define KEYBOARD_RIGHT_SHIFT (1 << 1)
29 #define KEYBOARD_CTRL (1 << 2)
30 #define KEYBOARD_ALT (1 << 3)
33 grub_console_getkeystatus (struct grub_term_input
*term
__attribute__ ((unused
)))
35 grub_uint8_t status
= bios_data_area
->keyboard_flag_lower
;
38 if (status
& (KEYBOARD_LEFT_SHIFT
| KEYBOARD_RIGHT_SHIFT
))
39 mods
|= GRUB_TERM_STATUS_SHIFT
;
40 if (status
& KEYBOARD_CTRL
)
41 mods
|= GRUB_TERM_STATUS_CTRL
;
42 if (status
& KEYBOARD_ALT
)
43 mods
|= GRUB_TERM_STATUS_ALT
;
48 static struct grub_term_input grub_console_term_input
=
51 .checkkey
= grub_console_checkkey
,
52 .getkey
= grub_console_getkey
,
53 .getkeystatus
= grub_console_getkeystatus
,
56 static struct grub_term_output grub_console_term_output
=
59 .putchar
= grub_console_putchar
,
60 .getwh
= grub_console_getwh
,
61 .getxy
= grub_console_getxy
,
62 .gotoxy
= grub_console_gotoxy
,
63 .cls
= grub_console_cls
,
64 .setcolorstate
= grub_console_setcolorstate
,
65 .setcursor
= grub_console_setcursor
,
66 .flags
= GRUB_TERM_CODE_TYPE_CP437
,
67 .normal_color
= GRUB_TERM_DEFAULT_NORMAL_COLOR
,
68 .highlight_color
= GRUB_TERM_DEFAULT_HIGHLIGHT_COLOR
,
72 grub_console_init (void)
74 grub_term_register_output ("console", &grub_console_term_output
);
75 grub_term_register_input ("console", &grub_console_term_input
);
79 grub_console_fini (void)
81 grub_term_unregister_input (&grub_console_term_input
);
82 grub_term_unregister_output (&grub_console_term_output
);