pool = [ [ NSAutoreleasePool alloc ] init ];
distantPast = [ NSDate distantPast ];
- if (is_active_console(vga_console))
- vga_update_display();
+ vga_hw_update();
+
do {
event = [ NSApp nextEventMatchingMask:NSAnyEventMask untilDate:distantPast
inMode: NSDefaultRunLoopMode dequeue:YES ];
/* emulate caps lock and num lock keydown and keyup */
kbd_put_keycode(keycode);
kbd_put_keycode(keycode | 0x80);
- } else if (is_active_console(vga_console)) {
+ } else if (is_graphic_console()) {
if (keycode & 0x80)
kbd_put_keycode(0xe0);
if (modifiers_state[keycode] == 0) {
/* toggle Monitor */
case 0x02 ... 0x0a: /* '1' to '9' keys */
console_select(keycode - 0x02);
- if (is_active_console(vga_console)) {
- /* tell the vga console to redisplay itself */
- vga_invalidate_display();
break;
}
}
} else {
/* handle standard key events */
- if (is_active_console(vga_console)) {
+ if (is_graphic_console()) {
if (keycode & 0x80) //check bit for e0 in front
kbd_put_keycode(0xe0);
kbd_put_keycode(keycode & 0x7f); //remove e0 bit in front
case NSKeyUp:
{
int keycode = cocoa_keycode_to_qemu([event keyCode]);
- if (is_active_console(vga_console)) {
+ if (is_graphic_console()) {
if (keycode & 0x80)
kbd_put_keycode(0xe0);
kbd_put_keycode(keycode | 0x80); //add 128 to signal release of key
TTY_STATE_CSI,
};
-
+/* ??? This is mis-named.
+ It is used for both text and graphical consoles. */
struct TextConsole {
int text_console; /* true if text console */
DisplayState *ds;
+ /* Graphic console state. */
+ vga_hw_update_ptr hw_update;
+ vga_hw_invalidate_ptr hw_invalidate;
+ vga_hw_screen_dump_ptr hw_screen_dump;
+ void *hw;
+
int g_width, g_height;
int width;
int height;
static TextConsole *consoles[MAX_CONSOLES];
static int nb_consoles = 0;
+void vga_hw_update(void)
+{
+ if (active_console->hw_update)
+ active_console->hw_update(active_console->hw);
+}
+
+void vga_hw_invalidate(void)
+{
+ if (active_console->hw_invalidate)
+ active_console->hw_invalidate(active_console->hw);
+}
+
+void vga_hw_screen_dump(const char *filename)
+{
+ /* There is currently no was of specifying which screen we want to dump,
+ so always dump the dirst one. */
+ if (consoles[0]->hw_screen_dump)
+ consoles[0]->hw_screen_dump(consoles[0]->hw, filename);
+}
+
/* convert a RGBA color to a color index usable in graphic primitives */
static unsigned int vga_get_color(DisplayState *ds, unsigned int rgba)
{
s->g_width = s->ds->width;
s->g_height = s->ds->height;
text_console_resize(s);
- }
+ }
console_refresh(s);
+ } else {
+ vga_hw_invalidate();
}
}
}
}
}
-TextConsole *graphic_console_init(DisplayState *ds)
+static TextConsole *new_console(DisplayState *ds, int text)
{
TextConsole *s;
+ int i;
if (nb_consoles >= MAX_CONSOLES)
return NULL;
if (!s) {
return NULL;
}
- if (!active_console)
+ if (!active_console || (active_console->text_console && !text))
active_console = s;
s->ds = ds;
- consoles[nb_consoles++] = s;
+ s->text_console = text;
+ if (text) {
+ consoles[nb_consoles++] = s;
+ } else {
+ /* HACK: Put graphical consoles before text consoles. */
+ for (i = nb_consoles; i > 0; i--) {
+ if (!consoles[i - 1]->text_console)
+ break;
+ consoles[i] = consoles[i - 1];
+ }
+ consoles[i] = s;
+ }
+ return s;
+}
+
+TextConsole *graphic_console_init(DisplayState *ds, vga_hw_update_ptr update,
+ vga_hw_invalidate_ptr invalidate,
+ vga_hw_screen_dump_ptr screen_dump,
+ void *opaque)
+{
+ TextConsole *s;
+
+ s = new_console(ds, 0);
+ if (!s)
+ return NULL;
+ s->hw_update = update;
+ s->hw_invalidate = invalidate;
+ s->hw_screen_dump = screen_dump;
+ s->hw = opaque;
return s;
}
-int is_active_console(TextConsole *s)
+int is_graphic_console(void)
{
- return s == active_console;
+ return !active_console->text_console;
}
CharDriverState *text_console_init(DisplayState *ds)
chr = qemu_mallocz(sizeof(CharDriverState));
if (!chr)
return NULL;
- s = graphic_console_init(ds);
+ s = new_console(ds, 1);
if (!s) {
free(chr);
return NULL;
}
- s->text_console = 1;
chr->opaque = s;
chr->chr_write = console_puts;
chr->chr_add_read_handler = console_chr_add_read_handler;
{
}
-static void *lcd;
-
-void vga_update_display(void)
-{
- pl110_update_display(lcd);
-}
-
-void vga_screen_dump(const char *filename)
-{
-}
-
-void vga_invalidate_display(void)
-{
- pl110_invalidate_display(lcd);
-}
-
void DMA_run (void)
{
}
exit (1);
}
}
- lcd = pl110_init(ds, 0xc0000000, pic, 22);
+ pl110_init(ds, 0xc0000000, pic, 22, 0);
/* Load the kernel. */
if (!kernel_filename) {
return (s->cr & PL110_CR_EN) && (s->cr & PL110_CR_PWR);
}
-void pl110_update_display(void *opaque)
+static void pl110_update_display(void *opaque)
{
pl110_state *s = (pl110_state *)opaque;
drawfn* fntable;
dpy_update(s->ds, 0, first, s->cols, last - first + 1);
}
-void pl110_invalidate_display(void * opaque)
+static void pl110_invalidate_display(void * opaque)
{
pl110_state *s = (pl110_state *)opaque;
s->invalidate = 1;
pl110_write
};
-void *pl110_init(DisplayState *ds, uint32_t base, void *pic, int irq)
+void *pl110_init(DisplayState *ds, uint32_t base, void *pic, int irq,
+ int versatile)
{
pl110_state *s;
int iomemtype;
s = (pl110_state *)qemu_mallocz(sizeof(pl110_state));
iomemtype = cpu_register_io_memory(0, pl110_readfn,
pl110_writefn, s);
- cpu_register_physical_memory(base, 0x007fffff, iomemtype);
+ cpu_register_physical_memory(base, 0x00000fff, iomemtype);
s->base = base;
s->ds = ds;
s->pic = pic;
s->irq = irq;
+ graphic_console_init(ds, pl110_update_display, pl110_invalidate_display,
+ NULL, s);
/* ??? Save/restore. */
return s;
}
slavio_pic_set_irq_cpu(slavio_intctl, irq, level, cpu);
}
-static void *tcx;
-
-void vga_update_display()
-{
- tcx_update_display(tcx);
-}
-
-void vga_invalidate_display()
-{
- tcx_invalidate_display(tcx);
-}
-
-void vga_screen_dump(const char *filename)
-{
- tcx_screen_dump(tcx, filename);
-}
-
static void *iommu;
uint32_t iommu_translate(uint32_t addr)
slavio_intctl_set_cpu(slavio_intctl, i, envs[i]);
}
- tcx = tcx_init(ds, PHYS_JJ_TCX_FB, phys_ram_base + ram_size, ram_size, vram_size, graphic_width, graphic_height);
+ tcx_init(ds, PHYS_JJ_TCX_FB, phys_ram_base + ram_size, ram_size, vram_size, graphic_width, graphic_height);
if (nd_table[0].vlan) {
if (nd_table[0].model == NULL
|| strcmp(nd_table[0].model, "lance") == 0) {
uint8_t dac_index, dac_state;
} TCXState;
+static void tcx_screen_dump(void *opaque, const char *filename);
+
static void tcx_draw_line32(TCXState *s1, uint8_t *d,
const uint8_t *s, int width)
{
/* Fixed line length 1024 allows us to do nice tricks not possible on
VGA... */
-void tcx_update_display(void *opaque)
+static void tcx_update_display(void *opaque)
{
TCXState *ts = opaque;
uint32_t page;
}
}
-void tcx_invalidate_display(void *opaque)
+static void tcx_invalidate_display(void *opaque)
{
TCXState *s = opaque;
int i;
tcx_dac_writel,
};
-void *tcx_init(DisplayState *ds, uint32_t addr, uint8_t *vram_base,
- unsigned long vram_offset, int vram_size, int width, int height)
+void tcx_init(DisplayState *ds, uint32_t addr, uint8_t *vram_base,
+ unsigned long vram_offset, int vram_size, int width, int height)
{
TCXState *s;
int io_memory;
s = qemu_mallocz(sizeof(TCXState));
if (!s)
- return NULL;
+ return;
s->ds = ds;
s->addr = addr;
s->vram = vram_base;
io_memory = cpu_register_io_memory(0, tcx_dac_read, tcx_dac_write, s);
cpu_register_physical_memory(addr + 0x200000, TCX_DAC_NREGS, io_memory);
+ graphic_console_init(s->ds, tcx_update_display, tcx_invalidate_display,
+ tcx_screen_dump, s);
register_savevm("tcx", addr, 1, tcx_save, tcx_load, s);
qemu_register_reset(tcx_reset, s);
tcx_reset(s);
dpy_resize(s->ds, width, height);
- return s;
}
-void tcx_screen_dump(void *opaque, const char *filename)
+static void tcx_screen_dump(void *opaque, const char *filename)
{
TCXState *s = opaque;
FILE *f;
VGAState *vga_state;
int vga_io_memory;
+static void vga_screen_dump(void *opaque, const char *filename);
+
static uint32_t vga_ioport_read(void *opaque, uint32_t addr)
{
VGAState *s = opaque;
#define GMODE_GRAPH 1
#define GMODE_BLANK 2
-void vga_update_display(void)
+static void vga_update_display(void *opaque)
{
- VGAState *s = vga_state;
+ VGAState *s = (VGAState *)opaque;
int full_update, graphic_mode;
if (s->ds->depth == 0) {
}
/* force a full display refresh */
-void vga_invalidate_display(void)
+static void vga_invalidate_display(void *opaque)
{
- VGAState *s = vga_state;
+ VGAState *s = (VGAState *)opaque;
s->last_width = -1;
s->last_height = -1;
s->get_bpp = vga_get_bpp;
s->get_offsets = vga_get_offsets;
s->get_resolution = vga_get_resolution;
+ graphic_console_init(s->ds, vga_update_display, vga_invalidate_display,
+ vga_screen_dump, s);
/* XXX: currently needed for display */
vga_state = s;
}
/* save the vga display in a PPM image even if no display is
available */
-void vga_screen_dump(const char *filename)
+static void vga_screen_dump(void *opaque, const char *filename)
{
- VGAState *s = vga_state;
+ VGAState *s = (VGAState *)opaque;
DisplayState *saved_ds, ds1, *ds = &ds1;
/* XXX: this is a little hackish */
- vga_invalidate_display();
+ vga_invalidate_display(s);
saved_ds = s->ds;
memset(ds, 0, sizeof(DisplayState));
s->ds = ds;
s->graphic_mode = -1;
- vga_update_display();
+ vga_update_display(s);
if (ds->data) {
ppm_save(filename, ds->data, vga_save_w, vga_save_h,
static void do_screen_dump(const char *filename)
{
- vga_screen_dump(filename);
+ vga_hw_screen_dump(filename);
}
static void do_log(const char *items)
if (!gui_saved_grab)
sdl_grab_end();
}
- vga_invalidate_display();
- vga_update_display();
+ vga_hw_invalidate();
+ vga_hw_update();
}
static void sdl_refresh(DisplayState *ds)
sdl_update_caption();
}
- if (is_active_console(vga_console))
- vga_update_display();
+ vga_hw_update();
while (SDL_PollEvent(ev)) {
switch (ev->type) {
break;
case 0x02 ... 0x0a: /* '1' to '9' keys */
console_select(keycode - 0x02);
- if (is_active_console(vga_console)) {
- /* tell the vga console to redisplay itself */
- vga_invalidate_display();
- } else {
+ if (!is_graphic_console()) {
/* display grab if going to a text console */
if (gui_grab)
sdl_grab_end();
default:
break;
}
- } else if (!is_active_console(vga_console)) {
+ } else if (!is_graphic_console()) {
int keysym;
keysym = 0;
if (ev->key.keysym.mod & (KMOD_LCTRL | KMOD_RCTRL)) {
}
}
}
- if (is_active_console(vga_console))
+ if (is_graphic_console())
sdl_process_key(&ev->key);
break;
case SDL_QUIT:
#endif
int graphic_depth = 15;
int full_screen = 0;
-TextConsole *vga_console;
CharDriverState *serial_hds[MAX_SERIAL_PORTS];
CharDriverState *parallel_hds[MAX_PARALLEL_PORTS];
#ifdef TARGET_I386
static void dumb_refresh(DisplayState *ds)
{
- vga_update_display();
+ vga_hw_update();
}
void dumb_display_init(DisplayState *ds)
#endif
}
- vga_console = graphic_console_init(ds);
-
monitor_hd = qemu_chr_open(monitor_device);
if (!monitor_hd) {
fprintf(stderr, "qemu: could not open monitor device '%s'\n", monitor_device);
typedef struct DisplayState DisplayState;
typedef struct TextConsole TextConsole;
-extern TextConsole *vga_console;
-
-TextConsole *graphic_console_init(DisplayState *ds);
-int is_active_console(TextConsole *s);
+typedef void (*vga_hw_update_ptr)(void *);
+typedef void (*vga_hw_invalidate_ptr)(void *);
+typedef void (*vga_hw_screen_dump_ptr)(void *, const char *);
+
+TextConsole *graphic_console_init(DisplayState *ds, vga_hw_update_ptr update,
+ vga_hw_invalidate_ptr invalidate,
+ vga_hw_screen_dump_ptr screen_dump,
+ void *opaque);
+void vga_hw_update(void);
+void vga_hw_invalidate(void);
+void vga_hw_screen_dump(const char *filename);
+
+int is_graphic_console(void);
CharDriverState *text_console_init(DisplayState *ds);
void console_select(unsigned int index);
int vga_initialize(PCIBus *bus, DisplayState *ds, uint8_t *vga_ram_base,
unsigned long vga_ram_offset, int vga_ram_size,
unsigned long vga_bios_offset, int vga_bios_size);
-void vga_update_display(void);
-void vga_invalidate_display(void);
-void vga_screen_dump(const char *filename);
/* cirrus_vga.c */
void pci_cirrus_vga_init(PCIBus *bus, DisplayState *ds, uint8_t *vga_ram_base,
void lance_init(NICInfo *nd, int irq, uint32_t leaddr, uint32_t ledaddr);
/* tcx.c */
-void *tcx_init(DisplayState *ds, uint32_t addr, uint8_t *vram_base,
+void tcx_init(DisplayState *ds, uint32_t addr, uint8_t *vram_base,
unsigned long vram_offset, int vram_size, int width, int height);
-void tcx_update_display(void *opaque);
-void tcx_invalidate_display(void *opaque);
-void tcx_screen_dump(void *opaque, const char *filename);
/* slavio_intctl.c */
void *slavio_intctl_init();
void smc91c111_init(NICInfo *, uint32_t, void *, int);
/* pl110.c */
-void *pl110_init(DisplayState *ds, uint32_t base, void *pic, int irq);
-void pl110_update_display(void *opaque);
-void pl110_invalidate_display(void *opaque);
+void *pl110_init(DisplayState *ds, uint32_t base, void *pic, int irq, int);
#endif /* defined(QEMU_TOOL) */