1 /* console.c - console interface layer for U-Boot platforms */
3 * GRUB -- GRand Unified Bootloader
4 * Copyright (C) 2013 Free Software Foundation, Inc.
6 * GRUB is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * GRUB is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
20 #include <grub/term.h>
21 #include <grub/misc.h>
22 #include <grub/types.h>
24 #include <grub/terminfo.h>
25 #include <grub/uboot/uboot.h>
26 #include <grub/uboot/console.h>
29 put (struct grub_term_output
*term
__attribute__ ((unused
)), const int c
)
35 readkey (struct grub_term_input
*term
__attribute__ ((unused
)))
37 if (grub_uboot_tstc () > 0)
38 return grub_uboot_getc ();
44 uboot_console_setcursor (struct grub_term_output
*term
45 __attribute__ ((unused
)), int on
46 __attribute__ ((unused
)))
48 grub_terminfo_setcursor (term
, on
);
52 uboot_console_init_input (struct grub_term_input
*term
)
54 return grub_terminfo_input_init (term
);
57 extern struct grub_terminfo_output_state uboot_console_terminfo_output
;
61 uboot_console_init_output (struct grub_term_output
*term
)
63 grub_terminfo_output_init (term
);
68 struct grub_terminfo_input_state uboot_console_terminfo_input
= {
72 struct grub_terminfo_output_state uboot_console_terminfo_output
= {
74 /* FIXME: In rare cases when console isn't serial,
75 determine real width. */
79 static struct grub_term_input uboot_console_term_input
= {
81 .init
= uboot_console_init_input
,
82 .getkey
= grub_terminfo_getkey
,
83 .data
= &uboot_console_terminfo_input
86 static struct grub_term_output uboot_console_term_output
= {
88 .init
= uboot_console_init_output
,
89 .putchar
= grub_terminfo_putchar
,
90 .getwh
= grub_terminfo_getwh
,
91 .getxy
= grub_terminfo_getxy
,
92 .gotoxy
= grub_terminfo_gotoxy
,
93 .cls
= grub_terminfo_cls
,
94 .setcolorstate
= grub_terminfo_setcolorstate
,
95 .setcursor
= uboot_console_setcursor
,
96 .flags
= GRUB_TERM_CODE_TYPE_ASCII
,
97 .data
= &uboot_console_terminfo_output
,
98 .progress_update_divisor
= GRUB_PROGRESS_FAST
102 grub_console_init_early (void)
104 grub_term_register_input ("console", &uboot_console_term_input
);
105 grub_term_register_output ("console", &uboot_console_term_output
);
110 * grub_console_init_lately():
111 * Initializes terminfo formatting by registering terminal type.
112 * Called after heap has been configured.
116 grub_console_init_lately (void)
120 /* See if explicitly set by U-Boot environment */
121 type
= grub_uboot_env_get ("grub_term");
125 grub_terminfo_init ();
126 grub_terminfo_output_register (&uboot_console_term_output
, type
);
130 grub_console_fini (void)