Palacios Public Git Repository

To checkout Palacios execute

  git clone http://v3vee.org/palacios/palacios.web/palacios.git
This will give you the master branch. You probably want the devel branch or one of the release branches. To switch to the devel branch, simply execute
  cd palacios
  git checkout --track -b devel origin/devel
The other branches are similar.


f571a83b13ed357cec3e50cdf14e272a7bb140db
[palacios.git] / nautilus / console.c
1 /*
2   Interface to Nautilus screen and keyboard
3 */
4
5 #include <nautilus/nautilus.h>
6 #include <nautilus/printk.h>
7 #include <nautilus/cga.h>
8 #include <dev/kbd.h>
9
10
11 #include <palacios/vmm.h>
12
13 #include <interfaces/vmm_console.h>
14 #include <palacios/vmm_host_events.h>
15
16 #include "palacios.h"
17
18 /*
19   This is a gruesome hack to allow the VM designated by the 
20   host as "the_vm" to do I/O to the standard VGA text mode console
21 */
22
23 extern void *the_vm;
24
25 static void * palacios_tty_open(void * private_data, unsigned int width, unsigned int height) 
26 {
27     if (width!=80 || height!=25) { 
28         ERROR("Console is wrong size\n");
29         return 0;
30     }
31     INFO("Console connected\n");
32     return (void*)1;
33 }
34
35
36 static int palacios_tty_cursor_set(void * console, int x, int y) 
37 {
38     if (console) { 
39         term_setpos(x,y);
40         return 0;
41     } else {
42         return -1;
43     }
44 }
45
46 static int palacios_tty_character_set(void * console, int x, int y, char c, unsigned char style) 
47 {
48     if (console) {
49         term_putc(c,style,x,y);
50         return 0;
51     } else {
52         return -1;
53     }
54 }
55
56 static int palacios_tty_scroll(void * console, int lines) 
57 {
58     if (console) { 
59         int i;
60         for (i=0;i<lines;i++) {
61             term_scrollup();
62         }
63         return 0;
64     } else {
65         return -1;
66     }
67 }
68
69
70 static int palacios_set_text_resolution(void * console, int cols, int rows) 
71 {
72     if (console) { 
73         if (cols!=80 || rows!=25) { 
74             ERROR("Cannot change resolution\n");
75             return -1;
76         }
77         else return 0;
78     } else {
79         return -1;
80     }
81 }
82  
83 static int palacios_tty_update(void * console) 
84 {
85     return 0;
86 }
87
88 static void palacios_tty_close(void * console) 
89 {
90     if (console) { 
91         term_clear();
92         term_print("Palacios Console Finished\n");
93     }
94 }
95
96 static void kbd_callback(uint8_t scancode, uint8_t status)
97 {
98     struct v3_keyboard_event event = {status,scancode};
99
100     //INFO("kbd callback scancode=%x\n",scancode);
101     if (the_vm) {
102         //INFO("Deliver scancode 0x%x\n",scancode);
103         v3_deliver_keyboard_event(the_vm, &event);
104     }
105 }
106
107
108 static struct v3_console_hooks palacios_console_hooks = {
109     .open                       = palacios_tty_open,
110     .set_cursor                 = palacios_tty_cursor_set,
111     .set_character              = palacios_tty_character_set,
112     .scroll                     = palacios_tty_scroll,
113     .set_text_resolution        = palacios_set_text_resolution,
114     .update                     = palacios_tty_update,
115     .close                      = palacios_tty_close,
116 };
117
118
119
120 int nautilus_console_init(void) 
121 {
122     term_clear();
123     term_print("Palacios Console\n");
124
125     V3_Init_Console(&palacios_console_hooks);
126
127     kbd_register_callback(kbd_callback);
128     
129     return 0;
130 }
131
132 int nautilus_console_deinit(void)
133 {
134     // nothing to do
135     return 0;
136 }
137
138
139
140