kernel: Use hashdestroy() to free hash tables allocated with hashinit().
[dragonfly.git] / usr.bin / doscmd / doscmd.1
1 .\"
2 .\" Copyright (c) 1992, 1993, 1996
3 .\"     Berkeley Software Design, Inc.  All rights reserved.
4 .\"
5 .\" Redistribution and use in source and binary forms, with or without
6 .\" modification, are permitted provided that the following conditions
7 .\" are met:
8 .\" 1. Redistributions of source code must retain the above copyright
9 .\"    notice, this list of conditions and the following disclaimer.
10 .\" 2. Redistributions in binary form must reproduce the above copyright
11 .\"    notice, this list of conditions and the following disclaimer in the
12 .\"    documentation and/or other materials provided with the distribution.
13 .\" 3. All advertising materials mentioning features or use of this software
14 .\"    must display the following acknowledgement:
15 .\"     This product includes software developed by Berkeley Software
16 .\"     Design, Inc.
17 .\"
18 .\" THIS SOFTWARE IS PROVIDED BY Berkeley Software Design, Inc. ``AS IS'' AND
19 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 .\" ARE DISCLAIMED.  IN NO EVENT SHALL Berkeley Software Design, Inc. BE LIABLE
22 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 .\" SUCH DAMAGE.
29 .\"
30 .\"     BSDI doscmd.1,v 2.3 1996/04/08 19:32:29 bostic Exp
31 .\" $FreeBSD: src/usr.bin/doscmd/doscmd.1,v 1.12.2.11 2002/06/20 23:45:41 charnier Exp $
32 .\"
33 .Dd January 30, 1995
34 .Dt DOSCMD 1
35 .Os
36 .Sh NAME
37 .Nm doscmd
38 .Nd run a subset of real-mode DOS programs
39 .Sh SYNOPSIS
40 .Nm
41 .Fl 23AbDEfGHIMOPRrtVvXxYz
42 .Fl c Ar file
43 .Fl d Ar file
44 .Fl i Ar port Ns Xo
45 .Op : Ns Ar cnt
46 .Xc
47 .Fl o Ar port Ns Xo
48 .Op : Ns Ar cnt
49 .Xc
50 .Fl S Ar int
51 .Fl U Ar int
52 .Op Ar cmd Op Ar args ...
53 .Sh DESCRIPTION
54 The
55 .Nm
56 utility can either emulate a subset of DOS and run the
57 single command
58 .Ar cmd
59 .Ar args ,
60 or it can be used to emulate a PC and boot DOS,
61 which allows it to run a larger variety of DOS applications.
62 It should be noted that MS-DOS 6.2 and higher appear
63 to cause difficulties for
64 .Nm .
65 To boot DOS, either provide the
66 .Fl b
67 flag or omit the
68 .Ar cmd
69 argument.
70 If
71 .Fl b
72 is specified,
73 .Ar cmd
74 and
75 .Ar args
76 are ignored.
77 .Pp
78 Although
79 .Nm
80 only provides a subset of DOS, it is sufficient to run a variety of
81 programs, including, but not limited to, compilers, assemblers and
82 linker-loaders.
83 .Pp
84 The various flags available to
85 .Nm
86 are:
87 .Bl -tag -width indent
88 .It Fl 2
89 Enable debugging traces of every trap to the
90 .Nm
91 emulator from the DOS program.
92 Note that some traps are handled in the kernel and hence will not
93 be traced.
94 .It Fl 3
95 Enable debugging of several lower level functions, such
96 as changing of interrupt vectors and initializing paths to logical drives.
97 .\"
98 .\"
99 .\"
100 .It Fl A
101 Enable tracing of all interrupts that pass into the emulator.
102 This is the same as using the
103 .Fl S
104 option with all 256 possible interrupt values.
105 .\"
106 .\"
107 .\"
108 .It Fl b
109 Attempt to boot DOS rather than emulate it.
110 .\"
111 .\"
112 .\"
113 .It Fl c Ar file
114 Capture all output directed at the screen into
115 .Ar file .
116 Note that direct screen writes will not be captured.
117 .\"
118 .\"
119 .\"
120 .It Fl C
121 List MS-DOS calls emulated and their return values.
122 .\"
123 .\"
124 .\"
125 .It Fl D
126 Enable debugging of the disk and file operations.
127 .\"
128 .\"
129 .\"
130 .It Fl d Ar file
131 Send the debug output to
132 .Ar file
133 instead of stderr.
134 .\"
135 .\"
136 .\"
137 .It Fl E
138 Enable debugging of the exec routines.
139 .\"
140 .\"
141 .\"
142 .It Fl G
143 Enable debugging of the video (graphics) routines.
144 .\"
145 .\"
146 .\"
147 .It Fl H
148 Enable tracing of half implemented calls.
149 .\"
150 .\"
151 .\"
152 .It Fl I
153 Enable tracing of all interrupts.  Almost the same as
154 .Fl A
155 except a few less traces are turned on.
156 .\"
157 .\"
158 .\"
159 .It Fl i Ar port Ns Xo
160 .Op : Ns Ar cnt
161 .Xc
162 Enable tracing of all inputs requested from the io
163 .Ar port .
164 If
165 .Ar cnt
166 is present, trace from
167 .Ar port
168 to
169 .Ar port+cnt Ns No -1 .
170 .\"
171 .\"
172 .\"
173 .It Fl M
174 Enable debugging of the memory operations.
175 .\"
176 .\"
177 .\"
178 .It Fl O
179 Direct the debugging output to stdout rather than stderr.
180 .\"
181 .\"
182 .\"
183 .It Fl o Ar port Ns Xo
184 .Op : Ns Ar cnt
185 .Xc
186 Enable tracing of all outputs requested from the io
187 .Ar port .
188 If
189 .Ar cnt
190 is present, trace from
191 .Ar port
192 to
193 .Ar port+cnt Ns No -1 .
194 .\"
195 .\"
196 .\"
197 .It Fl p Ar port Ns Xo
198 .Op : Ns Ar cnt
199 .Xc
200 Map the requested io
201 .Ar port
202 (with optional range up to to
203 .Ar port+cnt Ns No -1 )
204 to the real hardware I/O port(s).
205 This will likely require root privs to access them.
206 .\"
207 .\"
208 .\"
209 .It Fl P
210 Enable tracing of io port calls (such as
211 .Li inb ,
212 .Li outb ,
213 etc).
214 .\"
215 .\"
216 .\"
217 .It Fl R
218 Enable debugging of the file redirect code.
219 .\"
220 .\"
221 .\"
222 .It Fl r
223 Use the raw keyboard and display.  Pressing <CTRL-ALT-DEL> will
224 cause doscmd to exit.  This allows use of VGA graphics.
225 .\"
226 .\"
227 .\"
228 .It Fl S Ar int
229 Enable tracing of the interrupt
230 .Ar int .
231 .\"
232 .\"
233 .\"
234 .It Fl t
235 Attempt to do instruction level tracing.
236 Some instructions confuse the trace.
237 Pressing
238 .Li <CTRL-ALT-T>
239 attempts to toggle the trace mode on and off.
240 .\"
241 .\"
242 .\"
243 .It Fl U Ar int
244 Disable tracing of the interrupt
245 .Ar int .
246 Useful after
247 .Fl A
248 or
249 .Fl I .
250 .\"
251 .\"
252 .\"
253 .It Fl V
254 Include register dumps when reporting unknown interrupts.
255 .\"
256 .\"
257 .\"
258 .It Fl v
259 Same as
260 .Fl AH
261 .\"
262 .\"
263 .\"
264 .It Fl X
265 Enable debugging of the XMS operations.
266 .\"
267 .\"
268 .\"
269 .It Fl x
270 Open an X11 window to display output.  This enables a
271 variety interrupts not available otherwise.  This
272 can be used with or without
273 .Fl b .
274 .\"
275 .\"
276 .\"
277 .It Fl Y
278 Enable debugging of the EMS operations.
279 .\"
280 .\"
281 .\"
282 .It Fl z
283 Cause
284 .Nm
285 to pause just prior to jumping to the DOS program.
286 Very little use except for developing
287 .Nm .
288 .El
289 .Pp
290 When starting up,
291 .Nm
292 attempts to read a configuration file.  First the file
293 .Cm .doscmdrc
294 in the current directory.  If not found there, the
295 .Cm $HOME
296 directory is searched.  If still not found, the file
297 .Cm /etc/doscmdrc
298 is used.
299 .Pp
300 In the configuration file, a comment is started with the \fB#\fP character.
301 Blank lines are ignored.
302 Non empty lines either are environment variables
303 or commands which configure devices.
304 Any line which has an \fB=\fP before any white space is considered to be
305 an environment variable assignment and is added to the DOS environment.
306 The rest of the lines are one of the following
307 .Bl -tag -width XXXXX
308 .\"
309 .\"
310 .\"
311 .It Cm boot Op Cm A: | C:
312 Set the device to boot from.
313 By default
314 .Cm A:
315 is first tried, if it is defined, and if that fails,
316 .Cm C:
317 is tried.
318 .\"
319 .\"
320 .\"
321 .It Cm assign Xo
322 .Op Cm A-Z :
323 .Op Fl ro
324 .Ar path
325 .Xc
326 Assigns the
327 .Bsx
328 directory
329 .Ar path
330 to be assigned as the specified drive.  If the
331 .Fl ro
332 flag is specified, it is a read only file system.
333 These assignments will not take place when booting DOS until the
334 .Pa /usr/libdata/doscmd/redir.com
335 binary is run.
336 .\"
337 .\"
338 .\"
339 .It Cm assign Xo
340 .Cm lpt Ns Op Cm 0-4 :
341 .Op Cm direct
342 .Ar path
343 .Op Ar timeout
344 .Xc
345 Attempt to assign the specified printer to
346 .Ar path .
347 If
348 .Ar timeout
349 is specified then use it as the length of time for no
350 activity (in seconds) to indicate that the printer
351 should be flushed.  The default is 30 seconds.
352 The
353 .Cm direct
354 option should be set when
355 .Ar path
356 refers to a real printer.
357 .\"
358 .\"
359 .\"
360 .It Cm assign Xo
361 .Op Cm A: | B:
362 .Op Fl ro
363 .Ar path
364 .Ar density
365 .Xc
366 .It Cm assign Xo
367 .Cm flop Ns Op Cm 01
368 .Op Fl ro
369 .Ar path
370 .Ar density
371 .Xc
372 Assign the file
373 .Ar path
374 to be used as either the next available floppy or
375 to the specified floppy.
376 If
377 .Fl ro
378 is specified the floppy will be read only.
379 The
380 .Ar density
381 may be one of:
382 .Pp
383 .Bl -tag -compact -width 1440x
384 .It 180
385 9 head 40 track single sided floppy
386 .It 360
387 9 head 40 track double sided floppy
388 .It 720
389 9 head 80 track double sided floppy
390 .It 1200
391 15 head 80 track double sided floppy
392 .It 1440
393 18 head 80 track double sided floppy
394 .It 2880
395 36 head 80 track double sided floppy
396 .El
397 .\"
398 .\"
399 .\"
400 .It Cm assign Xo
401 .Op Cm C-Z  :
402 .Op Fl ro
403 .Ar path
404 .Op Ar type | cyl head sec
405 .Op Ar fdisk_tab
406 .Xc
407 .It Cm assign Xo
408 .Cm hard Ns Op Cm 01
409 .Op Fl ro
410 .Ar path
411 .Op Ar type | cyl head sec
412 .Op Ar fdisk_tab
413 .Xc
414 Assign the file
415 .Ar path
416 to be used as either the next available hard disk or
417 to the specified hard disk.
418 A disk's geometry can either be directly specified with
419 .Ar cyl
420 being the number of cylinders,
421 .Ar head
422 the number of heads and
423 .Ar sec
424 the number of sectors per track,
425 or it can be one of the standard types specified by
426 .Ar type
427 (see below).
428 The option
429 .Ar fdisk_tab
430 argument specifies file to use as the first sector
431 of this disk.  This can be useful for inserting a
432 false fdisk table when
433 .Ar path
434 only refers to part of a disk.
435 .\"
436 .\"
437 .\"
438 .It Cm assign Xo
439 .Cm com Ns Op Cm 1-4 :
440 .Ar path
441 .Ar port
442 .Ar irq
443 .Xc
444 Assign the tty or pty specified by
445 .Ar path
446 to be used as the specified com port.
447 Its base address will be emulated at
448 .Ar port
449 at interrupt specified by
450 .Ar irq .
451 This code is lightly tested and may not suit all needs.
452 .\"
453 .\"
454 .\"
455 .It Cm portmap Xo
456 .Ar port
457 .Op Ar count
458 .Xc
459 Map the requested io
460 .Ar port
461 (with optional range up to to
462 .Ar port+count Ns No -1 )
463 to the real hardware I/O port(s).
464 This will likely require root privs to access them.
465 .\"
466 .\"
467 .\"
468 .It Cm "setver command version"
469 Cause doscmd, when emulating DOS, to report
470 .Cm version
471 as the version number of DOS when called from the program named
472 .Cm command .
473 The format of
474 .Cm version
475 is the same as of the
476 .Cm MS_VERSION
477 variable described below.
478 .El
479 .Pp
480 If not already assigned,
481 .Cm C:
482 will be assigned to the root directory (/) and the current directory
483 for
484 .Cm C:
485 will be set to the actual current directory.
486 Note that this means that invocations such as:
487 .Pp
488 .Dl "doscmd ../foo"
489 .Pp
490 will not work as the
491 .Cm C:
492 directory will start with the current path.
493 Also, the following environment variables will be defined if not
494 already defined:
495 .Bd -literal
496 .Cm "COMSPEC=C:\eCOMMAND.COM"
497 .Cm "PATH=C:\e"
498 .Cm "PROMPT=DOS>"
499 .Ed
500 .Pp
501 The
502 .Cm PATH
503 variable is also used to find
504 .Ar cmd .
505 Like DOS, first
506 .Ar cmd.com
507 will be looked for and then
508 .Ar cmd.exe .
509 .Sh "CONFIGURATION VARIABLES"
510 There are several variables in the
511 .Cm .doscmdrc
512 file which are internal to doscmd and do not actually get inserted into
513 the DOS environment.  These are:
514 .Bl -tag -width MS_VERSION
515 .It Cm MS_VERSION
516 The value of this variable is used to determine the version of DOS that
517 should be reported by
518 .Nm .
519 Note that
520 .Nm
521 will not change the way
522 it works, just the way it reports.  By default this value is
523 .Cm 410 ,
524 which corresponds to
525 .Tn "MS-DOS"
526 version 4.1.
527 To change it to version 3.2 (the default in previous versions of
528 .Nm )
529 use the value of
530 .Cm 320 .
531 .It Cm X11_FONT
532 The value of this variable determines the font used in an X window.
533 The default font is
534 .Cm vga ,
535 which is installed in
536 .Pa /usr/libdata/doscmd/fonts .
537 Add the line
538 .Ql xset fp+ /usr/libdata/doscmd/fonts
539 to your
540 .Pa ${HOME}/.xsession
541 or
542 .Pa ${HOME}/.xinitrc
543 to let the X server find it.
544 .El
545 .Sh FILE TRANSLATION
546 The
547 .Nm
548 utility translates
549 .Bsx
550 file names into
551 .Tn DOS
552 file names by converting to all upper case and eliminating any invalid
553 character.  It does not make any attempt to convert ASCII files into
554 the
555 .Cm <CR><LF>
556 format favored in the DOS world.  Use
557 .Xr unix2dos 1
558 (part of the
559 .Xr pkgsrc 7
560 collection) or similar tools to convert ASCII files.
561 .bp
562 .Sh DISK TYPES
563 .TS H
564 expand, box;
565 r | r | r | r | r.
566 Type    Cylinders       Heads   Sectors Size
567 =
568 01      306     4       17      10MB
569 02      615     4       17      20MB
570 03      615     6       17      30MB
571 04      940     8       17      62MB
572 05      940     6       17      46MB
573 _
574 06      615     4       17      20MB
575 07      462     8       17      30MB
576 08      733     5       17      30MB
577 09      900     15      17      112MB
578 10      820     3       17      20MB
579 _
580 11      855     5       17      35MB
581 12      855     7       17      49MB
582 13      306     8       17      20MB
583 14      733     7       17      42MB
584 15      976     15      17      121MB
585 _
586 16      612     4       17      20MB
587 17      977     5       17      40MB
588 18      977     7       17      56MB
589 19      1024    7       17      59MB
590 20      733     5       17      30MB
591 _
592 21      733     7       17      42MB
593 22      733     5       17      30MB
594 23      306     4       17      10MB
595 24      925     7       17      53MB
596 25      925     9       17      69MB
597 _
598 26      754     7       17      43MB
599 27      754     11      17      68MB
600 28      699     7       17      40MB
601 29      823     10      17      68MB
602 30      918     7       17      53MB
603 _
604 31      1024    11      17      93MB
605 32      1024    15      17      127MB
606 33      1024    5       17      42MB
607 34      612     2       17      10MB
608 35      1024    9       17      76MB
609 _
610 36      1024    8       17      68MB
611 37      615     8       17      40MB
612 38      987     3       17      24MB
613 39      987     7       17      57MB
614 40      820     6       17      40MB
615 _
616 41      977     5       17      40MB
617 42      981     5       17      40MB
618 43      830     7       17      48MB
619 44      830     10      17      68MB
620 45      917     15      17      114MB
621 _
622 46      1224    15      17      152MB
623 .TE
624 .bp
625 .Sh INSTALLING DOS ON A PSEUDO DISK
626 To install DOS on a pseudo hard disk under doscmd, do the following:
627 .Bl -tag -width XXXX
628 .It 1
629 Create a
630 .Pa .doscmdrc
631 with at least the following:
632 .Bd -literal -offset indent
633 assign A: /dev/fd0.1440 1440
634 assign A: /dev/fd0.720 720
635 assign hard boot_drive 80 2 2
636 .Ed
637 .Pp
638 You may need to adjust the raw files for the A: drive to match
639 your system.  This example will cause the HD drive to be tried
640 first and the DD drive second.
641 .Pp
642 Note that you should only use raw devices or files at this point,
643 do not use a cooked device!  (Well, it would probably be okay
644 for a hard disk, but certainly not the floppy)
645 .Pp
646 .Li boot_drive
647 should be the file name of where you want your bootable
648 image to be.  The three numbers which follow
649 .Li 80 2 2
650 say that the drive will have 80 cylinders, 2 heads and 2 sectors per track.
651 This is the smallest drive possible which still can have MS-DOS
652 5.0 installed on it along with a
653 .Pa config.sys
654 and
655 .Pa autoexec.bat
656 file.
657 .Pp
658 You might want to create a larger boot drive.
659 .Pp
660 The file
661 .Pa boot_drive
662 must exist, so use the command touch to create it.
663 .It 2
664 Insert a floppy disk into the A: drive which is bootable to MS-DOS
665 and has the commands fdisk, format and sys on it.  You should also
666 copy the file redir.com onto the floppy by either mounting it
667 with the msdos file system type or by using mtools
668 (e.g.,
669 .Dq Li mwrite redir.com a: ) .
670 .It 3
671 run doscmd.
672 .It 4
673 At the > prompt type
674 .Li fdisk .
675 .It 5
676 Select
677 .Li Create DOS partition or Logical Drive .
678 .It 6
679 Select
680 .Li Create Primary DOS Partition .
681 .It 7
682 Tell it how big to make it
683 (Typically the whole drive.  It is pretty tiny after all.)
684 .It 8
685 Get out of FDISK by hitting
686 .Li <ESC>
687 a few times.
688 .It 9
689 doscmd may abort, if it does, start up doscmd again.
690 .It 10
691 At the > prompt, type
692 .Li format c:
693 and follow the instructions.
694 .It 11
695 At the > prompt type
696 .Li sys c: .
697 .It 12
698 Get out of doscmd.
699 .It 13
700 Either remove the floppy from the drive or add the line
701 .Bd -literal -offset indent
702 boot C:
703 .Ed
704 to your
705 .Pa .doscmdrc .
706 .It 14
707 You should now be running DOS off of your new disk.  You will
708 probably want both config.sys and an autoexec.bat file.  To
709 start with, you can say:
710 .Bd -literal -offset indent
711 > copy con: config.sys
712 LASTDRIVE=Z
713 ^Z
714 > copy con: autoexec.bat
715 @echo off
716 redir.com
717 ^Z
718 .Ed
719 .It 15
720 Quit doscmd.
721 .It 16
722 You know have a bootable pseudo disk which will automatically call
723 the magic
724 .Li redir
725 program, which installs
726 .Dx
727 disks.  To use
728 them add lines to your .doscmdrc such as:
729 .Bd -literal -offset indent
730 assign D: /usr/dos
731 assign P: -ro /usr/prb
732 .Ed
733 Note that you will not always be able to access every file due to
734 naming problems.
735 .El
736 .Sh DIAGNOSTICS
737 If
738 .Nm
739 encounters an interrupt which is unimplemented, it will print a message
740 such as:
741 .Pp
742 .Dl Unknown interrupt 21 function 99
743 .Pp
744 and exit.
745 .Pp
746 If
747 .Nm
748 emits the message
749 .Ic X11 support not compiled in
750 when supplied the
751 .Fl x
752 switch, this support can be added by defining an environment variable
753 .Ev X11BASE
754 which points to the installed X Window System (normally
755 .Pa /usr/X11R6 )
756 and then typing
757 .Ic make install
758 in the source directory (normally
759 .Pa /usr/src/usr.bin/doscmd ) .
760 For this to work, the X programmer's kit must have been installed.
761 .Sh HISTORY
762 The
763 .Nm
764 program first appeared in
765 .Tn BSD/386 .
766 .Sh AUTHORS
767 .An Pace Willisson ,
768 .An Paul Borman