aboutsummaryrefslogtreecommitdiff
path: root/vgasrc/vgahw.h
blob: 39f818ab5583966c9353a05c93ae2669d665f0cb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#ifndef __VGAHW_H
#define __VGAHW_H

#include "types.h" // u8
#include "config.h" // CONFIG_*

#include "cbvga.h" // cbvga_setup
#include "clext.h" // clext_set_mode
#include "bochsvga.h" // bochsvga_set_mode
#include "stdvga.h" // stdvga_set_mode
#include "geodevga.h" // geodevga_setup

static inline struct vgamode_s *vgahw_find_mode(int mode) {
    if (CONFIG_VGA_CIRRUS)
        return clext_find_mode(mode);
    if (CONFIG_VGA_BOCHS)
        return bochsvga_find_mode(mode);
    if (CONFIG_VGA_COREBOOT)
        return cbvga_find_mode(mode);
    return stdvga_find_mode(mode);
}

static inline int vgahw_set_mode(struct vgamode_s *vmode_g, int flags) {
    if (CONFIG_VGA_CIRRUS)
        return clext_set_mode(vmode_g, flags);
    if (CONFIG_VGA_BOCHS)
        return bochsvga_set_mode(vmode_g, flags);
    if (CONFIG_VGA_COREBOOT)
        return cbvga_set_mode(vmode_g, flags);
    return stdvga_set_mode(vmode_g, flags);
}

static inline void vgahw_list_modes(u16 seg, u16 *dest, u16 *last) {
    if (CONFIG_VGA_CIRRUS)
        clext_list_modes(seg, dest, last);
    else if (CONFIG_VGA_BOCHS)
        bochsvga_list_modes(seg, dest, last);
    else if (CONFIG_VGA_COREBOOT)
        cbvga_list_modes(seg, dest, last);
    else
        stdvga_list_modes(seg, dest, last);
}

static inline int vgahw_setup(void) {
    if (CONFIG_VGA_CIRRUS)
        return clext_setup();
    if (CONFIG_VGA_BOCHS)
        return bochsvga_setup();
    if (CONFIG_VGA_GEODEGX2 || CONFIG_VGA_GEODELX)
        return geodevga_setup();
    if (CONFIG_VGA_COREBOOT)
        return cbvga_setup();
    return stdvga_setup();
}

static inline int vgahw_get_window(struct vgamode_s *vmode_g, int window) {
    if (CONFIG_VGA_CIRRUS)
        return clext_get_window(vmode_g, window);
    if (CONFIG_VGA_BOCHS)
        return bochsvga_get_window(vmode_g, window);
    if (CONFIG_VGA_COREBOOT)
        return cbvga_get_window(vmode_g, window);
    return stdvga_get_window(vmode_g, window);
}

static inline int vgahw_set_window(struct vgamode_s *vmode_g, int window
                                   , int val) {
    if (CONFIG_VGA_CIRRUS)
        return clext_set_window(vmode_g, window, val);
    if (CONFIG_VGA_BOCHS)
        return bochsvga_set_window(vmode_g, window, val);
    if (CONFIG_VGA_COREBOOT)
        return cbvga_set_window(vmode_g, window, val);
    return stdvga_set_window(vmode_g, window, val);
}

static inline int vgahw_get_linelength(struct vgamode_s *vmode_g) {
    if (CONFIG_VGA_CIRRUS)
        return clext_get_linelength(vmode_g);
    if (CONFIG_VGA_BOCHS)
        return bochsvga_get_linelength(vmode_g);
    if (CONFIG_VGA_COREBOOT)
        return cbvga_get_linelength(vmode_g);
    return stdvga_get_linelength(vmode_g);
}

static inline int vgahw_set_linelength(struct vgamode_s *vmode_g, int val) {
    if (CONFIG_VGA_CIRRUS)
        return clext_set_linelength(vmode_g, val);
    if (CONFIG_VGA_BOCHS)
        return bochsvga_set_linelength(vmode_g, val);
    if (CONFIG_VGA_COREBOOT)
        return cbvga_set_linelength(vmode_g, val);
    return stdvga_set_linelength(vmode_g, val);
}

static inline int vgahw_get_displaystart(struct vgamode_s *vmode_g) {
    if (CONFIG_VGA_CIRRUS)
        return clext_get_displaystart(vmode_g);
    if (CONFIG_VGA_BOCHS)
        return bochsvga_get_displaystart(vmode_g);
    if (CONFIG_VGA_COREBOOT)
        return cbvga_get_displaystart(vmode_g);
    return stdvga_get_displaystart(vmode_g);
}

static inline int vgahw_set_displaystart(struct vgamode_s *vmode_g, int val) {
    if (CONFIG_VGA_CIRRUS)
        return clext_set_displaystart(vmode_g, val);
    if (CONFIG_VGA_BOCHS)
        return bochsvga_set_displaystart(vmode_g, val);
    if (CONFIG_VGA_COREBOOT)
        return cbvga_set_displaystart(vmode_g, val);
    return stdvga_set_displaystart(vmode_g, val);
}

static inline int vgahw_get_dacformat(struct vgamode_s *vmode_g) {
    if (CONFIG_VGA_BOCHS)
        return bochsvga_get_dacformat(vmode_g);
    if (CONFIG_VGA_COREBOOT)
        return cbvga_get_dacformat(vmode_g);
    return stdvga_get_dacformat(vmode_g);
}

static inline int vgahw_set_dacformat(struct vgamode_s *vmode_g, int val) {
    if (CONFIG_VGA_BOCHS)
        return bochsvga_set_dacformat(vmode_g, val);
    if (CONFIG_VGA_COREBOOT)
        return cbvga_set_dacformat(vmode_g, val);
    return stdvga_set_dacformat(vmode_g, val);
}

static inline int vgahw_save_restore(int cmd, u16 seg, void *data) {
    if (CONFIG_VGA_CIRRUS)
        return clext_save_restore(cmd, seg, data);
    if (CONFIG_VGA_BOCHS)
        return bochsvga_save_restore(cmd, seg, data);
    if (CONFIG_VGA_COREBOOT)
        return cbvga_save_restore(cmd, seg, data);
    return stdvga_save_restore(cmd, seg, data);
}

#endif // vgahw.h