forked from kjliew/qemu-3dfx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path99-3dfx.patch
304 lines (293 loc) · 8.64 KB
/
99-3dfx.patch
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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
diff -ru ../qemu-2.12.1/configure ./configure
--- ../qemu-2.12.1/configure 2018-08-02 14:48:53.000000000 -0700
+++ ./configure 2019-08-20 01:38:26.053625288 -0700
@@ -782,6 +782,8 @@
# won't work when we're compiling with gcc as a C compiler.
QEMU_CFLAGS="-DOS_OBJECT_USE_OBJC=0 $QEMU_CFLAGS"
HOST_VARIANT_DIR="darwin"
+# For 3Dfx Glide pass-through ##
+ LIBS="-ldl $LIBS"
supported_os="yes"
;;
SunOS)
@@ -818,6 +820,8 @@
vhost_scsi="yes"
vhost_vsock="yes"
QEMU_INCLUDES="-I\$(SRC_PATH)/linux-headers -I$(pwd)/linux-headers $QEMU_INCLUDES"
+# For 3Dfx Glide pass-through ##
+ LIBS="-ldl $LIBS"
supported_os="yes"
;;
esac
Only in ./hw: 3dfx
diff -ru ../qemu-2.12.1/hw/i386/pc.c ./hw/i386/pc.c
--- ../qemu-2.12.1/hw/i386/pc.c 2018-08-02 14:48:53.000000000 -0700
+++ ./hw/i386/pc.c 2019-08-20 01:32:20.539363427 -0700
@@ -1670,6 +1670,16 @@
for (i = 0; i < IOAPIC_NUM_PINS; i++) {
gsi_state->ioapic_irq[i] = qdev_get_gpio_in(dev, i);
}
+ glidept_mm_init();
+}
+
+void glidept_mm_init(void)
+{
+ DeviceState *glidept_dev = NULL;
+
+ glidept_dev = qdev_create(NULL, TYPE_GLIDEPT);
+ qdev_init_nofail(glidept_dev);
+ sysbus_mmio_map(SYS_BUS_DEVICE(glidept_dev), 0, GLIDEPT_MM_BASE);
}
static void pc_dimm_plug(HotplugHandler *hotplug_dev,
diff -ru ../qemu-2.12.1/hw/Makefile.objs ./hw/Makefile.objs
--- ../qemu-2.12.1/hw/Makefile.objs 2018-08-02 14:48:53.000000000 -0700
+++ ./hw/Makefile.objs 2019-08-20 01:32:20.539363427 -0700
@@ -35,6 +35,7 @@
devices-dirs-$(CONFIG_SOFTMMU) += xen/
devices-dirs-$(CONFIG_MEM_HOTPLUG) += mem/
devices-dirs-$(CONFIG_SOFTMMU) += smbios/
+devices-dirs-y += 3dfx/
devices-dirs-y += core/
common-obj-y += $(devices-dirs-y)
obj-y += $(devices-dirs-y)
diff -ru ../qemu-2.12.1/include/hw/i386/pc.h ./include/hw/i386/pc.h
--- ../qemu-2.12.1/include/hw/i386/pc.h 2018-08-02 14:48:53.000000000 -0700
+++ ./include/hw/i386/pc.h 2019-08-20 01:32:20.542696275 -0700
@@ -176,6 +176,11 @@
void gsi_handler(void *opaque, int n, int level);
+/* GLIDE pass-through */
+#define TYPE_GLIDEPT "glidept"
+#define GLIDEPT_MM_BASE 0xfbdff000
+void glidept_mm_init(void);
+
/* vmport.c */
#define TYPE_VMPORT "vmport"
typedef uint32_t (VMPortReadFunc)(void *opaque, uint32_t address);
diff -ru ../qemu-2.12.1/include/ui/console.h ./include/ui/console.h
--- ../qemu-2.12.1/include/ui/console.h 2018-08-02 14:48:53.000000000 -0700
+++ ./include/ui/console.h 2019-08-20 01:32:20.542696275 -0700
@@ -462,4 +462,13 @@
/* input.c */
int index_from_key(const char *key, size_t key_length);
+/* glidewnd.c */
+uintptr_t glide_prepare_window(int w, int h);
+void glide_release_window(void);
+uint32_t glide_window_stat(int);
+int glide_gui_fullscreen(void);
+int is_glide_enabled(void);
+void glide_enabled_set(void);
+void glide_enabled_reset(void);
+
#endif
diff -ru ../qemu-2.12.1/ui/console.c ./ui/console.c
--- ../qemu-2.12.1/ui/console.c 2018-08-02 14:48:53.000000000 -0700
+++ ./ui/console.c 2019-08-20 01:33:44.559366716 -0700
@@ -256,8 +256,15 @@
ds->have_text = have_text;
}
+static int glide_enabled = 0;
+int is_glide_enabled(void) { return glide_enabled; }
+void glide_enabled_set(void) { glide_enabled = 1; }
+void glide_enabled_reset(void) { glide_enabled = 0; }
+
void graphic_hw_update(QemuConsole *con)
{
+ if (is_glide_enabled())
+ return;
if (!con) {
con = active_console;
}
diff -ru ../qemu-2.12.1/ui/sdl2-2d.c ./ui/sdl2-2d.c
--- ../qemu-2.12.1/ui/sdl2-2d.c 2018-08-02 14:48:53.000000000 -0700
+++ ./ui/sdl2-2d.c 2019-08-20 01:32:20.546029124 -0700
@@ -41,6 +41,9 @@
assert(!scon->opengl);
+ if (is_glide_enabled())
+ return;
+
if (!surf) {
return;
}
diff -ru ../qemu-2.12.1/ui/sdl2.c ./ui/sdl2.c
--- ../qemu-2.12.1/ui/sdl2.c 2018-08-02 14:48:53.000000000 -0700
+++ ./ui/sdl2.c 2019-08-20 01:34:55.013815041 -0700
@@ -37,6 +37,8 @@
static SDL_Surface *guest_sprite_surface;
static int gui_grab; /* if true, all keyboard/mouse events are grabbed */
+static int gui_saved_width;
+static int gui_saved_height;
static int gui_saved_grab;
static int gui_fullscreen;
static int gui_keysym;
@@ -537,6 +539,14 @@
sdl2_redraw(scon);
break;
case SDL_WINDOWEVENT_EXPOSED:
+ if (ev->window.data1 && ev->window.data2) {
+ if ((ev->window.data1 == gui_saved_width) &&
+ (ev->window.data2 == gui_saved_height)) {
+ gui_saved_width = 0;
+ gui_saved_height = 0;
+ }
+ SDL_SetWindowSize(scon->real_window, ev->window.data1, ev->window.data2);
+ }
sdl2_redraw(scon);
break;
case SDL_WINDOWEVENT_FOCUS_GAINED:
@@ -721,6 +731,68 @@
SDL_QuitSubSystem(SDL_INIT_VIDEO);
}
+uintptr_t glide_prepare_window(int w, int h)
+{
+ uintptr_t hwndSDL = 0;
+ SDL_SysWMinfo wmi;
+ SDL_Event ev1, *ev = &ev1;
+ int scr_w, scr_h;
+
+ if (!sdl2_console)
+ return hwndSDL;
+
+ SDL_VERSION(&wmi.version);
+ if (SDL_GetWindowWMInfo(sdl2_console[0].real_window, &wmi)) {
+#if defined(SDL_VIDEO_DRIVER_WINDOWS)
+ hwndSDL = (uintptr_t)wmi.info.win.window;
+#elif defined(SDL_VIDEO_DRIVER_X11)
+ hwndSDL = (uintptr_t)wmi.info.x11.window;
+#endif
+ }
+ SDL_GetWindowSize(sdl2_console[0].real_window, &scr_w, &scr_h);
+ gui_saved_width = scr_w;
+ gui_saved_height = scr_h;
+
+ glide_enabled_set();
+ smp_mb();
+
+ ev->type = SDL_WINDOWEVENT;
+ ev->window.windowID = SDL_GetWindowID(sdl2_console[0].real_window);
+ ev->window.event = SDL_WINDOWEVENT_EXPOSED;
+ ev->window.data1 = w;
+ ev->window.data2 = h;
+ SDL_PushEvent(ev);
+
+ return hwndSDL;
+}
+
+void glide_release_window(void)
+{
+ glide_enabled_reset();
+ smp_mb();
+ SDL_Event ev1, *ev = &ev1;
+ ev->type = SDL_WINDOWEVENT;
+ ev->window.windowID = SDL_GetWindowID(sdl2_console[0].real_window);
+ ev->window.event = SDL_WINDOWEVENT_EXPOSED;
+ ev->window.data1 = gui_saved_width;
+ ev->window.data2 = gui_saved_height;
+ SDL_PushEvent(ev);
+}
+
+uint32_t glide_window_stat(int activate)
+{
+ int scr_w, scr_h;
+ uint32_t stat;
+ SDL_GetWindowSize(sdl2_console[0].real_window, &scr_w, &scr_h);
+ if (activate)
+ stat = (uint32_t)(((scr_h & 0xFFFFU) << 0x10) | scr_w);
+ else
+ stat = (((gui_saved_height & 0xFFFFU) << 0x10) | gui_saved_width)? 1:0;
+ return stat;
+}
+
+int glide_gui_fullscreen(void) { return gui_fullscreen; }
+
static const DisplayChangeListenerOps dcl_2d_ops = {
.dpy_name = "sdl2-2d",
.dpy_gfx_update = sdl2_2d_update,
diff -ru ../qemu-2.12.1/ui/sdl.c ./ui/sdl.c
--- ../qemu-2.12.1/ui/sdl.c 2018-08-02 14:48:53.000000000 -0700
+++ ./ui/sdl.c 2019-08-20 01:33:58.624744618 -0700
@@ -90,6 +90,9 @@
x, y, w, h, scaling_active);
#endif
+ if (is_glide_enabled())
+ return;
+
if (guest_screen) {
if (!scaling_active) {
SDL_BlitSurface(guest_screen, &rec, real_screen, &rec);
@@ -821,6 +824,10 @@
break;
case SDL_VIDEORESIZE:
sdl_scale(ev->resize.w, ev->resize.h);
+ if ((ev->resize.w == gui_saved_width) && (ev->resize.h == gui_saved_height)) {
+ gui_saved_width = 0;
+ gui_saved_height = 0;
+ }
graphic_hw_invalidate(NULL);
graphic_hw_update(NULL);
break;
@@ -891,6 +898,66 @@
SDL_QuitSubSystem(SDL_INIT_VIDEO);
}
+uintptr_t glide_prepare_window(int w, int h)
+{
+ uintptr_t hwndSDL = 0;
+ SDL_SysWMinfo wmi;
+
+ if (!guest_screen)
+ return hwndSDL;
+
+ SDL_VERSION(&wmi.version);
+ if(SDL_GetWMInfo(&wmi)) {
+#if defined(_WIN32)
+ hwndSDL = (uintptr_t)wmi.window;
+#else
+#if defined(SDL_VIDEO_DRIVER_X11)
+ hwndSDL = (uintptr_t)wmi.info.x11.window;
+#endif
+#endif
+ }
+ gui_saved_width = real_screen->w;
+ gui_saved_height = real_screen->h;
+
+ glide_enabled_set();
+ smp_mb();
+
+ SDL_Event ev1, *ev = &ev1;
+ ev->type = SDL_VIDEORESIZE;
+ ev->resize.w = w;
+ ev->resize.h = h;
+ SDL_PushEvent(ev);
+
+ return hwndSDL;
+}
+
+void glide_release_window(void)
+{
+ glide_enabled_reset();
+ smp_mb();
+
+ SDL_Event ev1, *ev = &ev1;
+ ev->type = SDL_VIDEORESIZE;
+ ev->resize.w = gui_saved_width;
+ ev->resize.h = gui_saved_height;
+ SDL_PushEvent(ev);
+}
+
+uint32_t glide_window_stat(int activate)
+{
+ int scr_w, scr_h;
+ uint32_t stat;
+ scr_w = real_screen->w;
+ scr_h = real_screen->h;
+ if (activate)
+ stat = (uint32_t)(((scr_h & 0xFFFFU) << 0x10) | scr_w);
+ else
+ stat = (((gui_saved_height & 0xFFFFU) << 0x10) | gui_saved_width)? 1:0;
+ return stat;
+}
+
+int glide_gui_fullscreen(void) { return gui_fullscreen; }
+
static const DisplayChangeListenerOps dcl_ops = {
.dpy_name = "sdl",
.dpy_gfx_update = sdl_update,