10
#include <drivers/diag.h>
14
#include <xen/io/console.h>
15
#include <xen_hypercall-x86_32.h>
21
static evtchn_port_t console_evt;
23
struct xencons_interface * console;
25
static int diag_xen_init(const struct diag *diag) {
26
extern start_info_t *xen_start_info_global;
27
console = (struct xencons_interface*)
28
((machine_to_phys_mapping[xen_start_info_global->console.domU.mfn] << 12)
30
((unsigned long)&_text_vma));
31
console_evt = xen_start_info_global->console.domU.evtchn;
36
static void diag_xen_putc(const struct diag *diag, char ch) {
37
struct evtchn_send event;
38
event.port = console_evt;
43
XENCONS_RING_IDX data;
46
data = console->out_prod - console->out_cons;
47
HYPERVISOR_event_channel_op(EVTCHNOP_send, &event);
49
} while (data >= sizeof(console->out));
51
int ring_index = MASK_XENCONS_IDX(console->out_prod, console->out);
52
console->out[ring_index] = *message;
58
HYPERVISOR_event_channel_op(EVTCHNOP_send, &event);
61
static char diag_xen_getc(const struct diag *diag) {
62
assert(console->in_prod != console->in_cons);
64
int ring_index = MASK_XENCONS_IDX(console->in_cons, console->in);
65
char ch = console->in[ring_index];
72
static int diag_xen_kbhit(const struct diag *diag) {
73
return console->in_prod != console->in_cons;
77
.init = diag_xen_init,
78
.putc = diag_xen_putc,
79
.getc = diag_xen_getc,
80
.kbhit = diag_xen_kbhit,