First import
[xorg_rtime.git] / xorg-server-1.4 / hw / xfree86 / os-support / lynxos / lynx_mmap.c
blob3364399aa98b8592777d41ba7a9aeaf29270124a
1 /*
2 * Copyright 1993 by Thomas Mueller
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.
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.
25 #ifdef HAVE_XORG_CONFIG_H
26 #include <xorg-config.h>
27 #endif
29 #include <X11/X.h>
31 #include "xf86.h"
32 #include "xf86Priv.h"
33 #include "xf86_OSlib.h"
36 * Read BIOS using smem_create facility
39 _X_EXPORT int
40 xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf,
41 int Len)
43 #if defined(__powerpc__)
44 xf86Msg(X_WARNING, "xf86ReadBios: no BIOS-probe on PowerPC\n");
45 return(-1);
46 #else
47 char *p;
48 int mlen;
50 mlen = (Offset + Len + 4095) & ~4095;
51 p = smem_create("BIOS-probe", (char *)Base, mlen, SM_READ);
52 if (p == NULL)
54 /* check if there is a stale segment around */
55 if (smem_remove("BIOS-probe") == 0) {
56 xf86Msg(X_INFO,
57 "xf86ReadBios: removed stale smem_ segment\n");
58 p = smem_create("BIOS-probe", (char *)Base, mlen, SM_READ);
60 if (p == NULL) {
61 xf86Msg(X_WARNING, "xf86ReadBios: Failed to smem_create "
62 "Base %x len %x %s \n",
63 Base, mlen, strerror(errno));
64 return(-1);
67 memcpy(Buf, p + Offset, Len);
68 smem_create(NULL, p, 0, SM_DETACH);
69 smem_remove("BIOS-probe");
70 return(Len);
71 #endif