}
fw_cfg_add_bytes(s, FW_CFG_SIGNATURE, (uint8_t *)"QEMU", 4);
fw_cfg_add_bytes(s, FW_CFG_UUID, qemu_uuid, 16);
- fw_cfg_add_i16(s, FW_CFG_NOGRAPHIC, (uint16_t)nographic);
+ fw_cfg_add_i16(s, FW_CFG_NOGRAPHIC, (uint16_t)(display_type == DT_NOGRAPHIC));
fw_cfg_add_i16(s, FW_CFG_NB_CPUS, (uint16_t)smp_cpus);
register_savevm("fw_cfg", -1, 1, fw_cfg_save, fw_cfg_load, s);
slavio_cpu_irq, smp_cpus);
slavio_serial_ms_kbd_init(hwdef->ms_kb_base, slavio_irq[hwdef->ms_kb_irq],
- nographic, ESCC_CLOCK, 1);
+ display_type == DT_NOGRAPHIC, ESCC_CLOCK, 1);
// Slavio TTYA (base+4, Linux ttyS0) is the first Qemu serial device
// Slavio TTYB (base+0, Linux ttyS1) is the second Qemu serial device
escc_init(hwdef->serial_base, slavio_irq[hwdef->ser_irq], slavio_irq[hwdef->ser_irq],
sbi_cpu_irq, smp_cpus);
slavio_serial_ms_kbd_init(hwdef->ms_kb_base, sbi_irq[hwdef->ms_kb_irq],
- nographic, ESCC_CLOCK, 1);
+ display_type == DT_NOGRAPHIC, ESCC_CLOCK, 1);
// Slavio TTYA (base+4, Linux ttyS0) is the first Qemu serial device
// Slavio TTYB (base+0, Linux ttyS1) is the second Qemu serial device
escc_init(hwdef->serial_base, sbi_irq[hwdef->ser_irq], sbi_irq[hwdef->ser_irq],
hwdef->nvram_size, 2);
slavio_serial_ms_kbd_init(hwdef->ms_kb_base, slavio_irq[hwdef->ms_kb_irq],
- nographic, ESCC_CLOCK, 1);
+ display_type == DT_NOGRAPHIC, ESCC_CLOCK, 1);
// Slavio TTYA (base+4, Linux ttyS0) is the first Qemu serial device
// Slavio TTYB (base+0, Linux ttyS1) is the second Qemu serial device
escc_init(hwdef->serial_base, slavio_irq[hwdef->ser_irq],
FDCharDriver *s = chr->opaque;
if (s->fd_in >= 0) {
- if (nographic && s->fd_in == 0) {
+ if (display_type == DT_NOGRAPHIC && s->fd_in == 0) {
} else {
qemu_set_fd_handler2(s->fd_in, fd_chr_read_poll,
fd_chr_read, NULL, chr);
FDCharDriver *s = chr->opaque;
if (s->fd_in >= 0) {
- if (nographic && s->fd_in == 0) {
+ if (display_type == DT_NOGRAPHIC && s->fd_in == 0) {
} else {
qemu_set_fd_handler2(s->fd_in, NULL, NULL, NULL, NULL);
}
tty.c_oflag |= OPOST;
tty.c_lflag &= ~(ECHO|ECHONL|ICANON|IEXTEN);
/* if graphical mode, we allow Ctrl-C handling */
- if (nographic)
+ if (display_type == DT_NOGRAPHIC)
tty.c_lflag &= ~ISIG;
tty.c_cflag &= ~(CSIZE|PARENB);
tty.c_cflag |= CS8;
/* SLIRP */
void do_info_slirp(Monitor *mon);
+typedef enum DisplayType
+{
+ DT_DEFAULT,
+ DT_CURSES,
+ DT_SDL,
+ DT_VNC,
+ DT_NOGRAPHIC,
+} DisplayType;
+
extern int bios_size;
extern int cirrus_vga_enabled;
extern int std_vga_enabled;
extern int graphic_width;
extern int graphic_height;
extern int graphic_depth;
-extern int nographic;
+extern DisplayType display_type;
extern const char *keyboard_layout;
extern int win2k_install_hack;
extern int rtc_td_hack;
int nb_drives;
enum vga_retrace_method vga_retrace_method = VGA_RETRACE_DUMB;
static DisplayState *display_state;
-int nographic;
-static int curses;
-static int sdl = 1;
+DisplayType display_type = DT_DEFAULT;
const char* keyboard_layout = NULL;
int64_t ticks_per_sec;
ram_addr_t ram_size;
const char *run_as = NULL;
#endif
CPUState *env;
+ int show_vnc_port = 0;
qemu_cache_utils_init(envp);
initrd_filename = NULL;
ram_size = 0;
snapshot = 0;
- nographic = 0;
- curses = 0;
kernel_filename = NULL;
kernel_cmdline = "";
cyls = heads = secs = 0;
numa_add(optarg);
break;
case QEMU_OPTION_nographic:
- nographic = 1;
+ display_type = DT_NOGRAPHIC;
break;
#ifdef CONFIG_CURSES
case QEMU_OPTION_curses:
- curses = 1;
+ display_type = DT_CURSES;
break;
#endif
case QEMU_OPTION_portrait:
no_quit = 1;
break;
case QEMU_OPTION_sdl:
- sdl = 1;
+ display_type = DT_SDL;
break;
#endif
case QEMU_OPTION_pidfile:
}
break;
case QEMU_OPTION_vnc:
+ display_type = DT_VNC;
vnc_display = optarg;
break;
#ifdef TARGET_I386
exit(1);
}
- if (nographic) {
+ if (display_type == DT_NOGRAPHIC) {
if (serial_device_index == 0)
serial_devices[0] = "stdio";
if (parallel_device_index == 0)
dumb_display_init();
/* just use the first displaystate for the moment */
ds = display_state;
- /* terminal init */
- if (nographic) {
- if (curses) {
- fprintf(stderr, "fatal: -nographic can't be used with -curses\n");
- exit(1);
- }
- } else {
+
+ if (display_type == DT_DEFAULT) {
+#if defined(CONFIG_SDL) || defined(CONFIG_COCOA)
+ display_type = DT_SDL;
+#else
+ display_type = DT_VNC;
+ vnc_display = "localhost:0,to=99";
+ show_vnc_port = 1;
+#endif
+ }
+
+
+ switch (display_type) {
+ case DT_NOGRAPHIC:
+ break;
#if defined(CONFIG_CURSES)
- if (curses) {
- /* At the moment curses cannot be used with other displays */
- curses_display_init(ds, full_screen);
- } else
+ case DT_CURSES:
+ curses_display_init(ds, full_screen);
+ break;
#endif
-#if defined(CONFIG_SDL) || defined(CONFIG_COCOA)
- if (sdl) {
#if defined(CONFIG_SDL)
- sdl_display_init(ds, full_screen, no_frame);
+ case DT_SDL:
+ sdl_display_init(ds, full_screen, no_frame);
+ break;
#elif defined(CONFIG_COCOA)
- cocoa_display_init(ds, full_screen);
-#endif
- } else
+ case DT_SDL:
+ cocoa_display_init(ds, full_screen);
+ break;
#endif
- {
- int print_port = 0;
-
- if (vnc_display == NULL) {
- vnc_display = "localhost:0,to=99";
- print_port = 1;
- }
-
- vnc_display_init(ds);
- if (vnc_display_open(ds, vnc_display) < 0)
- exit(1);
+ case DT_VNC:
+ vnc_display_init(ds);
+ if (vnc_display_open(ds, vnc_display) < 0)
+ exit(1);
- if (print_port) {
- printf("VNC server running on `%s'\n", vnc_display_local_addr(ds));
- }
+ if (show_vnc_port) {
+ printf("VNC server running on `%s'\n", vnc_display_local_addr(ds));
}
+ break;
+ default:
+ break;
}
dpy_resize(ds);
dcl = dcl->next;
}
- if (nographic || (vnc_display && !sdl)) {
+ if (display_type == DT_NOGRAPHIC || display_type == DT_VNC) {
nographic_timer = qemu_new_timer(rt_clock, nographic_update, NULL);
qemu_mod_timer(nographic_timer, qemu_get_clock(rt_clock));
}