Revision 95219897 console.c
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; |
Also available in: Unified diff