2 * GRUB -- GRand Unified Bootloader
3 * Copyright (C) 2011 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/arc/arc.h>
20 #include <grub/arc/console.h>
21 #include <grub/term.h>
22 #include <grub/terminfo.h>
24 /* FIXME: use unicode. */
27 readkey (struct grub_term_input
*term
__attribute__ ((unused
)))
32 if (GRUB_ARC_FIRMWARE_VECTOR
->get_read_status (GRUB_ARC_STDIN
))
35 if (GRUB_ARC_FIRMWARE_VECTOR
->read (GRUB_ARC_STDIN
, &chr
, 1, &count
))
43 put (struct grub_term_output
*term
__attribute__ ((unused
)), const int c
)
48 GRUB_ARC_FIRMWARE_VECTOR
->write (GRUB_ARC_STDOUT
, &chr
, 1, &count
);
51 static struct grub_terminfo_output_state grub_console_terminfo_output
;
54 grub_console_init_output (struct grub_term_output
*term
)
56 struct grub_arc_display_status
*info
= NULL
;
57 if (GRUB_ARC_SYSTEM_PARAMETER_BLOCK
->firmware_vector_length
58 >= ((char *) (&GRUB_ARC_FIRMWARE_VECTOR
->getdisplaystatus
+ 1)
59 - (char *) GRUB_ARC_FIRMWARE_VECTOR
)
60 && GRUB_ARC_FIRMWARE_VECTOR
->getdisplaystatus
)
61 info
= GRUB_ARC_FIRMWARE_VECTOR
->getdisplaystatus (GRUB_ARC_STDOUT
);
64 grub_console_terminfo_output
.width
= info
->w
+ 1;
65 grub_console_terminfo_output
.height
= info
->h
+ 1;
67 grub_terminfo_output_init (term
);
72 static struct grub_terminfo_input_state grub_console_terminfo_input
=
77 static struct grub_terminfo_output_state grub_console_terminfo_output
=
84 static struct grub_term_input grub_console_term_input
=
87 .init
= grub_terminfo_input_init
,
88 .getkey
= grub_terminfo_getkey
,
89 .data
= &grub_console_terminfo_input
92 static struct grub_term_output grub_console_term_output
=
95 .init
= grub_console_init_output
,
96 .putchar
= grub_terminfo_putchar
,
97 .getxy
= grub_terminfo_getxy
,
98 .getwh
= grub_terminfo_getwh
,
99 .gotoxy
= grub_terminfo_gotoxy
,
100 .cls
= grub_terminfo_cls
,
101 .setcolorstate
= grub_terminfo_setcolorstate
,
102 .setcursor
= grub_terminfo_setcursor
,
103 .flags
= GRUB_TERM_CODE_TYPE_ASCII
,
104 .data
= &grub_console_terminfo_output
,
105 .normal_color
= GRUB_TERM_DEFAULT_NORMAL_COLOR
,
106 .highlight_color
= GRUB_TERM_DEFAULT_HIGHLIGHT_COLOR
,
110 grub_console_init_early (void)
112 grub_term_register_input ("console", &grub_console_term_input
);
113 grub_term_register_output ("console", &grub_console_term_output
);
117 grub_console_init_lately (void)
119 grub_terminfo_init ();
120 grub_terminfo_output_register (&grub_console_term_output
, "arc");