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

« back to all changes in this revision

Viewing changes to hw/xfree86/os-support/lynxos/lynx_mmap.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
/*
 
2
 * Copyright 1993 by Thomas Mueller
 
3
 *
 
4
 * Permission to use, copy, modify, distribute, and sell this software and its
 
5
 * documentation for any purpose is hereby granted without fee, provided that
 
6
 * the above copyright notice appear in all copies and that both that
 
7
 * copyright notice and this permission notice appear in supporting
 
8
 * documentation, and that the name of Thomas Mueller not be used in
 
9
 * advertising or publicity pertaining to distribution of the software without
 
10
 * specific, written prior permission.  Thomas Mueller makes no representations
 
11
 * about the suitability of this software for any purpose.  It is provided
 
12
 * "as is" without express or implied warranty.
 
13
 *
 
14
 * THOMAS MUELLER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
 
15
 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
 
16
 * EVENT SHALL THOMAS MUELLER BE LIABLE FOR ANY SPECIAL, INDIRECT OR
 
17
 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
 
18
 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
 
19
 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
 
20
 * PERFORMANCE OF THIS SOFTWARE.
 
21
 *
 
22
 */
 
23
 
 
24
/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/lynxos/lynx_mmap.c,v 3.5 1998/08/29 05:43:58 dawes Exp $ */
 
25
 
 
26
#ifdef HAVE_XORG_CONFIG_H
 
27
#include <xorg-config.h>
 
28
#endif
 
29
 
 
30
#include <X11/X.h>
 
31
 
 
32
#include "xf86.h"
 
33
#include "xf86Priv.h"
 
34
#include "xf86_OSlib.h"
 
35
 
 
36
/*
 
37
 * Read BIOS using smem_create facility
 
38
 */
 
39
 
 
40
int
 
41
xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf,
 
42
             int Len)
 
43
{
 
44
#if defined(__powerpc__)
 
45
        xf86Msg(X_WARNING, "xf86ReadBios: no BIOS-probe on PowerPC\n");
 
46
        return(-1);
 
47
#else
 
48
        char *p;
 
49
        int mlen;
 
50
 
 
51
        mlen = (Offset + Len + 4095) & ~4095;
 
52
        p = smem_create("BIOS-probe", (char *)Base, mlen, SM_READ);
 
53
        if (p == NULL)
 
54
        {
 
55
                /* check if there is a stale segment around */
 
56
                if (smem_remove("BIOS-probe") == 0) {
 
57
                    xf86Msg(X_INFO,
 
58
                        "xf86ReadBios: removed stale smem_ segment\n");
 
59
                    p = smem_create("BIOS-probe", (char *)Base, mlen, SM_READ);
 
60
                }
 
61
                if (p == NULL) {
 
62
                    xf86Msg(X_WARNING, "xf86ReadBios: Failed to smem_create "
 
63
                            "Base %x len %x %s \n",
 
64
                            Base, mlen, strerror(errno));
 
65
                    return(-1);
 
66
                }
 
67
        }
 
68
        memcpy(Buf, p + Offset, Len);
 
69
        smem_create(NULL, p, 0, SM_DETACH);
 
70
        smem_remove("BIOS-probe");
 
71
        return(Len);
 
72
#endif
 
73
}