2 * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany
3 * Copyright 1993 by David Wexelblat <dwex@goblin.org>
5 * Permission to use, copy, modify, distribute, and sell this software and its
6 * documentation for any purpose is hereby granted without fee, provided that
7 * the above copyright notice appear in all copies and that both that copyright
8 * notice and this permission notice appear in supporting documentation, and
9 * that the names of the copyright holders not be used in advertising or
10 * publicity pertaining to distribution of the software without specific,
11 * written prior permission. The copyright holders make no representations
12 * about the suitability of this software for any purpose. It is provided "as
13 * is" without express or implied warranty.
15 * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
16 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT
17 * SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
18 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
19 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
20 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
25 #ifdef HAVE_XORG_CONFIG_H
26 #include <xorg-config.h>
29 #include <sys/types.h> /* get __x86 definition if not set by compiler */
31 #if defined(i386) || defined(__x86)
36 #include "xf86_OSlib.h"
39 #define MAP_FAILED ((void *)-1)
42 /***************************************************************************/
43 /* Video Memory Mapping section */
44 /***************************************************************************/
46 char *apertureDevName
= NULL
;
49 xf86LinearVidMem(void)
56 apertureDevName
= "/dev/xsvc";
57 if ((mmapFd
= open(apertureDevName
, O_RDWR
)) < 0)
59 apertureDevName
= "/dev/fbs/aperture";
60 if((mmapFd
= open(apertureDevName
, O_RDWR
)) < 0)
62 xf86MsgVerb(X_WARNING
, 0,
63 "xf86LinearVidMem: failed to open %s (%s)\n",
64 apertureDevName
, strerror(errno
));
65 xf86MsgVerb(X_WARNING
, 0,
66 "xf86LinearVidMem: either /dev/fbs/aperture or /dev/xsvc"
67 " device driver required\n");
68 xf86MsgVerb(X_WARNING
, 0,
69 "xf86LinearVidMem: linear memory access disabled\n");
70 apertureDevName
= NULL
;
79 xf86MapVidMem(int ScreenNum
, int Flags
, unsigned long Base
, unsigned long Size
)
86 * Solaris 2.1 x86 SVR4 (10/27/93)
87 * The server must treat the virtual terminal device file as the
88 * standard SVR4 /dev/pmem.
90 * Using the /dev/vtXX device as /dev/pmem only works for the
91 * A0000-FFFFF region - If we wish you mmap the linear aperture
92 * it requires a device driver.
94 * So what we'll do is use /dev/vtXX for the A0000-FFFFF stuff, and
95 * try to use the /dev/fbs/aperture or /dev/xsvc driver if the server
96 * tries to mmap anything > FFFFF. Its very very unlikely that the
97 * server will try to mmap anything below FFFFF that can't be handled
101 * DWH - 1/31/99 (Gee has it really been 5 years?)
103 * Solaris 2.8 7/26/99
104 * Use /dev/xsvc for everything
106 * DWH - 7/26/99 - Solaris8/dev/xsvc changes
108 * TSI - 2001.09 - SPARC changes
111 #if defined(i386) && !defined(__SOL8__)
113 sprintf(vtname
, "/dev/vt%02d", xf86Info
.vtno
);
117 if (!xf86LinearVidMem())
118 FatalError("xf86MapVidMem: no aperture device\n");
120 strcpy(vtname
, apertureDevName
);
123 fd
= open(vtname
, (Flags
& VIDMEM_READONLY
) ? O_RDONLY
: O_RDWR
);
125 FatalError("xf86MapVidMem: failed to open %s (%s)\n",
126 vtname
, strerror(errno
));
128 base
= mmap(NULL
, Size
,
129 (Flags
& VIDMEM_READONLY
) ?
130 PROT_READ
: (PROT_READ
| PROT_WRITE
),
131 MAP_SHARED
, fd
, (off_t
)Base
);
133 if (base
== MAP_FAILED
)
134 FatalError("xf86MapVidMem: mmap failure: %s\n",
142 xf86UnMapVidMem(int ScreenNum
, pointer Base
, unsigned long Size
)
147 /***************************************************************************/
148 /* I/O Permissions section */
149 /***************************************************************************/
151 #if defined(i386) || defined(__x86)
152 static Bool ExtendedEnabled
= FALSE
;
158 #if defined(i386) || defined(__x86)
162 if (sysi86(SI86V86
, V86SC_IOPL
, PS_IOPL
) < 0) {
163 xf86Msg(X_WARNING
,"xf86EnableIOPorts: Failed to set IOPL for I/O\n");
166 ExtendedEnabled
= TRUE
;
174 #if defined(i386) || defined(__x86)
178 sysi86(SI86V86
, V86SC_IOPL
, 0);
180 ExtendedEnabled
= FALSE
;
185 /***************************************************************************/
186 /* Interrupt Handling section */
187 /***************************************************************************/
189 _X_EXPORT Bool
xf86DisableInterrupts(void)
191 #if defined(i386) || defined(__x86)
192 if (!ExtendedEnabled
&& (sysi86(SI86V86
, V86SC_IOPL
, PS_IOPL
) < 0))
196 __asm__
__volatile__("cli");
199 #endif /* __GNUC__ */
201 if (!ExtendedEnabled
)
202 sysi86(SI86V86
, V86SC_IOPL
, 0);
208 _X_EXPORT
void xf86EnableInterrupts(void)
210 #if defined(i386) || defined(__x86)
211 if (!ExtendedEnabled
&& (sysi86(SI86V86
, V86SC_IOPL
, PS_IOPL
) < 0))
215 __asm__
__volatile__("sti");
218 #endif /* __GNUC__ */
220 if (!ExtendedEnabled
)
221 sysi86(SI86V86
, V86SC_IOPL
, 0);
226 xf86MapReadSideEffects(int ScreenNum
, int Flags
, pointer Base
,
232 xf86CheckMTRR(int ScreenNum
)