Indentation fix, cleanup.
[AROS.git] / arch / all-pc / boot / grub2-aros / grub-core / term / uboot / console.c
blobdfdbe990948d3981921750c01038f4198dd9957c
1 /* console.c - console interface layer for U-Boot platforms */
2 /*
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>
23 #include <grub/err.h>
24 #include <grub/terminfo.h>
25 #include <grub/uboot/uboot.h>
26 #include <grub/uboot/console.h>
28 static void
29 put (struct grub_term_output *term __attribute__ ((unused)), const int c)
31 grub_uboot_putc (c);
34 static int
35 readkey (struct grub_term_input *term __attribute__ ((unused)))
37 if (grub_uboot_tstc () > 0)
38 return grub_uboot_getc ();
40 return -1;
43 static void
44 uboot_console_setcursor (struct grub_term_output *term
45 __attribute__ ((unused)), int on
46 __attribute__ ((unused)))
48 grub_terminfo_setcursor (term, on);
51 static grub_err_t
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;
60 static grub_err_t
61 uboot_console_init_output (struct grub_term_output *term)
63 grub_terminfo_output_init (term);
65 return 0;
68 struct grub_terminfo_input_state uboot_console_terminfo_input = {
69 .readkey = readkey
72 struct grub_terminfo_output_state uboot_console_terminfo_output = {
73 .put = put,
74 /* FIXME: In rare cases when console isn't serial,
75 determine real width. */
76 .size = { 80, 24 }
79 static struct grub_term_input uboot_console_term_input = {
80 .name = "console",
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 = {
87 .name = "console",
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
101 void
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.
115 void
116 grub_console_init_lately (void)
118 const char *type;
120 /* See if explicitly set by U-Boot environment */
121 type = grub_uboot_env_get ("grub_term");
122 if (!type)
123 type = "vt100";
125 grub_terminfo_init ();
126 grub_terminfo_output_register (&uboot_console_term_output, type);
129 void
130 grub_console_fini (void)