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