~ubuntu-branches/ubuntu/intrepid/xserver-xgl/intrepid

« back to all changes in this revision

Viewing changes to hw/xfree86/os-support/solaris/sun_bios.c

  • Committer: Bazaar Package Importer
  • Author(s): Matthew Garrett
  • Date: 2006-02-13 14:21:43 UTC
  • Revision ID: james.westby@ubuntu.com-20060213142143-mad6z9xzem7hzxz9
Tags: upstream-7.0.0
ImportĀ upstreamĀ versionĀ 7.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/sunos/sun_bios.c,v 1.2tsi Exp $ */
 
2
/*
 
3
 * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany
 
4
 * Copyright 1993 by David Wexelblat <dwex@goblin.org>
 
5
 * Copyright 1999 by David Holland <davidh@iquest.net>
 
6
 *
 
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 copyright
 
10
 * notice and this permission notice appear in supporting documentation, and
 
11
 * that the names of the copyright holders not be used in advertising or
 
12
 * publicity pertaining to distribution of the software without specific,
 
13
 * written prior permission.  The copyright holders make no representations
 
14
 * about the suitability of this software for any purpose.  It is provided "as
 
15
 * is" without express or implied warranty.
 
16
 *
 
17
 * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
 
18
 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT
 
19
 * SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
 
20
 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
 
21
 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
 
22
 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
 
23
 * OF THIS SOFTWARE.
 
24
 */
 
25
 
 
26
#ifdef HAVE_XORG_CONFIG_H
 
27
#include <xorg-config.h>
 
28
#endif
 
29
 
 
30
#ifdef i386
 
31
#define _NEED_SYSI86
 
32
#endif
 
33
#include "xf86.h"
 
34
#include "xf86Priv.h"
 
35
#include "xf86_OSlib.h"
 
36
 
 
37
#ifndef MAP_FAILED
 
38
#define MAP_FAILED ((void *)-1)
 
39
#endif
 
40
 
 
41
extern char *apertureDevName;
 
42
 
 
43
/*
 
44
 * Read BIOS via mmap()ing physical memory.
 
45
 */
 
46
int
 
47
xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf,
 
48
             int Len)
 
49
{
 
50
        int fd;
 
51
        unsigned char *ptr;
 
52
        char solx86_vtname[20];
 
53
        int psize;
 
54
        int mlen;
 
55
 
 
56
        /*
 
57
         * Solaris 2.1 x86 SVR4 (10/27/93)
 
58
         *      The server must treat the virtual terminal device file
 
59
         *      as the standard SVR4 /dev/pmem. By default, then used VT
 
60
         *      is considered the "default" file to open.
 
61
         *
 
62
         * Solaris 2.8 x86 (7/26/99) - DWH
 
63
         *
 
64
         *      Use /dev/xsvc for everything.
 
65
         */
 
66
        psize = xf86getpagesize();
 
67
        Offset += Base & (psize - 1);
 
68
        Base &= ~(psize - 1);
 
69
        mlen = (Offset + Len + psize - 1) & ~(psize - 1);
 
70
#if defined(i386) && !defined(__SOL8__)
 
71
        if (Base >= 0xA0000 && Base + mlen < 0xFFFFF && xf86Info.vtno >= 0)
 
72
                sprintf(solx86_vtname, "/dev/vt%02d", xf86Info.vtno);
 
73
        else
 
74
#endif
 
75
        {
 
76
                if (!xf86LinearVidMem())
 
77
                        FatalError("xf86ReadBIOS: Could not mmap BIOS"
 
78
                                   " [a=%lx]\n", Base);
 
79
                sprintf(solx86_vtname, apertureDevName);
 
80
        }
 
81
 
 
82
        if ((fd = open(solx86_vtname, O_RDONLY)) < 0)
 
83
        {
 
84
                xf86Msg(X_WARNING, "xf86ReadBIOS: Failed to open %s (%s)\n",
 
85
                        solx86_vtname, strerror(errno));
 
86
                return(-1);
 
87
        }
 
88
        ptr = (unsigned char *)mmap((caddr_t)0, mlen, PROT_READ,
 
89
                                        MAP_SHARED, fd, (off_t)Base);
 
90
        if (ptr == MAP_FAILED)
 
91
        {
 
92
                xf86Msg(X_WARNING, "xf86ReadBIOS: %s mmap failed "
 
93
                        "[0x%08lx, 0x%04x]\n",
 
94
                        solx86_vtname, Base, mlen);
 
95
                close(fd);
 
96
                return -1;
 
97
        }
 
98
 
 
99
        (void)memcpy(Buf, (void *)(ptr + Offset), Len);
 
100
        (void)munmap((caddr_t)ptr, mlen);
 
101
        (void)close(fd);
 
102
 
 
103
        return Len;
 
104
}