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.


Revised Nautilus Aerokernel Host Functionality
[palacios.git] / nautilus / console.c
1 /*
2   Interface to Nautilus screen and keyboard
3 */
4
5 #include <nautilus/nautilus.h>
6 #include <nautilus/vc.h>
7 #include <dev/kbd.h>
8
9
10 #include <palacios/vmm.h>
11
12 #include <interfaces/vmm_console.h>
13 #include <palacios/vmm_host_events.h>
14
15 #include "palacios.h"
16
17 static void kbd_callback(nk_scancode_t scancode, void *priv)
18 {
19   struct nk_vm_state *n = (struct nk_vm_state *) priv;
20
21   struct v3_keyboard_event event = {0,scancode};
22
23   if (n && n->vm) {
24     v3_deliver_keyboard_event(n->vm, &event);
25   } else {
26     ERROR("Missing target for event... n=%p, n->vm=%p\n", n, n?n->vm:0);
27   }
28 }
29
30
31 static void * palacios_tty_open(void * private_data, unsigned int width, unsigned int height) 
32 {
33   struct nk_vm_state *n = palacios_get_selected_vm();
34
35   if (!n) { 
36     ERROR("Cannot create console without selected VM\n");
37     return 0;
38   }
39   if (width!=80 || height!=25) { 
40     ERROR("Console is wrong size\n");
41     return 0;
42   }
43
44   if (n->vc) { 
45     ERROR("Cannot open multiple consoles per selected VM\n");
46     return 0;
47   }
48
49   
50   n->vc = nk_create_vc(n->name,
51                        RAW_NOQUEUE,
52                        0x5f,
53                        kbd_callback,
54                        n);
55
56   if (!n->vc) { 
57     ERROR("Failed to create vc\n");
58     return 0;
59   }
60
61   nk_vc_clear_specific(n->vc,0x5f);
62
63   return n;
64
65 }
66
67
68 static int palacios_tty_cursor_set(void * console, int x, int y) 
69 {
70   struct nk_vm_state *n = (struct nk_vm_state *) console;
71
72   if (n && n->vc) { 
73     nk_vc_setpos_specific(n->vc,x,y);
74     return 0;
75   } else {
76     return -1;
77   }
78 }
79
80 static int palacios_tty_character_set(void * console, int x, int y, char c, unsigned char style) 
81 {
82   struct nk_vm_state *n = (struct nk_vm_state *) console;
83
84   if (n && n->vc) { 
85     nk_vc_display_char_specific(n->vc,c,style,x,y);
86     nk_vc_setattr_specific(n->vc,style);
87     return 0;
88   } else {
89     return -1;
90   }
91 }
92
93 static int palacios_tty_scroll(void * console, int lines) 
94 {
95   struct nk_vm_state *n = (struct nk_vm_state *) console;
96
97   if (n && n->vc) { 
98     int i;
99     for (i=0;i<lines;i++) {
100       nk_vc_scrollup_specific(n->vc);
101     }
102     return 0;
103   } else {
104     return -1;
105   }
106 }
107
108
109 static int palacios_set_text_resolution(void * console, int cols, int rows) 
110 {
111   if (console) { 
112     if (cols!=80 || rows!=25) { 
113       ERROR("Cannot change resolution\n");
114       return -1;
115     } else {
116       return 0;
117     }
118   } else {
119     return -1;
120   }
121 }
122  
123 static int palacios_tty_update(void * console) 
124 {
125   // not used for VC
126   return 0;
127 }
128
129 static void palacios_tty_close(void * console) 
130 {
131   struct nk_vm_state *n = (struct nk_vm_state *) console;
132
133   if (n && n->vc) { 
134     nk_destroy_vc(n->vc);
135   }
136 }
137
138
139
140 static struct v3_console_hooks palacios_console_hooks = {
141     .open                       = palacios_tty_open,
142     .set_cursor                 = palacios_tty_cursor_set,
143     .set_character              = palacios_tty_character_set,
144     .scroll                     = palacios_tty_scroll,
145     .set_text_resolution        = palacios_set_text_resolution,
146     .update                     = palacios_tty_update,
147     .close                      = palacios_tty_close,
148 };
149
150
151
152 int nautilus_console_init(void) 
153 {
154   INFO("Palacios Console\n");
155   
156   V3_Init_Console(&palacios_console_hooks);
157   
158   return 0;
159 }
160
161 int nautilus_console_deinit(void)
162 {
163     return 0;
164 }
165
166
167
168