2
# $XFree86: xc/programs/Xserver/hw/xfree86/etc/dmmap.shar,v 3.2 1996/12/23 06:47:08 dawes Exp $
3
# This is a shell archive (produced by shar 3.49)
4
# To extract the files from this archive, save it to a file, remove
5
# everything above the "!/bin/sh" line above, and type "sh file_name".
7
# made 10/02/1993 09:11 UTC by root@gamma
8
# Source directory /home1/tmp/x11r5
10
# $XConsortium: dmmap.shar /main/4 1996/02/21 17:47:27 kaleb $
12
# existing files will NOT be overwritten unless -c is specified
16
# ------ ---------- ------------------------------------------
17
# 822 -r--r----- dmmap-1.0/Makefile
18
# 2560 -r--r----- dmmap-1.0/README
19
# 1139 -r--r----- dmmap-1.0/COPYING
20
# 273 -r--r----- dmmap-1.0/version.h
21
# 2413 -r--r----- dmmap-1.0/dmmap.c
22
# 24 -r--r----- dmmap-1.0/conf/System
23
# 29 -r--r----- dmmap-1.0/conf/Master
24
# 16 -r--r----- dmmap-1.0/conf/Node
25
# 631 -r-xr-xr-x dmmap-1.0/conf/install
26
# 85 -r--r----- dmmap-1.0/test/Makefile
27
# 2384 -r--r----- dmmap-1.0/test/tst_dmmap.c
29
# ============= dmmap-1.0/Makefile ==============
30
if test ! -d 'dmmap-1.0'; then
31
echo 'x - creating directory dmmap-1.0'
34
if test -f 'dmmap-1.0/Makefile' -a X"$1" != X"-c"; then
35
echo 'x - skipping dmmap-1.0/Makefile (File already exists)'
37
echo 'x - extracting dmmap-1.0/Makefile (Text)'
38
sed 's/^X//' << 'SHAR_EOF' > 'dmmap-1.0/Makefile' &&
41
BINDIST = $(DISTDIR).btz
42
SRCDIST = $(DISTDIR).stz
45
DISTFIL = README COPYING conf/install conf/System conf/Master conf/Node $(TEST)
46
DISTSRC = Makefile README COPYING version.h dmmap.c conf \
47
X test/Makefile test/tst_dmmap.c
49
CFLAGS = -D_INKERNEL=1 -D_COMPAT322=1
51
all: $(DRIVER) $(TEST)
54
X cd $(DISTDIR); ./install
56
dist: bin-dist src-dist
59
X tar cvf - $(DISTDIR) | gzip -9 > $(BINDIST)
62
X tar cvf - $(DISTSRC) | gzip -9 > $(SRCDIST)
72
X cd test; $(MAKE) $(MAKEARGS)
74
$(DISTDIR): $(DRIVER) $(DISTFIL)
77
X cp $(DISTFIL) $(DISTDIR)
78
X cp $(DRIVER) $(DISTDIR)/Driver.o
81
chmod 0440 dmmap-1.0/Makefile ||
82
echo 'restore of dmmap-1.0/Makefile failed'
83
Wc_c="`wc -c < 'dmmap-1.0/Makefile'`"
84
test 822 -eq "$Wc_c" ||
85
echo 'dmmap-1.0/Makefile: original size 822, current size' "$Wc_c"
87
# ============= dmmap-1.0/README ==============
88
if test -f 'dmmap-1.0/README' -a X"$1" != X"-c"; then
89
echo 'x - skipping dmmap-1.0/README (File already exists)'
91
echo 'x - extracting dmmap-1.0/README (Text)'
92
sed 's/^X//' << 'SHAR_EOF' > 'dmmap-1.0/README' &&
106
The "dmmap" driver is a generic video mapping driver for SCO unix. It differs
107
from the standard SCO video mapping in that it allows you to map memory above
108
1Mb and memory not usually associated with the current video card. This
109
allows the user to map linear frame buffers into user space. It can only
110
be accessed by root to limit security problems.
112
The distribution comes in two files,
114
X dmmap-XX.btz, the binary files required to install and test dmmap
115
X dmmap-XX.stz, the source for dmmap and test program(s)
117
To extract one of these files use the following command,
119
X gunzip < dmmap-XX.?tz | tar xvf -
121
For information on copyright and copying see the file COPYING that appears in
126
To install the dmmap driver, extract the dmmap.tar file somewhere
127
convenient, then run "install" as root. The "install" script will take it
128
from there. If building from source, type 'make install' as root.
132
To remove the dmmap driver follow these steps:
136
X ./idinstall -d dmmap
141
A simple test program, "tst_dmmap" is provided with the driver. After the
142
kernel is built and you have rebooted confirm the installation of the
143
driver by running "tst_dmmap". It will do a simple test by mapping in the
144
bios rom and checksumming it. If you have a bios at address 0xf0000 it
145
will display the first 20 characters from the bios.
149
dmmap accepts two ioctls, KDMAPDISP and KDUNMAPDISP, both of which require
150
as an argument a pointer to a completed "kd_memloc" stucture. A special
151
ioctl of '-1' will return the version number of scmap you are running.
152
A sample of code to map and unmap some memory follows below. For more
153
detail see "test/tst_dmmap.c".
159
X struct kd_memloc memloc;
161
X if ((fd = open("/dev/dmmap", O_RDWR)) < 0)
164
X memloc.vaddr = NULL;
165
X memloc.physaddr = 0xf0000;
166
X memloc.length = 0x10000
168
X if (ioctl(fd, KDMAPDISP, &memloc) < 0) {
169
X perror("KDMAPDISP");
173
X printf("The first byte of 0x%x is 0x%02x\n", memloc.vaddr, *memloc.vaddr);
175
X if (ioctl(fd, KDUNMAPDISP, &memloc) < 0) {
176
X perror("KDMAPDISP");
186
Currently this driver can only map in at most 4Mb of memory. This is not
187
about to change as vasmalloc can only handle that much. It may be possible
188
to rewrite vasmalloc but thats not going to happen any time soon.
191
chmod 0440 dmmap-1.0/README ||
192
echo 'restore of dmmap-1.0/README failed'
193
Wc_c="`wc -c < 'dmmap-1.0/README'`"
194
test 2560 -eq "$Wc_c" ||
195
echo 'dmmap-1.0/README: original size 2560, current size' "$Wc_c"
197
# ============= dmmap-1.0/COPYING ==============
198
if test -f 'dmmap-1.0/COPYING' -a X"$1" != X"-c"; then
199
echo 'x - skipping dmmap-1.0/COPYING (File already exists)'
201
echo 'x - extracting dmmap-1.0/COPYING (Text)'
202
sed 's/^X//' << 'SHAR_EOF' > 'dmmap-1.0/COPYING' &&
204
Copyright 1993 by David McCullough <davidm@stallion.oz.au>
206
Permission to use, copy, modify, distribute, and sell this software and its
207
documentation for any purpose is hereby granted without fee, provided that
208
the above copyright notice appear in all copies and that both that
209
copyright notice and this permission notice appear in supporting
210
documentation, and that the name of David McCullough not be used in
211
advertising or publicity pertaining to distribution of the software without
212
specific, written prior permission. David McCullough makes no representations
213
about the suitability of this software for any purpose. It is provided "as is"
214
without express or implied warranty.
216
DAVID MCCULLOUGH DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
217
INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT
218
SHALL DAVID MCCULLOUGH BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
219
DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
220
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
221
OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
224
chmod 0440 dmmap-1.0/COPYING ||
225
echo 'restore of dmmap-1.0/COPYING failed'
226
Wc_c="`wc -c < 'dmmap-1.0/COPYING'`"
227
test 1139 -eq "$Wc_c" ||
228
echo 'dmmap-1.0/COPYING: original size 1139, current size' "$Wc_c"
230
# ============= dmmap-1.0/version.h ==============
231
if test -f 'dmmap-1.0/version.h' -a X"$1" != X"-c"; then
232
echo 'x - skipping dmmap-1.0/version.h (File already exists)'
234
echo 'x - extracting dmmap-1.0/version.h (Text)'
235
sed 's/^X//' << 'SHAR_EOF' > 'dmmap-1.0/version.h' &&
236
#ifndef DMMAP_VERSION_H
237
#define DMMAP_VERSION_H 1
238
/******************************************************************************/
240
#define DMMAP_VERSION 0x0100
242
/******************************************************************************/
243
#endif /* DMMAP_VERSION_H */
245
chmod 0440 dmmap-1.0/version.h ||
246
echo 'restore of dmmap-1.0/version.h failed'
247
Wc_c="`wc -c < 'dmmap-1.0/version.h'`"
248
test 273 -eq "$Wc_c" ||
249
echo 'dmmap-1.0/version.h: original size 273, current size' "$Wc_c"
251
# ============= dmmap-1.0/dmmap.c ==============
252
if test -f 'dmmap-1.0/dmmap.c' -a X"$1" != X"-c"; then
253
echo 'x - skipping dmmap-1.0/dmmap.c (File already exists)'
255
echo 'x - extracting dmmap-1.0/dmmap.c (Text)'
256
sed 's/^X//' << 'SHAR_EOF' > 'dmmap-1.0/dmmap.c' &&
257
/******************************************************************************/
259
X * Copyright 1993 by David McCullough <davidm@stallion.oz.au>
260
X * see file COPYING for more details.
262
/******************************************************************************/
264
#include <sys/types.h>
265
#include <sys/errno.h>
266
#include <sys/param.h>
268
#include <sys/user.h>
269
#include <sys/vtkd.h>
270
#include <sys/immu.h>
274
/******************************************************************************/
276
extern int vasbind(paddr_t, caddr_t, unsigned int);
277
extern caddr_t vasmalloc(paddr_t, unsigned int);
278
extern caddr_t vasmapped(paddr_t, unsigned int);
279
extern int vasunbind(caddr_t, unsigned int);
281
/******************************************************************************/
283
int dmapioctl(dev, cmd, arg)
288
X struct kd_memloc memloc;
297
X u.u_error = EINVAL;
300
X case -1: /* saves anyone using header files that aren't part of the OS */
301
X u.u_rval1 = DMMAP_VERSION;
305
X if (copyin((caddr_t) arg, &memloc, sizeof(memloc)) == -1) {
306
X u.u_error = EFAULT;
311
X * mapping to a provided memory addr not supported yet 8)
312
X * when it is, vaddr must be below KVBASE, and we don't do the
313
X * vasmalloc or the vasmapped checks quite the same way.
315
X if (memloc.vaddr || memloc.length <= 0 || !memloc.physaddr) {
316
X u.u_error = EINVAL;
320
X if (memloc.vaddr = vasmapped((paddr_t) memloc.physaddr, memloc.length))
323
X if (!(memloc.vaddr = vasmalloc((paddr_t)memloc.physaddr,memloc.length)))
326
X if (vasbind((paddr_t) memloc.physaddr,memloc.vaddr,memloc.length) == -1)
329
X if (copyout(&memloc, arg, sizeof(memloc)) == -1) {
330
X u.u_error = EFAULT;
336
X if (copyin((caddr_t) arg, &memloc, sizeof(memloc)) == -1) {
337
X u.u_error = EFAULT;
341
X if (!memloc.vaddr || memloc.length <= 0 || !memloc.physaddr) {
342
X u.u_error = EINVAL;
346
X if (memloc.vaddr != vasmapped((paddr_t)memloc.physaddr,memloc.length)) {
351
X if (vasunbind(memloc.vaddr, memloc.length) == -1)
357
/******************************************************************************/
359
chmod 0440 dmmap-1.0/dmmap.c ||
360
echo 'restore of dmmap-1.0/dmmap.c failed'
361
Wc_c="`wc -c < 'dmmap-1.0/dmmap.c'`"
362
test 2413 -eq "$Wc_c" ||
363
echo 'dmmap-1.0/dmmap.c: original size 2413, current size' "$Wc_c"
365
# ============= dmmap-1.0/conf/System ==============
366
if test ! -d 'dmmap-1.0/conf'; then
367
echo 'x - creating directory dmmap-1.0/conf'
368
mkdir 'dmmap-1.0/conf'
370
if test -f 'dmmap-1.0/conf/System' -a X"$1" != X"-c"; then
371
echo 'x - skipping dmmap-1.0/conf/System (File already exists)'
373
echo 'x - extracting dmmap-1.0/conf/System (Text)'
374
sed 's/^X//' << 'SHAR_EOF' > 'dmmap-1.0/conf/System' &&
375
dmmap Y 0 0 0 0 0 0 0 0
377
chmod 0440 dmmap-1.0/conf/System ||
378
echo 'restore of dmmap-1.0/conf/System failed'
379
Wc_c="`wc -c < 'dmmap-1.0/conf/System'`"
380
test 24 -eq "$Wc_c" ||
381
echo 'dmmap-1.0/conf/System: original size 24, current size' "$Wc_c"
383
# ============= dmmap-1.0/conf/Master ==============
384
if test -f 'dmmap-1.0/conf/Master' -a X"$1" != X"-c"; then
385
echo 'x - skipping dmmap-1.0/conf/Master (File already exists)'
387
echo 'x - extracting dmmap-1.0/conf/Master (Text)'
388
sed 's/^X//' << 'SHAR_EOF' > 'dmmap-1.0/conf/Master' &&
389
dmmap i ico dmap 0 0 0 1 -1
391
chmod 0440 dmmap-1.0/conf/Master ||
392
echo 'restore of dmmap-1.0/conf/Master failed'
393
Wc_c="`wc -c < 'dmmap-1.0/conf/Master'`"
394
test 29 -eq "$Wc_c" ||
395
echo 'dmmap-1.0/conf/Master: original size 29, current size' "$Wc_c"
397
# ============= dmmap-1.0/conf/Node ==============
398
if test -f 'dmmap-1.0/conf/Node' -a X"$1" != X"-c"; then
399
echo 'x - skipping dmmap-1.0/conf/Node (File already exists)'
401
echo 'x - extracting dmmap-1.0/conf/Node (Text)'
402
sed 's/^X//' << 'SHAR_EOF' > 'dmmap-1.0/conf/Node' &&
405
chmod 0440 dmmap-1.0/conf/Node ||
406
echo 'restore of dmmap-1.0/conf/Node failed'
407
Wc_c="`wc -c < 'dmmap-1.0/conf/Node'`"
408
test 16 -eq "$Wc_c" ||
409
echo 'dmmap-1.0/conf/Node: original size 16, current size' "$Wc_c"
411
# ============= dmmap-1.0/conf/install ==============
412
if test -f 'dmmap-1.0/conf/install' -a X"$1" != X"-c"; then
413
echo 'x - skipping dmmap-1.0/conf/install (File already exists)'
415
echo 'x - extracting dmmap-1.0/conf/install (Text)'
416
sed 's/^X//' << 'SHAR_EOF' > 'dmmap-1.0/conf/install' &&
419
# installation script for dmmap driver
422
if id | grep root > /dev/null 2>&1
426
X echo "Please run this script as root" >&2
430
if /etc/conf/bin/idinstall -s -g dmmap > /dev/null 2>&1
432
X echo "Updating existing dmmap driver ..."
433
X /etc/conf/bin/idinstall -k -u dmmap
435
X echo "Installing dmmap driver ..."
436
X /etc/conf/bin/idinstall -k -a dmmap
439
echo "Do you wish to re-link the kernel now (y/n)[y]: \c"
447
X echo "\n\nWarning!"
448
X echo "\nYou must re-link the the kernel in order to use the dmmap driver"
454
chmod 0555 dmmap-1.0/conf/install ||
455
echo 'restore of dmmap-1.0/conf/install failed'
456
Wc_c="`wc -c < 'dmmap-1.0/conf/install'`"
457
test 631 -eq "$Wc_c" ||
458
echo 'dmmap-1.0/conf/install: original size 631, current size' "$Wc_c"
460
# ============= dmmap-1.0/test/Makefile ==============
461
if test ! -d 'dmmap-1.0/test'; then
462
echo 'x - creating directory dmmap-1.0/test'
463
mkdir 'dmmap-1.0/test'
465
if test -f 'dmmap-1.0/test/Makefile' -a X"$1" != X"-c"; then
466
echo 'x - skipping dmmap-1.0/test/Makefile (File already exists)'
468
echo 'x - extracting dmmap-1.0/test/Makefile (Text)'
469
sed 's/^X//' << 'SHAR_EOF' > 'dmmap-1.0/test/Makefile' &&
471
CFLAGS = -D_INKERNEL=1 -D_COMPAT322=1
476
X rm -f *.o tst_dmmap
479
chmod 0440 dmmap-1.0/test/Makefile ||
480
echo 'restore of dmmap-1.0/test/Makefile failed'
481
Wc_c="`wc -c < 'dmmap-1.0/test/Makefile'`"
482
test 85 -eq "$Wc_c" ||
483
echo 'dmmap-1.0/test/Makefile: original size 85, current size' "$Wc_c"
485
# ============= dmmap-1.0/test/tst_dmmap.c ==============
486
if test -f 'dmmap-1.0/test/tst_dmmap.c' -a X"$1" != X"-c"; then
487
echo 'x - skipping dmmap-1.0/test/tst_dmmap.c (File already exists)'
489
echo 'x - extracting dmmap-1.0/test/tst_dmmap.c (Text)'
490
sed 's/^X//' << 'SHAR_EOF' > 'dmmap-1.0/test/tst_dmmap.c' &&
491
/******************************************************************************/
493
X * Copyright 1993 by David McCullough <davidm@stallion.oz.au>
494
X * see file COPYING for more details.
496
/******************************************************************************/
502
#include <sys/types.h>
503
#include <sys/vtkd.h>
505
/******************************************************************************/
513
X for (i = 0; i < n; i += 16) {
514
X printf("%08x: ", s + i);
515
X for (j = 0; j < 8; j++)
517
X printf("%02x ", s[i + j]);
521
X for (; j < 16; j++)
523
X printf("%02x ", s[i + j]);
527
X for (j = 0; j < 16; j++)
528
X printf("%c", (i+j < n && isprint(s[i + j])) ? s[i+j] : '.');
533
/******************************************************************************/
540
X struct kd_memloc memloc;
542
X if (argc != 1 && argc != 3) {
543
X fprintf(stderr, "usage: %s [physaddr length]\n", argv[0]);
547
X if ((fd = open("/dev/dmmap", O_RDWR)) < 0) {
548
X fprintf(stderr, "Cannot open /dev/dmmap : %s\n", sys_errlist[errno]);
552
X if ((ver = ioctl(fd, -1)) < 0) {
553
X perror("Failed to get version");
557
X printf("dmmap version 0x%04x\n", ver);
559
X memloc.vaddr = NULL; /* this must be NULL for now */
561
X memloc.physaddr = (char *) 0xf0000; /* common bios location */
562
X memloc.length = 32; /* map only 32 bytes by default */
564
X if (sscanf(argv[1], "%i", &memloc.physaddr) != 1) {
565
X fprintf(stderr, "physaddr is not a valid number!\n");
568
X if (sscanf(argv[2], "%i", &memloc.length) != 1) {
569
X fprintf(stderr, "length is not a valid number!\n");
574
X printf("mapping %d bytes at physical address 0x%x\n", memloc.length,
577
X if (ioctl(fd, KDMAPDISP, &memloc) < 0) {
578
X perror("KDMAPDISP failed");
582
X hex_dump(memloc.vaddr, memloc.length);
584
X if (ioctl(fd, KDUNMAPDISP, &memloc) < 0) {
585
X perror("KDUNMAPDISP failed");
593
/******************************************************************************/
595
chmod 0440 dmmap-1.0/test/tst_dmmap.c ||
596
echo 'restore of dmmap-1.0/test/tst_dmmap.c failed'
597
Wc_c="`wc -c < 'dmmap-1.0/test/tst_dmmap.c'`"
598
test 2384 -eq "$Wc_c" ||
599
echo 'dmmap-1.0/test/tst_dmmap.c: original size 2384, current size' "$Wc_c"