]> git.proxmox.com Git - grub2.git/blob - grub-core/term/i386/pc/console.c
merge mainline to ia64
[grub2.git] / grub-core / term / i386 / pc / console.c
1 /*
2 * GRUB -- GRand Unified Bootloader
3 * Copyright (C) 2002,2003,2005,2007,2008,2009 Free Software Foundation, Inc.
4 *
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.
9 *
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.
14 *
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/>.
17 */
18
19 #include <grub/machine/memory.h>
20 #include <grub/machine/console.h>
21 #include <grub/term.h>
22 #include <grub/types.h>
23
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;
26
27 static int
28 grub_console_getkeystatus (struct grub_term_input *term __attribute__ ((unused)))
29 {
30 /* conveniently GRUB keystatus is modelled after BIOS one. */
31 return bios_data_area->keyboard_flag_lower & ~0x80;
32 }
33
34 static struct grub_term_input grub_console_term_input =
35 {
36 .name = "console",
37 .getkey = grub_console_getkey,
38 .getkeystatus = grub_console_getkeystatus
39 };
40
41 static struct grub_term_output grub_console_term_output =
42 {
43 .name = "console",
44 .putchar = grub_console_putchar,
45 .getwh = grub_console_getwh,
46 .getxy = grub_console_getxy,
47 .gotoxy = grub_console_gotoxy,
48 .cls = grub_console_cls,
49 .setcolorstate = grub_console_setcolorstate,
50 .setcursor = grub_console_setcursor,
51 .flags = GRUB_TERM_CODE_TYPE_CP437,
52 .normal_color = GRUB_TERM_DEFAULT_NORMAL_COLOR,
53 .highlight_color = GRUB_TERM_DEFAULT_HIGHLIGHT_COLOR,
54 };
55
56 void
57 grub_console_init (void)
58 {
59 grub_term_register_output ("console", &grub_console_term_output);
60 grub_term_register_input ("console", &grub_console_term_input);
61 }
62
63 void
64 grub_console_fini (void)
65 {
66 grub_term_unregister_input (&grub_console_term_input);
67 grub_term_unregister_output (&grub_console_term_output);
68 }