source: grub-pc/trunk/fuentes/grub-core/term/uboot/console.c @ 22

Last change on this file since 22 was 22, checked in by mabarracus, 4 years ago

updated version and apply net.ifnames=0 into debian/rules

File size: 3.3 KB
Line 
1/* console.c - console interface layer for U-Boot platforms */
2/*
3 *  GRUB  --  GRand Unified Bootloader
4 *  Copyright (C) 2013  Free Software Foundation, Inc.
5 *
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.
10 *
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.
15 *
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/>.
18 */
19
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>
27
28static void
29put (struct grub_term_output *term __attribute__ ((unused)), const int c)
30{
31  grub_uboot_putc (c);
32}
33
34static int
35readkey (struct grub_term_input *term __attribute__ ((unused)))
36{
37  if (grub_uboot_tstc () > 0)
38    return grub_uboot_getc ();
39
40  return -1;
41}
42
43static void
44uboot_console_setcursor (struct grub_term_output *term
45                         __attribute__ ((unused)), int on
46                         __attribute__ ((unused)))
47{
48  grub_terminfo_setcursor (term, on);
49}
50
51static grub_err_t
52uboot_console_init_input (struct grub_term_input *term)
53{
54  return grub_terminfo_input_init (term);
55}
56
57extern struct grub_terminfo_output_state uboot_console_terminfo_output;
58
59
60static grub_err_t
61uboot_console_init_output (struct grub_term_output *term)
62{
63  grub_terminfo_output_init (term);
64
65  return 0;
66}
67
68struct grub_terminfo_input_state uboot_console_terminfo_input = {
69  .readkey = readkey
70};
71
72struct 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 }
77};
78
79static 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
84};
85
86static 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
99};
100
101void
102grub_console_init_early (void)
103{
104  grub_term_register_input ("console", &uboot_console_term_input);
105  grub_term_register_output ("console", &uboot_console_term_output);
106}
107
108
109/*
110 * grub_console_init_lately():
111 *   Initializes terminfo formatting by registering terminal type.
112 *   Called after heap has been configured.
113 *   
114 */
115void
116grub_console_init_lately (void)
117{
118  const char *type;
119
120  /* See if explicitly set by U-Boot environment */
121  type = grub_uboot_env_get ("grub_term");
122  if (!type)
123    type = "vt100";
124
125  grub_terminfo_init ();
126  grub_terminfo_output_register (&uboot_console_term_output, type);
127}
128
129void
130grub_console_fini (void)
131{
132}
Note: See TracBrowser for help on using the repository browser.