2 * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany
3 * Copyright 1993 by David Wexelblat <dwex@goblin.org>
4 * Copyright 1999 by David Holland <davidh@iquest.net>
6 * Permission to use, copy, modify, distribute, and sell this software and its
7 * documentation for any purpose is hereby granted without fee, provided that
8 * the above copyright notice appear in all copies and that both that copyright
9 * notice and this permission notice appear in supporting documentation, and
10 * that the names of the copyright holders not be used in advertising or
11 * publicity pertaining to distribution of the software without specific,
12 * written prior permission. The copyright holders make no representations
13 * about the suitability of this software for any purpose. It is provided "as
14 * is" without express or implied warranty.
16 * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
17 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT
18 * SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
19 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
20 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
21 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
25 #ifdef HAVE_XORG_CONFIG_H
26 #include <xorg-config.h>
34 #include "xf86_OSlib.h"
37 #define MAP_FAILED ((void *)-1)
40 extern char *apertureDevName
;
43 * Read BIOS via mmap()ing physical memory.
46 xf86ReadBIOS(unsigned long Base
, unsigned long Offset
, unsigned char *Buf
,
51 char solx86_vtname
[20];
56 * Solaris 2.1 x86 SVR4 (10/27/93)
57 * The server must treat the virtual terminal device file
58 * as the standard SVR4 /dev/pmem. By default, then used VT
59 * is considered the "default" file to open.
61 * Solaris 2.8 x86 (7/26/99) - DWH
63 * Use /dev/xsvc for everything.
65 psize
= xf86getpagesize();
66 Offset
+= Base
& (psize
- 1);
68 mlen
= (Offset
+ Len
+ psize
- 1) & ~(psize
- 1);
69 #if defined(i386) && !defined(__SOL8__)
70 if (Base
>= 0xA0000 && Base
+ mlen
< 0xFFFFF && xf86Info
.vtno
>= 0)
71 sprintf(solx86_vtname
, "/dev/vt%02d", xf86Info
.vtno
);
75 if (!xf86LinearVidMem())
76 FatalError("xf86ReadBIOS: Could not mmap BIOS"
78 sprintf(solx86_vtname
, apertureDevName
);
81 if ((fd
= open(solx86_vtname
, O_RDONLY
)) < 0)
83 xf86Msg(X_WARNING
, "xf86ReadBIOS: Failed to open %s (%s)\n",
84 solx86_vtname
, strerror(errno
));
87 ptr
= (unsigned char *)mmap((caddr_t
)0, mlen
, PROT_READ
,
88 MAP_SHARED
, fd
, (off_t
)Base
);
89 if (ptr
== MAP_FAILED
)
91 xf86Msg(X_WARNING
, "xf86ReadBIOS: %s mmap failed "
92 "[0x%08lx, 0x%04x]\n",
93 solx86_vtname
, Base
, mlen
);
98 (void)memcpy(Buf
, (void *)(ptr
+ Offset
), Len
);
99 (void)munmap((caddr_t
)ptr
, mlen
);