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/term.h>
20 #include <grub/types.h>
21 #include <grub/misc.h>
23 #include <grub/time.h>
24 #include <grub/terminfo.h>
28 readkey (struct grub_term_input
*term
__attribute__ ((unused
)))
30 grub_size_t prod
, cons
;
33 prod
= grub_xen_xcons
->in_prod
;
34 cons
= grub_xen_xcons
->in_cons
;
37 r
= grub_xen_xcons
->in
[cons
];
40 grub_xen_xcons
->in_cons
= cons
;
44 static int signal_sent
= 1;
47 refresh (struct grub_term_output
*term
__attribute__ ((unused
)))
49 struct evtchn_send send
;
50 send
.port
= grub_xen_start_page_addr
->console
.domU
.evtchn
;
51 grub_xen_event_channel_op (EVTCHNOP_send
, &send
);
53 while (grub_xen_xcons
->out_prod
!= grub_xen_xcons
->out_cons
)
55 grub_xen_sched_op (SCHEDOP_yield
, 0);
60 put (struct grub_term_output
*term
__attribute__ ((unused
)), const int c
)
62 grub_size_t prod
, cons
;
67 prod
= grub_xen_xcons
->out_prod
;
68 cons
= grub_xen_xcons
->out_cons
;
69 if (prod
< cons
+ sizeof (grub_xen_xcons
->out
))
73 grub_xen_sched_op (SCHEDOP_yield
, 0);
75 grub_xen_xcons
->out
[prod
++ & (sizeof (grub_xen_xcons
->out
) - 1)] = c
;
77 grub_xen_xcons
->out_prod
= prod
;
82 struct grub_terminfo_input_state grub_console_terminfo_input
= {
86 struct grub_terminfo_output_state grub_console_terminfo_output
= {
91 static struct grub_term_input grub_console_term_input
= {
94 .getkey
= grub_terminfo_getkey
,
95 .data
= &grub_console_terminfo_input
98 static struct grub_term_output grub_console_term_output
= {
101 .putchar
= grub_terminfo_putchar
,
102 .getxy
= grub_terminfo_getxy
,
103 .getwh
= grub_terminfo_getwh
,
104 .gotoxy
= grub_terminfo_gotoxy
,
105 .cls
= grub_terminfo_cls
,
107 .setcolorstate
= grub_terminfo_setcolorstate
,
108 .setcursor
= grub_terminfo_setcursor
,
109 .flags
= GRUB_TERM_CODE_TYPE_ASCII
,
110 .data
= &grub_console_terminfo_output
,
115 grub_console_init (void)
117 grub_term_register_input ("console", &grub_console_term_input
);
118 grub_term_register_output ("console", &grub_console_term_output
);
120 grub_terminfo_init ();
121 grub_terminfo_output_register (&grub_console_term_output
, "vt100-color");