diff options
author | ths <ths@c046a42c-6fe2-441c-8c8c-71466251a162> | 2007-02-18 17:04:49 +0000 |
---|---|---|
committer | ths <ths@c046a42c-6fe2-441c-8c8c-71466251a162> | 2007-02-18 17:04:49 +0000 |
commit | 20d8a3edb062c96f9a08ccf0637f76ae2563c5e1 (patch) | |
tree | 1b9a0aa58961c3c2de88f899acc7e120a8150c73 /monitor.c | |
parent | 925fd0f202e430fc18e1e4986cc066ea44504c9e (diff) | |
download | qemu-20d8a3edb062c96f9a08ccf0637f76ae2563c5e1.zip |
Monitor multiplexing, by Jason Wessel.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@2434 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'monitor.c')
-rw-r--r-- | monitor.c | 32 |
1 files changed, 28 insertions, 4 deletions
@@ -54,7 +54,8 @@ typedef struct term_cmd_t { const char *help; } term_cmd_t; -static CharDriverState *monitor_hd; +#define MAX_MON 4 +static CharDriverState *monitor_hd[MAX_MON]; static int hide_banner; static term_cmd_t term_cmds[]; @@ -69,8 +70,11 @@ CPUState *mon_cpu = NULL; void term_flush(void) { + int i; if (term_outbuf_index > 0) { - qemu_chr_write(monitor_hd, term_outbuf, term_outbuf_index); + for (i = 0; i < MAX_MON; i++) + if (monitor_hd[i] && monitor_hd[i]->focus == 0) + qemu_chr_write(monitor_hd[i], term_outbuf, term_outbuf_index); term_outbuf_index = 0; } } @@ -2452,9 +2456,25 @@ static void term_event(void *opaque, int event) monitor_start_input(); } +static int is_first_init = 1; + void monitor_init(CharDriverState *hd, int show_banner) { - monitor_hd = hd; + int i; + + if (is_first_init) { + for (i = 0; i < MAX_MON; i++) { + monitor_hd[i] = NULL; + } + is_first_init = 0; + } + for (i = 0; i < MAX_MON; i++) { + if (monitor_hd[i] == NULL) { + monitor_hd[i] = hd; + break; + } + } + hide_banner = !show_banner; qemu_chr_add_handlers(hd, term_can_read, term_read, term_event, NULL); @@ -2475,8 +2495,12 @@ static void monitor_readline_cb(void *opaque, const char *input) void monitor_readline(const char *prompt, int is_password, char *buf, int buf_size) { + int i; + if (is_password) { - qemu_chr_send_event(monitor_hd, CHR_EVENT_FOCUS); + for (i = 0; i < MAX_MON; i++) + if (monitor_hd[i] && monitor_hd[i]->focus == 0) + qemu_chr_send_event(monitor_hd[i], CHR_EVENT_FOCUS); } readline_start(prompt, is_password, monitor_readline_cb, NULL); monitor_readline_buf = buf; |