~sbeattie/ubuntu/lucid/vnc4/lp556147

« back to all changes in this revision

Viewing changes to unix/xc/programs/Xserver/hw/xfree86/etc/dmmap.shar

  • Committer: Bazaar Package Importer
  • Author(s): Ola Lundqvist
  • Date: 2006-05-15 20:35:17 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20060515203517-l4lre1ku942mn26k
Tags: 4.1.1+X4.3.0-10
* Correction of critical security issue. Thanks to Martin Kogler
  <e9925248@student.tuwien.ac.at> that informed me about the issue,
  and provided the patch.
  This flaw was originally found by Steve Wiseman of intelliadmin.com.
* Applied patch from Javier Kohen <jkohen@users.sourceforge.net> that
  inform the user that only 8 first characters of the password will
  actually be used when typing more than 8 characters, closes:
  #355619.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh
 
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".
 
6
#
 
7
# made 10/02/1993 09:11 UTC by root@gamma
 
8
# Source directory /home1/tmp/x11r5
 
9
#
 
10
# $XConsortium: dmmap.shar /main/4 1996/02/21 17:47:27 kaleb $
 
11
#
 
12
# existing files will NOT be overwritten unless -c is specified
 
13
#
 
14
# This shar contains:
 
15
# length  mode       name
 
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
 
28
#
 
29
# ============= dmmap-1.0/Makefile ==============
 
30
if test ! -d 'dmmap-1.0'; then
 
31
    echo 'x - creating directory dmmap-1.0'
 
32
    mkdir 'dmmap-1.0'
 
33
fi
 
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)'
 
36
else
 
37
echo 'x - extracting dmmap-1.0/Makefile (Text)'
 
38
sed 's/^X//' << 'SHAR_EOF' > 'dmmap-1.0/Makefile' &&
 
39
X
 
40
DISTDIR = dmmap-1.0
 
41
BINDIST = $(DISTDIR).btz
 
42
SRCDIST = $(DISTDIR).stz
 
43
DRIVER  = dmmap.o
 
44
TEST    = test/tst_dmmap
 
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
 
48
X
 
49
CFLAGS = -D_INKERNEL=1 -D_COMPAT322=1
 
50
X
 
51
all: $(DRIVER) $(TEST)
 
52
X
 
53
install: $(DISTDIR)
 
54
X       cd $(DISTDIR); ./install
 
55
X
 
56
dist: bin-dist src-dist
 
57
X
 
58
bin-dist: $(DISTDIR)
 
59
X       tar cvf - $(DISTDIR) | gzip -9 > $(BINDIST)
 
60
X
 
61
src-dist:
 
62
X       tar cvf - $(DISTSRC) | gzip -9 > $(SRCDIST)
 
63
X
 
64
clean:
 
65
X       rm -f *.o
 
66
X       rm -f $(BINDIST)
 
67
X       rm -f $(SRCDIST)
 
68
X       rm -rf $(DISTDIR)
 
69
X       cd test; make clean
 
70
X
 
71
$(TEST): $(TEST).c
 
72
X       cd test; $(MAKE) $(MAKEARGS)
 
73
X
 
74
$(DISTDIR): $(DRIVER) $(DISTFIL)
 
75
X       rm -rf $(DISTDIR)
 
76
X       mkdir $(DISTDIR)
 
77
X       cp $(DISTFIL) $(DISTDIR)
 
78
X       cp $(DRIVER) $(DISTDIR)/Driver.o
 
79
X
 
80
SHAR_EOF
 
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"
 
86
fi
 
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)'
 
90
else
 
91
echo 'x - extracting dmmap-1.0/README (Text)'
 
92
sed 's/^X//' << 'SHAR_EOF' > 'dmmap-1.0/README' &&
 
93
X                 The DMMAP Driver
 
94
X
 
95
Contents:
 
96
1. General.
 
97
2. Installation.
 
98
3. Removal.
 
99
4. Testing.
 
100
5. Using the driver.
 
101
6. Limitations.
 
102
X
 
103
X
 
104
1. General
 
105
X
 
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.
 
111
X
 
112
The distribution comes in two files,
 
113
X
 
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)
 
116
X
 
117
To extract one of these files use the following command,
 
118
X
 
119
X       gunzip < dmmap-XX.?tz | tar xvf -
 
120
X
 
121
For information on copyright and copying see the file COPYING that appears in
 
122
this package.
 
123
X
 
124
2. Installation
 
125
X
 
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.
 
129
X
 
130
3. Removal
 
131
X
 
132
To remove the dmmap driver follow these steps:
 
133
X
 
134
X       login as root
 
135
X       cd /etc/conf/bin
 
136
X       ./idinstall -d dmmap
 
137
X       ./idbuild
 
138
X
 
139
4. Testing
 
140
X
 
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.
 
146
X
 
147
5. Using the driver
 
148
X
 
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".
 
154
X
 
155
X       .
 
156
X       .
 
157
X       .
 
158
X
 
159
X       struct kd_memloc memloc;
 
160
X
 
161
X       if ((fd = open("/dev/dmmap", O_RDWR)) < 0)
 
162
X               exit(0);
 
163
X
 
164
X       memloc.vaddr    = NULL;
 
165
X       memloc.physaddr = 0xf0000;
 
166
X       memloc.length   = 0x10000
 
167
X
 
168
X       if (ioctl(fd, KDMAPDISP, &memloc) < 0) {
 
169
X               perror("KDMAPDISP");
 
170
X               exit(1);
 
171
X       }
 
172
X
 
173
X       printf("The first byte of 0x%x is 0x%02x\n", memloc.vaddr, *memloc.vaddr);
 
174
X
 
175
X       if (ioctl(fd, KDUNMAPDISP, &memloc) < 0) {
 
176
X               perror("KDMAPDISP");
 
177
X               exit(1);
 
178
X       }
 
179
X
 
180
X       .
 
181
X       .
 
182
X       .
 
183
X
 
184
6. Limitations
 
185
X
 
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.
 
189
X
 
190
SHAR_EOF
 
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"
 
196
fi
 
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)'
 
200
else
 
201
echo 'x - extracting dmmap-1.0/COPYING (Text)'
 
202
sed 's/^X//' << 'SHAR_EOF' > 'dmmap-1.0/COPYING' &&
 
203
X
 
204
Copyright 1993 by David McCullough <davidm@stallion.oz.au>
 
205
X
 
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.
 
215
X
 
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.
 
222
X
 
223
SHAR_EOF
 
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"
 
229
fi
 
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)'
 
233
else
 
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
/******************************************************************************/
 
239
X
 
240
#define DMMAP_VERSION           0x0100
 
241
X
 
242
/******************************************************************************/
 
243
#endif /* DMMAP_VERSION_H */
 
244
SHAR_EOF
 
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"
 
250
fi
 
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)'
 
254
else
 
255
echo 'x - extracting dmmap-1.0/dmmap.c (Text)'
 
256
sed 's/^X//' << 'SHAR_EOF' > 'dmmap-1.0/dmmap.c' &&
 
257
/******************************************************************************/
 
258
/*
 
259
X *     Copyright 1993 by David McCullough <davidm@stallion.oz.au>
 
260
X *         see file COPYING for more details.
 
261
X */
 
262
/******************************************************************************/
 
263
X
 
264
#include        <sys/types.h>
 
265
#include        <sys/errno.h>
 
266
#include        <sys/param.h>
 
267
#include        <sys/dir.h>
 
268
#include        <sys/user.h>
 
269
#include        <sys/vtkd.h>
 
270
#include        <sys/immu.h>
 
271
X
 
272
#include        "version.h"
 
273
X
 
274
/******************************************************************************/
 
275
X
 
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);
 
280
X
 
281
/******************************************************************************/
 
282
X
 
283
int dmapioctl(dev, cmd, arg)
 
284
X    int dev;
 
285
X    int cmd;
 
286
X    int arg;
 
287
{
 
288
X       struct kd_memloc        memloc;
 
289
X
 
290
X       if (!suser()) {
 
291
X               u.u_error = EPERM;
 
292
X               return(0);
 
293
X       }
 
294
X       
 
295
X       switch (cmd) {
 
296
X       default:
 
297
X               u.u_error = EINVAL;
 
298
X               break;
 
299
X
 
300
X       case -1: /* saves anyone using header files that aren't part of the OS */
 
301
X               u.u_rval1 = DMMAP_VERSION;
 
302
X               break;
 
303
X
 
304
X       case KDMAPDISP:
 
305
X               if (copyin((caddr_t) arg, &memloc, sizeof(memloc)) == -1) {
 
306
X                       u.u_error = EFAULT;
 
307
X                       break;
 
308
X               }
 
309
/*
 
310
X *             arg checking.
 
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.
 
314
X */
 
315
X               if (memloc.vaddr || memloc.length <= 0 || !memloc.physaddr) {
 
316
X                       u.u_error = EINVAL;
 
317
X                       break;
 
318
X               }
 
319
X
 
320
X               if (memloc.vaddr = vasmapped((paddr_t) memloc.physaddr, memloc.length))
 
321
X                       break;
 
322
X
 
323
X               if (!(memloc.vaddr = vasmalloc((paddr_t)memloc.physaddr,memloc.length)))
 
324
X                       break;
 
325
X
 
326
X               if (vasbind((paddr_t) memloc.physaddr,memloc.vaddr,memloc.length) == -1)
 
327
X                       break;
 
328
X
 
329
X               if (copyout(&memloc, arg, sizeof(memloc)) == -1) {
 
330
X                       u.u_error = EFAULT;
 
331
X                       break;
 
332
X               }
 
333
X               break;
 
334
X
 
335
X       case KDUNMAPDISP:
 
336
X               if (copyin((caddr_t) arg, &memloc, sizeof(memloc)) == -1) {
 
337
X                       u.u_error = EFAULT;
 
338
X                       break;
 
339
X               }
 
340
X
 
341
X               if (!memloc.vaddr || memloc.length <= 0 || !memloc.physaddr) {
 
342
X                       u.u_error = EINVAL;
 
343
X                       break;
 
344
X               }
 
345
X
 
346
X               if (memloc.vaddr != vasmapped((paddr_t)memloc.physaddr,memloc.length)) {
 
347
X                       u.u_error = ENXIO;
 
348
X                       break;
 
349
X               }
 
350
X
 
351
X               if (vasunbind(memloc.vaddr, memloc.length) == -1)
 
352
X                       break;
 
353
X               break;
 
354
X       }
 
355
}
 
356
X
 
357
/******************************************************************************/
 
358
SHAR_EOF
 
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"
 
364
fi
 
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'
 
369
fi
 
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)'
 
372
else
 
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
 
376
SHAR_EOF
 
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"
 
382
fi
 
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)'
 
386
else
 
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
 
390
SHAR_EOF
 
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"
 
396
fi
 
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)'
 
400
else
 
401
echo 'x - extracting dmmap-1.0/conf/Node (Text)'
 
402
sed 's/^X//' << 'SHAR_EOF' > 'dmmap-1.0/conf/Node' &&
 
403
dmmap   dmmap   c       0
 
404
SHAR_EOF
 
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"
 
410
fi
 
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)'
 
414
else
 
415
echo 'x - extracting dmmap-1.0/conf/install (Text)'
 
416
sed 's/^X//' << 'SHAR_EOF' > 'dmmap-1.0/conf/install' &&
 
417
: !/bin/sh
 
418
#
 
419
# installation script for dmmap driver
 
420
#
 
421
X
 
422
if id | grep root > /dev/null 2>&1
 
423
then
 
424
X       :
 
425
else
 
426
X       echo "Please run this script as root" >&2
 
427
X       exit 1
 
428
fi
 
429
X
 
430
if /etc/conf/bin/idinstall -s -g dmmap > /dev/null 2>&1
 
431
then
 
432
X       echo "Updating existing dmmap driver ..."
 
433
X       /etc/conf/bin/idinstall -k -u dmmap
 
434
else
 
435
X       echo "Installing dmmap driver ..."
 
436
X       /etc/conf/bin/idinstall -k -a dmmap
 
437
fi
 
438
X
 
439
echo "Do you wish to re-link the kernel now (y/n)[y]: \c"
 
440
read t
 
441
case ${t:-y} in
 
442
[yY]|[yY][eE][sS])
 
443
X       cd /etc/conf/bin;
 
444
X       ./idbuild
 
445
X       ;;
 
446
*)
 
447
X       echo "\n\nWarning!"
 
448
X       echo "\nYou must re-link the the kernel in order to use the dmmap driver"
 
449
X       ;;
 
450
esac
 
451
X
 
452
Xexit 0
 
453
SHAR_EOF
 
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"
 
459
fi
 
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'
 
464
fi
 
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)'
 
467
else
 
468
echo 'x - extracting dmmap-1.0/test/Makefile (Text)'
 
469
sed 's/^X//' << 'SHAR_EOF' > 'dmmap-1.0/test/Makefile' &&
 
470
X
 
471
CFLAGS = -D_INKERNEL=1 -D_COMPAT322=1
 
472
X
 
473
all: tst_dmmap
 
474
X
 
475
clean:
 
476
X       rm -f *.o tst_dmmap
 
477
X
 
478
SHAR_EOF
 
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"
 
484
fi
 
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)'
 
488
else
 
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
/******************************************************************************/
 
492
/*
 
493
X *     Copyright 1993 by David McCullough <davidm@stallion.oz.au>
 
494
X *         see file COPYING for more details.
 
495
X */
 
496
/******************************************************************************/
 
497
X
 
498
#include        <stdio.h>
 
499
#include        <fcntl.h>
 
500
#include        <errno.h>
 
501
#include        <ctype.h>
 
502
#include        <sys/types.h>
 
503
#include        <sys/vtkd.h>
 
504
X
 
505
/******************************************************************************/
 
506
X
 
507
hex_dump(s, n)
 
508
X       unsigned char   *s;
 
509
X       unsigned int     n;
 
510
{
 
511
X       int                              i, j;
 
512
X
 
513
X       for (i = 0; i < n; i += 16) {
 
514
X               printf("%08x: ", s + i);
 
515
X               for (j = 0; j < 8; j++)
 
516
X                       if (i + j < n)
 
517
X                               printf("%02x ", s[i + j]);
 
518
X                       else
 
519
X                               printf("   ");
 
520
X               printf("  ");
 
521
X               for (; j < 16; j++)
 
522
X                       if (i + j < n)
 
523
X                               printf("%02x ", s[i + j]);
 
524
X                       else
 
525
X                               printf("   ");
 
526
X               printf("  ");
 
527
X               for (j = 0; j < 16; j++)
 
528
X                       printf("%c", (i+j < n && isprint(s[i + j])) ? s[i+j] : '.');
 
529
X               printf("\n");
 
530
X       }
 
531
}
 
532
X
 
533
/******************************************************************************/
 
534
X
 
535
main(argc, argv)
 
536
X       int                                      argc;
 
537
X       char                            *argv[];
 
538
{
 
539
X       int                                      fd, ver;
 
540
X       struct kd_memloc         memloc;
 
541
X
 
542
X       if (argc != 1 && argc != 3) {
 
543
X               fprintf(stderr, "usage: %s [physaddr length]\n", argv[0]);
 
544
X               exit(1);
 
545
X       }
 
546
X
 
547
X       if ((fd = open("/dev/dmmap", O_RDWR)) < 0) {
 
548
X               fprintf(stderr, "Cannot open /dev/dmmap : %s\n", sys_errlist[errno]);
 
549
X               exit(1);
 
550
X       }
 
551
X
 
552
X       if ((ver = ioctl(fd, -1)) < 0) {
 
553
X               perror("Failed to get version");
 
554
X               exit(1);
 
555
X       }
 
556
X
 
557
X       printf("dmmap version 0x%04x\n", ver);
 
558
X
 
559
X       memloc.vaddr    = NULL;                         /* this must be NULL for now */
 
560
X       if (argc == 1) {
 
561
X               memloc.physaddr = (char *) 0xf0000;     /* common bios location */
 
562
X               memloc.length   = 32;                           /* map only 32 bytes by default */
 
563
X       } else {
 
564
X               if (sscanf(argv[1], "%i", &memloc.physaddr) != 1) {
 
565
X                       fprintf(stderr, "physaddr is not a valid number!\n");
 
566
X                       exit(1);
 
567
X               }
 
568
X               if (sscanf(argv[2], "%i", &memloc.length) != 1) {
 
569
X                       fprintf(stderr, "length is not a valid number!\n");
 
570
X                       exit(1);
 
571
X               }
 
572
X       }
 
573
X
 
574
X       printf("mapping %d bytes at physical address 0x%x\n", memloc.length,
 
575
X                       memloc.physaddr);
 
576
X
 
577
X       if (ioctl(fd, KDMAPDISP, &memloc) < 0) {
 
578
X               perror("KDMAPDISP failed");
 
579
X               exit(1);
 
580
X       }
 
581
X
 
582
X       hex_dump(memloc.vaddr, memloc.length);
 
583
X
 
584
X       if (ioctl(fd, KDUNMAPDISP, &memloc) < 0) {
 
585
X               perror("KDUNMAPDISP failed");
 
586
X               exit(1);
 
587
X       }
 
588
X
 
589
X       close(fd);
 
590
X       exit(0);
 
591
}
 
592
X
 
593
/******************************************************************************/
 
594
SHAR_EOF
 
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"
 
600
fi
 
601
exit 0