1
/* $XdotOrg: xserver/xorg/hw/xfree86/os-support/usl/usl_video.c,v 1.2 2005/11/08 06:33:30 jkj Exp $ */
3
* Copyrught 2005 Kean Johnston <jkj@sco.com>
4
* Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany
5
* Copyright 1993 by David Wexelblat <dwex@goblin.org>
7
* Permission to use, copy, modify, distribute, and sell this software and its
8
* documentation for any purpose is hereby granted without fee, provided that
9
* the above copyright notice appear in all copies and that both that
10
* copyright notice and this permission notice appear in supporting
11
* documentation, and that the names of Thomas Roell, David Dawes
12
* and Kean Johnston not be used in advertising or publicity pertaining to
13
* distribution of the software without specific, written prior permission.
14
* Thomas Roell, David Dawes and Kean Johnston make no representations
15
* about the suitability of this software for any purpose. It is provided
16
* "as is" without express or implied warranty.
18
* THOMAS ROELL, DAVID DAWES AND KEAN JOHNSTON DISCLAIM ALL WARRANTIES
19
* WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
20
* MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL THOMAS ROELLm DAVID WEXELBLAT
21
* OR KEAN JOHNSTON BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
22
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
23
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
24
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
35
#include "xf86_OSlib.h"
36
#include "xf86OSpriv.h"
39
#define MAP_FAILED ((void *)-1)
49
mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags)
54
fd = open(DEV_MEM, (flags & VIDMEM_READONLY) ? O_RDONLY : O_RDWR);
56
FatalError("xf86MapVidMem: failed to open %s (%s)\n",
57
DEV_MEM, strerror(errno));
59
base = mmap((caddr_t)0, Size, (flags & VIDMEM_READONLY) ?
60
PROT_READ : (PROT_READ | PROT_WRITE),
61
MAP_SHARED, fd, (off_t)Base);
64
if (base == MAP_FAILED) {
65
FatalError("%s: Could not mmap framebuffer [s=%x,a=%x] (%s)\n",
66
"xf86MapVidMem", Size, Base, strerror(errno));
73
unmapVidMem(int ScreenNum, pointer Base, unsigned long Size)
79
* For some SVR4 versions, a 32-bit read is done for the first location
80
* in each page when the page is first mapped. If this is done while
81
* memory access is enabled for regions that have read side-effects,
82
* this can cause unexpected results, including lockups on some hardware.
83
* This function is called to make sure each page is mapped while it is
87
#define X_PAGE_SIZE 4096
90
readSideEffects(int ScreenNum, pointer Base, unsigned long Size)
92
unsigned long base, end, addr;
95
base = (unsigned long)Base;
98
for (addr = base; addr < end; addr += X_PAGE_SIZE)
99
val = *(volatile CARD32 *)addr;
103
xf86OSInitVidMem(VidMemInfoPtr pVidMem)
105
pVidMem->linearSupported = linearVidMem();
106
pVidMem->mapMem = mapVidMem;
107
pVidMem->unmapMem = unmapVidMem;
108
pVidMem->readSideEffects = readSideEffects;
109
pVidMem->initialised = TRUE;