Remove dos driver
[mesa.git] / src / mesa / drivers / ggi / default / genkgi_mode.c
1 /*
2 ******************************************************************************
3
4 display-fbdev-kgicon-generic-mesa
5
6 Copyright (C) 1999 Jon Taylor [taylorj@ggi-project.org]
7
8 Permission is hereby granted, free of charge, to any person obtaining a
9 copy of this software and associated documentation files (the "Software"),
10 to deal in the Software without restriction, including without limitation
11 the rights to use, copy, modify, merge, publish, distribute, sublicense,
12 and/or sell copies of the Software, and to permit persons to whom the
13 Software is furnished to do so, subject to the following conditions:
14
15 The above copyright notice and this permission notice shall be included in
16 all copies or substantial portions of the Software.
17
18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21 THE AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
22 IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24
25 ******************************************************************************
26 */
27
28 #include <stdio.h>
29 #include <stdlib.h>
30 #include <string.h>
31 #include <unistd.h>
32 #include <fcntl.h>
33 #include <sys/ioctl.h>
34 #include <sys/mman.h>
35
36 #include <ggi/internal/ggi-dl.h>
37 #include <ggi/mesa/ggimesa_int.h>
38 #include <ggi/mesa/debug.h>
39 #include "genkgi.h"
40
41 int GGIMesa_genkgi_getapi(ggi_visual *vis, int num, char *apiname, char *arguments)
42 {
43 struct genkgi_priv_mesa *priv = GENKGI_PRIV_MESA(vis);
44
45 GGIMESADPRINT_CORE("Entered mesa_genkgi_getapi, num=%d\n", num);
46
47 strcpy(arguments, "");
48
49 switch(num)
50 {
51 case 0:
52 if (priv->have_accel)
53 {
54 strcpy(apiname, priv->accel);
55 return 0;
56 }
57 break;
58 }
59 return -1;
60 }
61
62 int GGIMesa_genkgi_flush(ggi_visual *vis, int x, int y, int w, int h, int tryflag)
63 {
64 struct genkgi_priv_mesa *priv = GENKGI_PRIV_MESA(vis);
65 int junkval;
66
67 priv->oldpriv->kgicommand_ptr += getpagesize();
68 (kgiu32)(priv->oldpriv->kgicommand_ptr) &= 0xfffff000;
69 junkval = *((int *)(priv->oldpriv->kgicommand_ptr));
70
71 /* Check if we are now in the last page, and reset the
72 * FIFO if so. We can't use the last page to send
73 * more commands, since there's no page after it that
74 * we can touch to fault in the last page's commands.
75 *
76 * FIXME: This will be replaced with a flush-and-reset handler
77 * on the end-of-buffer pagefault at some point....
78 *
79 */
80 if ((priv->oldpriv->kgicommand_ptr - priv->oldpriv->mapped_kgicommand)
81 >= (priv->oldpriv->kgicommand_buffersize - getpagesize()))
82 {
83 munmap(priv->oldpriv->mapped_kgicommand, priv->oldpriv->kgicommand_buffersize);
84 if ((priv->oldpriv->mapped_kgicommand =
85 mmap(NULL,
86 priv->oldpriv->kgicommand_buffersize,
87 PROT_READ | PROT_WRITE,
88 MAP_SHARED,
89 priv->oldpriv->fd_kgicommand,
90 0)) == MAP_FAILED)
91 {
92 ggiPanic("Failed to remap kgicommand!");
93 }
94 priv->oldpriv->kgicommand_ptr = priv->oldpriv->mapped_kgicommand;
95 }
96 return 0;
97 }