Add qemu 2.4.0
[kvmfornfv.git] / qemu / roms / seabios / vgasrc / vgahw.h
1 #ifndef __VGAHW_H
2 #define __VGAHW_H
3
4 #include "types.h" // u8
5 #include "config.h" // CONFIG_*
6
7 #include "cbvga.h" // cbvga_setup
8 #include "clext.h" // clext_set_mode
9 #include "bochsvga.h" // bochsvga_set_mode
10 #include "stdvga.h" // stdvga_set_mode
11 #include "geodevga.h" // geodevga_setup
12
13 static inline struct vgamode_s *vgahw_find_mode(int mode) {
14     if (CONFIG_VGA_CIRRUS)
15         return clext_find_mode(mode);
16     if (CONFIG_VGA_BOCHS)
17         return bochsvga_find_mode(mode);
18     if (CONFIG_VGA_COREBOOT)
19         return cbvga_find_mode(mode);
20     return stdvga_find_mode(mode);
21 }
22
23 static inline int vgahw_set_mode(struct vgamode_s *vmode_g, int flags) {
24     if (CONFIG_VGA_CIRRUS)
25         return clext_set_mode(vmode_g, flags);
26     if (CONFIG_VGA_BOCHS)
27         return bochsvga_set_mode(vmode_g, flags);
28     if (CONFIG_VGA_COREBOOT)
29         return cbvga_set_mode(vmode_g, flags);
30     return stdvga_set_mode(vmode_g, flags);
31 }
32
33 static inline void vgahw_list_modes(u16 seg, u16 *dest, u16 *last) {
34     if (CONFIG_VGA_CIRRUS)
35         clext_list_modes(seg, dest, last);
36     else if (CONFIG_VGA_BOCHS)
37         bochsvga_list_modes(seg, dest, last);
38     else if (CONFIG_VGA_COREBOOT)
39         cbvga_list_modes(seg, dest, last);
40     else
41         stdvga_list_modes(seg, dest, last);
42 }
43
44 static inline int vgahw_setup(void) {
45     if (CONFIG_VGA_CIRRUS)
46         return clext_setup();
47     if (CONFIG_VGA_BOCHS)
48         return bochsvga_setup();
49     if (CONFIG_VGA_GEODEGX2 || CONFIG_VGA_GEODELX)
50         return geodevga_setup();
51     if (CONFIG_VGA_COREBOOT)
52         return cbvga_setup();
53     return stdvga_setup();
54 }
55
56 static inline int vgahw_get_window(struct vgamode_s *vmode_g, int window) {
57     if (CONFIG_VGA_CIRRUS)
58         return clext_get_window(vmode_g, window);
59     if (CONFIG_VGA_BOCHS)
60         return bochsvga_get_window(vmode_g, window);
61     if (CONFIG_VGA_COREBOOT)
62         return cbvga_get_window(vmode_g, window);
63     return stdvga_get_window(vmode_g, window);
64 }
65
66 static inline int vgahw_set_window(struct vgamode_s *vmode_g, int window
67                                    , int val) {
68     if (CONFIG_VGA_CIRRUS)
69         return clext_set_window(vmode_g, window, val);
70     if (CONFIG_VGA_BOCHS)
71         return bochsvga_set_window(vmode_g, window, val);
72     if (CONFIG_VGA_COREBOOT)
73         return cbvga_set_window(vmode_g, window, val);
74     return stdvga_set_window(vmode_g, window, val);
75 }
76
77 static inline int vgahw_get_linelength(struct vgamode_s *vmode_g) {
78     if (CONFIG_VGA_CIRRUS)
79         return clext_get_linelength(vmode_g);
80     if (CONFIG_VGA_BOCHS)
81         return bochsvga_get_linelength(vmode_g);
82     if (CONFIG_VGA_COREBOOT)
83         return cbvga_get_linelength(vmode_g);
84     return stdvga_get_linelength(vmode_g);
85 }
86
87 static inline int vgahw_set_linelength(struct vgamode_s *vmode_g, int val) {
88     if (CONFIG_VGA_CIRRUS)
89         return clext_set_linelength(vmode_g, val);
90     if (CONFIG_VGA_BOCHS)
91         return bochsvga_set_linelength(vmode_g, val);
92     if (CONFIG_VGA_COREBOOT)
93         return cbvga_set_linelength(vmode_g, val);
94     return stdvga_set_linelength(vmode_g, val);
95 }
96
97 static inline int vgahw_get_displaystart(struct vgamode_s *vmode_g) {
98     if (CONFIG_VGA_CIRRUS)
99         return clext_get_displaystart(vmode_g);
100     if (CONFIG_VGA_BOCHS)
101         return bochsvga_get_displaystart(vmode_g);
102     if (CONFIG_VGA_COREBOOT)
103         return cbvga_get_displaystart(vmode_g);
104     return stdvga_get_displaystart(vmode_g);
105 }
106
107 static inline int vgahw_set_displaystart(struct vgamode_s *vmode_g, int val) {
108     if (CONFIG_VGA_CIRRUS)
109         return clext_set_displaystart(vmode_g, val);
110     if (CONFIG_VGA_BOCHS)
111         return bochsvga_set_displaystart(vmode_g, val);
112     if (CONFIG_VGA_COREBOOT)
113         return cbvga_set_displaystart(vmode_g, val);
114     return stdvga_set_displaystart(vmode_g, val);
115 }
116
117 static inline int vgahw_get_dacformat(struct vgamode_s *vmode_g) {
118     if (CONFIG_VGA_BOCHS)
119         return bochsvga_get_dacformat(vmode_g);
120     if (CONFIG_VGA_COREBOOT)
121         return cbvga_get_dacformat(vmode_g);
122     return stdvga_get_dacformat(vmode_g);
123 }
124
125 static inline int vgahw_set_dacformat(struct vgamode_s *vmode_g, int val) {
126     if (CONFIG_VGA_BOCHS)
127         return bochsvga_set_dacformat(vmode_g, val);
128     if (CONFIG_VGA_COREBOOT)
129         return cbvga_set_dacformat(vmode_g, val);
130     return stdvga_set_dacformat(vmode_g, val);
131 }
132
133 static inline int vgahw_save_restore(int cmd, u16 seg, void *data) {
134     if (CONFIG_VGA_CIRRUS)
135         return clext_save_restore(cmd, seg, data);
136     if (CONFIG_VGA_BOCHS)
137         return bochsvga_save_restore(cmd, seg, data);
138     if (CONFIG_VGA_COREBOOT)
139         return cbvga_save_restore(cmd, seg, data);
140     return stdvga_save_restore(cmd, seg, data);
141 }
142
143 #endif // vgahw.h