Revision 95219897

b/cocoa.m
365 365
    pool = [ [ NSAutoreleasePool alloc ] init ];
366 366
    distantPast = [ NSDate distantPast ];
367 367
    
368
    if (is_active_console(vga_console)) 
369
        vga_update_display();
368
    vga_hw_update();
369

  
370 370
    do {
371 371
        event = [ NSApp nextEventMatchingMask:NSAnyEventMask untilDate:distantPast
372 372
                        inMode: NSDefaultRunLoopMode dequeue:YES ];
......
382 382
                                /* emulate caps lock and num lock keydown and keyup */
383 383
                                kbd_put_keycode(keycode);
384 384
                                kbd_put_keycode(keycode | 0x80);
385
                            } else if (is_active_console(vga_console)) {
385
                            } else if (is_graphic_console()) {
386 386
                                if (keycode & 0x80)
387 387
                                    kbd_put_keycode(0xe0);
388 388
                                if (modifiers_state[keycode] == 0) {
......
429 429
                                /* toggle Monitor */
430 430
                                case 0x02 ... 0x0a: /* '1' to '9' keys */
431 431
                                    console_select(keycode - 0x02);
432
                                    if (is_active_console(vga_console)) {
433
                                        /* tell the vga console to redisplay itself */
434
                                        vga_invalidate_display();
435 432
                                    break;
436 433
                                }
437 434
                            }
438 435
                        } else {
439 436
                            /* handle standard key events */
440
                            if (is_active_console(vga_console)) {
437
                            if (is_graphic_console()) {
441 438
                                if (keycode & 0x80) //check bit for e0 in front
442 439
                                    kbd_put_keycode(0xe0);
443 440
                                kbd_put_keycode(keycode & 0x7f); //remove e0 bit in front
......
468 465
                case NSKeyUp:
469 466
                    {
470 467
                        int keycode = cocoa_keycode_to_qemu([event keyCode]);   
471
                        if (is_active_console(vga_console)) {
468
                        if (is_graphic_console()) {
472 469
                            if (keycode & 0x80)
473 470
                                kbd_put_keycode(0xe0);
474 471
                            kbd_put_keycode(keycode | 0x80); //add 128 to signal release of key
b/console.c
53 53
    TTY_STATE_CSI,
54 54
};
55 55

  
56

  
56
/* ??? This is mis-named.
57
   It is used for both text and graphical consoles.  */
57 58
struct TextConsole {
58 59
    int text_console; /* true if text console */
59 60
    DisplayState *ds;
61
    /* Graphic console state.  */
62
    vga_hw_update_ptr hw_update;
63
    vga_hw_invalidate_ptr hw_invalidate;
64
    vga_hw_screen_dump_ptr hw_screen_dump;
65
    void *hw;
66

  
60 67
    int g_width, g_height;
61 68
    int width;
62 69
    int height;
......
82 89
static TextConsole *consoles[MAX_CONSOLES];
83 90
static int nb_consoles = 0;
84 91

  
92
void vga_hw_update(void)
93
{
94
    if (active_console->hw_update)
95
        active_console->hw_update(active_console->hw);
96
}
97

  
98
void vga_hw_invalidate(void)
99
{
100
    if (active_console->hw_invalidate)
101
        active_console->hw_invalidate(active_console->hw);
102
}
103

  
104
void vga_hw_screen_dump(const char *filename)
105
{
106
    /* There is currently no was of specifying which screen we want to dump,
107
       so always dump the dirst one.  */
108
    if (consoles[0]->hw_screen_dump)
109
        consoles[0]->hw_screen_dump(consoles[0]->hw, filename);
110
}
111

  
85 112
/* convert a RGBA color to a color index usable in graphic primitives */
86 113
static unsigned int vga_get_color(DisplayState *ds, unsigned int rgba)
87 114
{
......
782 809
                s->g_width = s->ds->width;
783 810
                s->g_height = s->ds->height;
784 811
                text_console_resize(s);
785
        }
812
            }
786 813
            console_refresh(s);
814
        } else {
815
            vga_hw_invalidate();
787 816
        }
788 817
    }
789 818
}
......
874 903
    }
875 904
}
876 905

  
877
TextConsole *graphic_console_init(DisplayState *ds)
906
static TextConsole *new_console(DisplayState *ds, int text)
878 907
{
879 908
    TextConsole *s;
909
    int i;
880 910

  
881 911
    if (nb_consoles >= MAX_CONSOLES)
882 912
        return NULL;
......
884 914
    if (!s) {
885 915
        return NULL;
886 916
    }
887
    if (!active_console)
917
    if (!active_console || (active_console->text_console && !text))
888 918
        active_console = s;
889 919
    s->ds = ds;
890
    consoles[nb_consoles++] = s;
920
    s->text_console = text;
921
    if (text) {
922
        consoles[nb_consoles++] = s;
923
    } else {
924
        /* HACK: Put graphical consoles before text consoles.  */
925
        for (i = nb_consoles; i > 0; i--) {
926
            if (!consoles[i - 1]->text_console)
927
                break;
928
            consoles[i] = consoles[i - 1];
929
        }
930
        consoles[i] = s;
931
    }
932
    return s;
933
}
934

  
935
TextConsole *graphic_console_init(DisplayState *ds, vga_hw_update_ptr update,
936
                                  vga_hw_invalidate_ptr invalidate,
937
                                  vga_hw_screen_dump_ptr screen_dump,
938
                                  void *opaque)
939
{
940
    TextConsole *s;
941

  
942
    s = new_console(ds, 0);
943
    if (!s)
944
      return NULL;
945
    s->hw_update = update;
946
    s->hw_invalidate = invalidate;
947
    s->hw_screen_dump = screen_dump;
948
    s->hw = opaque;
891 949
    return s;
892 950
}
893 951

  
894
int is_active_console(TextConsole *s)
952
int is_graphic_console(void)
895 953
{
896
    return s == active_console;
954
    return !active_console->text_console;
897 955
}
898 956

  
899 957
CharDriverState *text_console_init(DisplayState *ds)
......
906 964
    chr = qemu_mallocz(sizeof(CharDriverState));
907 965
    if (!chr)
908 966
        return NULL;
909
    s = graphic_console_init(ds);
967
    s = new_console(ds, 1);
910 968
    if (!s) {
911 969
        free(chr);
912 970
        return NULL;
913 971
    }
914
    s->text_console = 1;
915 972
    chr->opaque = s;
916 973
    chr->chr_write = console_puts;
917 974
    chr->chr_add_read_handler = console_chr_add_read_handler;
b/hw/integratorcp.c
27 27
{
28 28
}
29 29

  
30
static void *lcd;
31

  
32
void vga_update_display(void)
33
{
34
    pl110_update_display(lcd);
35
}
36

  
37
void vga_screen_dump(const char *filename)
38
{
39
}
40

  
41
void vga_invalidate_display(void)
42
{
43
    pl110_invalidate_display(lcd);
44
}
45

  
46 30
void DMA_run (void)
47 31
{
48 32
}
......
1210 1194
            exit (1);
1211 1195
        }
1212 1196
    }
1213
    lcd = pl110_init(ds, 0xc0000000, pic, 22);
1197
    pl110_init(ds, 0xc0000000, pic, 22, 0);
1214 1198

  
1215 1199
    /* Load the kernel.  */
1216 1200
    if (!kernel_filename) {
b/hw/pl110.c
89 89
  return (s->cr & PL110_CR_EN) && (s->cr & PL110_CR_PWR);
90 90
}
91 91

  
92
void pl110_update_display(void *opaque)
92
static void pl110_update_display(void *opaque)
93 93
{
94 94
    pl110_state *s = (pl110_state *)opaque;
95 95
    drawfn* fntable;
......
205 205
    dpy_update(s->ds, 0, first, s->cols, last - first + 1);
206 206
}
207 207

  
208
void pl110_invalidate_display(void * opaque)
208
static void pl110_invalidate_display(void * opaque)
209 209
{
210 210
    pl110_state *s = (pl110_state *)opaque;
211 211
    s->invalidate = 1;
......
378 378
   pl110_write
379 379
};
380 380

  
381
void *pl110_init(DisplayState *ds, uint32_t base, void *pic, int irq)
381
void *pl110_init(DisplayState *ds, uint32_t base, void *pic, int irq,
382
                 int versatile)
382 383
{
383 384
    pl110_state *s;
384 385
    int iomemtype;
......
386 387
    s = (pl110_state *)qemu_mallocz(sizeof(pl110_state));
387 388
    iomemtype = cpu_register_io_memory(0, pl110_readfn,
388 389
                                       pl110_writefn, s);
389
    cpu_register_physical_memory(base, 0x007fffff, iomemtype);
390
    cpu_register_physical_memory(base, 0x00000fff, iomemtype);
390 391
    s->base = base;
391 392
    s->ds = ds;
392 393
    s->pic = pic;
393 394
    s->irq = irq;
395
    graphic_console_init(ds, pl110_update_display, pl110_invalidate_display,
396
                         NULL, s);
394 397
    /* ??? Save/restore.  */
395 398
    return s;
396 399
}
b/hw/sun4m.c
187 187
    slavio_pic_set_irq_cpu(slavio_intctl, irq, level, cpu);
188 188
}
189 189

  
190
static void *tcx;
191

  
192
void vga_update_display()
193
{
194
    tcx_update_display(tcx);
195
}
196

  
197
void vga_invalidate_display()
198
{
199
    tcx_invalidate_display(tcx);
200
}
201

  
202
void vga_screen_dump(const char *filename)
203
{
204
    tcx_screen_dump(tcx, filename);
205
}
206

  
207 190
static void *iommu;
208 191

  
209 192
uint32_t iommu_translate(uint32_t addr)
......
256 239
        slavio_intctl_set_cpu(slavio_intctl, i, envs[i]);
257 240
    }
258 241

  
259
    tcx = tcx_init(ds, PHYS_JJ_TCX_FB, phys_ram_base + ram_size, ram_size, vram_size, graphic_width, graphic_height);
242
    tcx_init(ds, PHYS_JJ_TCX_FB, phys_ram_base + ram_size, ram_size, vram_size, graphic_width, graphic_height);
260 243
    if (nd_table[0].vlan) {
261 244
        if (nd_table[0].model == NULL
262 245
            || strcmp(nd_table[0].model, "lance") == 0) {
b/hw/tcx.c
37 37
    uint8_t dac_index, dac_state;
38 38
} TCXState;
39 39

  
40
static void tcx_screen_dump(void *opaque, const char *filename);
41

  
40 42
static void tcx_draw_line32(TCXState *s1, uint8_t *d, 
41 43
			    const uint8_t *s, int width)
42 44
{
......
81 83

  
82 84
/* Fixed line length 1024 allows us to do nice tricks not possible on
83 85
   VGA... */
84
void tcx_update_display(void *opaque)
86
static void tcx_update_display(void *opaque)
85 87
{
86 88
    TCXState *ts = opaque;
87 89
    uint32_t page;
......
158 160
    }
159 161
}
160 162

  
161
void tcx_invalidate_display(void *opaque)
163
static void tcx_invalidate_display(void *opaque)
162 164
{
163 165
    TCXState *s = opaque;
164 166
    int i;
......
269 271
    tcx_dac_writel,
270 272
};
271 273

  
272
void *tcx_init(DisplayState *ds, uint32_t addr, uint8_t *vram_base,
273
	       unsigned long vram_offset, int vram_size, int width, int height)
274
void tcx_init(DisplayState *ds, uint32_t addr, uint8_t *vram_base,
275
	      unsigned long vram_offset, int vram_size, int width, int height)
274 276
{
275 277
    TCXState *s;
276 278
    int io_memory;
277 279

  
278 280
    s = qemu_mallocz(sizeof(TCXState));
279 281
    if (!s)
280
        return NULL;
282
        return;
281 283
    s->ds = ds;
282 284
    s->addr = addr;
283 285
    s->vram = vram_base;
......
289 291
    io_memory = cpu_register_io_memory(0, tcx_dac_read, tcx_dac_write, s);
290 292
    cpu_register_physical_memory(addr + 0x200000, TCX_DAC_NREGS, io_memory);
291 293

  
294
    graphic_console_init(s->ds, tcx_update_display, tcx_invalidate_display,
295
                         tcx_screen_dump, s);
292 296
    register_savevm("tcx", addr, 1, tcx_save, tcx_load, s);
293 297
    qemu_register_reset(tcx_reset, s);
294 298
    tcx_reset(s);
295 299
    dpy_resize(s->ds, width, height);
296
    return s;
297 300
}
298 301

  
299
void tcx_screen_dump(void *opaque, const char *filename)
302
static void tcx_screen_dump(void *opaque, const char *filename)
300 303
{
301 304
    TCXState *s = opaque;
302 305
    FILE *f;
b/hw/vga.c
146 146
VGAState *vga_state;
147 147
int vga_io_memory;
148 148

  
149
static void vga_screen_dump(void *opaque, const char *filename);
150

  
149 151
static uint32_t vga_ioport_read(void *opaque, uint32_t addr)
150 152
{
151 153
    VGAState *s = opaque;
......
1482 1484
#define GMODE_GRAPH    1
1483 1485
#define GMODE_BLANK 2 
1484 1486

  
1485
void vga_update_display(void)
1487
static void vga_update_display(void *opaque)
1486 1488
{
1487
    VGAState *s = vga_state;
1489
    VGAState *s = (VGAState *)opaque;
1488 1490
    int full_update, graphic_mode;
1489 1491

  
1490 1492
    if (s->ds->depth == 0) {
......
1532 1534
}
1533 1535

  
1534 1536
/* force a full display refresh */
1535
void vga_invalidate_display(void)
1537
static void vga_invalidate_display(void *opaque)
1536 1538
{
1537
    VGAState *s = vga_state;
1539
    VGAState *s = (VGAState *)opaque;
1538 1540
    
1539 1541
    s->last_width = -1;
1540 1542
    s->last_height = -1;
......
1698 1700
    s->get_bpp = vga_get_bpp;
1699 1701
    s->get_offsets = vga_get_offsets;
1700 1702
    s->get_resolution = vga_get_resolution;
1703
    graphic_console_init(s->ds, vga_update_display, vga_invalidate_display,
1704
                         vga_screen_dump, s);
1701 1705
    /* XXX: currently needed for display */
1702 1706
    vga_state = s;
1703 1707
}
......
1854 1858

  
1855 1859
/* save the vga display in a PPM image even if no display is
1856 1860
   available */
1857
void vga_screen_dump(const char *filename)
1861
static void vga_screen_dump(void *opaque, const char *filename)
1858 1862
{
1859
    VGAState *s = vga_state;
1863
    VGAState *s = (VGAState *)opaque;
1860 1864
    DisplayState *saved_ds, ds1, *ds = &ds1;
1861 1865
    
1862 1866
    /* XXX: this is a little hackish */
1863
    vga_invalidate_display();
1867
    vga_invalidate_display(s);
1864 1868
    saved_ds = s->ds;
1865 1869

  
1866 1870
    memset(ds, 0, sizeof(DisplayState));
......
1871 1875

  
1872 1876
    s->ds = ds;
1873 1877
    s->graphic_mode = -1;
1874
    vga_update_display();
1878
    vga_update_display(s);
1875 1879
    
1876 1880
    if (ds->data) {
1877 1881
        ppm_save(filename, ds->data, vga_save_w, vga_save_h, 
b/monitor.c
356 356

  
357 357
static void do_screen_dump(const char *filename)
358 358
{
359
    vga_screen_dump(filename);
359
    vga_hw_screen_dump(filename);
360 360
}
361 361

  
362 362
static void do_log(const char *items)
b/sdl.c
314 314
        if (!gui_saved_grab)
315 315
            sdl_grab_end();
316 316
    }
317
    vga_invalidate_display();
318
    vga_update_display();
317
    vga_hw_invalidate();
318
    vga_hw_update();
319 319
}
320 320

  
321 321
static void sdl_refresh(DisplayState *ds)
......
328 328
        sdl_update_caption();
329 329
    }
330 330

  
331
    if (is_active_console(vga_console)) 
332
        vga_update_display();
331
    vga_hw_update();
333 332

  
334 333
    while (SDL_PollEvent(ev)) {
335 334
        switch (ev->type) {
......
352 351
                        break;
353 352
                    case 0x02 ... 0x0a: /* '1' to '9' keys */ 
354 353
                        console_select(keycode - 0x02);
355
                        if (is_active_console(vga_console)) {
356
                            /* tell the vga console to redisplay itself */
357
                            vga_invalidate_display();
358
                        } else {
354
                        if (!is_graphic_console()) {
359 355
                            /* display grab if going to a text console */
360 356
                            if (gui_grab)
361 357
                                sdl_grab_end();
......
365 361
                    default:
366 362
                        break;
367 363
                    }
368
                } else if (!is_active_console(vga_console)) {
364
                } else if (!is_graphic_console()) {
369 365
                    int keysym;
370 366
                    keysym = 0;
371 367
                    if (ev->key.keysym.mod & (KMOD_LCTRL | KMOD_RCTRL)) {
......
420 416
                    }
421 417
                }
422 418
            }
423
            if (is_active_console(vga_console)) 
419
            if (is_graphic_console()) 
424 420
                sdl_process_key(&ev->key);
425 421
            break;
426 422
        case SDL_QUIT:
b/vl.c
137 137
#endif
138 138
int graphic_depth = 15;
139 139
int full_screen = 0;
140
TextConsole *vga_console;
141 140
CharDriverState *serial_hds[MAX_SERIAL_PORTS];
142 141
CharDriverState *parallel_hds[MAX_PARALLEL_PORTS];
143 142
#ifdef TARGET_I386
......
2994 2993

  
2995 2994
static void dumb_refresh(DisplayState *ds)
2996 2995
{
2997
    vga_update_display();
2996
    vga_hw_update();
2998 2997
}
2999 2998

  
3000 2999
void dumb_display_init(DisplayState *ds)
......
5123 5122
#endif
5124 5123
    }
5125 5124

  
5126
    vga_console = graphic_console_init(ds);
5127
    
5128 5125
    monitor_hd = qemu_chr_open(monitor_device);
5129 5126
    if (!monitor_hd) {
5130 5127
        fprintf(stderr, "qemu: could not open monitor device '%s'\n", monitor_device);
b/vl.h
254 254
typedef struct DisplayState DisplayState;
255 255
typedef struct TextConsole TextConsole;
256 256

  
257
extern TextConsole *vga_console;
258

  
259
TextConsole *graphic_console_init(DisplayState *ds);
260
int is_active_console(TextConsole *s);
257
typedef void (*vga_hw_update_ptr)(void *);
258
typedef void (*vga_hw_invalidate_ptr)(void *);
259
typedef void (*vga_hw_screen_dump_ptr)(void *, const char *);
260

  
261
TextConsole *graphic_console_init(DisplayState *ds, vga_hw_update_ptr update,
262
                                  vga_hw_invalidate_ptr invalidate,
263
                                  vga_hw_screen_dump_ptr screen_dump,
264
                                  void *opaque);
265
void vga_hw_update(void);
266
void vga_hw_invalidate(void);
267
void vga_hw_screen_dump(const char *filename);
268

  
269
int is_graphic_console(void);
261 270
CharDriverState *text_console_init(DisplayState *ds);
262 271
void console_select(unsigned int index);
263 272

  
......
673 682
int vga_initialize(PCIBus *bus, DisplayState *ds, uint8_t *vga_ram_base, 
674 683
                   unsigned long vga_ram_offset, int vga_ram_size,
675 684
                   unsigned long vga_bios_offset, int vga_bios_size);
676
void vga_update_display(void);
677
void vga_invalidate_display(void);
678
void vga_screen_dump(const char *filename);
679 685

  
680 686
/* cirrus_vga.c */
681 687
void pci_cirrus_vga_init(PCIBus *bus, DisplayState *ds, uint8_t *vga_ram_base, 
......
844 850
void lance_init(NICInfo *nd, int irq, uint32_t leaddr, uint32_t ledaddr);
845 851

  
846 852
/* tcx.c */
847
void *tcx_init(DisplayState *ds, uint32_t addr, uint8_t *vram_base,
853
void tcx_init(DisplayState *ds, uint32_t addr, uint8_t *vram_base,
848 854
	       unsigned long vram_offset, int vram_size, int width, int height);
849
void tcx_update_display(void *opaque);
850
void tcx_invalidate_display(void *opaque);
851
void tcx_screen_dump(void *opaque, const char *filename);
852 855

  
853 856
/* slavio_intctl.c */
854 857
void *slavio_intctl_init();
......
976 979
void smc91c111_init(NICInfo *, uint32_t, void *, int);
977 980

  
978 981
/* pl110.c */
979
void *pl110_init(DisplayState *ds, uint32_t base, void *pic, int irq);
980
void pl110_update_display(void *opaque);
981
void pl110_invalidate_display(void *opaque);
982
void *pl110_init(DisplayState *ds, uint32_t base, void *pic, int irq, int);
982 983

  
983 984
#endif /* defined(QEMU_TOOL) */
984 985

  

Also available in: Unified diff