25 |
* SUCH DAMAGE. |
* SUCH DAMAGE. |
26 |
* |
* |
27 |
* |
* |
28 |
* $Id: console.c,v 1.16 2006/05/05 21:28:09 debug Exp $ |
* $Id: console.c,v 1.21 2006/10/31 08:26:38 debug Exp $ |
29 |
* |
* |
30 |
* Generic console support functions. |
* Generic console support functions. |
31 |
* |
* |
92 |
static int console_slave_outputd; |
static int console_slave_outputd; |
93 |
|
|
94 |
static int console_initialized = 0; |
static int console_initialized = 0; |
95 |
|
static struct settings *console_settings = NULL; |
96 |
static int console_stdout_pending; |
static int console_stdout_pending; |
97 |
|
|
98 |
#define CONSOLE_FIFO_LEN 4096 |
#define CONSOLE_FIFO_LEN 4096 |
99 |
|
|
|
/* Mouse coordinates: */ |
|
|
static int console_framebuffer_mouse_x; /* absolute x, 0-based */ |
|
|
static int console_framebuffer_mouse_y; /* absolute y, 0-based */ |
|
|
static int console_framebuffer_mouse_fb_nr; /* fb_number of last |
|
|
framebuffer cursor update */ |
|
|
|
|
100 |
static int console_mouse_x; /* absolute x, 0-based */ |
static int console_mouse_x; /* absolute x, 0-based */ |
101 |
static int console_mouse_y; /* absolute y, 0-based */ |
static int console_mouse_y; /* absolute y, 0-based */ |
102 |
static int console_mouse_fb_nr; /* framebuffer number of |
static int console_mouse_fb_nr; /* framebuffer number of |
134 |
|
|
135 |
|
|
136 |
/* |
/* |
137 |
* console_deinit(): |
* console_deinit_main(): |
138 |
* |
* |
139 |
* Restore host's console settings. |
* Restore host's console settings. |
140 |
*/ |
*/ |
141 |
void console_deinit(void) |
void console_deinit_main(void) |
142 |
{ |
{ |
143 |
if (!console_initialized) |
if (!console_initialized) |
144 |
return; |
return; |
153 |
* console_sigcont(): |
* console_sigcont(): |
154 |
* |
* |
155 |
* If the user presses CTRL-Z (to stop the emulator process) and then |
* If the user presses CTRL-Z (to stop the emulator process) and then |
156 |
* continues, we have to make sure that the right termios settings are |
* continues, the termios settings might have been invalidated. This |
157 |
* active. (This should be set as the SIGCONT signal handler in src/emul.c.) |
* function restores them. |
158 |
|
* |
159 |
|
* (This function should be set as the SIGCONT signal handler in src/emul.c.) |
160 |
*/ |
*/ |
161 |
void console_sigcont(int x) |
void console_sigcont(int x) |
162 |
{ |
{ |
163 |
if (!console_initialized) |
if (!console_initialized) |
164 |
return; |
return; |
165 |
|
|
166 |
/* Make sure our 'current' termios setting is active: */ |
/* Make sure that the correct (current) termios setting is active: */ |
167 |
tcsetattr(STDIN_FILENO, TCSANOW, &console_curtermios); |
tcsetattr(STDIN_FILENO, TCSANOW, &console_curtermios); |
168 |
|
|
169 |
/* Reset the signal handler: */ |
/* Reset the signal handler: */ |
486 |
|
|
487 |
|
|
488 |
/* |
/* |
|
* console_get_framebuffer_mouse(): |
|
|
* |
|
|
* TODO: Comment |
|
|
*/ |
|
|
void console_get_framebuffer_mouse(int *x, int *y, int *fb_nr) |
|
|
{ |
|
|
*x = console_framebuffer_mouse_x; |
|
|
*y = console_framebuffer_mouse_y; |
|
|
*fb_nr = console_framebuffer_mouse_fb_nr; |
|
|
} |
|
|
|
|
|
|
|
|
/* |
|
|
* console_set_framebuffer_mouse(): |
|
|
* |
|
|
* A framebuffer device calls this function when it sets the |
|
|
* position of a cursor (ie a mouse cursor). |
|
|
*/ |
|
|
void console_set_framebuffer_mouse(int x, int y, int fb_nr) |
|
|
{ |
|
|
console_framebuffer_mouse_x = x; |
|
|
console_framebuffer_mouse_y = y; |
|
|
console_framebuffer_mouse_fb_nr = fb_nr; |
|
|
} |
|
|
|
|
|
|
|
|
/* |
|
489 |
* console_getmouse(): |
* console_getmouse(): |
490 |
* |
* |
491 |
* Puts current mouse data into the variables pointed to by |
* Puts current mouse data into the variables pointed to by |
542 |
int inputd; |
int inputd; |
543 |
int len; |
int len; |
544 |
char *p; |
char *p; |
545 |
char buf[400]; |
char buf[16384]; |
546 |
|
|
547 |
/* arg = '3,6' or similar, input and output descriptors */ |
/* arg = '3,6' or similar, input and output descriptors */ |
548 |
/* printf("console_slave(): arg = '%s'\n", arg); */ |
/* printf("console_slave(): arg = '%s'\n", arg); */ |
588 |
write(console_slave_outputd, buf, len); |
write(console_slave_outputd, buf, len); |
589 |
} |
} |
590 |
|
|
591 |
usleep(100); |
usleep(10000); |
592 |
} |
} |
593 |
} |
} |
594 |
|
|
684 |
chp->outputonly = 1; |
chp->outputonly = 1; |
685 |
chp->in_use_for_input = 0; |
chp->in_use_for_input = 0; |
686 |
} |
} |
687 |
chp->machine_name = strdup(machine->machine_name); |
|
688 |
|
if (machine->machine_name != NULL) |
689 |
|
chp->machine_name = strdup(machine->machine_name); |
690 |
|
else |
691 |
|
chp->machine_name = strdup(""); |
692 |
|
|
693 |
chp->name = strdup(consolename); |
chp->name = strdup(consolename); |
694 |
|
|
695 |
if (allow_slaves) |
if (allow_slaves) |
948 |
{ |
{ |
949 |
int handle; |
int handle; |
950 |
struct console_handle *chp; |
struct console_handle *chp; |
951 |
struct settings *console_settings = settings_new(); |
|
952 |
|
console_settings = settings_new(); |
953 |
|
|
954 |
settings_add(global_settings, "console", 1, |
settings_add(global_settings, "console", 1, |
955 |
SETTINGS_TYPE_SUBSETTINGS, 0, console_settings); |
SETTINGS_TYPE_SUBSETTINGS, 0, console_settings); |
967 |
chp->in_use_for_input = 1; |
chp->in_use_for_input = 1; |
968 |
} |
} |
969 |
|
|
970 |
|
|
971 |
|
/* |
972 |
|
* console_deinit(): |
973 |
|
* |
974 |
|
* Unregister settings registered by console_init(). |
975 |
|
*/ |
976 |
|
void console_deinit(void) |
977 |
|
{ |
978 |
|
settings_remove(console_settings, "allow_slaves"); |
979 |
|
settings_remove(global_settings, "console"); |
980 |
|
} |
981 |
|
|