TO_REMOVE+=/usr/lib/libmytinfo.so
TO_REMOVE+=/usr/lib/profile/libmytinfo.a
TO_REMOVE+=/usr/include/sys/ccms.h
+TO_REMOVE+=/usr/bin/doscmd
+TO_REMOVE+=/usr/libdata/doscmd
+TO_REMOVE+=/usr/share/man/cat1/doscmd.1.gz
+TO_REMOVE+=/usr/share/man/man1/doscmd.1.gz
.if ${MACHINE_ARCH} == "x86_64"
TO_REMOVE+=/usr/libdata/stallion/2681.sys
The wdog framework is now compiled into our kernels by default, so the
options are no longer needed.
+DOSCMD(1) REMOVED
+-----------------
+
+doscmd(1) has been removed. It was i386 only. The doscmd(1) specific
+NO_X make.conf option was removed too.
+
+-----------------------------------------------------------------------+
+ UPGRADING DRAGONFLY FROM 2.10 to later versions +
+-----------------------------------------------------------------------+
#NO_OPENSSL= true # do not build OpenSSL (implies NO_OPENSSH)
#NO_SENDMAIL= true # do not build sendmail and related programs
#NO_SHARE= true # do not enter the share subdirectory
-#NO_X= true # do not compile in XWindows support (e.g. doscmd)
#NOINFO= true # do not make or install info files
#NOINFOCOMPRESS=true # do not compress info files
#NOMAN= true # do not build manual pages
..
..
libdata
- doscmd
- fonts
- ..
- ..
gcc41
..
gcc44
.It Va NO_SHARE
.Pq Vt bool
Set to not enter the share subdirectory.
-.It Va NO_X
-.Pq Vt bool
-Set to not compile in X\-Windows support (e.g.\&
-.Xr doscmd 1 ) .
.It Va NOCLEAN
.Pq Vt bool
Set this to disable cleaning during
misc. utility data files
.Pp
.Bl -tag -width ".Pa stallion/" -compact
-.It Pa doscmd/
-files used by doscmd (drivers, fonts, etc.);
-see
-.Xr doscmd 1
-.Pp
-.Bl -tag -width ".Pa fonts/" -compact
-.It Pa fonts/
-fonts used by doscmd
-.El
-.Pp
.It Pa lint/
various prebuilt lint libraries;
see
.if ${MACHINE_ARCH} == "i386"
# Things that don't compile on x86_64 or are i386 specific:
-SUBDIR+=doscmd \
- gcore \
+SUBDIR+=gcore \
ncplist \
ncplogin \
smbutil
+++ /dev/null
-/*
- * 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 AsyncIO.c,v 2.2 1996/04/08 19:32:10 bostic Exp
- *
- * $FreeBSD: src/usr.bin/doscmd/AsyncIO.c,v 1.3.2.3 2002/05/21 11:49:47 tg Exp $
- */
-
-#include <sys/param.h>
-#include <sys/types.h>
-#include <sys/time.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <limits.h>
-#include <signal.h>
-#include <stdio.h>
-#include <unistd.h>
-
-#include "doscmd.h"
-#include "AsyncIO.h"
-
-#define FD_ISZERO(p) ((p)->fds_bits[0] == 0)
-
-/*
- * Set or Clear the Async nature of an FD
- */
-
-#define SETASYNC(fd) fcntl(fd, F_SETFL, handlers[fd].flag | FASYNC)
-#define CLRASYNC(fd) fcntl(fd, F_SETFL, handlers[fd].flag & ~FASYNC)
-
-/*
- * Request that ``func'' be called everytime data is available on ``fd''
- */
-
-static fd_set fdset; /* File Descriptors to select on */
-
-typedef struct {
- void (*func)(int, int, void *, regcontext_t *);
- /* Function to call on data arrival */
- void (*failure)(void *); /* Function to call on failure */
- void *arg; /* Argument to above functions */
- int lockcnt; /* Nested level of lock */
- fd_set members; /* Set of FD's to disable on SIGIO */
- int flag; /* The flag from F_GETFL (we own it) */
-} Async;
-
-static Async handlers[OPEN_MAX];
-
-static void CleanIO(void);
-static void HandleIO(struct sigframe *sf);
-
-void
-_RegisterIO(int fd, void (*func)(int, int, void *, regcontext_t *),
- void *arg, void (*failure)(void *))
-{
- static int firsttime = 1;
- Async *as;
-
- if (fd < 0 || fd > OPEN_MAX) {
-printf("%d: Invalid FD\n", fd);
- return;
- }
-
- as = &handlers[fd];
-
- if ((as->flag = fcntl(fd, F_GETFL, 0)) == -1) {
- if (func) {
-/*@*/ perror("get fcntl");
-/*@*/ abort();
- return;
- }
- }
-
- if (firsttime) {
- firsttime = 0;
- setsignal(SIGIO, HandleIO);
- }
-
- if ((handlers[fd].func = func) != NULL) {
- as->lockcnt = 0;
- as->arg = arg;
- as->failure = failure;
-
- FD_SET(fd, &fdset);
- FD_ZERO(&handlers[fd].members);
- FD_SET(fd, &handlers[fd].members);
- if (fcntl(fd, F_SETOWN, getpid()) < 0) {
-/*@*/ perror("SETOWN");
- }
- SETASYNC(fd);
- } else {
- as->arg = NULL;
- as->failure = NULL;
- as->lockcnt = 0;
-
- CLRASYNC(fd);
- FD_CLR(fd, &fdset);
- }
-}
-
-static void
-CleanIO(void)
-{
- int x;
- static struct timeval tv;
-
- /*
- * For every file des in fd_set, we check to see if it
- * causes a fault on select(). If so, we unregister it
- * for the user.
- */
- for (x = 0; x < OPEN_MAX; ++x) {
- fd_set set;
-
- if (!FD_ISSET(x, &fdset))
- continue;
-
- FD_ZERO(&set);
- FD_SET(x, &set);
- errno = 0;
- if (select(FD_SETSIZE, &set, 0, 0, &tv) < 0 &&
- errno == EBADF) {
- void (*f)(void *);
- void *a;
-printf("Closed file descriptor %d\n", x);
-
- f = handlers[x].failure;
- a = handlers[x].arg;
- handlers[x].failure = NULL;
- handlers[x].func = NULL;
- handlers[x].arg = NULL;
- handlers[x].lockcnt = 0;
- FD_CLR(x, &fdset);
- if (f)
- (*f)(a);
- }
- }
-}
-
-static void
-HandleIO(struct sigframe *sf)
-{
- static struct timeval tv;
- fd_set readset, writeset;
- int x, fd;
-
-again:
- readset = writeset = fdset;
- if ((x = select(FD_SETSIZE, &readset, &writeset, 0, &tv)) < 0) {
- /*
- * If we failed because of a BADFiledes, go find
- * which one(s), fail them out and then try a
- * new select to see if any of the good ones are
- * okay.
- */
- if (errno == EBADF) {
- CleanIO();
- if (FD_ISZERO(&fdset))
- return;
- goto again;
- }
- perror("select");
- return;
- }
-
- /*
- * If we run out of fds to look at, break out of the loop
- * and exit the handler.
- */
- if (x == 0)
- return;
-
- /*
- * If there is at least 1 fd saying it has something for
- * us, then loop through the sets looking for those
- * bits, stopping when we have handleed the number it has
- * asked for.
- */
- for (fd = 0; x && fd < OPEN_MAX; fd ++) {
- Async *as;
- int cond;
-
- cond = 0;
-
- if (FD_ISSET(fd, &readset)) {
- cond |= AS_RD;
- x --;
- }
- if (FD_ISSET(fd, &writeset)) {
- cond |= AS_WR;
- x --;
- }
-
- if (cond == 0)
- continue;
-
- /*
- * Is suppose it is possible that one of the previous
- * I/O requests changed the fdset.
- * We do know that SIGIO is turned off right now,
- * so it is safe to checkit.
- */
- if (!FD_ISSET(fd, &fdset)) {
- continue;
- }
- as = &handlers[fd];
-
- /*
- * as in above, maybe someone locked us...
- * we are in dangerous water now if we are
- * multi-tasked
- */
- if (as->lockcnt) {
- fprintf(stderr, "Selected IO on locked %d\n",fd);
- continue;
- }
- /*
- * Okay, now if there exists a handler, we should
- * call it. We must turn back on SIGIO if there
- * are possibly other people waiting for it.
- */
- if (as->func) {
- (*handlers[fd].func)(fd, cond, handlers[fd].arg,
- (regcontext_t *)&sf->sf_uc.uc_mcontext);
- } else {
- /*
- * Otherwise deregister this guy.
- */
- _RegisterIO(fd, 0, 0, 0);
- }
- }
- /*
- * If we did not process all the fd's, then we should
- * break out of the probable infinite loop.
- */
-}
+++ /dev/null
-/*
- * 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 AsyncIO.h,v 2.2 1996/04/08 19:32:12 bostic Exp
- *
- * $FreeBSD: src/usr.bin/doscmd/AsyncIO.h,v 1.1.6.1 2002/04/25 11:04:50 tg Exp $
- * $DragonFly: src/usr.bin/doscmd/AsyncIO.h,v 1.2 2003/06/17 04:29:25 dillon Exp $
- */
-
-#if defined(__cplusplus)
-extern "C" {
-#endif
-enum {
- AS_RD = 1,
- AS_WR = 2
-};
-
-void _RegisterIO(int, void (*)(int, int, void *, regcontext_t *),
- void *, void (*)(void *));
-#if defined(__cplusplus)
-}
-#endif
-
-#define _Un_RegisterIO(x) _RegisterIO((x), (void (*))0, NULL, (void (*))0)
+++ /dev/null
-# from BSDI Makefile,v 2.6 1996/04/08 20:06:40 bostic Exp
-#
-# $FreeBSD: src/usr.bin/doscmd/Makefile,v 1.21.2.5 2002/08/07 16:32:01 ru Exp $
-# $DragonFly: src/usr.bin/doscmd/Makefile,v 1.5 2007/08/27 16:50:53 pavalos Exp $
-
-PROG= doscmd
-SRCS= AsyncIO.c ParseBuffer.c bios.c callback.c cmos.c config.c cpu.c cwd.c \
- debug.c disktab.c dos.c doscmd.c ems.c emuint.c exe.c i386-pinsn.c \
- int.c int10.c int13.c int14.c int16.c int17.c int1a.c int2f.c intff.c \
- mem.c mouse.c net.c port.c setver.c signal.c timer.c trace.c trap.c \
- tty.c video.c xms.c ${FONTHDRS}
-CFLAGS+= -I. -DDISASSEMBLER
-FONTFILES= cp437-8x8.pcf.gz cp437-8x14.pcf.gz cp437-8x16.pcf.gz
-FONTHDRS= font8x8.h font8x14.h font8x16.h
-CLEANFILES= ${FONTFILES} ${FONTHDRS} emsdriv.sys redir.com
-
-XINCDIR= ${DESTDIR}${X11BASE}/include
-XLIBDIR= ${DESTDIR}${X11BASE}/lib
-
-EXEGRP:= ${BINGRP}
-EXEMODE= ${NOBINMODE}
-#BINGRP= kmem
-#BINMODE= 2555
-WARNS?= 1
-
-.if !defined(NO_X) && exists(${XINCDIR}/X11/X.h) && exists(${XLIBDIR}/libX11.a)
-CFLAGS+= -I${XINCDIR}
-LDADD+= -L${XLIBDIR} -lX11
-DPADD+= ${XLIBDIR}/libX11.a
-.else
-CFLAGS+= -DNO_X
-.endif
-
-beforeinstall:
- ${INSTALL} -o ${BINOWN} -g ${EXEGRP} -m ${EXEMODE} \
- emsdriv.sys redir.com ${DESTDIR}/usr/libdata/doscmd/
- ${INSTALL} -o ${BINOWN} -g ${EXEGRP} -m ${SHAREMODE} \
- ${FONTFILES} ${DESTDIR}/usr/libdata/doscmd/fonts
- cd ${.CURDIR} && \
- ${INSTALL} -o ${BINOWN} -g ${EXEGRP} -m ${SHAREMODE} \
- fonts.dir ${DESTDIR}/usr/libdata/doscmd/fonts
-
-cp437-8x8.pcf.gz: cp437-8x8.pcf.gz.uu
- uudecode ${.CURDIR}/cp437-8x8.pcf.gz.uu
-
-cp437-8x14.pcf.gz: cp437-8x14.pcf.gz.uu
- uudecode ${.CURDIR}/cp437-8x14.pcf.gz.uu
-
-cp437-8x16.pcf.gz: cp437-8x16.pcf.gz.uu
- uudecode ${.CURDIR}/cp437-8x16.pcf.gz.uu
-
-emsdriv.sys: emsdriv.sys.uu
- uudecode ${.CURDIR}/emsdriv.sys.uu
-
-font8x8.h: ${.CURDIR}/../../share/syscons/fonts/cp437-8x8.fnt
- uudecode -p ${.ALLSRC} | \
- file2c 'u_int8_t font8x8[] = {' '};' > ${.TARGET}
-
-font8x14.h: ${.CURDIR}/../../share/syscons/fonts/cp437-8x14.fnt
- uudecode -p ${.ALLSRC} | \
- file2c 'u_int8_t font8x14[] = {' '};' > ${.TARGET}
-
-font8x16.h: ${.CURDIR}/../../share/syscons/fonts/cp437-8x16.fnt
- uudecode -p ${.ALLSRC} | \
- file2c 'u_int8_t font8x16[] = {' '};' > ${.TARGET}
-
-redir.com: redir.com.uu
- uudecode ${.CURDIR}/redir.com.uu
-
-# Make sure the library names are defined. We want to specify the full
-# path to the standard crt0.o, and building two binaries in one directory
-# breaks the automatic generation of dependencies for binaries.
-NEED_LIBNAMES= yes
-
-.include <bsd.prog.mk>
-
-# add dependancy after inclusion so we do not override the ${PROG}: target.
-#
-doscmd: ${FONTFILES} ${FONTHDRS} emsdriv.sys redir.com
-
+++ /dev/null
-# Special makefile for the as86/ld86 tools
-#
-# This is used only to make the dos tools. It is not used in the normal
-# build process, except one of the *.S files is changed. The ready to
-# use tools are included as uuencoded files.
-# To use this makefile you must have Bruce Evans bcc package installed
-#
-# $FreeBSD: src/usr.bin/doscmd/Makefile.dos,v 1.1.6.1 2002/04/25 11:04:50 tg Exp $
-# $DragonFly: src/usr.bin/doscmd/Makefile.dos,v 1.2 2003/06/17 04:29:25 dillon Exp $
-
-AS86 = as86
-LD86 = ld86
-
-OBJS = redir.o emsdriv.o
-DOSPROG = redir.com emsdriv.sys
-DOSDIST = redir.com.uu emsdriv.sys.uu
-
-all: ${DOSPROG} ${DOSDIST}
-
-redir.com: redir.o
- $(LD86) -T 0 -s -o ${.PREFIX}.tmp ${.ALLSRC}
- dd if=${.PREFIX}.tmp of=${.TARGET} bs=1 skip=288
- rm -f ${.PREFIX}.tmp
-
-emsdriv.sys: emsdriv.o
- $(LD86) -T 0 -s -o ${.PREFIX}.tmp ${.ALLSRC}
- dd if=${.PREFIX}.tmp of=${.TARGET} bs=1 skip=32
- rm -f ${.PREFIX}.tmp
-
-redir.com.uu: redir.com
- uuencode redir.com redir.com > redir.com.uu
-
-emsdriv.sys.uu: emsdriv.sys
- uuencode emsdriv.sys emsdriv.sys > emsdriv.sys.uu
-
-clean:
- rm -f ${DOSPROG} ${OBJS}
-
-allclean:
- rm -f ${DOSPROG} ${DOSDIST} ${OBJS}
-
-
-# Rule for as86
-.S.o:
- $(AS86) -0 -o ${.TARGET} ${.IMPSRC}
-
-
-
-
+++ /dev/null
-trailing \ missing in tempname (affects PKZIP)
-
-FCB find routines don't store the state correctly (affects DIR, NUSQ, GET)
-support for non-extended FCBs is broken (affects LAR)
-wrong device attributes reported after redirection (affects GZIP)
-REP IN/OUT not implemented
-find_next may not close fd
-tty modes wrong when running in terminal session
-devices not really implemented
-
-keyboard queue not fully implemented (affects VSAFE)
-several ioctl request not implemented (affects PKZOOM)
-no font file
-int 0x28 not implemented
-timer chip not implemented
-country info needs localization
-
-specific programs:
-charc crashes with a segment overrun
-sqwez gets a fault while exiting
-jrc outputs its banner again on exit, and sometimes complains about aa.aaa
+++ /dev/null
-/*
- * 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 ParseBuffer.c,v 2.2 1996/04/08 19:32:15 bostic Exp
- *
- * $FreeBSD: src/usr.bin/doscmd/ParseBuffer.c,v 1.2.2.2 2002/04/25 11:04:50 tg Exp $
- * $DragonFly: src/usr.bin/doscmd/ParseBuffer.c,v 1.4 2005/04/10 20:55:38 drhodus Exp $
- */
-
-#include <stdlib.h>
-#include <string.h>
-
-#include "doscmd.h"
-int
-ParseBuffer(char *obuf, char **av, int mac)
-{
- static char *_buf;
- char *buf = NULL;
- static int buflen = 0;
- int len;
-
- char *b = buf;
- char *p;
- char **a;
- char **e;
-
- len = strlen(obuf) + 1;
- if (len > buflen) {
- if (buflen)
- free(_buf);
- buflen = (len + 1023) & ~1023;
- _buf = malloc(buflen);
- }
- buf = _buf;
- strcpy(buf, obuf);
-
- a = av;
- e = &av[mac];
-
- while (*buf) {
- while (*buf == ' ' || *buf == '\t' || *buf == '\n')
- ++buf;
- if (*buf) {
- p = b = buf;
-
- *a++ = buf;
- if (a == e) {
- a[-1] = NULL;
- return(mac - 1);
- }
-
- while (*p && !(*p == ' ' || *p == '\t' || *p == '\n')) {
- *b++ = *p++ & 0177;
- }
- if (*p)
- ++p;
- *b = 0;
- buf = p;
- }
- }
- *a = NULL;
- return(a - av);
-}
+++ /dev/null
-/* BSDI README,v 2.2 1996/04/08 19:32:16 bostic Exp*/
-/* $FreeBSD: src/usr.bin/doscmd/README,v 1.2.6.1 2001/08/02 02:17:15 obrien Exp $ */
-/* $DragonFly: src/usr.bin/doscmd/README,v 1.2 2003/06/17 04:29:25 dillon Exp $ */
-
-This is the merged doscmd/rundos project. Please read the man
-page for help on configuring doscmd.
-
-Things known not to work:
- * No mouse support (yet)
- * No raw VGA support (yet)
- * Printer support (yet)
- * COM ports (being worked on)
- * redirected file system only supported for DOS 4.0 and above
- (3.3 will be supported in a future version)
- * Graphics in an X window (only 16 colors, very few programs)
-
-Even with this, I think it is actually a much better product. There have
-been problems reported with the ibmpc font and the distributed X server.
-If you have that problem, try setting
-
- X11_FONT=fixed
-
-in your .doscmdrc. Be aware that graphics characters will not print correctly
-if you do this.
-
-You will need to patch your kernel. Diffs are provided against the CD-ROM.
-Please let me know if there are a problem with them (I am running a pre 1.1
-kernel now).
-
-It is possible there are some problems in the floppy code due to the fact
-that I am not set up to test under 1.0 at this point. I will be in a few
-days I hope.
-
-Please send all bug reports to prb@BSDI.COM.
-
- -Paul Borman
- prb@BSDI.COM
- Jan 4 1994
+++ /dev/null
-/* BSDI README.booting_dos,v 2.2 1996/04/08 19:32:18 bostic Exp*/
-/* $FreeBSD: src/usr.bin/doscmd/README.booting_dos,v 1.3.2.1 2000/06/29 23:47:28 ps Exp $ */
-/* $DragonFly: src/usr.bin/doscmd/README.booting_dos,v 1.2 2003/06/17 04:29:25 dillon Exp $ */
-
-To install DOS on a pseudo hard disk under doscmd:
-
- 1) Create a .doscmdrc with at least the following:
-
- assign A: /dev/fd0.1440 1440
- assign A: /dev/fd0.720 720
- assign hard boot_drive 80 2 2
-
- 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.
-
- 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)
-
- boot_drive should be the file name of where you want your bootable
- image to be. The three numbers which follow "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 config.sys and autoexec.bat file.
-
- You might want to create a larger boot drive.
-
- The file boot_drive must exist, so use the command touch to create
- 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.
-
- (i.e. mwrite redir.com a:)
-
- 3) run doscmd.
-
- 4) At the > prompt type "fdisk"
-
- 5) Select "Create DOS partition or Logical Drive"
-
- 6) Select "Create Primary DOS Partition"
-
- 7) Tell it how big to make it (I say use the whole drive.
- It is pretty tiny after all.)
-
- 8) Get out of FDISK by hitting <ESC> a few times.
-
- 9) doscmd will now abort (will try and fix this in a future version)
-
- 10) start up doscmd again, leaving the floppy in the drive.
-
- 11) At the > prompt, type "format c:" and follow the instructions.
-
- 12) At the > prompt type "sys c:"
-
- 13) Get out of doscmd.
-
- 14) Either remove the floppy from the drive or add the line
-
- boot C:
-
- to your .doscmdrc
-
- 15) 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:
-
- > copy con: config.sys
- LASTDRIVE=Z
- ^Z
- > copy con: autoexec.bat
- @echo off
- redir.com
- ^Z
-
-
- 16) Quit doscmd.
-
- 17) You now have a bootable pseudo disk which will automatically call
- the magic "redir" program, which installs FreeBSD disks. To use
- them add lines to your .doscmdrc such as:
-
- assign D: /usr/dos
- assign P: -ro /usr/prb
-
- Note that you will not always be able to access every file due to
- naming problems.
-
- 18) To use the new EMS memory you need to copy the file emsdriv.sys
- to your DOS boot disk (disk image) in the same way you copied
- redir.com. The use it in your "config.sys" from DOS:
- device=C:\emsdriv.sys
- where C: is your boot drive (supply the correct letter, if needed)
- and emsdriv.sys is the driver. You could load it high. It should
- report "Doscmd EMS 4.0 driver installed".
+++ /dev/null
-/*
- * 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 bios.c,v 2.3 1996/04/08 19:32:19 bostic Exp
- *
- * $FreeBSD: src/usr.bin/doscmd/bios.c,v 1.5.2.1 2002/04/25 11:04:50 tg Exp $
- * $DragonFly: src/usr.bin/doscmd/bios.c,v 1.2 2003/06/17 04:29:25 dillon Exp $
- */
-
-#include "doscmd.h"
-#include "mouse.h"
-#include "com.h"
-
-#define BIOS_copyright 0xfe000
-#define BIOS_reset 0xfe05b
-#define BIOS_nmi 0xfe2c3
-#define BIOS_hdisk_table 0xfe401
-#define BIOS_boot 0xfe6f2
-#define BIOS_comm_table 0xfe729
-#define BIOS_comm_io 0xfe739
-#define BIOS_keyboard_io 0xfe82e
-#define BIOS_keyboard_isr 0xfe987
-#define BIOS_fdisk_io 0xfec59
-#define BIOS_fdisk_isr 0xfef57
-#define BIOS_disk_parms 0xfefc7
-#define BIOS_printer_io 0xfefd2
-#define BIOS_video_io 0xff065
-#define BIOS_video_parms 0xff0a4
-#define BIOS_mem_size 0xff841
-#define BIOS_equipment 0xff84d
-#define BIOS_cassette_io 0xff859
-#define BIOS_video_font 0xffa6e
-#define BIOS_time_of_day 0xffe6e
-#define BIOS_timer_int 0xffea5
-#define BIOS_vector 0xffef3
-#define BIOS_dummy_iret 0xfff53
-#define BIOS_print_screen 0xfff54
-#define BIOS_hard_reset 0xffff0
-#define BIOS_date_stamp 0xffff5
-#define BIOS_hardware_id 0xffffe
-
-static u_char disk_params[] = {
- 0xdf, 2, 0x25, 2, 0x0f, 0x1b, 0xff, 0x54, 0xf6, 0x0f, 8,
-};
-
-static u_short comm_table[] = {
- 1047, 768, 384, 192, 96, 48, 24, 12,
-};
-
-/* exports */
-
-int nfloppies = 0;
-int ndisks = 0;
-int nserial = 0;
-int nparallel = 0;
-unsigned long rom_config;
-
-/*
-** BIOS equipment list
-*/
-static void
-int11(regcontext_t *REGS)
-{
- R_AX =
- (nfloppies ? 1:0) | /* do we have any floppydisks? */
- (0x2 << 4) | /* 80x25 colour */
- ((nfloppies-1) << 6) | /* how many floppies? */
- (nserial << 9) | /* serial ports? */
- (nparallel << 14); /* parallel ports? */
-}
-
-/*
-** get installed memory
-*/
-static void
-int12(regcontext_t *REGS)
-{
- R_AX = 640;
-}
-
-/*
-** assorted oddments
-*/
-static void
-int15(regcontext_t *REGS)
-{
- R_FLAGS &= ~PSL_C;
-
- switch (R_AH) {
- case 0x00: /* Get Cassette Status */
- R_AH = 0x86;
- R_FLAGS |= PSL_C; /* We don't support a cassette */
- break;
- case 0x04: /* Set ABIOS table */
- R_FLAGS |= PSL_C; /* We don't support it */
- break;
- case 0x4f: /* Keyboard intercept */
- debug(D_TRAPS | 0x15, "BIOS: Keyboard intercept\n");
- /* Don't translate scan code. */
- break;
- case 0x88:
- get_raw_extmemory_info(REGS);
- break;
- case 0xc0: /* Get configuration */
- debug(D_TRAPS | 0x15, "BIOS: Get configuration\n");
- PUTVEC(R_ES, R_BX, rom_config);
- R_AH = 0;
- break;
- case 0xc1: /* Get extended BIOS data area */
- R_FLAGS |= PSL_C;
- break;
- case 0xc2: /* Pointing device */
- debug(D_TRAPS | 0x15, "BIOS: Pointing device?\n");
- R_FLAGS |= PSL_C;
- R_AH = 5; /* No pointer */
- break;
- default:
- unknown_int2(0x15, R_AX, REGS);
- break;
- }
-}
-
-void
-bios_init(void)
-{
- int i, j, k;
- u_char *jtab;
- struct timeval tv;
- time_t tv_sec;
- struct timezone tz;
- struct tm tm;
- u_long vec;
-
- strcpy((char *)BIOS_copyright,
- "Copyright (C) 1993 Krystal Technologies/BSDI");
-
- *(u_short *)BIOS_reset = 0xffcd;
- *(u_short *)BIOS_nmi = 0xffcd;
- *(u_short *)BIOS_boot = 0xffcd;
- *(u_short *)BIOS_comm_io = 0xffcd;
- *(u_short *)BIOS_keyboard_io = 0xffcd;
- *(u_short *)BIOS_keyboard_isr = 0xffcd;
- *(u_short *)BIOS_fdisk_io = 0xffcd;
- *(u_short *)BIOS_fdisk_isr = 0xffcd;
- *(u_short *)BIOS_printer_io = 0xffcd;
- *(u_short *)BIOS_video_io = 0xffcd;
- *(u_short *)BIOS_cassette_io = 0xffcd;
- *(u_short *)BIOS_time_of_day = 0xffcd;
- *(u_short *)BIOS_timer_int = 0xffcd;
- *(u_short *)BIOS_dummy_iret = 0xffcd;
- *(u_short *)BIOS_print_screen = 0xffcd;
- *(u_short *)BIOS_hard_reset = 0xffcd;
- *(u_short *)BIOS_mem_size = 0xffcd;
- *(u_short *)BIOS_equipment = 0xffcd;
- *(u_short *)BIOS_vector = 0xffcd;
- *(u_char *)0xffff2 = 0xcf; /* IRET */
-
- memcpy((u_char *)BIOS_disk_parms, disk_params, sizeof(disk_params));
- memcpy((u_char *)BIOS_comm_table, comm_table, sizeof(comm_table));
-
- *(u_short *)BIOS_video_font = 0xffcd;
-
- jtab = (u_char *)BIOS_date_stamp;
- *jtab++ = '1';
- *jtab++ = '0';
- *jtab++ = '/';
- *jtab++ = '3';
- *jtab++ = '1';
- *jtab++ = '/';
- *jtab++ = '9';
- *jtab++ = '3';
-
- *(u_char *)BIOS_hardware_id = 0xfc; /* Identify as a PC/AT */
-
- /*
- * Interrupt revectors F000:0000 - F000:03ff
- */
- for (i = 0, j = 0, k = 0; i < 0x100; ++i) {
- if ((i >= 0x60 && i < 0x68) ||
- (i >= 0x78 && i < 0xe2))
- continue;
- if ((i >= 0x00 && i < 0x2f) ||
- (i >= 0x30 && i < 0xfe)) {
- ivec[i] = 0xF0300000L | (k * 1);
- jtab = (u_char *)VECPTR(ivec[i]);
- *jtab++ = 0xf4; /* HLT */
- ++k;
- } else {
- ivec[i] = 0xF0000000L | (j * 6);
- jtab = (u_char *)VECPTR(ivec[i]);
- *jtab++ = 0xcd; /* INT i */
- *jtab++ = i;
- *jtab++ = 0xca; /* RETF 2 */
- *jtab++ = 2;
- *jtab++ = 0;
- ++j;
- }
- }
-
- /*
- * Misc variables from F000:0400 - F000:0fff
- */
- rom_config = 0xF0000400;
- jtab = (u_char *)VECPTR(rom_config);
- *jtab++ = 20; /* length of entry */
- *jtab++ = 0;
- *jtab++ = *(u_char *)BIOS_hardware_id;
- *jtab++ = 0x00; /* Sub model */
- *jtab++ = 0x01; /* Bios Rev Enhanced kbd w/3.5" floppy */
- *jtab++ = 0x20; /* real time clock present */
- *jtab++ = 0; /* Reserved */
- *jtab++ = 0;
- *jtab++ = 0;
- *jtab++ = 0;
- strcpy((char *)jtab, "BSDI BIOS");
- *jtab += 10;
-
- InDOS = jtab++;
- *InDOS = 0;
-
- mouse_area = jtab;
- jtab += 0x10;
-
- *(u_short *)&BIOSDATA[0x10] =
- (1 << 0) | /* Diskette avail for boot */
- (1 << 1) | /* Math co-processor */
- (nmice << 2) | /* No pointing device */
- (2 << 4) | /* Initial video (80 x 25 C) */
- ((nfloppies - 1) << 6) | /* Number of floppies - 1 */
- (nserial << 9) | /* Number of serial devices */
- (nparallel << 14); /* Number of parallel devices */
-
-
- *(u_short *)&BIOSDATA[0x13] = 640; /* Amount of memory */
- BIOSDATA[0x75] = ndisks; /* number of fixed disks */
-
- BIOSDATA[0x8F] = 0;
- if (nfloppies >= 1) {
- BIOSDATA[0x8F] |= 0x04;
- BIOSDATA[0x90] = 0x40;
- }
- if (nfloppies >= 2) {
- BIOSDATA[0x8F] |= 0x40;
- BIOSDATA[0x91] = 0x40;
- }
-
- gettimeofday(&tv, &tz);
- tv_sec = tv.tv_sec;
- tm = *localtime(&tv_sec);
- *(u_long *)&BIOSDATA[0x6c] =
- (((tm.tm_hour * 60 + tm.tm_min) * 60) + tm.tm_sec) * 182 / 10;
-
- vec = insert_softint_trampoline();
- ivec[0x11] = vec;
- register_callback(vec, int11, "int 11");
-
- vec = insert_softint_trampoline();
- ivec[0x12] = vec;
- register_callback(vec, int12, "int 12");
-
- vec = insert_softint_trampoline();
- ivec[0x14] = vec;
- register_callback(vec, int14, "int 14");
-
- vec = insert_softint_trampoline();
- ivec[0x15] = vec;
- register_callback(vec, int15, "int 15");
-
- vec = insert_softint_trampoline();
- ivec[0x16] = vec;
- register_callback(vec, int16, "int 16");
-
- vec = insert_softint_trampoline();
- ivec[0x17] = vec;
- register_callback(vec, int17, "int 17");
-
- vec = insert_softint_trampoline();
- ivec[0x1a] = vec;
- register_callback(vec, int1a, "int 1a");
-}
+++ /dev/null
-/*
- * No copyright?!
- *
- * $FreeBSD: src/usr.bin/doscmd/callback.c,v 1.2.2.2 2002/04/25 11:04:50 tg Exp $
- * $DragonFly: src/usr.bin/doscmd/callback.c,v 1.2 2003/06/17 04:29:25 dillon Exp $
- */
-
-#include <sys/queue.h>
-#include "doscmd.h"
-
-/*
-** Callbacks are used for chaining interrupt handlers
-** off interrupt vectors
-*/
-
-struct callback {
- LIST_ENTRY(callback) chain;
- u_long vec;
- callback_t func;
- const char *name;
-};
-
-LIST_HEAD(cbhead , callback) cbhead[127];
-
-#define CBHASH(x) (((x) * 17) % 127)
-
-/*
-** Register (func) as a handler for (vec)
-*/
-void
-register_callback(u_long vec, callback_t func, const char *name)
-{
- struct cbhead *head;
- struct callback *elm;
-
- elm = malloc(sizeof(struct callback));
- elm->vec = vec;
- elm->func = func;
- elm->name = name;
-
- head = &cbhead[CBHASH(vec)];
- LIST_INSERT_HEAD(head, elm, chain);
-}
-
-/*
-** Find a handler for (vec)
-*/
-callback_t
-find_callback(u_long vec)
-{
- struct cbhead *head;
- struct callback *elm;
-
- head = &cbhead[CBHASH(vec)];
- LIST_FOREACH(elm, head, chain)
- if (elm->vec == vec)
- break;
- if (elm) {
- debug(D_TRAPS2, "callback %s\n", elm->name);
- return (elm->func);
- } else
- return ((callback_t)0);
-}
-
-u_long trampoline_rover = 0xF1000000;
-
-/*
- * Interrupts are disabled on an INTn call, so we must restore interrupts
- * before via STI returning. IRET is not used here because 1) some DOS
- * calls want to return status via the FLAGS register, and 2) external
- * routines which hook INTn calls do not always put a FLAGS image on the
- * stack which re-enables interrupts.
- */
-u_char softint_trampoline[] = {
- 0xf4, /* HLT */
- 0xfb, /* STI */
- 0xca, /* RETF 2 */
- 2,
- 0,
-};
-u_char hardint_trampoline[] = {
- 0xf4, /* HLT */
- 0xcf, /* IRET */
-};
-u_char null_trampoline[] = {
- 0xcf, /* IRET */
-};
-
-u_long
-insert_generic_trampoline(size_t len, u_char *p)
-{
- u_char *q;
- u_long where;
-
- where = trampoline_rover;
- q = (u_char *)VECPTR(where);
- memcpy(q, p, len);
- trampoline_rover += len;
- return (where);
-}
-
-u_long
-insert_softint_trampoline(void)
-{
- return (insert_generic_trampoline(
- sizeof(softint_trampoline), softint_trampoline));
-}
-
-u_long
-insert_hardint_trampoline(void)
-{
- return (insert_generic_trampoline(
- sizeof(hardint_trampoline), hardint_trampoline));
-}
-
-u_long
-insert_null_trampoline(void)
-{
- return (insert_generic_trampoline(
- sizeof(null_trampoline), null_trampoline));
-}
+++ /dev/null
-/*
-** No copyright?!
-**
-** $FreeBSD: src/usr.bin/doscmd/callback.h,v 1.2.2.1 2002/04/25 11:04:50 tg Exp $
-** $DragonFly: src/usr.bin/doscmd/callback.h,v 1.2 2003/06/17 04:29:25 dillon Exp $
-*/
-typedef void (*callback_t)(regcontext_t *);
-
-void register_callback(u_long, callback_t, const char *);
-callback_t find_callback(u_long);
-u_long insert_generic_trampoline(size_t, u_char *);
-u_long insert_softint_trampoline(void);
-u_long insert_hardint_trampoline(void);
-u_long insert_null_trampoline(void);
+++ /dev/null
-/*
- * 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 cmos.c,v 2.3 1996/04/08 19:32:20 bostic Exp
- *
- * $FreeBSD: src/usr.bin/doscmd/cmos.c,v 1.2.2.2 2002/04/25 11:04:50 tg Exp $
- * $DragonFly: src/usr.bin/doscmd/cmos.c,v 1.2 2003/06/17 04:29:25 dillon Exp $
- */
-
-#include "doscmd.h"
-
-#define ALARM_ON ((unsigned char) 0x20)
-#define FAST_TIMER ((unsigned char) 0x40)
-#define SEC_SIZE 1
-#define MIN_SIZE 60
-#define HOUR_SIZE (MIN_SIZE * 60)
-#define DAY_SIZE (HOUR_SIZE * 24)
-#define YEAR_DAY 365
-
-#define SEC_MS 1000000
-#define FAST_TICK_BSD 0x3D00
-
-#define Jan 31
-#define Feb 28
-#define Mar 31
-#define Apr 30
-#define May 31
-#define Jun 30
-#define Jul 31
-#define Aug 31
-#define Sep 31
-#define Oct 31
-#define Nov 30
-#define Dec 31
-
-static unsigned char cmos_last_port_70 = 0;
-static unsigned char cmos_data[0x40] = {
- 0x00, /* 0x00 Current Second */
- 0x00, /* 0x01 Alarm Second */
- 0x00, /* 0x02 Current minute */
- 0x00, /* 0x03 Alarm minute */
- 0x00, /* 0x04 Current hour */
- 0x00, /* 0x05 Alarm hour */
- 0x00, /* 0x06 Current week day */
- 0x00, /* 0x07 Current day */
- 0x00, /* 0x08 Current month */
- 0x00, /* 0x09 Current year */
- 0x26, /* 0x0A Status register A */
- 0x02, /* 0x0B Status register B */
- 0x00, /* 0x0C Status register C */
- 0x80, /* 0x0D Status register D */
- 0x00, /* 0x0E Diagnostic status */
- 0x00, /* 0x0F Shutdown Code */
- 0x00, /* 0x10 Drive types (1 FDHD disk) */
- 0x00, /* 0x11 Fixed disk 0 type */
- 0x00, /* 0x12 Fixed disk 1 type */
- 0x00,
- 0x00, /* Installed equipment */
-};
-
-int day_in_year [12] = {
- 0, Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov
-};
-
-/* consumed by dos.c */
-time_t delta_clock = 0;
-
-/* locals */
-static struct timeval fast_clock;
-static int fast_tick;
-
-static struct timeval glob_clock;
-static int cmos_alarm_time = 0;
-static int cmos_alarm_daytime = 0;
-
-static inline int
-day_in_mon_year(int mon, int year)
-{
- return day_in_year[mon] + (mon > 2 && (year % 4 == 0));
-}
-
-static inline int
-to_BCD (int n)
-{
- n &= 0xFF;
- return n%10 + ((n/10)<<4);
-}
-
-static inline int
-from_BCD (int n)
-{
- n &= 0xFF;
- return (n & 0xF) + (n >> 4) * 10;
-}
-
-/*
-** inb() from clock ports.
-**
-** 0x70 is scratchpad/register select
-** 0x71 is data
-*/
-static unsigned char
-cmos_inb(int portnum)
-{
- unsigned char ret_val = 0;
- int cmos_reg;
- struct timezone tz;
- struct tm tm = { .tm_sec = 0 };
- time_t now;
-
- switch (portnum) {
- case 0x70:
- ret_val = cmos_last_port_70;
- break;
- case 0x71:
- cmos_reg = cmos_last_port_70 & 0x3f;
- if (cmos_reg < 0xa) {
- gettimeofday(&glob_clock, &tz);
- now = glob_clock.tv_sec + delta_clock;
- tm = *localtime(&now);
- }
- switch (cmos_reg) {
- case 0:
- ret_val = to_BCD(tm.tm_sec);
- break;
- case 2:
- ret_val = to_BCD(tm.tm_min);
- break;
- case 4:
- ret_val = to_BCD(tm.tm_hour);
- break;
- case 6:
- ret_val = to_BCD(tm.tm_wday);
- break;
- case 7:
- ret_val = to_BCD(tm.tm_mday);
- break;
- case 8:
- ret_val = to_BCD(tm.tm_mon + 1);
- break;
- case 9:
- ret_val = to_BCD((tm.tm_year + 1900) % 100);
- break;
- default:
- ret_val = cmos_data[cmos_reg];
- break;
- }
- break;
- }
- return (ret_val);
-}
-
-static void
-cmos_outb(int portnum, unsigned char byte)
-{
- int cmos_reg;
- int year;
- int time00;
- struct timezone tz;
- struct tm tm = { .tm_sec = 0 };
- time_t now;
-
- switch (portnum) {
- case 0x70:
- cmos_last_port_70 = byte;
- break;
- case 0x71:
- cmos_reg = cmos_last_port_70 & 0x3f;
- if (cmos_reg < 0xa) {
- gettimeofday(&glob_clock, &tz);
- now = glob_clock.tv_sec + delta_clock;
- tm = *localtime(&now);
- }
- switch (cmos_reg) {
- case 0:
- delta_clock += SEC_SIZE * (from_BCD(byte) - tm.tm_sec);
- break;
- case 1:
- cmos_alarm_daytime +=
- SEC_SIZE * (from_BCD(byte) - from_BCD(cmos_data[1]));
- break;
- case 2:
- delta_clock += MIN_SIZE * (from_BCD(byte) - tm.tm_min);
- break;
- case 3:
- cmos_alarm_daytime +=
- MIN_SIZE * (from_BCD(byte) - from_BCD(cmos_data[3]));
- break;
- case 4:
- delta_clock += HOUR_SIZE * (from_BCD(byte) - tm.tm_hour);
- break;
- case 5:
- cmos_alarm_daytime +=
- HOUR_SIZE * (from_BCD(byte) - from_BCD(cmos_data[5]));
- break;
- case 7:
- delta_clock += DAY_SIZE * (from_BCD(byte) - tm.tm_mday);
- break;
- case 8:
- delta_clock += DAY_SIZE *
- (day_in_mon_year(from_BCD(byte), tm.tm_year) -
- day_in_mon_year(tm.tm_mon + 1, tm.tm_year));
- break;
- case 9:
- year = from_BCD(byte);
- delta_clock += DAY_SIZE * (YEAR_DAY * (year - tm.tm_year)
- + (year/4 - tm.tm_year/4));
- break;
- case 0xB:
- cmos_data[0xc] = byte;
- if (byte & ALARM_ON) {
- debug(D_ALWAYS, "Alarm turned on\n");
- time00 = glob_clock.tv_sec + delta_clock -
- (tm.tm_sec + MIN_SIZE * tm.tm_min
- + HOUR_SIZE * tm.tm_hour);
- cmos_alarm_time = time00 + cmos_alarm_daytime;
- if (cmos_alarm_time < (glob_clock.tv_sec + delta_clock))
- cmos_alarm_time += DAY_SIZE;
- }
- if (byte & FAST_TIMER) {
- debug(D_ALWAYS, "Fast timer turned on\n");
- fast_clock = glob_clock;
- fast_tick = 0;
- }
- break;
- }
- cmos_data[cmos_reg] = byte;
- break;
- }
-}
-
-
-void
-cmos_init(void)
-{
- int numflops = 0;
- int checksum = 0;
- int i;
-
- cmos_data[0x0e] = 0;
-
- numflops = nfloppies;
- cmos_data[0x10] = (search_floppy(0) << 4) | search_floppy(1);
-
- if (numflops) /* floppy drives present + numflops */
- cmos_data[0x14] = ((numflops - 1) << 6) | 1;
-
- cmos_data[0x15] = 0x80; /* base memory 640k */
- cmos_data[0x16] = 0x2;
- for (i=0x10; i<=0x2d; i++)
- checksum += cmos_data[i];
- cmos_data[0x2e] = checksum >>8; /* High byte */
- cmos_data[0x2f] = checksum & 0xFF; /* Low byte */
-
- cmos_data[0x32] = 0x19; /* Century in BCD ; temporary */
-
- for (i = 1; i < 12; i++){
- day_in_year[i] += day_in_year[i-1];
- }
-
- define_input_port_handler(0x70, cmos_inb);
- define_input_port_handler(0x71, cmos_inb);
- define_output_port_handler(0x70, cmos_outb);
- define_output_port_handler(0x71, cmos_outb);
-}
+++ /dev/null
-/*
- * 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 com.h,v 2.2 1996/04/08 19:32:21 bostic Exp
- *
- * $FreeBSD: src/usr.bin/doscmd/com.h,v 1.2.2.1 2002/04/25 11:04:50 tg Exp $
- * $DragonFly: src/usr.bin/doscmd/com.h,v 1.2 2003/06/17 04:29:25 dillon Exp $
- */
-
-/* com.h for doscmd int14.c */
-
-/* NS16550A register definitions */
-
-/* interrupt enable register */
-
-#define IE_NOP 0xF0 /* Not used */
-#define IE_MODEM_STAT 0x08 /* modem status int. */
-#define IE_LINE_STAT 0x04 /* receiver-line status int. */
-#define IE_TRANS_HLD 0x02 /* transmitter holding register empty int. */
-#define IE_RCV_DATA 0x01 /* received data available int. */
-
-/* interrupt identification register */
-
-#define II_FIFOS_EN 0xC0 /* if FIFOs are enabled */
-#define II_NOP 0x30 /* not used */
-#define II_INT_ID 0x0E /* mask: bits see below */
-#define II_PEND_INT 0x01 /* 1=no interrupt pending */
-
-/* bit masks for II_INT_ID */
-
-#define II_TO 0x0C
-#define II_LINE_STAT 0x06
-#define II_RCV_DATA 0x04
-#define II_TRANS_HLD 0x02
-#define II_MODEM_STAT 0x00
-
-/* FIFO control reg */
-
-#define FC_FIFO_SZ_MASK 0xC0
-#define FC_FIFO_1B 0x80
-#define FC_FIFO_4B 0x40
-#define FC_FIFO_8B 0x80
-#define FC_FIFO_14B 0xC0
-#define FC_FIFO_CTR 0x04
-#define FC_FIFO_CRV 0x02
-#define FC_FIFO_EN 0x01
-
-/* line control register */
-
-#define LC_DIV_ACC 0x80 /* divisor latch access bit */
-#define LC_BRK_CTRL 0x40 /* set break control */
-#define LC_S_PAR 0x20 /* stick parity */
-#define LC_EVEN_P 0x10 /* even parity select */
-#define LC_PAR_E 0x08 /* parity enable */
-#define LC_STOP_B 0x04 /* number of stop bits (0 - 1 bit) */
-#define LC_W_LEN 0x03 /* unsigned short length (00 - 5, 01 - 6 etc.) */
-
-/* line status register */
-
-#define LS_NOP 0x80 /* not used */
-#define LS_X_DATA_E 0x40 /* 1=empty */
-#define LS_X_HOLD_E 0x20 /* 1=empty */
-#define LS_BREAK 0x10 /* break received */
-#define LS_FRM_ERR 0x08 /* framing error */
-#define LS_PAR_ERR 0x04 /* parity error */
-#define LS_OVRN_ERR 0x02 /* overrun error */
-#define LS_RCV_DATA_RD 0x01 /* data received */
-
-/* modem status register */
-
-#define MS_DCD 0x80 /* Data Carrier Detect in */
-#define MS_RI 0x40 /* Ring Indicator in */
-#define MS_DSR 0x20 /* Data Set Ready in */
-#define MS_CTS 0x10 /* Clear To Send in */
-#define MS_DELTA_DCD 0x08 /* Data Carrier Detect changed state */
-#define MS_DELTA_RI 0x04 /* Ring Indicator changed state */
-#define MS_DELTA_DSR 0x02 /* Data Set Ready changed state */
-#define MS_DELTA_CTS 0x01 /* Clear To Send changed state */
-
-/* DOS definitions -- parameters */
-
-#define BITRATE_110 0x00
-#define BITRATE_150 0x20
-#define BITRATE_300 0x40
-#define BITRATE_600 0x60
-#define BITRATE_1200 0x80
-#define BITRATE_2400 0xA0
-#define BITRATE_4800 0xC0
-#define BITRATE_9600 0xE0
-#define PARITY_NONE 0x00
-#define PARITY_ODD 0x08
-#define PARITY_EVEN 0x18
-#define STOPBIT_1 0x00
-#define STOPBIT_2 0x04
-#define TXLEN_7BITS 0x02
-#define TXLEN_8BITS 0x03
-
-#define N_OF_COM_REGS 8
-
-/* DOS definitions -- return codes */
-
-#define LS_SW_TIME_OUT LS_NOP /* return value used by DOS */
-
-/* routine declarations */
-
-void int14(regcontext_t *REGS);
-void init_com(int, char *, int, unsigned char);
-
-/* end of file com.h */
+++ /dev/null
-/*
- * 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 config.c,v 2.2 1996/04/08 19:32:22 bostic Exp
- *
- * $FreeBSD: src/usr.bin/doscmd/config.c,v 1.4.2.1 2002/04/25 11:04:50 tg Exp $
- */
-
-#include <sys/types.h>
-#include <sys/uio.h>
-#include <ctype.h>
-#include <stdio.h>
-#include <string.h>
-#include <unistd.h>
-
-#include "doscmd.h"
-#include "com.h"
-#include "cwd.h"
-#include "tty.h"
-#include "video.h"
-
-/*
-** doscmdrc parser
-*/
-int
-read_config(FILE *fp)
-{
- char *buffer;
- char _buffer[1024];
- char *_av[16];
- char **av;
- int ac;
- int bootdrive = -1;
-
- while ((buffer = fgets(_buffer, sizeof(_buffer), fp)) != NULL) {
- char *comment = strchr(buffer, '#');
- char *equal;
-
- if (comment)
- *comment = 0;
-
- while (isspace(*buffer))
- ++buffer;
- if (!*buffer)
- continue;
-
- /*
- * Strip <CR><LF>
- */
- comment = buffer;
- while (*comment && *comment != '\n' && *comment != '\r')
- ++comment;
- *comment = 0;
-
- /*
- * Check to see if this is to go in the environment
- */
- equal = buffer;
- while (*equal && *equal != '=' && !isspace(*equal))
- ++equal;
-
- if (*equal == '=') {
- if (strncmp(buffer, "MS_VERSION=", 11) == 0)
- setver(0, strtol(equal + 1, 0, 0));
- else if (strncmp(buffer, "X11_FONT=", 9) == 0)
- xfont = strdup(equal + 1);
- else
- put_dosenv(buffer);
- continue;
- }
-
- ac = ParseBuffer(buffer, av = _av, 16);
-
- if (ac == 0)
- continue;
- if (!strcasecmp(av[0], "assign")) {
- int drive = -1;
- int printer;
- int ro = 0;
-
- if (ac < 2) {
- fprintf(stderr, "Usage: assign device ...\n");
- quit(1);
- }
- if (av[2] && !strcasecmp(av[2], "-ro")) {
- av[2] = av[1];
- av[1] = av[0];
- ++av;
- --ac;
- ro = 1;
- }
- if (!strncasecmp(av[1], "lpt", 3)) {
- if (av[1][3] < '1' || av[1][3] > '4'
- || av[1][4] != ':' || ac < 3) {
- fprintf(stderr, "Usage: assign lptn: [direct] lpr-name [ time-out]\n");
- quit(1);
- }
- printer = av[1][3] - '1';
- if (strchr(av[2], '/')) {
- printer_direct(printer);
- printer_spool(printer, av[2]);
- } else if (!strcasecmp(av[2], "direct")) {
- printer_direct(printer);
- printer_spool(printer, 0);
- } else {
- printer_spool(printer, av[2]);
- if (ac == 4)
- printer_timeout(printer, av[3]);
- }
- } else if (!strncasecmp(av[1], "flop", 4)) {
- if (ac != 4) {
- fprintf(stderr, "Usage: assign flop [-ro] file type\n");
- quit(1);
- }
-
- if (isdigit(av[1][4])) {
- drive = atoi(&av[1][4]) - 1;
- } else if (isalpha(av[1][4]) && av[1][5] == ':' && !av[1][6]) {
- drive = drlton(av[1][4]);
- }
-init_soft:
- drive = init_floppy(drive, atoi(av[3]), av[2]);
- if (ro)
- make_readonly(drive);
- } else if (!strncasecmp(av[1], "hard", 4)) {
- int cyl, head, sec;
-
- if (isdigit(av[1][4])) {
- drive = atoi(&av[1][4]) + 1;
- } else if (isalpha(av[1][4]) && av[1][5] == ':' && !av[1][6]) {
- drive = drlton(av[1][4]);
- }
-
-init_hard:
- switch (ac) {
- default:
- fprintf(stderr, "Usage: assign [A-Z]: [-ro] directory\n"
- " assign hard [-ro] file type [boot_sector]\n"
- " assign hard [-ro] file cylinders heads sectors/track [boot_sector]\n");
- quit(1);
- case 5:
- case 4:
- if (!map_type(atoi(av[3]), &cyl, &head, &sec)) {
- fprintf(stderr, "%s: invalid type\n", av[3]);
- quit(1);
- }
- drive = init_hdisk(drive, cyl, head, sec, av[2], av[4]);
- if (ro)
- make_readonly(drive);
- break;
- case 7:
- case 6:
- drive = init_hdisk(drive, atoi(av[3]), atoi(av[4]), atoi(av[5]),
- av[2], av[6]);
- if (ro)
- make_readonly(drive);
- break;
- }
- } else if (av[1][1] == ':') {
- if (av[1][2] || !isalpha(av[1][0])) {
- fprintf(stderr, "Usage: assign [A-Z]: ...\n");
- quit(1);
- }
- drive = drlton(av[1][0]);
-
- if (ac == 3) {
- init_path(drive, (u_char *)av[2], 0);
- if (ro)
- dos_makereadonly(drive);
- } else if (drive < 2)
- goto init_soft;
- else
- goto init_hard;
- } else if (!strncasecmp(av[1], "com", 3)) {
- int port;
- int addr;
- unsigned char irq;
-
- if ((ac != 5) || (!isdigit(av[1][3]))) {
- fprintf(stderr, "Usage: assign com[1-4] path addr irq\n");
- quit(1);
- }
- port = atoi(&av[1][3]) - 1;
- if ((port < 0) || (port > (N_COMS_MAX - 1))) {
- fprintf(stderr, "Usage: assign com[1-4] path addr irq\n");
- quit(1);
- }
- errno = 0;
- addr = (int)strtol(av[3], '\0', 0);
- /* XXX DEBUG ISA-specific */
- if ((errno != 0) || (addr > MAXPORT)) {
- fprintf(stderr, "Usage: assign com[1-4] path addr irq\n");
- quit(1);
- }
- errno = 0;
- irq = (unsigned char)strtol(av[4], '\0', 0);
- /* XXX DEBUG ISA-specific */
- if ((errno != 0) || (irq < 2) || (irq > 7)) {
- fprintf(stderr, "Usage: assign com[1-4] path addr irq[2-7]\n");
- quit(1);
- }
- init_com(port, av[2], addr, irq);
- } else {
- fprintf(stderr, "Usage: assign flop ...\n");
- fprintf(stderr, " assign hard ...\n");
- fprintf(stderr, " assign [A-Z]: ...\n");
- fprintf(stderr, " assign comX ...\n");
- quit(1);
- }
- } else if (!strcasecmp(av[0], "boot")) {
- if (ac != 2 || av[1][2] || !isalpha(av[1][0])) {
- fprintf(stderr, "Usage: boot [A: | C:]\n");
- quit(1);
- }
- bootdrive = drlton(av[1][0]);
- if (bootdrive != 0 && bootdrive != 2) {
- fprintf(stderr, "Boot drive must be either A: or C:\n");
- quit(1);
- }
- } else if (!strcasecmp(av[0], "portmap")) {
- int p, c;
- if (ac < 2 || ac > 3 || !isdigit(av[1][0]) ||
- (ac == 3 && !isdigit(av[2][0]))) {
- fprintf(stderr, "Usage: portmap port [count]\n");
- quit(1);
- }
- p = strtol(av[1], 0, 0);
- c = (ac == 3) ? strtol(av[2], 0, 0) : 1;
- iomap_port(p, c);
-
- while (c-- > 0) {
- define_input_port_handler(p++, inb_port);
- define_output_port_handler(p++, outb_port);
- }
- } else if (!strcasecmp(av[0], "setver")) {
- int v = 0;
- if (ac != 3 || !(v = strtol(av[2], 0, 0))) {
- fprintf(stderr, "Usage: setver command version\n");
- quit(1);
- }
- setver(av[1], v);
- } else {
- fprintf(stderr, "%s: invalid command\n", av[0]);
- quit(1);
- }
- }
- fclose(fp);
- return(bootdrive);
-}
+++ /dev/null
-$FreeBSD: src/usr.bin/doscmd/cp437-8x14.pcf.gz.uu,v 1.1.2.1 2002/04/25 11:04:50 tg Exp $
-$DragonFly: src/usr.bin/doscmd/cp437-8x14.pcf.gz.uu,v 1.2 2003/06/17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4J6:>2=2I9IY)U*EFGDA5O<2I9I]+M5+J=2K=3Z78JW4ZE
-MVZET.Y5NI](M3J=>)V[7)G[7)H[7)I[7)J[7)K[7)L[7)M[7)N[7)GH3;BQZ
-MZLCJR>K*ZLOJS.K-ZL[BST8<VD0:%Z(G/FW$J8UXM1&W-N+71AS;B&<;<6TC
-MOFTR&FBB)^YMQ+^-.+@1#S?BXD9\W(B3&_%R(VYNVC5R14\\W8BK&_%U(\YN
-MQ-N-N+L1?S?B\$8\WG3H4"!ZXO1&O-Z(VQOQ>R..;\3SC;B^$=\WXORF4\<6
-MT1/_-Q(`1B+`2`@8B0$C06`D"HR$@9$X,%TZ6(F>A(*16#`2#$:BP4@X&(D'
-M(P%A)"*,A(3)ZN@G>A(51L+"2%P8"0PCD6$D-(S$AI'@,!(=IEN'4QU/94"5
-M^(@D/B*)CTCB(Y+XB"0^(HF/2.(CDOB(C`[0HB?Q$4E\1!(?D<1')/$127Q$
-M$A^1CO<ZX$^,^**G8[X.^CKJZ["OX[X._!(?D<1')/$1970*$3V)CTCB(Y+X
-MB"0^(HF/2.(CDOB()#XBB8^H7><DT9/XB"0^(HF/2.(CDOB()#XBB8](XB.2
-6^(@Z=)+K`/[7_A\"WP<A_#T,0$(``)/X
-`
-end
+++ /dev/null
-/*
- * Copyright (c) 2001 The FreeBSD Project, 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.
- *
- * THIS SOFTWARE IS PROVIDED BY The FreeBSD Project, Inc. AND CONTRIBUTORS
- * ``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 The FreeBSD Project, Inc. OR
- * CONTRIBUTORS 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.
- *
- * $FreeBSD: src/usr.bin/doscmd/cpu.c,v 1.2.2.2 2002/05/21 11:49:47 tg Exp $
- * $DragonFly: src/usr.bin/doscmd/cpu.c,v 1.2 2003/06/17 04:29:25 dillon Exp $
- */
-
-#include "doscmd.h"
-#include "video.h"
-
-static u_int32_t decode_modrm(u_int8_t *, u_int16_t,
- regcontext_t *, int *);
-static u_int8_t *reg8(u_int8_t c, regcontext_t *);
-static u_int16_t *reg16(u_int8_t c, regcontext_t *);
-#if 0
-static u_int32_t *reg32(u_int8_t c, regcontext_t *);
-#endif
-static u_int8_t read_byte(u_int32_t);
-static void write_byte(u_int32_t, u_int8_t);
-static void write_word(u_int32_t, u_int16_t);
-
-/*
-** Hardware /0 interrupt
-*/
-void
-int00(regcontext_t *REGS __unused)
-{
- debug(D_ALWAYS, "Divide by 0 in DOS program!\n");
- exit(1);
-}
-
-void
-int01(regcontext_t *REGS __unused)
-{
- debug(D_ALWAYS, "INT 1 with no handler! (single-step/debug)\n");
-}
-
-void
-int03(regcontext_t *REGS __unused)
-{
- debug(D_ALWAYS, "INT 3 with no handler! (breakpoint)\n");
-}
-
-void
-int0d(regcontext_t *REGS __unused)
-{
- debug(D_ALWAYS, "IRQ5 with no handler!\n");
-}
-
-void
-cpu_init(void)
-{
- u_long vec;
-
- vec = insert_hardint_trampoline();
- ivec[0x00] = vec;
- register_callback(vec, int00, "int 00");
-
- vec = insert_softint_trampoline();
- ivec[0x01] = vec;
- register_callback(vec, int01, "int 01");
-
- vec = insert_softint_trampoline();
- ivec[0x03] = vec;
- register_callback(vec, int03, "int 03");
-
- vec = insert_hardint_trampoline();
- ivec[0x0d] = vec;
- register_callback(vec, int0d, "int 0d");
-
- vec = insert_null_trampoline();
- ivec[0x34] = vec; /* floating point emulator */
- ivec[0x35] = vec; /* floating point emulator */
- ivec[0x36] = vec; /* floating point emulator */
- ivec[0x37] = vec; /* floating point emulator */
- ivec[0x38] = vec; /* floating point emulator */
- ivec[0x39] = vec; /* floating point emulator */
- ivec[0x3a] = vec; /* floating point emulator */
- ivec[0x3b] = vec; /* floating point emulator */
- ivec[0x3c] = vec; /* floating point emulator */
- ivec[0x3d] = vec; /* floating point emulator */
- ivec[0x3e] = vec; /* floating point emulator */
- ivec[0x3f] = vec; /* floating point emulator */
-}
-
-/*
- * Emulate CPU instructions. We need this for VGA graphics, at least in the 16
- * color modes.
- *
- * The emulator is far from complete. We are adding the instructions as we
- * encounter them, so this function is likely to change over time. There are
- * no optimizations and we only emulate a single instruction at a time.
- *
- * As long as there is no support for DPMI or the Operand Size Override prefix
- * we won't need the 32-bit registers. This also means that the default
- * operand size is 16 bit.
- */
-int
-emu_instr(regcontext_t *REGS)
-{
- int prefix = 1;
- u_int8_t *cs = (u_int8_t *)(R_CS << 4);
- int ip = R_IP;
- int dir, i, instrlen;
- u_int8_t *r8;
- u_int8_t val8;
- u_int16_t val16;
- u_int16_t *seg = &R_DS;
- u_int32_t addr, toaddr;
-
- while (prefix) {
- prefix = 0;
- switch (cs[ip]) {
- case 0x08: /* or r/m8, r8 */
- addr = decode_modrm(cs + ip, *seg, REGS, &instrlen);
- r8 = reg8(cs[ip + 1], REGS);
- val8 = read_byte(addr) | *r8;
- write_byte(addr, val8);
- /* clear carry and overflow; check zero, sign, parity */
- R_EFLAGS &= ~PSL_C | ~PSL_V;
- if (val8 == 0)
- R_EFLAGS |= PSL_Z;
- if (val8 % 2 != 0)
- R_EFLAGS |= PSL_PF;
- if (val8 & 0x80)
- R_EFLAGS |= PSL_N;
- ip += 2 + instrlen;
- break;
- case 0x22: /* and r8, r/m8 */
- addr = decode_modrm(cs + ip, *seg, REGS, &instrlen);
- r8 = reg8(cs[ip + 1], REGS);
- *r8 &= read_byte(addr);
- /* clear carry and overflow; check zero, sign, parity */
- R_EFLAGS &= ~PSL_C | ~PSL_V;
- if (*r8 == 0)
- R_EFLAGS |= PSL_Z;
- if (*r8 % 2 != 0)
- R_EFLAGS |= PSL_PF;
- if (*r8 & 0x80)
- R_EFLAGS |= PSL_N;
- ip += 2 + instrlen;
- break;
- case 0x26: /* Segment Override ES */
- seg = &R_ES;
- prefix = 1;
- ip++;
- break;
- case 0x2e: /* Segment Override CS */
- seg = &R_CS;
- prefix = 1;
- ip++;
- break;
- case 0x36: /* Segment Override SS */
- seg = &R_SS;
- prefix = 1;
- ip++;
- break;
- case 0x3e: /* Segment Override DS */
- seg = &R_DS;
- prefix = 1;
- ip++;
- break;
- case 0x64: /* Segment Override FS */
- seg = &R_FS;
- prefix = 1;
- ip++;
- break;
- case 0x65: /* Segment Override GS */
- seg = &R_GS;
- prefix = 1;
- ip++;
- break;
- case 0x88: /* mov r/m8, r8 */
- addr = decode_modrm(cs + ip, *seg, REGS, &instrlen);
- write_byte(addr, *reg8(cs[ip + 1], REGS));
- ip += 2 + instrlen;
- break;
- case 0x8a: /* mov r8, r/m8 */
- addr = decode_modrm(cs + ip, *seg, REGS, &instrlen);
- r8 = reg8(cs[ip + 1], REGS);
- *r8 = read_byte(addr);
- ip += 2 + instrlen;
- break;
- case 0xc6: /* mov r/m8, imm8 */
- addr = decode_modrm(cs + ip, *seg, REGS, &instrlen);
- write_byte(addr, cs[ip + 2 + instrlen]);
- ip += 2 + instrlen + 1;
- break;
- case 0xc7: /* mov r/m32/16, imm32/16 */
- addr = decode_modrm(cs + ip, *seg, REGS, &instrlen);
- val16 = *(u_int16_t *)&cs[ip + 2 + instrlen];
- write_word(addr, val16);
- ip += 2 + instrlen + 2;
- break;
- case 0xa4: /* movs m8, m8 */
- write_byte(MAKEPTR(R_ES, R_DI), read_byte(MAKEPTR(*seg, R_SI)));
- dir = (R_EFLAGS & PSL_D) ? -1 : 1;
- R_DI += dir;
- R_SI += dir;
- ip++;
- break;
- case 0xaa: /* stos m8 */
- addr = MAKEPTR(R_ES, R_DI);
- write_byte(addr, R_AL);
- R_DI += (R_EFLAGS & PSL_D) ? -1 : 1;
- ip++;
- break;
- case 0xab: /* stos m32/16*/
- addr = MAKEPTR(R_ES, R_DI);
- write_word(addr, R_AX);
- R_DI += (R_EFLAGS & PSL_D) ? -2 : 2;
- ip++;
- break;
- case 0xf3: /* rep */
- switch (cs[++ip]) {
- case 0xa4: /* movs m8, m8 */
- /* XXX Possible optimization: if both source and target
- addresses lie within the video memory and write mode 1 is
- selected, we can use memcpy(). */
- dir = (R_EFLAGS & PSL_D) ? -1 : 1;
- addr = MAKEPTR(R_ES, R_DI);
- toaddr = MAKEPTR(*seg, R_SI);
- for (i = R_CX; i > 0; i--) {
- write_byte(addr, read_byte(toaddr));
- addr += dir;
- toaddr += dir;
- }
- PUTPTR(R_ES, R_DI, addr);
- PUTPTR(*seg, R_SI, toaddr);
- ip++;
- break;
- case 0xaa: /* stos m8 */
- /* direction */
- dir = (R_EFLAGS & PSL_D) ? -1 : 1;
- addr = MAKEPTR(R_ES, R_DI);
- for (i = R_CX; i > 0; i--) {
- write_byte(addr, R_AL);
- addr += dir;
- }
- PUTPTR(R_ES, R_DI, addr);
- ip++;
- break;
- case 0xab: /* stos m32/16 */
- /* direction */
- dir = (R_EFLAGS & PSL_D) ? -2 : 2;
- addr = MAKEPTR(R_ES, R_DI);
- for (i = R_CX; i > 0; i--) {
- write_word(addr, R_AX);
- addr += dir;
- }
- PUTPTR(R_ES, R_DI, addr);
- ip++;
- break;
- default:
- R_IP = --ip; /* Move IP back to the 'rep' instruction. */
- return -1;
- }
- R_CX = 0;
- break;
- default:
- /* Unknown instruction, get out of here and let trap.c:sigbus()
- catch it. */
- return -1;
- }
- R_IP = ip;
- }
-
- return 0;
-}
-
-/* Decode the ModR/M byte. Returns the memory address of the operand. 'c'
- points to the current instruction, 'seg' contains the value for the current
- base segment; this is usually 'DS', but may have been changed by a segment
- override prefix. We return the length of the current instruction in
- 'instrlen' so we can adjust 'IP' on return.
-
- XXX We will probably need a second function for 32-bit instructions.
-
- XXX We do not check for undefined combinations, like Mod=01, R/M=001. */
-static u_int32_t
-decode_modrm(u_int8_t *c, u_int16_t seg, regcontext_t *REGS, int *instrlen)
-{
- u_int32_t addr = 0; /* absolute address */
- int16_t dspl = 0; /* displacement, signed */
- *instrlen = 0;
-
- switch (c[1] & 0xc0) { /* decode Mod */
- case 0x00: /* DS:[reg] */
- /* 'reg' is selected in the R/M bits */
- break;
- case 0x40: /* 8 bit displacement */
- dspl = (int16_t)(int8_t)c[2];
- *instrlen = 1;
- break;
- case 0x80: /* 16 bit displacement */
- dspl = *(int16_t *)&c[2];
- *instrlen = 2;
- break;
- case 0xc0: /* reg in R/M */
- if (c[0] & 1) /* 16-bit reg */
- return *reg16(c[1], REGS);
- else /* 8-bit reg */
- return *reg8(c[1], REGS);
- break;
- }
-
- switch (c[1] & 0x07) { /* decode R/M */
- case 0x00:
- addr = MAKEPTR(seg, R_BX + R_SI);
- break;
- case 0x01:
- addr = MAKEPTR(seg, R_BX + R_DI);
- break;
- case 0x02:
- addr = MAKEPTR(seg, R_BP + R_SI);
- break;
- case 0x03:
- addr = MAKEPTR(seg, R_BP + R_DI);
- break;
- case 0x04:
- addr = MAKEPTR(seg, R_SI);
- break;
- case 0x05:
- addr = MAKEPTR(seg, R_DI);
- break;
- case 0x06:
- if ((c[1] & 0xc0) >= 0x40)
- addr += R_BP;
- else {
- addr = MAKEPTR(seg, *(int16_t *)&c[2]);
- *instrlen = 2;
- }
- break;
- case 0x07:
- addr = MAKEPTR(seg, R_BX + dspl);
- break;
- }
-
- return addr;
-}
-
-static u_int8_t *
-reg8(u_int8_t c, regcontext_t *REGS)
-{
- u_int8_t *r8[] = {&R_AL, &R_CL, &R_DL, &R_BL,
- &R_AH, &R_CH, &R_DH, &R_BH};
-
- /* select 'rrr' bits in ModR/M */
- return r8[(c & 0x38) >> 3];
-}
-
-static u_int16_t *
-reg16(u_int8_t c, regcontext_t *REGS)
-{
- u_int16_t *r16[] = {&R_AX, &R_CX, &R_DX, &R_BX,
- &R_SP, &R_BP, &R_SI, &R_DI};
-
- return r16[(c & 0x38) >> 3];
-}
-
-#if 0
-/* not yet */
-static u_int32_t *
-reg32(u_int8_t c, regcontext_t *REGS)
-{
- u_int32_t *r32[] = {&R_EAX, &R_ECX, &R_EDX, &R_EBX,
- &R_ESP, &R_EBP, &R_ESI, &R_EDI};
-
- return r32[(c & 0x38) >> 3];
-}
-#endif
-
-/* Read an 8-bit value from the location specified by 'addr'. If 'addr' lies
- within the video memory, we call 'video.c:vga_read()'. */
-static u_int8_t
-read_byte(u_int32_t addr)
-{
- if (addr >= 0xa0000 && addr < 0xb0000)
- return vga_read(addr);
- else
- return *(u_int8_t *)addr;
-}
-
-/* Write an 8-bit value to the location specified by 'addr'. If 'addr' lies
- within the video memory region, we call 'video.c:vga_write()'. */
-static void
-write_byte(u_int32_t addr, u_int8_t val)
-{
- if (addr >= 0xa0000 && addr < 0xb0000)
- vga_write(addr, val);
- else
- *(u_int8_t *)addr = val;
-
- return;
-}
-
-/* Write a 16-bit value to the location specified by 'addr'. If 'addr' lies
- within the video memory region, we call 'video.c:vga_write()'. */
-static void
-write_word(u_int32_t addr, u_int16_t val)
-{
- if (addr >= 0xa0000 && addr < 0xb0000) {
- vga_write(addr, (u_int8_t)(val & 0xff));
- vga_write(addr + 1, (u_int8_t)((val & 0xff00) >> 8));
- } else
- *(u_int16_t *)addr = val;
-
- return;
-}
+++ /dev/null
-/*
- * 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 crt0.c,v 2.2 1996/04/08 19:32:24 bostic Exp
- *
- * $FreeBSD: src/usr.bin/doscmd/crt0.c,v 1.2.2.1 2002/04/25 11:04:50 tg Exp $
- * $DragonFly: src/usr.bin/doscmd/crt0.c,v 1.2 2003/06/17 04:29:25 dillon Exp $
- */
-
-char **environ;
-char *__progname;
-
-start(int argc, char **argv, char **env)
-{
- environ = env;
- __progname = *argv;
- quit(main(argc, argv, environ));
-}
+++ /dev/null
-/*
- * 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 cwd.c,v 2.2 1996/04/08 19:32:25 bostic Exp
- *
- * $FreeBSD: src/usr.bin/doscmd/cwd.c,v 1.6.2.3 2002/04/25 11:04:50 tg Exp $
- */
-
-#include <sys/types.h>
-#include <sys/param.h>
-#include <sys/mount.h>
-#include <dirent.h>
-#include <errno.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <string.h>
-#include <ctype.h>
-#include <stdio.h>
-
-#include "doscmd.h"
-#include "cwd.h"
-
-/* Local functions */
-static inline int isvalid(unsigned);
-static inline int isdot(unsigned);
-static inline int isslash(unsigned);
-static void to_dos_fcb(u_char *, u_char *);
-
-#define D_REDIR 0x0080000 /* XXX - ack */
-#define D_TRAPS3 0x0200000
-
-typedef struct {
- u_char *path;
- u_char *cwd;
- int len;
- int maxlen;
- int read_only:1;
-} Path_t;
-
-typedef struct Name_t {
- u_char *real;
- struct Name_t *next;
- u_char name[9];
- u_char ext[4];
-} Name_t;
-
-
-#define MAX_DRIVE 26
-
-static Path_t paths[MAX_DRIVE];
-static Name_t *names;
-
-/*
- * Initialize the drive to be based at 'base' in the BSD filesystem
- */
-void
-init_path(int drive, const u_char *base, const u_char *dir)
-{
- Path_t *d;
-
- if (drive < 0 || drive >= MAX_DRIVE)
- return;
-
- debug(D_TRAPS3, "init_path(%d, %s, %s)\n", drive, base, dir);
-
- d = &paths[drive];
-
- if (d->path)
- free(d->path);
-
- if ((d->path = ustrdup(base)) == NULL)
- fatal("strdup in init_path for %c:%s: %s", drntol(drive), base,
- strerror(errno));
-
- if (d->maxlen < 2) {
- d->maxlen = 128;
- if ((d->cwd = (u_char *)malloc(d->maxlen)) == NULL)
- fatal("malloc in init_path for %c:%s: %s", drntol(drive), base,
- strerror(errno));
- }
-
- d->cwd[0] = '\\';
- d->cwd[1] = 0;
- d->len = 1;
- if (dir) {
- if (ustrncmp(base, dir, ustrlen(base)) == 0)
- dir += ustrlen(base);
- while (*dir == '/')
- ++dir;
-
- while (*dir) {
- u_char dosname[15];
- u_char realname[256];
- u_char *r = realname;
-
- while ((*r = *dir) && *dir++ != '/') {
- ++r;
- }
- *r = 0;
- while (*dir == '/')
- ++dir;
-
- dosname[0] = drntol(drive);
- dosname[1] = ':';
- real_to_dos(realname, &dosname[2]);
-
- if (dos_setcwd(dosname)) {
- fprintf(stderr, "Failed to CD to directory %s in %s\n",
- dosname, d->cwd);
- }
- }
- }
-}
-
-/*
- * Mark this drive as read only
- */
-void
-dos_makereadonly(int drive)
-{
-
- if (drive < 0 || drive >= MAX_DRIVE)
- return;
- paths[drive].read_only = 1;
-}
-
-/*
- * Return read-only status of drive
- */
-int
-dos_readonly(int drive)
-{
-
- if (drive < 0 || drive >= MAX_DRIVE)
- return (0);
- debug(D_REDIR, "dos_readonly(%d) -> %d\n", drive, paths[drive].read_only);
- return (paths[drive].read_only);
-}
-
-/*
- * Return DOS's idea of the CWD for drive
- * Return 0 if the drive specified is not mapped (or bad)
- */
-u_char *
-dos_getcwd(int drive)
-{
-
- if (drive < 0 || drive >= MAX_DRIVE)
- return (0);
- debug(D_REDIR, "dos_getcwd(%d) -> %s\n", drive, paths[drive].cwd);
- return (paths[drive].cwd);
-}
-
-/*
- * Return DOS's idea of the CWD for drive
- * Return 0 if the drive specified is not mapped (or bad)
- */
-u_char *
-dos_getpath(int drive)
-{
-
- if (drive < 0 || drive >= MAX_DRIVE)
- return (0);
- debug(D_REDIR, "dos_getpath(%d) -> %s\n", drive, paths[drive].path);
- return (paths[drive].path);
-}
-
-/*
- * Fix up a DOS path name. Strip out all '.' and '..' entries, turn
- * '/' into '\\' and convert all lowercase to uppercase.
- * Returns 0 on success or DOS errno
- */
-int
-dos_makepath(u_char *where, u_char *newpath)
-{
- int drive;
- u_char **dirs;
- u_char *np;
- Path_t *d;
- u_char tmppath[1024];
- u_char *snewpath = newpath;
-
- if (where[0] != '\0' && where[1] == ':') {
- drive = drlton(*where);
- *newpath++ = *where++;
- *newpath++ = *where++;
- } else {
- drive = diskdrive;
- *newpath++ = drntol(diskdrive);
- *newpath++ = ':';
- }
-
- if (drive < 0 || drive >= MAX_DRIVE) {
- debug(D_REDIR,"drive %c invalid\n", drntol(drive));
- return (DISK_DRIVE_INVALID);
- }
-
- d = &paths[drive];
- if (d->cwd == NULL) {
- debug(D_REDIR,"no cwd for drive %c\n",drntol(drive));
- return (DISK_DRIVE_INVALID);
- }
-
- debug(D_REDIR, "dos_makepath(%d, %s)\n", drive, where);
-
- np = newpath;
- if (*where != '\\' && *where != '/') {
- ustrncpy(tmppath, d->cwd, 1024);
- if (d->cwd[1])
- ustrncat(tmppath, "/", 1024 - ustrlen(tmppath));
- ustrncat(tmppath, where, 1024 - ustrlen(tmppath));
- } else {
- ustrncpy(tmppath, where, 1024 - ustrlen(tmppath));
- }
-
- dirs = get_entries(tmppath);
- if (dirs == NULL)
- return (PATH_NOT_FOUND);
-
- np = newpath;
- while (*dirs) {
- u_char *dir = *dirs++;
- if (*dir == '/' || *dir == '\\') {
- np = newpath + 1;
- newpath[0] = '\\';
- } else if (dir[0] == '.' && dir[1] == 0) {
- ;
- } else if (dir[0] == '.' && dir[1] == '.' && dir[2] == '\0') {
- while (np[-1] != '/' && np[-1] != '\\')
- --np;
- if (np - 1 > newpath)
- --np;
- } else {
- if (np[-1] != '\\')
- *np++ = '\\';
- while ((*np = *dir++) && np - snewpath < 1023)
- ++np;
- }
- }
- *np = 0;
-
- return (0);
-}
-
-/*
- * Set DOS's idea of the CWD for drive to be where.
- * Returns DOS errno on failuer.
- */
-int
-dos_setcwd(u_char *where)
-{
- u_char new_path[1024];
- u_char real_path[1024];
- int drive;
- struct stat sb;
- Path_t *d;
- int error;
-
- debug(D_REDIR, "dos_setcwd(%s)\n", where);
-
- error = dos_makepath(where, new_path);
- if (error)
- return (error);
-
- error = dos_to_real_path(new_path, real_path, &drive);
- if (error)
- return (error);
-
- if (ustat(real_path, &sb) < 0 || !S_ISDIR(sb.st_mode))
- return (PATH_NOT_FOUND);
- if (uaccess(real_path, R_OK | X_OK))
- return (PATH_NOT_FOUND);
-
- d = &paths[drive];
- d->len = ustrlen(new_path + 2);
-
- if (d->len + 1 > d->maxlen) {
- free(d->cwd);
- d->maxlen = d->len + 1 + 32;
- d->cwd = (u_char *)malloc(d->maxlen);
- if (d->cwd == NULL)
- fatal("malloc in dos_setcwd for %c:%s: %s", drntol(drive),
- new_path, strerror(errno));
- }
- ustrncpy(d->cwd, new_path + 2, d->maxlen - d->len);
- return (0);
-}
-
-/*
- * Given a DOS path dos_path and a drive, convert it to a BSD pathname
- * and store the result in real_path.
- * Return DOS errno on failure.
- */
-int
-dos_to_real_path(u_char *dos_path, u_char *real_path, int *drivep)
-{
- Path_t *d;
- u_char new_path[1024];
- u_char *rp;
- u_char **dirs;
- u_char *dir;
- int drive;
-
- debug(D_REDIR, "dos_to_real_path(%s)\n", dos_path);
-
- if (dos_path[0] != '\0' && dos_path[1] == ':') {
- drive = drlton(*dos_path);
- dos_path++;
- dos_path++;
- } else {
- drive = diskdrive;
- }
-
- d = &paths[drive];
- if (d->cwd == NULL)
- return (DISK_DRIVE_INVALID);
-
- ustrcpy(real_path, d->path);
-
- rp = real_path;
- while (*rp)
- ++rp;
-
- ustrncpy(new_path, dos_path, 1024 - ustrlen(new_path));
-
- dirs = get_entries(new_path);
- if (dirs == NULL)
- return (PATH_NOT_FOUND);
-
- /*
- * Skip the leading /
- * There are no . or .. entries to worry about either
- */
-
- while ((dir = *++dirs) != NULL) {
- *rp++ = '/';
- dos_to_real(dir, rp);
- while (*rp)
- ++rp;
- }
-
- *drivep = drive;
- return (0);
-}
-
-/*
- * Provide a few istype() style functions.
- * isvalid: True if the character is a valid DOS filename character
- * isdot: True if '.'
- * isslash: True if '/' or '\'
- *
- * 0 - invalid
- * 1 - okay
- * 2 - *
- * 3 - dot
- * 4 - slash
- * 5 - colon
- * 6 - ?
- * 7 - lowercase
- */
-u_char cattr[256] = {
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x00 */
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x10 */
- 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 2, 0, 0, 1, 3, 4, /* 0x20 */
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 5, 0, 0, 0, 0, 6, /* 0x30 */
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0x40 */
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 4, 0, 1, 1, /* 0x50 */
- 1, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, /* 0x60 */
- 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 1, 0, 1, 1, 0, /* 0x70 */
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0x80 */
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
-};
-
-static inline int
-isvalid(unsigned c)
-{
- return (cattr[c & 0xff] == 1);
-}
-
-static inline int
-isdot(unsigned c)
-{
- return (cattr[c & 0xff] == 3);
-}
-
-static inline int
-isslash(unsigned c)
-{
- return (cattr[c & 0xff] == 4);
-}
-
-/*
- * Given a real component, compute the DOS component.
- */
-void
-real_to_dos(u_char *real, u_char *dos)
-{
- Name_t *n;
- Name_t *nn;
- u_char *p;
- u_char nm[9], ex[4];
- int ncnt, ecnt;
- int echar = '0';
- int nchar = '0';
-
- if (real[0] == '.' && (real[1] == '\0'
- || (real[1] == '.' && real[2] == '\0'))) {
- sprintf((char *)dos, "%.8s", real);
- return;
- }
-
- n = names;
- while (n) {
- if (ustrcmp(real, n->real) == 0) {
- if (n->ext[0])
- sprintf((char *)dos, "%.8s.%.3s", n->name, n->ext);
- else
- sprintf((char *)dos, "%.8s", n->name);
- return;
- }
- n = n->next;
- }
-
- p = real;
- ncnt = ecnt = 0;
- while (isvalid(*p) && ncnt < 8) {
- nm[ncnt] = *p;
- ++ncnt;
- ++p;
- }
- if (isdot(*p)) {
- ++p;
- while (isvalid(*p) && ecnt < 3) {
- ex[ecnt] = *p;
- ++ecnt;
- ++p;
- }
- }
- nm[ncnt] = '\0';
- ex[ecnt] = '\0';
-
- if (!*p && ncnt <= 8 && ecnt <= 3) {
- n = names;
- while (n) {
- if (ustrncmp(n->name, nm, 8) == 0 && ustrncmp(n->ext, ex, 3) == 0) {
- break;
- }
- n = n->next;
- }
- if (n == NULL) {
- ustrcpy(dos, real);
- return;
- }
- }
-
- n = (Name_t *)malloc(sizeof(Name_t));
-
- if (!n)
- fatal("malloc in real_to_dos: %s\n", strerror(errno));
-
- n->real = ustrdup(real);
-
- if (!n->real)
- fatal("strdup in real_to_dos: %s\n", strerror(errno));
-
- p = real;
- ncnt = ecnt = 0;
- while (*p && ncnt < 8) {
- if (isvalid(*p))
- n->name[ncnt] = *p;
- else if (islower(*p))
- n->name[ncnt] = toupper(*p);
- else if (isdot(*p))
- break;
- else
- n->name[ncnt] = (*p |= 0x80);
- ++ncnt;
- ++p;
- }
- if (isdot(*p)) {
- ++p;
- while (*p && ecnt < 3) {
- if (isvalid(*p))
- n->ext[ecnt] = *p;
- else if (islower(*p))
- n->ext[ecnt] = toupper(*p);
-#if 0
- else if (isdot(*p))
- ERROR
-#endif
- else
- n->ext[ecnt] = (*p |= 0x80);
- ++ecnt;
- ++p;
- }
- }
- n->name[ncnt] = '\0';
- n->ext[ecnt] = '\0';
-
- for (;;) {
- nn = names;
- while (nn) {
- if (ustrncmp(n->name, nn->name, 8) == 0 &&
- ustrncmp(n->ext, nn->ext, 3) == 0) {
- break;
- }
- nn = nn->next;
- }
- if (!nn)
- break;
- /*
- * Dang, this name was already in the cache.
- * Let's munge it a little and try again.
- */
- if (ecnt < 3) {
- n->ext[ecnt] = echar;
- if (echar == '9') {
- echar = 'A';
- } else if (echar == 'Z') {
- ++ecnt;
- echar = '0';
- } else {
- ++echar;
- }
- } else if (ncnt < 8) {
- n->name[ncnt] = nchar;
- if (nchar == '9') {
- nchar = 'A';
- } else if (nchar == 'Z') {
- ++ncnt;
- nchar = '0';
- } else {
- ++nchar;
- }
- } else if (n->ext[2] < 'Z')
- n->ext[2]++;
- else if (n->ext[1] < 'Z')
- n->ext[1]++;
- else if (n->ext[0] < 'Z')
- n->ext[0]++;
- else if (n->name[7] < 'Z')
- n->name[7]++;
- else if (n->name[6] < 'Z')
- n->name[6]++;
- else if (n->name[5] < 'Z')
- n->name[5]++;
- else if (n->name[4] < 'Z')
- n->name[4]++;
- else if (n->name[3] < 'Z')
- n->name[3]++;
- else if (n->name[2] < 'Z')
- n->name[2]++;
- else if (n->name[1] < 'Z')
- n->name[1]++;
- else if (n->name[0] < 'Z')
- n->name[0]++;
- else
- break;
- }
-
- if (n->ext[0])
- sprintf((char *)dos, "%.8s.%.3s", n->name, n->ext);
- else
- sprintf((char *)dos, "%.8s", n->name);
- n->next = names;
- names = n;
-}
-
-
-/*
- * Given a DOS component, compute the REAL component.
- */
-void
-dos_to_real(u_char *dos, u_char *real)
-{
- int ncnt = 0;
- int ecnt = 0;
- u_char name[8];
- u_char ext[3];
- Name_t *n = names;
-
- while (ncnt < 8 && (isvalid(*dos) || islower(*dos))) {
- name[ncnt++] = islower(*dos) ? toupper(*dos) : *dos;
- ++dos;
- }
- if (ncnt < 8)
- name[ncnt] = 0;
-
- if (isdot(*dos)) {
- while (ecnt < 3 && (isvalid(*++dos) || islower(*dos))) {
- ext[ecnt++] = islower(*dos) ? toupper(*dos) : *dos;
- }
- }
- if (ecnt < 3)
- ext[ecnt] = 0;
-
- while (n) {
- if (!ustrncmp(name, n->name, 8) && !ustrncmp(ext, n->ext, 3)) {
- ustrcpy(real, n->real);
- return;
- }
- n = n->next;
- }
-
- if (ext[0])
- sprintf((char *)real, "%-.8s.%-.3s", name, ext);
- else
- sprintf((char *)real, "%-.8s", name);
-
- while (*real) {
- if (isupper(*real))
- *real = tolower(*real);
- ++real;
- }
-}
-
-/*
- * convert a path into an argv[] like vector of components.
- * If the path starts with a '/' or '\' then the first entry
- * will be "/" or "\". This is the only case in which a "/"
- * or "\" may appear in an entry.
- * Also convert all lowercase to uppercase.
- * The data returned is in a static area, so a second call will
- * erase the data of the first.
- */
-u_char **
-get_entries(u_char *path)
-{
- static u_char *entries[128]; /* Maximum depth... */
- static u_char mypath[1024];
- u_char **e = entries;
- u_char *p = mypath;
-
- ustrncpy(mypath+1, path, 1022);
- p = mypath+1;
- mypath[1023] = 0;
- if (path[0] == '/' || path[0] == '\\') {
- mypath[0] = path[0];
- *e++ = mypath;
- *p++ = 0;
- }
- while (*p && e < entries + 127) {
- while (*p && (*p == '/' || *p == '\\')) {
- ++p;
- }
-
- if (!*p)
- break;
- *e++ = p;
- while (*p && (*p != '/' && *p != '\\')) {
- if (islower(*p))
- *p = tolower(*p);
- ++p;
- }
- /*
- * skip over the '/' or '\'
- */
- if (*p)
- *p++ = 0;
- }
- *e = NULL;
- return (entries);
-}
-
-/*
- * Return file system statistics for drive.
- * Return the DOS errno on failure.
- */
-int
-get_space(int drive, fsstat_t *fs)
-{
- Path_t *d;
- struct statfs *buf;
- int nfs;
- int i;
- struct statfs *me = NULL;
-
- if (drive < 0 || drive >= MAX_DRIVE)
- return (DISK_DRIVE_INVALID);
-
- d = &paths[drive];
-
- if (!d->path)
- return (DISK_DRIVE_INVALID);
-
- nfs = getfsstat(0, 0, MNT_WAIT);
-
- buf = (struct statfs *)malloc(sizeof(struct statfs) * nfs);
- if (buf == NULL) {
- perror("get_space");
- return (DISK_DRIVE_INVALID);
- }
- nfs = getfsstat(buf, sizeof(struct statfs) * nfs, MNT_WAIT);
-
- for (i = 0; i < nfs; ++i) {
- if (strncmp(buf[i].f_mntonname, (char *)d->path, strlen(buf[i].f_mntonname)))
- continue;
- if (me && strlen(me->f_mntonname) > strlen(buf[i].f_mntonname))
- continue;
- me = buf + i;
- }
- if (!me) {
- free(buf);
- return (3);
- }
- fs->bytes_sector = 512;
- fs->sectors_cluster = me->f_bsize / fs->bytes_sector;
- fs->total_clusters = me->f_blocks / fs->sectors_cluster;
- while (fs->total_clusters > 0xFFFF) {
- fs->sectors_cluster *= 2;
- fs->total_clusters = me->f_blocks / fs->sectors_cluster;
- }
- fs->avail_clusters = me->f_bavail / fs->sectors_cluster;
- free(buf);
- return (0);
-}
-
-#if 0
-DIR *dp = 0;
-u_char searchdir[1024];
-u_char *searchend;
-#endif
-
-/*
- * Convert a dos filename into normal form (8.3 format, space padded)
- */
-static void
-to_dos_fcb(u_char *p, u_char *expr)
-{
- int i;
-
- if (expr[0] == '.') {
- p[0] = '.';
- if (expr[1] == '\0') {
- for (i = 1; i < 11; i++)
- p[i] = ' ';
- return;
- }
- if (expr[1] == '.') {
- p[1] = '.';
- if (expr[2] == '\0') {
- for (i = 2; i < 11; i++)
- p[i] = ' ';
- return;
- }
- }
- }
-
- for (i = 8; i > 0; i--) {
- switch (*expr) {
- case '\0':
- case '.':
- for (; i > 0; i--)
- *p++ = ' ';
- break;
- case '*':
- for (; i > 0; i--)
- *p++ = '?';
- break;
- default:
- if (islower(*expr)) {
- *p++ = toupper(*expr++);
- break;
- }
- case '?':
- *p++ = *expr++;
- break;
- }
- }
-
- while (*expr != '\0' && *expr != '.')
- ++expr;
- if (*expr)
- ++expr;
-
- for (i = 3; i > 0; i--) {
- switch (*expr) {
- case '\0':
- case '.':
- for (; i > 0; i--)
- *p++ = ' ';
- break;
- case '*':
- for (; i > 0; i--)
- *p++ = '?';
- break;
- default:
- if (islower(*expr)) {
- *p++ = toupper(*expr++);
- break;
- }
- case '?':
- *p++ = *expr++;
- break;
- }
- }
-}
-
-/*
-** DOS can't handle multiple concurrent searches, and if we leave the
-** search instance in the DTA we get screwed as soon as someone starts lots
-** of searches without finishing them properly.
-** We allocate a single search structure, and recycle it if find_first()
-** is called before a search ends.
-*/
-static search_t dir_search;
-
-/*
- * Find the first file on drive which matches the path with the given
- * attributes attr.
- * If found, the result is placed in dir (32 bytes).
- * The DTA is populated as required by DOS, but the state area is ignored.
- * Returns DOS errno on failure.
- */
-int
-find_first(u_char *path, int attr, dosdir_t *dir, find_block_t *dta)
-{
- u_char new_path[1024], real_path[1024];
- u_char *expr, *slash;
- int drive;
- int error;
- search_t *search = &dir_search;
-
- debug(D_REDIR, "find_first(%s, %x, %x)\n", path, attr, (int)dta);
-
- error = dos_makepath(path, new_path);
- if (error)
- return (error);
-
- expr = new_path;
- slash = NULL;
- while (*expr != '\0') {
- if (*expr == '\\' || *expr == '/')
- slash = expr;
- expr++;
- }
- *slash++ = '\0';
-
- error = dos_to_real_path(new_path, real_path, &drive);
- if (error)
- return (error);
-
- if (attr == VOLUME_LABEL) /* never find a volume label */
- return (NO_MORE_FILES);
-
- if (search->dp) /* stale search? */
- closedir(search->dp);
-
- search->dp = opendir(real_path);
- if (search->dp == NULL)
- return (PATH_NOT_FOUND);
-
- ustrncpy(search->searchdir, real_path, 1024 - ustrlen(real_path));
- search->searchend = search->searchdir;
- while (*search->searchend)
- ++search->searchend;
- *search->searchend++ = '/';
-
- search->dp->dd_fd = squirrel_fd(search->dp->dd_fd);
-
- dta->drive = drive | 0x80;
- to_dos_fcb(dta->pattern, slash);
- dta->flag = attr;
-
- return (find_next(dir, dta));
-}
-
-/*
- * Continue on where find_first left off.
- * The results will be placed in dir.
- * DTA state area is ignored.
- */
-int
-find_next(dosdir_t *dir, find_block_t *dta)
-{
- search_t *search = &dir_search;
- struct dirent *d;
- struct stat sb;
- u_char name[16];
-
- if (!search->dp)
- return (NO_MORE_FILES);
-
-#if 0
- debug(D_REDIR, "find_next()\n");
-#endif
-
- while ((d = readdir(search->dp)) != NULL) {
- real_to_dos((u_char *)d->d_name, name);
- to_dos_fcb(dir->name, name);
-#if 0
-printf("find_next: |%-11.11s| |%-11.11s| |%s| |%s|\n", dta->pattern, dir->name, d->d_name, name);
-#endif
- if (dos_match(dta->pattern, dir->name) == 0)
- continue;
-
- ustrcpy(search->searchend, (u_char *)d->d_name);
- if (ustat(search->searchdir, &sb) < 0)
- continue;
-#if 0
-printf("find_next: %x\n", sb.st_mode);
-#endif
- if (S_ISDIR(sb.st_mode)) {
- if (!(dta->flag & DIRECTORY)) {
- continue;
- }
- }
- dir->attr = (S_ISDIR(sb.st_mode) ? DIRECTORY : 0) |
- (uaccess(search->searchdir, W_OK) < 0 ? READ_ONLY_FILE : 0);
- encode_dos_file_time(sb.st_mtime, &dir->date, &dir->time);
- dir->start = 1;
- dir->size = sb.st_size;
-#if 0
-printf("find_next: found %s\n",name);
-#endif
- return (0);
- }
- closedir(search->dp);
- search->dp = NULL;
- return (NO_MORE_FILES);
-}
-
-/*
- * perfrom hokey DOS pattern matching. pattern may contain the wild cards
- * '*' and '?' only. Follow the DOS convention that '?*', '*?' and '**' all
- * are the same as '*'. Also, allow '?' to match the blank padding in a
- * name (hence, ???? matchs all of "a", "ab", "abc" and "abcd" but not "abcde")
- * Return 1 if a match is found, 0 if not.
- *
- * XXX This appears to be severely busted! (no * handling - normal?)
- */
-int
-dos_match(u_char *pattern, u_char *string)
-{
- int i;
-
- /*
- * Check the base part first
- */
- for (i = 11; i > 0; i--) {
- if (*pattern != '?' && *string != *pattern)
- return (0);
- pattern++, string++;
- }
- return (1);
-}
+++ /dev/null
-/*
- * 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 cwd.h,v 2.2 1996/04/08 19:32:26 bostic Exp
- *
- * $FreeBSD: src/usr.bin/doscmd/cwd.h,v 1.2.2.2 2002/04/25 11:04:50 tg Exp $
- * $DragonFly: src/usr.bin/doscmd/cwd.h,v 1.2 2003/06/17 04:29:25 dillon Exp $
- */
-
-static inline u_char *
-ustrcpy(u_char *s1, u_char *s2)
-{
- return((u_char *)strcpy((char *)s1, (char *)s2));
-}
-
-static inline u_char *
-ustrcat(u_char *s1, u_char *s2)
-{
- return((u_char *)strcat((char *)s1, (char *)s2));
-}
-
-static inline u_char *
-ustrncat(u_char *s1, const u_char *s2, size_t n)
-{
- return((u_char *)strncat((char *)s1, (const char *)s2, n));
-}
-
-static inline u_char *
-ustrncpy(u_char *s1, u_char *s2, size_t n)
-{
- return((u_char *)strncpy((char *)s1, (char *)s2, n));
-}
-
-static inline int
-ustrcmp(u_char *s1, u_char *s2)
-{
- return(strcmp((char *)s1, (char *)s2));
-}
-
-static inline int
-ustrncmp(const u_char *s1, const u_char *s2, size_t n)
-{
- return(strncmp((const char *)s1, (const char *)s2, n));
-}
-
-static inline int
-ustrlen(const u_char *s)
-{
- return(strlen((const char *)s));
-}
-
-static inline u_char *
-ustrrchr(u_char *s, u_char c)
-{
- return((u_char *)strrchr((char *)s, c));
-}
-
-static inline u_char *
-ustrdup(const u_char *s)
-{
- return((u_char *)strdup((const char *)s));
-}
-
-static inline int
-ustat(u_char *s, struct stat *sb)
-{
- return(stat((char *)s, sb));
-}
-
-static inline int
-uaccess(u_char *s, int mode)
-{
- return(access((char *)s, mode));
-}
-
-extern void init_path(int, const u_char *, const u_char *);
-extern void dos_makereadonly(int);
-extern int dos_readonly(int);
-extern u_char *dos_getcwd(int);
-extern u_char *dos_getpath(int);
-extern int dos_makepath(u_char *, u_char *);
-extern int dos_match(u_char *, u_char *);
-extern int dos_setcwd(u_char *);
-extern int dos_to_real_path(u_char *, u_char *, int *);
-extern void real_to_dos(u_char *, u_char *);
-extern void dos_to_real(u_char *, u_char *);
-extern u_char **get_entries(u_char *);
-extern int get_space(int, fsstat_t *);
-extern int find_first(u_char *, int, dosdir_t *, find_block_t *);
-extern int find_next(dosdir_t *, find_block_t *);
+++ /dev/null
-/*
- * Copyright (c) 1996
- * Michael Smith, All rights reserved.
- * 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.
- *
- * from: BSDI doscmd.c,v 2.3 1996/04/08 19:32:30 bostic Exp
- *
- * $FreeBSD: src/usr.bin/doscmd/debug.c,v 1.3.2.2 2002/04/25 11:04:50 tg Exp $
- * $DragonFly: src/usr.bin/doscmd/debug.c,v 1.2 2003/06/17 04:29:25 dillon Exp $
- */
-
-#include <stdarg.h>
-
-#include "doscmd.h"
-#include "tty.h"
-
-/* debug output goes here */
-FILE *debugf;
-
-/* see doscmd.h for flag names */
-int debug_flags = D_ALWAYS;
-
-/* include register dumps when reporting unknown interrupts */
-int vflag = 0;
-
-/* interrupts to trace */
-#define BPW (sizeof(u_long) << 3)
-u_long debug_ints[256/BPW];
-
-/* Debug flag manipulation */
-void
-debug_set(int x)
-{
- x &= 0xff;
- debug_ints[x/BPW] |= 1 << (x & (BPW - 1));
-}
-
-void
-debug_unset(int x)
-{
- x &= 0xff;
- debug_ints[x/BPW] &= ~(1 << (x & (BPW - 1)));
-}
-
-u_long
-debug_isset(int x)
-{
- x &= 0xff;
- return(debug_ints[x/BPW] & (1 << (x & (BPW - 1))));
-}
-
-
-/*
-** Emit a debugging message if (flags) matches the current
-** debugging mode.
-*/
-void
-debug(int flags, const char *fmt, ...)
-{
- va_list args;
-
- if (flags & (debug_flags & ~0xff)) {
- if ((debug_flags & 0xff) == 0
- && (flags & (D_ITRAPS | D_TRAPS))
- && !debug_isset(flags & 0xff))
- return;
- va_start (args, fmt);
- vfprintf (debugf, fmt, args);
- va_end (args);
- }
-}
-
-/*
-** Emit a terminal error message and exit
-*/
-void
-fatal(const char *fmt, ...)
-{
- va_list args;
-
- dead = 1;
-
- if (xmode) {
- char buf[1024];
- const char *m;
-
- va_start (args, fmt);
- vfprintf (debugf, fmt, args);
- vsprintf (buf, fmt, args);
- va_end (args);
-
- tty_move(23, 0);
- for (m = buf; *m; ++m)
- tty_write(*m, 0x0400);
-
- tty_move(24, 0);
- for (m = "(PRESS <CTRL-ALT> ANY MOUSE BUTTON TO exit)"; *m; ++m)
- tty_write(*m, 0x0900);
- tty_move(-1, -1);
- for (;;)
- tty_pause();
- }
-
- va_start (args, fmt);
- fprintf (debugf, "doscmd: fatal error ");
- vfprintf (debugf, fmt, args);
- va_end (args);
- quit (1);
-}
-
-/*
-** Emit a register dump (usually when dying)
-*/
-void
-dump_regs(regcontext_t *REGS)
-{
- u_char *addr;
- int i;
- char buf[100];
-
- debug (D_ALWAYS, "\n");
- debug (D_ALWAYS, "ax=%04x bx=%04x cx=%04x dx=%04x\n", R_AX, R_BX, R_CX, R_DX);
- debug (D_ALWAYS, "si=%04x di=%04x sp=%04x bp=%04x\n", R_SI, R_DI, R_SP, R_BP);
- debug (D_ALWAYS, "cs=%04x ss=%04x ds=%04x es=%04x\n", R_CS, R_SS, R_DS, R_ES);
- debug (D_ALWAYS, "ip=%x eflags=%lx\n", R_IP, R_EFLAGS);
-
- addr = (u_char *)MAKEPTR(R_CS, R_IP);
-
- for (i = 0; i < 16; i++)
- debug (D_ALWAYS, "%02x ", addr[i]);
- debug (D_ALWAYS, "\n");
-
- addr = (char *)MAKEPTR(R_CS, R_IP);
- i386dis(R_CS, R_IP, addr, buf, 0);
-
- debug (D_ALWAYS, "%s\n", buf);
-}
-
-/*
-** Unknown interrupt error messages
-*/
-void
-unknown_int2(int maj, int min, regcontext_t *REGS)
-{
- if (vflag) dump_regs(REGS);
- printf("Unknown interrupt %02x function %02x\n", maj, min);
- R_FLAGS |= PSL_C;
-}
-
-void
-unknown_int3(int maj, int min, int sub, regcontext_t *REGS)
-{
- if (vflag) dump_regs(REGS);
- printf("Unknown interrupt %02x function %02x subfunction %02x\n",
- maj, min, sub);
- R_FLAGS |= PSL_C;
-}
-
-void
-unknown_int4(int maj, int min, int sub, int ss, regcontext_t *REGS)
-{
- if (vflag) dump_regs(REGS);
- printf("Unknown interrupt %02x function %02x subfunction %02x %02x\n",
- maj, min, sub, ss);
- R_FLAGS |= PSL_C;
-}
-
+++ /dev/null
-/*
- * 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 disktab.c,v 2.2 1996/04/08 19:32:27 bostic Exp
- *
- * $FreeBSD: src/usr.bin/doscmd/disktab.c,v 1.1.6.1 2002/04/25 11:04:50 tg Exp $
- * $DragonFly: src/usr.bin/doscmd/disktab.c,v 1.2 2003/06/17 04:29:25 dillon Exp $
- */
-
-/* XXX goaway (requires change to config.c) */
-
-#include "doscmd.h"
-
-static struct {
- int cylinders;
- int heads;
- int sectors;
-} disk_table[] = {
- { 306, 4, 17 }, /* type 01 10M */
- { 615, 4, 17 }, /* type 02 20M */
- { 615, 6, 17 }, /* type 03 30M */
- { 940, 8, 17 }, /* type 04 62M */
- { 940, 6, 17 }, /* type 05 46M */
- { 615, 4, 17 }, /* type 06 20M */
- { 462, 8, 17 }, /* type 07 30M */
- { 733, 5, 17 }, /* type 08 30M */
- { 900, 15, 17 }, /* type 09 112M */
- { 820, 3, 17 }, /* type 10 20M */
- { 855, 5, 17 }, /* type 11 35M */
- { 855, 7, 17 }, /* type 12 49M */
- { 306, 8, 17 }, /* type 13 20M */
- { 733, 7, 17 }, /* type 14 42M */
- { 976, 15, 17 }, /* type 15 121M */
- { 612, 4, 17 }, /* type 16 20M */
- { 977, 5, 17 }, /* type 17 40M */
- { 977, 7, 17 }, /* type 18 56M */
- { 1024, 7, 17 }, /* type 19 59M */
- { 733, 5, 17 }, /* type 20 30M */
- { 733, 7, 17 }, /* type 21 42M */
- { 733, 5, 17 }, /* type 22 30M */
- { 306, 4, 17 }, /* type 23 10M */
- { 925, 7, 17 }, /* type 24 53M */
- { 925, 9, 17 }, /* type 25 69M */
- { 754, 7, 17 }, /* type 26 43M */
- { 754, 11, 17 }, /* type 27 68M */
- { 699, 7, 17 }, /* type 28 40M */
- { 823, 10, 17 }, /* type 29 68M */
- { 918, 7, 17 }, /* type 30 53M */
- { 1024, 11, 17 }, /* type 31 93M */
- { 1024, 15, 17 }, /* type 32 127M */
- { 1024, 5, 17 }, /* type 33 42M */
- { 612, 2, 17 }, /* type 34 10M */
- { 1024, 9, 17 }, /* type 35 76M */
- { 1024, 8, 17 }, /* type 36 68M */
- { 615, 8, 17 }, /* type 37 40M */
- { 987, 3, 17 }, /* type 38 24M */
- { 987, 7, 17 }, /* type 39 57M */
- { 820, 6, 17 }, /* type 40 40M */
- { 977, 5, 17 }, /* type 41 40M */
- { 981, 5, 17 }, /* type 42 40M */
- { 830, 7, 17 }, /* type 43 48M */
- { 830, 10, 17 }, /* type 44 68M */
- { 917, 15, 17 }, /* type 45 114M */
- { 1224, 15, 17 }, /* type 46 152M */
-};
-
-static int ntypes = sizeof(disk_table)/sizeof(disk_table[0]);
-
-int
-map_type(int type, int *cyl, int *head, int *sec)
-{
- --type;
- if (type < 0 || type >= ntypes)
- return(0);
- *cyl = disk_table[type].cylinders;
- *head = disk_table[type].heads;
- *sec = disk_table[type].sectors;
- return(1);
-}
+++ /dev/null
-/*
-** Copyright (c) 1996
-** Michael Smith. 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.
-**
-** THIS SOFTWARE IS PROVIDED BY Michael Smith ``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 Michael Smith 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.
-**
-** $FreeBSD: src/usr.bin/doscmd/dispatch.h,v 1.2.2.1 2001/08/02 02:17:15 obrien Exp $
-** $DragonFly: src/usr.bin/doscmd/dispatch.h,v 1.2 2003/06/17 04:29:25 dillon Exp $
-*/
-
-/*
-** Interrupt dispatcher assistants.
-*/
-
-
-/*
-** Declare a static, initialised array of these, with one
-** entry per function/subfunction.
-**
-** The last element should be a dummy with a 'func' of -1
-*/
-struct intfunc_table
-{
- int func; /* interrupt function number */
- int subfunc; /* subfunction number */
- int (* handler)(regcontext_t *REGS);/* handling function */
- const char *desc; /* textual description */
-};
-#define IFT_NOSUBFUNC -1
-
-
-/*
-** Declare a static array of 256 integers to use as a fast lookup
-** into the table of handlers.
-**
-** Call this function to initialise the lookup. Note that the table
-** must be arranged with all handlers for a given function together, and
-** that the handler listed with IFT_NOSUBFUNC should be last.
-*/
-static inline void
-intfunc_init(struct intfunc_table table[], int idx[])
-{
- int hn;
-
- for (hn = 0; hn < 256; hn++) /* initialise all no-handler state */
- idx[hn] = -1; /* default to no handler */
-
- for (hn = 0; table[hn].func >= 0; hn++) /* walk list of handlers and add references */
- if (idx[table[hn].func] == -1 ) /* reference first handler */
- idx[table[hn].func] = hn;
-}
-
-/*
-** Call this to get an index matching the function/subfunction
-** described by (sc), or -1 if none exist
-*/
-static inline int
-intfunc_find(struct intfunc_table table[], int idx[], int func, int subfunc)
-{
- int ent = idx[func]; /* look for handler */
-
- while ((ent >= 0) && /* scan entries for function */
- (table[ent].func == func)) {
-
- if ((table[ent].subfunc == IFT_NOSUBFUNC) || /* handles all */
- (table[ent].subfunc == subfunc)) { /* handles this one */
- return(ent);
- }
- ent++;
- }
- return(-1);
-}
-
-/*
-** A slower lookup for a set of function handlers, but one that requires
-** no initialisation calls.
-** Again, handlers with IFT_NOSUBFUNC should be listed after any with
-** specific subfunction values.
-*/
-static inline int
-intfunc_search(struct intfunc_table table[], int func, int subfunc)
-{
- int ent;
-
- for (ent = 0; table[ent].func >= 0; ent++)
- if ((table[ent].func == func) && /* matches required function */
- ((table[ent].subfunc == IFT_NOSUBFUNC) || table[ent].subfunc == subfunc))
- return(ent);
- return(-1);
-}
-
-
+++ /dev/null
-/*
- * Copyright (c) 1996
- * Michael Smith. All rights reserved.
- * 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 int21.c,v 2.2 1996/04/08 19:32:51 bostic Exp
- *
- * $FreeBSD: src/usr.bin/doscmd/dos.c,v 1.7.2.5 2002/04/25 11:04:50 tg Exp $
- * $DragonFly: src/usr.bin/doscmd/dos.c,v 1.3 2008/10/16 01:52:32 swildner Exp $
- */
-
-#include <sys/ioctl.h>
-#include <sys/param.h>
-#include <sys/mount.h>
-#include <ctype.h>
-#include <dirent.h>
-#include <errno.h>
-#include <glob.h>
-#include <paths.h>
-#include <stddef.h>
-#include <time.h>
-#include <unistd.h>
-
-#include "doscmd.h"
-#include "cwd.h"
-#include "dispatch.h"
-#include "tty.h"
-
-/* Country Info */
-struct {
- ushort ciDateFormat;
- char ciCurrency[5];
- char ciThousands[2];
- char ciDecimal[2];
- char ciDateSep[2];
- char ciTimeSep[2];
- char ciCurrencyFormat;
- char ciCurrencyPlaces;
- char ciTimeFormat;
- ushort ciCaseMapOffset;
- ushort ciCaseMapSegment;
- char ciDataSep[2];
-#if 0
- char ciReserved[10];
-#endif
-} countryinfo = {
- 0, "$", ",", ".", "-", ":", 0, 2, 0, 0xffff, 0xffff, "?"
-};
-
-/* DOS File Control Block */
-struct fcb {
- u_char fcbMagic;
- u_char fcbResoived[5];
- u_char fcbAttribute;
- u_char fcbDriveID;
- u_char fcbFileName[8];
- u_char fcbExtent[3];
- u_short fcbCurBlockNo;
- u_short fcbRecSize;
- u_long fcbFileSize;
- u_short fcbFileDate;
- u_short fcbFileTime;
- int fcbReserved;
- int fcb_fd; /* hide UNIX FD here */
- u_char fcbCurRecNo;
- u_long fcbRandomRecNo;
-}/* __attribute__((__packed__))*/;
-
-/* exports */
-int diskdrive = 2; /* C: */
-char *InDOS;
-
-/* locals */
-static void fcb_to_string(struct fcb *, u_char *);
-
-static int ctrl_c_flag = 0;
-static int return_status = 0;
-static int doserrno = 0;
-static int memory_strategy = 0; /* first fit (we ignore this) */
-static u_long upcase_vector;
-
-static u_char upc_table[0x80] = {
- 0x80, 0x9a, 'E', 'A', 0x8e, 'A', 0x8f, 0x80,
- 'E', 'E', 'E', 'I', 'I', 'I', 0x8e, 0x8f,
- 0x90, 0x92, 0x92, 'O', 0x99, 'O', 'U', 'U',
- 'Y', 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f,
- 'A', 'I', 'O', 'U', 0xa5, 0xa5, 0xa6, 0xa7,
- 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf,
- 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7,
- 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf,
- 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
- 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
- 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7,
- 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf,
- 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7,
- 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef,
- 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
- 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff,
-};
-
-
-/******************************************************************************
-** utility functions
-*/
-
-static u_char
-upcase(u_char c)
-{
-
- if (islower(c))
- return (toupper(c));
- else if (c >= 0x80)
- return (upc_table[c - 0x80]);
- else
- return (c);
-}
-
-static void
-upcase_entry(regcontext_t *REGS)
-{
- R_AL = upcase(R_AL);
-}
-
-
-/*
-** Handle the DOS drive info/free space/etc. calls.
-*/
-static int
-int21_free(regcontext_t *REGS)
-{
- fsstat_t fs;
- int error;
- int drive = 0;
-
- /* work out drive */
- switch (R_AH) {
- case 0x1c:
- case 0x36:
- drive = R_DL;
- if (drive)
- break;
- /* FALLTHROUGH */
- case 0x1b:
- drive = diskdrive;
- break;
- default:
- fatal("int21_free called on unknown function %x\n",R_AH);
- }
-
- error = get_space(drive, &fs);
- if (error)
- return(error);
-
- R_AL = fs.sectors_cluster; /* sectors per cluster */
- R_CX = fs.bytes_sector; /* bytes per sector */
- R_DX = fs.total_clusters; /* total clusters */
-
- switch (R_AH) {
- case 0x1b:
- case 0x1c:
- BIOSDATA[0xb4] = 0xf0; /* "reserved" area, "other media" FAT ID */
- R_DX = 0x40; /* BIOS data area */
- R_BX = 0xb4;
- break;
-
- case 0x36:
- R_BX = fs.avail_clusters; /* number of available clusters */
- break;
- }
- return(0);
-}
-
-static void
-pack_name(u_char *p, u_char *q)
-{
- int i;
-
- for (i = 8; i > 0 && *p != ' '; i--)
- *q++ = *p++;
- p += i;
- if (*p != ' ') {
- *q++ = '.';
- for (i = 3; i > 0 && *p != ' '; i--)
- *q++ = *p++;
- p += i;
- }
- *q = '\0';
-}
-
-static void
-dosdir_to_dta(dosdir_t *dosdir, find_block_t *dta)
-{
- dta->attr = dosdir->attr;
- dta->time = dosdir->time;
- dta->date = dosdir->date;
- dta->size = dosdir->size;
- pack_name(dosdir->name, dta->name);
-}
-
-/* exported */
-void
-encode_dos_file_time(time_t t, u_short *dosdatep, u_short *dostimep)
-{
- struct tm tm;
-
- tm = *localtime(&t);
- *dostimep = (tm.tm_hour << 11) |
- (tm.tm_min << 5) |
- ((tm.tm_sec / 2) << 0);
- *dosdatep = ((tm.tm_year - 80) << 9) |
- ((tm.tm_mon + 1) << 5) |
- (tm.tm_mday << 0);
-}
-
-time_t
-decode_dos_file_time(u_short dosdate, u_short dostime)
-{
- struct tm tm;
- time_t then;
-
- tm.tm_hour = (dostime >> 11) & 0x1f;
- tm.tm_min = (dostime >> 5) & 0x3f;
- tm.tm_sec = ((dostime >> 0) & 0x1f) * 2;
- tm.tm_year = ((dosdate >> 9) & 0x7f) + 80;
- tm.tm_mon = ((dosdate >> 5) & 0x0f) - 1;
- tm.tm_mday = (dosdate >> 0) & 0x1f;
- /* tm_wday and tm_yday are ignored. */
- tm.tm_isdst = 0;
- /* tm_gmtoff is ignored. */
- then = mktime(&tm);
- return (then);
-}
-
-int
-translate_filename(u_char *dname, u_char *uname, int *drivep)
-{
- u_char newpath[1024];
- int error;
-
- if (!strcasecmp(dname, "con")) {
- *drivep = -1;
- strcpy(uname, _PATH_TTY);
- return (0);
- }
-
- /* XXX KLUDGE for EMS support w/o booting DOS */
- /* Really need a better way to handle devices */
- if (!strcasecmp(dname, "emmxxxx0")) {
- *drivep = -1;
- strcpy(uname, _PATH_DEVNULL);
- return (0);
- }
-
- error = dos_makepath(dname, newpath);
- if (error)
- return (error);
-
- error = dos_to_real_path(newpath, uname, drivep);
- if (error)
- return (error);
-
- return (0);
-}
-
-static u_char magic[0x7e] = {
- 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06,
- 0x06, 0x00, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06,
- 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06,
- 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06,
-
- 0x08, 0x0f, 0x06, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f,
- 0x0f, 0x0f, 0x0f, 0x04, 0x04, 0x0f, 0x0e, 0x06,
- 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f,
- 0x0f, 0x0f, 0x04, 0x04, 0x04, 0x04, 0x04, 0x0f,
-
- 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f,
- 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f,
- 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f,
- 0x0f, 0x0f, 0x0f, 0x06, 0x06, 0x06, 0x0f, 0x0f,
-
- 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f,
- 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f,
- 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f,
- 0x0f, 0x0f, 0x0f, 0x0f, 0x04, 0x0f,
-};
-
-#define isvalid(x) ((magic[(int)(x)] & 0x01) != 0)
-#define issep(x) ((magic[(int)(x)] & 0x02) == 0)
-#define iswhite(x) ((magic[(int)(x)] & 0x04) == 0)
-
-static char *
-skipwhite(char *p)
-{
- while (iswhite(*p))
- ++p;
- return (p);
-}
-
-#define get_drive_letter(x) ((x) - 0x40)
-
-int
-parse_filename(int flag, char *str, char *fcb, int *nb)
-{
- char *p;
- int ret = 0;
- int i;
-
- p = str;
-
- p = skipwhite(p);
- if (flag & 1) {
- if (issep(*p)) {
- ++p;
- p = skipwhite(p);
- }
- }
-
- if (isvalid(*p) && p[1] == ':') {
- *fcb++ = get_drive_letter(upcase(*p));
- p += 2;
- } else if (flag & 2) {
- fcb++;
- } else {
- *fcb++ = 0; /* default drive */
- }
-
- i = 8;
- if (isvalid(*p)) {
- for (;;) {
- if (!isvalid(*p)) {
- for (; i > 0; i--)
- *fcb++ = ' ';
- break;
- }
- if (i > 0) {
- switch (*p) {
- case '*':
- ret = 1;
- for (; i > 0; i--)
- *fcb++ = '?';
- break;
- case '?':
- ret = 1;
- default:
- *fcb++ = upcase(*p);
- i--;
- break;
- }
- }
- ++p;
- }
- } else if (flag & 4) {
- fcb += i;
- } else {
- for (; i > 0; i--)
- *fcb++ = ' ';
- }
-
- i = 3;
- if (*p == '.') {
- ++p;
- for (;;) {
- if (!isvalid(*p)) {
- for (; i > 0; i--)
- *fcb++ = ' ';
- break;
- }
- if (i > 0) {
- switch (*p) {
- case '*':
- ret = 1;
- for (; i > 0; i--)
- *fcb++ = '?';
- break;
- case '?':
- ret = 1;
- default:
- *fcb++ = upcase(*p);
- i--;
- break;
- }
- }
- ++p;
- }
- } else if (flag & 8) {
- fcb += i;
- } else {
- for (; i > 0; i--)
- *fcb++ = ' ';
- }
-
- for (i = 4; i > 0; i--)
- *fcb++ = 0; /* filler */
-
- *nb = p - str;
- return (ret);
-}
-
-/******************************************************************************
-** int21 functions
-*/
-
-/*
-** 21:00
-**
-** terminate
-*/
-static int
-int21_00(regcontext_t *REGS)
-{
- done(REGS,0);
- /* keep `gcc -Wall' happy */
- return(0);
-}
-
-/*
-** 21:01
-**
-** read character with echo
-*/
-static int
-int21_01(regcontext_t *REGS)
-{
- int n;
-
- if ((n = tty_read((regcontext_t *)®S->sc, TTYF_BLOCKALL)) >= 0)
- R_AL = n;
- return(0);
-}
-
-/*
-** 21:02
-**
-** write char to stdout
-*/
-static int
-int21_02(regcontext_t *REGS)
-{
- tty_write(R_DL, TTYF_REDIRECT);
- return(0);
-}
-
-/*
-** 21:06
-**
-** direct console I/O
-**
-** (dl) is output char unless 0xff, when we read instead
-*/
-static int
-int21_06(regcontext_t *REGS)
-{
- int n;
-
- /* XXX - should be able to read a file */
- if (R_DL == 0xff) {
- n = tty_read((regcontext_t *)®S->sc, TTYF_ECHO|TTYF_REDIRECT);
- if (n < 0) {
- R_FLAGS |= PSL_Z; /* nothing available */
- R_AL = 0;
- } else {
- R_AL = n; /* got character */
- R_FLAGS &= ~PSL_Z;
- }
- } else {
- /* write and return char in %al */
- tty_write(R_DL, TTYF_REDIRECT);
- R_AL = R_DL;
- }
- return(0);
-}
-
-/*
-** 21:07
-**
-** direct console input with no echo
-*/
-static int
-int21_07(regcontext_t *REGS)
-{
- R_AL = tty_read((regcontext_t *)®S->sc,
- TTYF_BLOCK|TTYF_REDIRECT) & 0xff;
- return(0);
-}
-
-/*
-** 21:08
-**
-** character input with no echo
-*/
-static int
-int21_08(regcontext_t *REGS)
-{
- int n;
-
- if ((n = tty_read((regcontext_t *)®S->sc,
- TTYF_BLOCK|TTYF_CTRL|TTYF_REDIRECT)) >= 0)
- R_AL = n;
- return(0);
-}
-
-/*
-** 21:09
-**
-** write string to standard out.
-**
-** We're a little paranoid here; if the string is very long, truncate it.
-*/
-static int
-int21_09(regcontext_t *REGS)
-{
- char *addr;
- int len;
-
- /* pointer to string */
- addr = (char *)MAKEPTR(R_DS, R_DX);
-
- /* walk string looking for terminator or overlength */
- for (len = 0; len < 10000; len++, addr++) {
- if (*addr == '$')
- break;
- tty_write(*addr, TTYF_REDIRECT);
- }
- R_AL = 0x24;
- return(0);
-}
-
-/*
-** 21:0a
-**
-** buffered input
-*/
-static int
-int21_0a(regcontext_t *REGS)
-{
- unsigned char *addr;
- int nbytes,avail;
- int n;
-
- /* pointer to buffer */
- addr = (unsigned char *)MAKEPTR(R_DS, R_DX);
-
- /* capacity of buffer */
- avail = addr[0];
- if (avail == 0) /* no space */
- return(0);
- nbytes = 0; /* read nothing yet */
-
- /* read loop */
- while (1) {
- n = tty_read((regcontext_t *)®S->sc,
- TTYF_BLOCK|TTYF_CTRL|TTYF_REDIRECT);
- if (n < 0) /* end of input */
- n = '\r'; /* make like CR */
-
- switch (n) {
- case '\r': /* done */
- addr[1] = nbytes;
- addr[nbytes+2] = '\r';
- addr[nbytes+3] = '\0'; /* XXX is this necessary? */
- return (0);
- case '\n': /* ignore */
- case '\0':
- break;
- case '\b': /* backspace */
- if (nbytes > 0) {
- --nbytes;
- tty_write('\b', TTYF_REDIRECT);
- if (addr[nbytes+2] < ' ')
- tty_write('\b', TTYF_REDIRECT);
- }
- break;
- default:
- if (nbytes >= (avail-2)) { /* buffer full */
- tty_write('\007', TTYF_REDIRECT);
- } else { /* add to end */
- addr[(nbytes++) +2] = n;
- if (n != '\t' && n < ' ') {
- tty_write('^', TTYF_REDIRECT);
- tty_write(n + '@', TTYF_REDIRECT);
- } else
- tty_write(n, TTYF_REDIRECT);
- }
- break;
- }
- }
-}
-
-/*
-** 21:0b
-**
-** get stdin status
-**
-** This is a favorite for camping on, so we do some poll-counting
-** here as well.
-*/
-static int
-int21_0b(regcontext_t *REGS)
-{
- int n;
-
- /* XXX this is pretty bogus, actually */
- if (!xmode) {
- R_AL = 0xff; /* no X mode, always claim data available */
- return(0);
- }
- /* XXX tty_peek is broken */
- n = tty_peek(REGS, poll_cnt ? 0 : TTYF_POLL) ? 0xff : 0;
- if (n < 0) /* control-break */
- return (0);
- R_AL = n; /* will be 0 or 0xff */
- if (poll_cnt)
- --poll_cnt;
- return(0);
-}
-
-/*
-** 21:0c
-**
-** flush stdin and read using other function
-*/
-static int
-int21_0c(regcontext_t *REGS)
-{
- if (xmode) /* XXX should always flush! */
- tty_flush();
-
- switch(R_AL) { /* which subfunction? */
- case 0x01:
- return(int21_01(REGS));
- case 0x06:
- return(int21_06(REGS));
- case 0x07:
- return(int21_07(REGS));
- case 0x08:
- return(int21_08(REGS));
- case 0x0a:
- return(int21_0a(REGS));
- }
- return(0);
-}
-
-/*
-** 21:0e
-**
-** select default drive
-*/
-static int
-int21_0e(regcontext_t *REGS)
-{
- diskdrive = R_DL; /* XXX rangecheck? */
- R_AL = ndisks + 2; /* report actual limit */
- return(0);
-}
-
-/*
-** 21:19
-**
-** get default drive
-*/
-static int
-int21_19(regcontext_t *REGS)
-{
- R_AL = diskdrive;
- return(0);
-}
-
-/*
-** 21:1a
-**
-** set DTA
-*/
-static int
-int21_1a(regcontext_t *REGS)
-{
- debug(D_FILE_OPS, "set dta to %x:%x\n", R_DS, R_DX);
- disk_transfer_addr = MAKEVEC(R_DS, R_DX);
- return(0);
-}
-
-/*
-** 21:23
-**
-** Get file size for fcb
-** DS:DX -> unopened FCB, no wildcards.
-** pcb random record field filled in with number of records, rounded up.
-*/
-static int
-int21_23(regcontext_t *REGS)
-{
- debug(D_HALF, "Returning failure from get file size for fcb 21:23\n");
- R_AL = 0xff;
- return(0);
-}
-
-/*
-** 21:25
-**
-** set interrupt vector
-*/
-static int
-int21_25(regcontext_t *REGS)
-{
- debug(D_MEMORY, "%02x -> %04x:%04x\n", R_AL, R_DS, R_DX);
- ivec[R_AL] = MAKEVEC(R_DS, R_DX);
- return(0);
-}
-
-/*
-** 21:26
-**
-** Create PSP
-*/
-static int
-int21_26(regcontext_t *REGS)
-{
- unsigned char *addr;
-
- /* address of new PSP */
- addr = (unsigned char *)MAKEPTR(R_DX, 0);
-
- /* copy this process' PSP - XXX needs some work 8( */
- memcpy (addr, dosmem, 256);
- return(0);
-}
-
-/*
-** 21:2a
-**
-** Get date
-*/
-static int
-int21_2a(regcontext_t *REGS)
-{
- struct timeval tv;
- struct timezone tz;
- struct tm tm;
- time_t now;
-
- gettimeofday(&tv, &tz); /* get time and apply DOS offset */
- now = tv.tv_sec + delta_clock;
-
- tm = *localtime(&now); /* deconstruct and timezoneify */
- R_CX = tm.tm_year + 1900;
- R_DH = tm.tm_mon + 1;
- R_DL = tm.tm_mday;
- R_AL = tm.tm_wday;
- return(0);
-}
-
-/*
-** 21:2b
-**
-** set date
-*/
-static int
-int21_2b(regcontext_t *REGS)
-{
- struct timeval tv;
- struct timezone tz;
- struct tm tm;
- time_t now;
-
- gettimeofday(&tv, &tz); /* get time and apply DOS offset */
- now = tv.tv_sec + delta_clock;
- tm = *localtime(&now);
-
- tm.tm_year = R_CX - 1900;
- tm.tm_mon = R_DH - 1;
- tm.tm_mday = R_DL;
- tm.tm_wday = R_AL;
-
- now = mktime(&tm);
- if (now == -1)
- return (DATA_INVALID);
-
- delta_clock = now - tv.tv_sec; /* compute new offset? */
- R_AL = 0;
- return(0);
-}
-
-/*
-** 21:2c
-**
-** Get time
-*/
-static int
-int21_2c(regcontext_t *REGS)
-{
- struct timeval tv;
- struct timezone tz;
- struct tm tm;
- time_t now;
-
- gettimeofday(&tv, &tz);
- now = tv.tv_sec + delta_clock;
- tm = *localtime(&now);
-
- R_CH = tm.tm_hour;
- R_CL = tm.tm_min;
- R_DH = tm.tm_sec;
- R_DL = tv.tv_usec / 10000;
- return(0);
-}
-
-/*
-** 21:2d
-**
-** Set time
-*/
-static int
-int21_2d(regcontext_t *REGS)
-{
- struct timeval tv;
- struct timezone tz;
- struct tm tm;
- time_t now;
-
- gettimeofday(&tv, &tz);
- now = tv.tv_sec + delta_clock;
- tm = *localtime(&now);
-
- tm.tm_hour = R_CH;
- tm.tm_min = R_CL;
- tm.tm_sec = R_DH;
- tv.tv_usec = R_DL * 10000;
-
- now = mktime(&tm);
- if (now == -1)
- return (DATA_INVALID);
-
- delta_clock = now - tv.tv_sec;
- R_AL = 0;
- return(0);
-}
-
-/*
-** 21:2f
-**
-** get DTA
-*/
-static int
-int21_2f(regcontext_t *REGS)
-{
- PUTVEC(R_ES, R_BX, disk_transfer_addr);
- debug(D_FILE_OPS, "get dta at %x:%x\n", R_ES, R_BX);
- return(0);
-}
-
-/*
-** 21:30
-**
-** get DOS version number.
-**
-** XXX begging for a rewrite
-*/
-static int
-int21_30(regcontext_t *REGS)
-{
- int v;
-
- char *cmd = (char *)MAKEPTR(get_env(), 0);
-
- /*
- * retch. I think this skips the environment and looks for the name
- * of the current command.
- */
- do {
- while (*cmd)
- ++cmd;
- } while (*++cmd);
- ++cmd;
- cmd += *(short *)cmd + 1;
- while (cmd[-1] && cmd[-1] != '\\' && cmd[-1] != ':')
- --cmd;
-
- /* get the version we're pretending to be for this sucker */
- v = getver(cmd);
- R_AL = (v / 100) & 0xff;
- R_AH = v % 100;
- return(0);
-}
-
-/*
-** 21:33:05
-**
-** Get boot drive
-*/
-static int
-int21_33_5(regcontext_t *REGS)
-{
- R_DL = 3; /* always booted from C */
- return(0);
-}
-
-/*
-** 21:33:06
-**
-** get true DOS version
-*/
-static int
-int21_33_6(regcontext_t *REGS)
-{
- int v;
-
- v = getver(NULL);
- R_BL = (v / 100) & 0xff;
- R_BH = v % 100;
- R_DH = 0;
- R_DL = 0;
- return(0);
-}
-
-/*
-** 21:33
-**
-** extended break checking
-*/
-static int
-int21_33(regcontext_t *REGS)
-{
- int ftemp;
-
- switch (R_AL) {
- case 0x00:
- R_DL = ctrl_c_flag;
- break;
- case 0x01:
- ctrl_c_flag = R_DL;
- break;
- case 0x02:
- ftemp = ctrl_c_flag;
- ctrl_c_flag = R_DL;
- R_DL = ftemp;
- break;
-
- default:
- unknown_int3(0x21, 0x33, R_AL, REGS);
- return(FUNC_NUM_IVALID);
- }
- return(0);
-}
-
-/*
-** 21:34
-**
-** Get address of InDos flag
-**
-** XXX check interrupt list WRT location of critical error flag too.
-*/
-static int
-int21_34(regcontext_t *REGS)
-{
- PUTVEC(R_ES, R_BX, (u_long)InDOS);
- return(0);
-}
-
-/*
-** 21:35
-**
-** get interrupt vector
-*/
-static int
-int21_35(regcontext_t *REGS)
-{
- PUTVEC(R_ES, R_BX, ivec[R_AL]);
- debug(D_MEMORY, "%02x <- %04x:%04x\n", R_AL, R_ES, R_BX);
- return(0);
-}
-
-/*
-** 21:37
-**
-** switch character manipulation
-**
-*/
-static int
-int21_37(regcontext_t *REGS)
-{
- switch (R_AL) {
- case 0: /* get switch character */
- R_DL = '/';
- break;
-
- case 1: /* set switch character (normally /) */
- /* ignored by most versions of DOS */
- break;
- default:
- unknown_int3(0x21, 0x37, R_AL, REGS);
- return (FUNC_NUM_IVALID);
- }
- return(0);
-
-}
-
-/*
-** 21:38
-**
-** country code information
-**
-** XXX internat guru?
-*/
-static int
-int21_38(regcontext_t *REGS)
-{
- char *addr;
-
- if (R_DX == 0xffff) {
- debug(D_HALF, "warning: set country code ignored");
- return(0);
- }
- addr = (char *)MAKEPTR(R_DS, R_DX);
- PUTVEC(countryinfo.ciCaseMapSegment, countryinfo.ciCaseMapOffset,
- upcase_vector);
- memcpy(addr, &countryinfo, sizeof(countryinfo));
- return(0);
-}
-
-/*
-** 21:39
-** 21:3a
-** 21:41
-** 21:56
-**
-** mkdir, rmdir, unlink, rename
-*/
-static int
-int21_dirfn(regcontext_t *REGS)
-{
- int error;
- char fname[PATH_MAX],tname[PATH_MAX];
- int drive;
-
- error = translate_filename((u_char *)MAKEPTR(R_DS, R_DX), fname, &drive);
- if (error)
- return (error);
-
- if (dos_readonly(drive))
- return (WRITE_PROT_DISK);
-
- switch(R_AH) {
- case 0x39:
- debug(D_FILE_OPS, "mkdir(%s)\n", fname);
- error = mkdir(fname, 0777);
- break;
- case 0x3a:
- debug(D_FILE_OPS, "rmdir(%s)\n", fname);
- error = rmdir(fname);
- break;
- case 0x41:
- debug(D_FILE_OPS, "unlink(%s)\n", fname);
- error = unlink(fname);
- break;
- case 0x56: /* rename - some extra work */
- error = translate_filename((u_char *)MAKEPTR(R_ES, R_DI), tname, &drive);
- if (error)
- return (error);
-
- debug(D_FILE_OPS, "rename(%s, %s)\n", fname, tname);
- error = rename(fname, tname);
- break;
-
- default:
- fatal("call to int21_dirfn for unknown function %x\n",R_AH);
- }
- if (error < 0) {
- switch (errno) {
- case ENOTDIR:
- case ENOENT:
- return (PATH_NOT_FOUND);
- case EXDEV:
- return (NOT_SAME_DEV);
- default:
- return (ACCESS_DENIED);
- }
- }
- return(0);
-}
-
-/*
-** 21:3b
-**
-** chdir
-*/
-static int
-int21_3b(regcontext_t *REGS)
-{
- debug(D_FILE_OPS, "chdir(%s)\n",(u_char *)MAKEPTR(R_DS, R_DX));
- return(dos_setcwd((u_char *)MAKEPTR(R_DS, R_DX)));
-}
-
-/*
-** 21:3c
-** 21:5b
-** 21:6c
-**
-** open, creat, creat new, multipurpose creat
-*/
-static int
-int21_open(regcontext_t *REGS)
-{
- int error;
- char fname[PATH_MAX];
- struct stat sb;
- int mode = 0, action = 0, status;
- char *pname = NULL;
- int drive;
- int fd;
-
- switch(R_AH) {
- case 0x3c: /* creat */
- pname = (char *)MAKEPTR(R_DS, R_DX);
- action = 0x12; /* create/truncate regardless */
- mode = O_RDWR;
- debug(D_FILE_OPS, "creat");
- break;
-
- case 0x3d: /* open */
- pname = (char *)MAKEPTR(R_DS, R_DX);
- action = 0x01; /* fail if not exist, open if exists */
- switch (R_AL & 3) {
- case 0:
- mode = O_RDONLY;
- break;
- case 1:
- mode = O_WRONLY;
- break;
- case 2:
- mode = O_RDWR;
- break;
- default:
- return (FUNC_NUM_IVALID);
- }
- debug(D_FILE_OPS, "open");
- break;
-
- case 0x5b: /* creat new */
- pname = (char *)MAKEPTR(R_DS, R_DL);
- action = 0x10; /* create if not exist, fail if exists */
- mode = O_RDWR;
- debug(D_FILE_OPS, "creat_new");
- break;
-
- case 0x6c: /* multipurpose */
- pname = (char *)MAKEPTR(R_DS, R_SI);
- action = R_DX;
- switch (R_BL & 3) {
- case 0:
- mode = O_RDONLY;
- break;
- case 1:
- mode = O_WRONLY;
- break;
- case 2:
- mode = O_RDWR;
- break;
- default:
- return (FUNC_NUM_IVALID);
- }
- debug(D_FILE_OPS, "mopen");
- break;
-
- default:
- fatal("called int21_creat for unknown function %x\n",R_AH);
- }
- if (action & 0x02) /* replace/open mode */
- mode |= O_TRUNC;
-
- /* consider proposed name */
- error = translate_filename(pname, fname, &drive);
- if (error)
- return (error);
-
- debug(D_FILE_OPS, "(%s)\n", fname);
-
- if (dos_readonly(drive) && (mode != O_RDONLY))
- return (WRITE_PROT_DISK);
-
- if (ustat(fname, &sb) < 0) { /* file does not exist */
- if (action & 0x10) { /* create? */
- sb.st_ino = 0;
- mode |= O_CREAT; /* have to create as we go */
- status = 0x02; /* file created */
- } else {
- return(FILE_NOT_FOUND);
- }
- } else {
- if (S_ISDIR(sb.st_mode))
- return(ACCESS_DENIED);
- if (action & 0x03) { /* exists, work with it */
- if (action & 0x02) {
- if (!S_ISREG(sb.st_mode)) { /* only allowed for files */
- debug(D_FILE_OPS,"attempt to truncate non-regular file\n");
- return(ACCESS_DENIED);
- }
- status = 0x03; /* we're going to truncate it */
- } else {
- status = 0x01; /* just open it */
- }
- } else {
- return(FILE_ALREADY_EXISTS); /* exists, fail */
- }
- }
-
- if ((fd = open(fname, mode, from_dos_attr(R_CX))) < 0) {
- debug(D_FILE_OPS,"failed to open %s : %s\n",fname,strerror(errno));
- return (ACCESS_DENIED);
- }
-
- if (R_AH == 0x6c) /* need to return status too */
- R_CX = status;
- R_AX = fd; /* return fd */
- return(0);
-}
-
-/*
-** 21:3e
-**
-** close
-*/
-static int
-int21_3e(regcontext_t *REGS)
-{
- debug(D_FILE_OPS, "close(%d)\n", R_BX);
-
- if (R_BX == fileno(debugf)) {
- printf("attempt to close debugging fd\n");
- return (HANDLE_INVALID);
- }
-
- if (close(R_BX) < 0)
- return (HANDLE_INVALID);
- return(0);
-}
-
-/*
-** 21:3f
-**
-** read
-*/
-static int
-int21_3f(regcontext_t *REGS)
-{
- char *addr;
- int n;
- int avail;
-
- addr = (char *)MAKEPTR(R_DS, R_DX);
-
- debug(D_FILE_OPS, "read(%d, %d)\n", R_BX, R_CX);
-
- if (R_BX == 0) {
- if (redirect0) {
- n = read (R_BX, addr, R_CX);
- } else {
- n = 0;
- while (n < R_CX) {
- avail = tty_read(REGS, TTYF_BLOCK|TTYF_CTRL|TTYF_ECHONL);
- if (avail < 0)
- return (0);
- if ((addr[n++] = avail) == '\r')
- break;
- }
- }
- } else {
- n = read (R_BX, addr, R_CX);
- }
- if (n < 0)
- return (READ_FAULT);
-
- R_AX = n;
- return(0);
-}
-
-/*
-** 21:40
-**
-** write
-*/
-static int
-write_or_truncate(int fd, char *addr, int len)
-{
- off_t offset;
-
- if (len == 0) {
- offset = lseek(fd, 0, SEEK_CUR);
- if (offset < 0)
- return -1;
- else
- return ftruncate(fd, offset);
- } else {
- return write(fd, addr, len);
- }
-}
-
-static int
-int21_40(regcontext_t *REGS)
-{
- char *addr;
- int nbytes,n;
-
- addr = (char *)MAKEPTR(R_DS, R_DX);
- nbytes = R_CX;
-
- debug(D_FILE_OPS, "write(%d, %d)\n", R_BX, nbytes);
-
- switch (R_BX) {
- case 0:
- if (redirect0) {
- n = write_or_truncate(R_BX, addr, nbytes);
- break;
- }
- n = nbytes;
- while (nbytes-- > 0)
- tty_write(*addr++, -1);
- break;
- case 1:
- if (redirect1) {
- n = write_or_truncate(R_BX, addr, nbytes);
- break;
- }
- n = nbytes;
- while (nbytes-- > 0)
- tty_write(*addr++, -1);
- break;
- case 2:
- if (redirect2) {
- n = write_or_truncate(R_BX, addr, nbytes);
- break;
- }
- n = nbytes;
- while (nbytes-- > 0)
- tty_write(*addr++, -1);
- break;
- default:
- n = write_or_truncate(R_BX, addr, nbytes);
- break;
- }
- if (n < 0)
- return (WRITE_FAULT);
-
- R_AX = n;
- return(0);
-}
-
-/*
-** 21:42
-**
-** seek
-*/
-static int
-int21_42(regcontext_t *REGS)
-{
- int whence;
- off_t offset;
-
- offset = (off_t) ((int) (R_CX << 16) + R_DX);
- switch (R_AL) {
- case 0:
- whence = SEEK_SET;
- break;
- case 1:
- whence = SEEK_CUR;
- break;
- case 2:
- whence = SEEK_END;
- break;
- default:
- return (FUNC_NUM_IVALID);
- }
-
- debug(D_FILE_OPS, "seek(%d, 0x%qx, %d)\n", R_BX, offset, whence);
-
- if ((offset = lseek(R_BX, offset, whence)) < 0) {
- if (errno == EBADF)
- return (HANDLE_INVALID);
- else
- return (SEEK_ERROR);
- }
-
- R_DX = (offset >> 16) & 0xffff;
- R_AX = offset & 0xffff;
- return(0);
-}
-
-/*
-** 21:43
-**
-** get/set attributes
-*/
-static int
-int21_43(regcontext_t *REGS)
-{
- int error;
- char fname[PATH_MAX];
- struct stat sb;
- int mode;
- int drive;
-
- error = translate_filename((u_char *)MAKEPTR(R_DS, R_DX), fname, &drive);
- if (error)
- return (error);
-
- debug(D_FILE_OPS, "get/set attributes: %s, cx=%x, al=%d\n",
- fname, R_CX, R_AL);
-
- if (stat(fname, &sb) < 0) {
- debug(D_FILE_OPS, "stat failed for %s\n", fname);
- return (FILE_NOT_FOUND);
- }
-
- switch (R_AL) {
- case 0: /* get attributes */
- mode = 0;
- if (dos_readonly(drive) || access(fname, W_OK))
- mode |= 0x01;
- if (S_ISDIR(sb.st_mode))
- mode |= 0x10;
- R_CX = mode;
- break;
-
- case 1: /* set attributes - XXX ignored */
- if (R_CX & 0x18)
- return (ACCESS_DENIED);
- break;
-
- default:
- return (FUNC_NUM_IVALID);
- }
- return(0);
-}
-
-/*
-** 21:44:0
-**
-** ioctl - get device info
-**
-** XXX it would be nice to detect EOF.
-*/
-static int
-int21_44_0(regcontext_t *REGS)
-{
- debug(D_FILE_OPS, "ioctl get %d\n", R_BX);
-
- switch (R_BX) {
- case 0:
- R_DX = 0x80 | 0x01; /* is device, is standard output */
- break;
- case 1:
- R_DX = 0x80 | 0x02; /* is device, is standard input */
- break;
- case 2:
- R_DX = 0x80; /* is device */
- break;
- default:
- if (isatty (R_BX))
- R_DX = 0x80; /* is a device */
- else
- R_DX = 0; /* is a file */
- break;
- }
- return(0);
-}
-
-/*
-** 21:44:01
-**
-** ioctl - set device info
-*/
-static int
-int21_44_1(regcontext_t *REGS)
-{
- debug(D_FILE_OPS, "ioctl set device info %d flags %x (ignored)\n",
- R_BX, R_DX);
- return(0);
-}
-
-/*
-** 21:44:7
-**
-** Get output status
-*/
-static int
-int21_44_7(regcontext_t *REGS)
-{
- /* XXX Should really check to see if BX is open or not */
- R_AX = 0xFF;
- return(0);
-}
-
-/*
-** 21:44:8
-**
-** test for removable block device
-*/
-static int
-int21_44_8(regcontext_t *REGS)
-{
- R_AX = 1; /* fixed */
- return(0);
-}
-
-/*
-** 21:44:0
-**
-** test for remote device (disallow direct I/O)
-*/
-static int
-int21_44_9(regcontext_t *REGS)
-{
- R_DX = 0x1200; /* disk is remote, direct I/O not allowed */
- return (0);
-}
-
-/*
-** 21:45
-**
-** dup
-*/
-static int
-int21_45(regcontext_t *REGS)
-{
- int nfd;
-
- debug(D_FILE_OPS, "dup(%d)\n", R_BX);
-
- if ((nfd = dup(R_BX)) < 0) {
- if (errno == EBADF)
- return (HANDLE_INVALID);
- else
- return (TOO_MANY_OPEN_FILES);
- }
- R_AX = nfd;
- return(0);
-}
-
-/*
-** 21:46
-**
-** dup2
-*/
-static int
-int21_46(regcontext_t *REGS)
-{
- debug(D_FILE_OPS, "dup2(%d, %d)\n", R_BX, R_CX);
-
- if (dup2(R_BX, R_CX) < 0) {
- if (errno == EMFILE)
- return (TOO_MANY_OPEN_FILES);
- else
- return (HANDLE_INVALID);
- }
- return(0);
-}
-
-/*
-** 21:47
-**
-** getcwd
-*/
-static int
-int21_47(regcontext_t *REGS)
-{
- int n,nbytes;
- char *p,*addr;
-
- n = R_DL;
- if (!n--)
- n = diskdrive;
-
- p = (char *)dos_getcwd(n) + 1;
- addr = (char *)MAKEPTR(R_DS, R_SI);
-
- nbytes = strlen(p);
- if (nbytes > 63)
- nbytes = 63;
-
- memcpy(addr, p, nbytes);
- addr[nbytes] = 0;
- return(0);
-}
-
-/*
-** 21:48
-**
-** allocate memory
-*/
-static int
-int21_48(regcontext_t *REGS)
-{
- int memseg,avail;
-
- memseg = mem_alloc(R_BX, pspseg, &avail);
-
- if (memseg == 0L) {
- R_BX = avail;
- return (INSUF_MEM);
- }
-
- R_AX = memseg;
- return(0);
-}
-
-/*
-** 21:49
-**
-** free memory
-*/
-static int
-int21_49(regcontext_t *REGS)
-{
- if (mem_adjust(R_ES, 0, NULL) < 0)
- return (MEM_BLK_ADDR_IVALID);
- return(0);
-}
-
-/*
-** 21:4a
-**
-** resize memory block
-*/
-static int
-int21_4a(regcontext_t *REGS)
-{
- int n,avail;
-
- if ((n = mem_adjust(R_ES, R_BX, &avail)) < 0) {
- R_BX = avail;
- if (n == -1)
- return (INSUF_MEM);
- else
- return (MEM_BLK_ADDR_IVALID);
- }
- return(0);
-}
-
-/*
-** 21:4b
-**
-** exec
-**
-** XXX verify!
-*/
-static int
-int21_4b(regcontext_t *REGS)
-{
- int fd;
- u_short *param;
-
- debug(D_EXEC, "exec(%s)\n",(u_char *)MAKEPTR(R_DS, R_DX));
-
- if ((fd = open_prog((u_char *)MAKEPTR(R_DS, R_DX))) < 0) {
- debug(D_EXEC, "%s: command not found\n",
- (u_char *)MAKEPTR(R_DS, R_DX));
- return (FILE_NOT_FOUND);
- }
-
- /* child */
- param = (u_short *)MAKEPTR(R_ES, R_BX);
-
- switch (R_AL) {
- case 0x00: /* load and execute */
- exec_command(REGS, 1, fd, cmdname, param);
- close(fd);
- break;
-
- case 0x01: /* just load */
- exec_command(REGS, 0, fd, cmdname, param);
- close(fd);
- break;
-
- case 0x03: /* load overlay */
- load_overlay(fd, param[0], param[1]);
- close(fd);
- break;
-
- default:
- unknown_int3(0x21, 0x4b, R_AL, REGS);
- return (FUNC_NUM_IVALID);
- }
- return(0);
-}
-
-/*
-** 21:4c
-**
-** return with code
-*/
-static int
-int21_4c(regcontext_t *REGS)
-{
- return_status = R_AL;
- done(REGS, R_AL);
- return 0;
-}
-
-/*
-** 21:4d
-**
-** get return code of child
-*/
-static int
-int21_4d(regcontext_t *REGS)
-{
- R_AX = return_status;
- return(0);
-}
-
-/*
-** 21:4e
-** 21:4f
-**
-** find first, find next
-*/
-static int
-int21_find(regcontext_t *REGS)
-{
- find_block_t *dta;
- dosdir_t dosdir;
- int error = 0;
-
- dta = (find_block_t *)VECPTR(disk_transfer_addr);
-
- switch (R_AH) {
- case 0x4e: /* find first */
- error = find_first((u_char *)MAKEPTR(R_DS, R_DX), R_CX, &dosdir, dta);
- break;
- case 0x4f:
- error = find_next(&dosdir, dta);
- break;
- default:
- fatal("called int21_find for unknown function %x\n",R_AH);
- }
- if (!error) {
- dosdir_to_dta(&dosdir, dta);
- R_AX = 0;
- }
- return(error);
-}
-
-/*
-** 21:50
-**
-** set PSP
-*/
-static int
-int21_50(regcontext_t *REGS)
-{
- pspseg = R_BX;
- return(0);
-}
-
-/*
-** 21:57:00
-**
-** get mtime for handle
-*/
-static int
-int21_57_0(regcontext_t *REGS)
-{
- struct stat sb;
- u_short date, mtime;
-
- if (fstat(R_BX, &sb) < 0)
- return (HANDLE_INVALID);
- encode_dos_file_time(sb.st_mtime, &date, &mtime);
- R_CX = mtime;
- R_DX = date;
- return(0);
-}
-
-/*
-** 21:57:01
-**
-** set mtime for handle
-*/
-static int
-int21_57_1(regcontext_t *REGS __unused)
-{
-#ifdef __NetBSD__ /* XXX need futimes() */
- struct stat sb;
- struct timeval tv[2];
- u_short date, time;
-
- time = R_CX;
- date = R_DX;
- tv[0].tv_sec = tv[1].tv_sec = decode_dos_file_time(date, time);
- tv[0].tv_usec = tv[1].tv_usec = 0;
- if (futimes(R_BX, tv) < 0)
- return (HANDLE_INVALID);
- break;
-#endif
- return(0);
-}
-
-/*
-** 21:58
-**
-** get/set memory strategy
-** get/set UMB link state
-*/
-static int
-int21_58(regcontext_t *REGS)
-{
- switch (R_AL) {
- case 0x00: /* get memory strategy */
- R_AX = memory_strategy;
- break;
- case 0x01: /* set memory strategy */
- memory_strategy = R_BL;
- if (memory_strategy > 2) /* higher make no sense without UMBs */
- memory_strategy = 2;
- break;
- case 0x02: /* get UMB link state */
- R_AL = 0; /* UMBs not in link chain */
- break;
- default: /* includes set, which is invalid */
- unknown_int3(0x21, 0x58, R_AL, REGS);
- return (FUNC_NUM_IVALID);
- }
- return(0);
-}
-
-/*
-** 21:59
-**
-** get extended error information
-*/
-static int
-int21_59(regcontext_t *REGS)
-{
- R_AX = doserrno;
- switch (doserrno) {
- case 1:
- case 6:
- case 9:
- case 10:
- case 11:
- case 12:
- case 13:
- case 15:
- R_BH = 7; /* application error */
- break;
-
- case 2:
- case 3:
- case 4:
- case 5:
- R_BH = 8; /* not found */
- break;
-
- case 7:
- case 8:
- R_BH = 1; /* out of resource */
- break;
-
- default:
- R_BH = 12; /* already exists */
- break;
- }
- R_BL = 6; /* always ignore! */
- R_CH = 1; /* unknown/inappropriate */
- return(0);
-}
-
-/*
-** 21:5a
-**
-** create temporary file
-*/
-static int
-int21_5a(regcontext_t *REGS)
-{
- char fname[PATH_MAX];
- char *pname;
- int error;
- int n;
- int drive;
- int fd;
-
- /* get and check proposed path */
- pname = (char *)MAKEPTR(R_DS, R_DX);
- error = translate_filename(pname, fname, &drive);
- if (error)
- return (error);
-
- debug(D_FILE_OPS, "tempname(%s)\n", fname);
-
- if (dos_readonly(drive))
- return (WRITE_PROT_DISK);
-
- n = strlen(fname);
- strcat(fname,"__dostmp.XXX");
- fd = mkstemp(fname);
- if (fd < 0)
- return (ACCESS_DENIED);
-
- strcat(pname, fname + n); /* give back the full name */
- R_AX = fd;
- return(0);
-}
-
-/*
-** 21:60
-**
-** canonicalise name
-*/
-static int
-int21_60(regcontext_t *REGS)
-{
- return(dos_makepath((char *)MAKEPTR(R_DS, R_SI),
- (char *)MAKEPTR(R_ES, R_DI)));
-}
-
-/*
-** 21:62
-**
-** get current PSP
-*/
-static int
-int21_62(regcontext_t *REGS)
-{
- R_BX = pspseg;
- return(0);
-}
-
-/*
-** 21:65:23
-**
-** determine yes/no
-** (mostly for humour value 8)
-*/
-static int
-int21_65_23(regcontext_t *REGS)
-{
- switch (R_DL) {
- case 'n': /* no, nein, non, nyet */
- case 'N':
- R_AX = 0;
- break;
- case 'y': /* yes */
- case 'Y':
- case 'j': /* ja */
- case 'J':
- case 'o': /* oui */
- case 'O':
- case 'd': /* da */
- case 'D':
- R_AX = 1;
- break;
- default: /* maybe */
- R_AX = 2;
- break;
- }
- return(0);
-}
-
-/*
-** 21:68
-** 21:6a
-**
-** fflush/commit file
-*/
-static int
-int21_fflush(regcontext_t *REGS)
-{
- debug(D_FILE_OPS, "fsync(%d)\n", R_BX);
-
- if (fsync(R_BX) < 0)
- return (HANDLE_INVALID);
- return(0);
-}
-
-/******************************************************************************
-** 21:0f 21:10 21:11 21:12 21:16 21:27 21:28:21:29
-**
-** FCB functions
-*/
-static void
-openfcb(struct fcb *fcbp)
-{
- struct stat statb;
-
- fcbp->fcbDriveID = 3; /* drive C */
- fcbp->fcbCurBlockNo = 0;
- fcbp->fcbRecSize = 128;
- if (fstat(fcbp->fcb_fd, &statb) < 0) {
- debug(D_FILE_OPS, "open not complete with errno %d\n", errno);
- return;
- }
- encode_dos_file_time(statb.st_mtime,
- &fcbp->fcbFileDate, &fcbp->fcbFileTime);
- fcbp->fcbFileSize = statb.st_size;
-}
-
-static int
-getfcb_rec(struct fcb *fcbp, int nrec)
-{
- int n;
-
- n = fcbp->fcbRandomRecNo;
- if (fcbp->fcbRecSize >= 64)
- n &= 0xffffff;
- fcbp->fcbCurRecNo = n % 128;
- fcbp->fcbCurBlockNo = n / 128;
- if (lseek(fcbp->fcb_fd, n * fcbp->fcbRecSize, SEEK_SET) < 0)
- return (-1);
- return (nrec * fcbp->fcbRecSize);
-}
-
-
-static int
-setfcb_rec(struct fcb *fcbp, int n)
-{
- int recs, total;
-
- total = fcbp->fcbRandomRecNo;
- if (fcbp->fcbRecSize >= 64)
- total &= 0xffffff;
- recs = (n+fcbp->fcbRecSize-1) / fcbp->fcbRecSize;
- total += recs;
-
- fcbp->fcbRandomRecNo = total;
- fcbp->fcbCurRecNo = total % 128;
- fcbp->fcbCurBlockNo = total / 128;
-
- return(0);
-}
-
-static void
-fcb_to_string(struct fcb *fcbp, u_char *buf)
-{
-
- if (fcbp->fcbDriveID != 0x00) {
- *buf++ = drntol(fcbp->fcbDriveID - 1);
- *buf++ = ':';
- }
- pack_name(fcbp->fcbFileName, buf);
-}
-
-
-static int
-int21_fcb(regcontext_t *REGS)
-{
- char buf[PATH_MAX];
- char fname[PATH_MAX];
- struct stat sb;
- dosdir_t dosdir;
- struct fcb *fcbp;
- find_block_t *dta;
- u_char *addr;
- int error;
- int drive;
- int fd;
- int nbytes,n;
-
-
- fcbp = (struct fcb *)MAKEPTR(R_DS, R_DX);
-
- switch (R_AH) {
-
- case 0x0f: /* open file with FCB */
- fcb_to_string(fcbp, buf);
- error = translate_filename(buf, fname, &drive);
- if (error)
- return (error);
-
- debug(D_FILE_OPS, "open FCB(%s)\n", fname);
-
- if (ustat(fname, &sb) < 0)
- sb.st_ino = 0;
-
- if (dos_readonly(drive))
- return (WRITE_PROT_DISK);
-
- if (sb.st_ino == 0 || S_ISDIR(sb.st_mode))
- return (FILE_NOT_FOUND);
-
- if ((fd = open(fname, O_RDWR)) < 0) {
- if (errno == ENOENT)
- return (FILE_NOT_FOUND);
- else
- return (ACCESS_DENIED);
- }
-
- fcbp->fcb_fd = fd;
- openfcb(fcbp);
- R_AL = 0;
- break;
-
- case 0x10: /* close file with FCB */
- debug(D_FILE_OPS, "close FCB(%d)\n", fcbp->fcb_fd);
-
- if (close(fcbp->fcb_fd) < 0)
- return (HANDLE_INVALID);
-
- fcbp->fcb_fd = -1;
- R_AL = 0;
- break;
-
- case 0x11: /* find_first with FCB */
- dta = (find_block_t *)VECPTR(disk_transfer_addr);
-
- fcb_to_string(fcbp, buf);
- error = find_first(buf, fcbp->fcbAttribute, &dosdir, dta);
- if (error)
- return (error);
-
- dosdir_to_dta(&dosdir, dta);
- R_AL = 0;
- break;
-
- case 0x12: /* find_next with FCB */
- dta = (find_block_t *)VECPTR(disk_transfer_addr);
-
- error = find_next(&dosdir, dta);
- if (error)
- return (error);
-
- dosdir_to_dta(&dosdir, dta);
- R_AL = 0;
- break;
-
- case 0x16: /* create file with FCB */
- fcb_to_string(fcbp, buf);
- error = translate_filename(buf, fname, &drive);
- if (error)
- return (error);
-
- debug(D_FILE_OPS, "creat FCB(%s)\n", fname);
-
- if (ustat(fname, &sb) < 0)
- sb.st_ino = 0;
-
- if (dos_readonly(drive))
- return (WRITE_PROT_DISK);
-
- if (sb.st_ino && !S_ISREG(sb.st_mode))
- return (ACCESS_DENIED);
-
- if ((fd = open(fname, O_CREAT|O_TRUNC|O_RDWR, 0666)) < 0)
- return (ACCESS_DENIED);
-
- fcbp->fcb_fd = fd;
- openfcb(fcbp);
- R_AL = 0;
- break;
-
- case 0x27: /* random block read */
- addr = (u_char *)VECPTR(disk_transfer_addr);
- nbytes = getfcb_rec(fcbp, R_CX);
-
- if (nbytes < 0)
- return (READ_FAULT);
- n = read(fcbp->fcb_fd, addr, nbytes);
- if (n < 0)
- return (READ_FAULT);
- R_CX = setfcb_rec(fcbp, n);
- if (n < nbytes) {
- nbytes = n % fcbp->fcbRecSize;
- if (0 == nbytes) {
- R_AL = 0x01;
- } else {
- bzero(addr + n, fcbp->fcbRecSize - nbytes);
- R_AL = 0x03;
- }
- } else {
- R_AL = 0;
- }
- break;
-
- case 0x28: /* random block write */
- addr = (u_char *)VECPTR(disk_transfer_addr);
- nbytes = getfcb_rec(fcbp, R_CX);
-
- if (nbytes < 0)
- return (WRITE_FAULT);
- n = write(fcbp->fcb_fd, addr, nbytes);
- if (n < 0)
- return (WRITE_FAULT);
- R_CX = setfcb_rec(fcbp, n);
- if (n < nbytes) {
- R_AL = 0x01;
- } else {
- R_AL = 0;
- }
- break;
-
- case 0x29: /* parse filename */
- debug(D_FILE_OPS,"parse filename: flag=%d, ", R_AL);
-
- R_AX = parse_filename(R_AL,
- (char *)MAKEPTR(R_DS, R_SI),
- (char *)MAKEPTR(R_ES, R_DI),
- &nbytes);
- debug(D_FILE_OPS, "%d %s, FCB: %d, %.11s\n",
- nbytes,
- (char *)MAKEPTR(R_DS, R_SI),
- *(int *)MAKEPTR(R_ES, R_DI),
- (char *)MAKEPTR(R_ES, R_DI) + 1);
-
- R_SI += nbytes;
- break;
-
- default:
- fatal("called int21_fcb with unknown function %x\n",R_AH);
- }
- return(0);
-}
-
-/*
-** 21:5d
-** 21:5e
-** 21:5f
-**
-** network functions
-** XXX relevant?
-*/
-static int
-int21_net(regcontext_t *REGS)
-{
- switch(R_AH) {
- case 0x5d:
- switch(R_AL) {
- case 0x06:
- debug(D_HALF, "Get Swapable Area\n");
- return (ACCESS_DENIED);
- case 0x08: /* Set redirected printer mode */
- debug(D_HALF, "Redirection is %s\n",
- R_DL ? "separate jobs" : "combined");
- break;
- case 0x09: /* Flush redirected printer output */
- break;
- default:
- unknown_int3(0x21, 0x5d, R_AL, REGS);
- return (FUNC_NUM_IVALID);
- }
- break;
-
- case 0x5e:
- case 0x5f:
- unknown_int2(0x21, R_AH, REGS);
- return (FUNC_NUM_IVALID);
- default:
- fatal("called int21_net with unknown function %x\n",R_AH);
- }
- return(0);
-}
-
-/*
-** 21:??
-**
-** Unknown/unsupported
-*/
-static int
-int21_NOFUNC(regcontext_t *REGS)
-{
- unknown_int2(0x21, R_AH, REGS);
- return (FUNC_NUM_IVALID);
-}
-
-/*
-** 21:??
-**
-** Null function; no error, no action
-*/
-static int
-int21_NULLFUNC(regcontext_t *REGS)
-{
- R_AL = 0;
- return(0);
-}
-
-
-static struct intfunc_table int21_table [] = {
- { 0x00, IFT_NOSUBFUNC, int21_00, "terminate"},
- { 0x01, IFT_NOSUBFUNC, int21_01, "read character with echo"},
- { 0x02, IFT_NOSUBFUNC, int21_02, "write char to stdout"},
- { 0x03, IFT_NOSUBFUNC, int21_NOFUNC, "read char from stdaux"},
- { 0x04, IFT_NOSUBFUNC, int21_NOFUNC, "write char to stdaux"},
- { 0x05, IFT_NOSUBFUNC, int21_NOFUNC, "write char to printer"},
- { 0x06, IFT_NOSUBFUNC, int21_06, "direct console I/O"},
- { 0x07, IFT_NOSUBFUNC, int21_07, "direct console in without echo"},
- { 0x08, IFT_NOSUBFUNC, int21_08, "read character, no echo"},
- { 0x09, IFT_NOSUBFUNC, int21_09, "write string to standard out"},
- { 0x0a, IFT_NOSUBFUNC, int21_0a, "buffered input"},
- { 0x0b, IFT_NOSUBFUNC, int21_0b, "get stdin status"},
- { 0x0c, IFT_NOSUBFUNC, int21_0c, "flush stdin and read"},
- { 0x0d, IFT_NOSUBFUNC, int21_NULLFUNC, "disk reset"},
- { 0x0e, IFT_NOSUBFUNC, int21_0e, "select default drive"},
- { 0x19, IFT_NOSUBFUNC, int21_19, "get default drive"},
- { 0x1a, IFT_NOSUBFUNC, int21_1a, "set DTA"},
- { 0x1b, IFT_NOSUBFUNC, int21_free, "get allocation for default drive"},
- { 0x1c, IFT_NOSUBFUNC, int21_free, "get allocation for specific drive"},
- { 0x1f, IFT_NOSUBFUNC, int21_NOFUNC, "get DPB for current drive"},
- { 0x23, IFT_NOSUBFUNC, int21_23, "Get file size (old)"},
- { 0x25, IFT_NOSUBFUNC, int21_25, "set interrupt vector"},
- { 0x26, IFT_NOSUBFUNC, int21_26, "create new PSP"},
- { 0x2a, IFT_NOSUBFUNC, int21_2a, "get date"},
- { 0x2b, IFT_NOSUBFUNC, int21_2b, "set date"},
- { 0x2c, IFT_NOSUBFUNC, int21_2c, "get time"},
- { 0x2d, IFT_NOSUBFUNC, int21_2d, "set time"},
- { 0x2e, IFT_NOSUBFUNC, int21_NULLFUNC, "set verify flag"},
- { 0x2f, IFT_NOSUBFUNC, int21_2f, "get DTA"},
- { 0x30, IFT_NOSUBFUNC, int21_30, "get DOS version"},
- { 0x31, IFT_NOSUBFUNC, int21_NOFUNC, "terminate and stay resident"},
- { 0x32, IFT_NOSUBFUNC, int21_NOFUNC, "get DPB for specific drive"},
- { 0x33, 0x05, int21_33_5, "get boot drive"},
- { 0x33, 0x06, int21_33_6, "get true version number"},
- { 0x33, IFT_NOSUBFUNC, int21_33, "extended break checking"},
- { 0x34, IFT_NOSUBFUNC, int21_34, "get address of InDos flag"},
- { 0x35, IFT_NOSUBFUNC, int21_35, "get interrupt vector"},
- { 0x36, IFT_NOSUBFUNC, int21_free, "get disk free space"},
- { 0x37, IFT_NOSUBFUNC, int21_37, "switch character"},
- { 0x38, IFT_NOSUBFUNC, int21_38, "country code/information"},
- { 0x39, IFT_NOSUBFUNC, int21_dirfn, "mkdir"},
- { 0x3a, IFT_NOSUBFUNC, int21_dirfn, "rmdir"},
- { 0x3b, IFT_NOSUBFUNC, int21_3b, "chdir"},
- { 0x3c, IFT_NOSUBFUNC, int21_open, "creat"},
- { 0x3d, IFT_NOSUBFUNC, int21_open, "open"},
- { 0x3e, IFT_NOSUBFUNC, int21_3e, "close"},
- { 0x3f, IFT_NOSUBFUNC, int21_3f, "read"},
- { 0x40, IFT_NOSUBFUNC, int21_40, "write"},
- { 0x41, IFT_NOSUBFUNC, int21_dirfn, "unlink"},
- { 0x42, IFT_NOSUBFUNC, int21_42, "lseek"},
- { 0x43, IFT_NOSUBFUNC, int21_43, "get/set file attributes"},
- { 0x44, 0x00, int21_44_0, "ioctl(get)"},
- { 0x44, 0x01, int21_44_1, "ioctl(set)"},
- { 0x44, 0x07, int21_44_7, "ioctl(Check output status)"},
- { 0x44, 0x08, int21_44_8, "ioctl(test removable)"},
- { 0x44, 0x09, int21_44_9, "ioctl(test remote)"},
- { 0x45, IFT_NOSUBFUNC, int21_45, "dup"},
- { 0x46, IFT_NOSUBFUNC, int21_46, "dup2"},
- { 0x47, IFT_NOSUBFUNC, int21_47, "getwd"},
- { 0x48, IFT_NOSUBFUNC, int21_48, "allocate memory"},
- { 0x49, IFT_NOSUBFUNC, int21_49, "free memory"},
- { 0x4a, IFT_NOSUBFUNC, int21_4a, "resize memory block"},
- { 0x4b, IFT_NOSUBFUNC, int21_4b, "exec"},
- { 0x4c, IFT_NOSUBFUNC, int21_4c, "exit with return code"},
- { 0x4d, IFT_NOSUBFUNC, int21_4d, "get return code from child"},
- { 0x4e, IFT_NOSUBFUNC, int21_find, "findfirst"},
- { 0x4f, IFT_NOSUBFUNC, int21_find, "findnext"},
- { 0x50, IFT_NOSUBFUNC, int21_50, "set psp"},
- { 0x51, IFT_NOSUBFUNC, int21_62, "get psp"},
- { 0x52, IFT_NOSUBFUNC, int21_NOFUNC, "get LoL"},
- { 0x53, IFT_NOSUBFUNC, int21_NOFUNC, "translate BPB to DPB"},
- { 0x54, IFT_NOSUBFUNC, int21_NULLFUNC, "get verify flag"},
- { 0x55, IFT_NOSUBFUNC, int21_NOFUNC, "create PSP"},
- { 0x56, IFT_NOSUBFUNC, int21_dirfn, "rename"},
- { 0x57, 0x00, int21_57_0, "get mtime"},
- { 0x57, 0x01, int21_57_1, "set mtime"},
- { 0x58, IFT_NOSUBFUNC, int21_58, "get/set memory strategy"},
- { 0x59, IFT_NOSUBFUNC, int21_59, "get extended error information"},
- { 0x5a, IFT_NOSUBFUNC, int21_5a, "create temporary file"},
- { 0x5b, IFT_NOSUBFUNC, int21_open, "create new file"},
- { 0x5c, IFT_NOSUBFUNC, int21_NOFUNC, "flock"},
- { 0x5d, IFT_NOSUBFUNC, int21_net, "network functions"},
- { 0x5e, IFT_NOSUBFUNC, int21_net, "network functions"},
- { 0x5f, IFT_NOSUBFUNC, int21_net, "network functions"},
- { 0x60, IFT_NOSUBFUNC, int21_60, "canonicalise name/path"},
- { 0x61, IFT_NOSUBFUNC, int21_NULLFUNC, "network functions (reserved)"},
- { 0x62, IFT_NOSUBFUNC, int21_62, "get current PSP"},
- { 0x63, IFT_NOSUBFUNC, int21_NOFUNC, "get DBCS lead-byte table"},
- { 0x64, IFT_NOSUBFUNC, int21_NOFUNC, "set device-driver lookahead"},
- { 0x65, 0x23, int21_65_23, "determine yes/no"},
- { 0x65, IFT_NOSUBFUNC, int21_NOFUNC, "get extended country information"},
- { 0x66, IFT_NOSUBFUNC, int21_NOFUNC, "get/set codepage table"},
- { 0x67, IFT_NOSUBFUNC, int21_NULLFUNC, "set handle count"},
- { 0x68, IFT_NOSUBFUNC, int21_fflush, "fflush"},
- { 0x69, IFT_NOSUBFUNC, int21_NOFUNC, "get/set disk serial number"},
- { 0x6a, IFT_NOSUBFUNC, int21_fflush, "commit file"},
- { 0x6b, IFT_NOSUBFUNC, int21_NULLFUNC, "IFS ioctl"},
- { 0x6c, IFT_NOSUBFUNC, int21_open, "extended open/create"},
-
-/* FCB functions */
- { 0x0f, IFT_NOSUBFUNC, int21_fcb, "open file"},
- { 0x10, IFT_NOSUBFUNC, int21_fcb, "close file"},
- { 0x11, IFT_NOSUBFUNC, int21_fcb, "find first"},
- { 0x12, IFT_NOSUBFUNC, int21_fcb, "find next"},
- { 0x13, IFT_NOSUBFUNC, int21_NOFUNC, "delete"},
- { 0x14, IFT_NOSUBFUNC, int21_NOFUNC, "sequential read"},
- { 0x15, IFT_NOSUBFUNC, int21_NOFUNC, "sequential write"},
- { 0x16, IFT_NOSUBFUNC, int21_fcb, "create/truncate"},
- { 0x17, IFT_NOSUBFUNC, int21_NOFUNC, "rename"},
- { 0x21, IFT_NOSUBFUNC, int21_NOFUNC, "read random"},
- { 0x22, IFT_NOSUBFUNC, int21_NOFUNC, "write random"},
- { 0x23, IFT_NOSUBFUNC, int21_NOFUNC, "get file size"},
- { 0x24, IFT_NOSUBFUNC, int21_NOFUNC, "set random record number"},
- { 0x27, IFT_NOSUBFUNC, int21_fcb, "random block read"},
- { 0x28, IFT_NOSUBFUNC, int21_fcb, "random block write"},
- { 0x29, IFT_NOSUBFUNC, int21_fcb, "parse filename into FCB"},
-
-/* CPM compactability */
- { 0x18, IFT_NOSUBFUNC, int21_NULLFUNC, "CPM"},
- { 0x1d, IFT_NOSUBFUNC, int21_NULLFUNC, "CPM"},
- { 0x1e, IFT_NOSUBFUNC, int21_NULLFUNC, "CPM"},
- { 0x20, IFT_NOSUBFUNC, int21_NULLFUNC, "CPM"},
-
- { -1, IFT_NOSUBFUNC, NULL, NULL} /* terminator */
-
-};
-
-static int int21_fastlookup[256];
-
-const char *dos_return[] = {
- "OK",
- "FUNC_NUM_IVALID",
- "FILE_NOT_FOUND",
- "PATH_NOT_FOUND",
- "TOO_MANY_OPEN_FILES",
- "ACCESS_DENIED",
- "HANDLE_INVALID",
- "MEM_CB_DEST",
- "INSUF_MEM",
- "MEM_BLK_ADDR_IVALID",
- "ENV_INVALID",
- "FORMAT_INVALID",
- "ACCESS_CODE_INVALID",
- "DATA_INVALID",
- "UNKNOWN_UNIT",
- "DISK_DRIVE_INVALID",
- "ATT_REM_CUR_DIR",
- "NOT_SAME_DEV",
- "NO_MORE_FILES",
- "WRITE_PROT_DISK",
- "UNKNOWN_UNIT_CERR",
- "DRIVE_NOT_READY",
- "UNKNOWN_COMMAND",
- "DATA_ERROR_CRC",
- "BAD_REQ_STRUCT_LEN",
- "SEEK_ERROR",
- "UNKNOWN_MEDIA_TYPE",
- "SECTOR_NOT_FOUND",
- "PRINTER_OUT_OF_PAPER",
- "WRITE_FAULT",
- "READ_FAULT",
- "GENERAL_FAILURE"
-};
-
-const int dos_ret_size = (sizeof(dos_return) / sizeof(char *));
-
-/*
-** for want of anywhere better to go
-*/
-static void
-int20(regcontext_t *REGS)
-{
- /* int 20 = exit(0) */
- done(REGS, 0);
-}
-
-static void
-int29(regcontext_t *REGS)
-{
- tty_write(R_AL, TTYF_REDIRECT);
-}
-
-/******************************************************************************
-** entrypoint for MS-DOS functions
-*/
-static void
-int21(regcontext_t *REGS)
-{
- int error;
- int idx;
-
- /* look for a handler */
- idx = intfunc_find(int21_table, int21_fastlookup, R_AH, R_AL);
-
- if (idx == -1) { /* no matching functions */
- unknown_int3(0x21, R_AH, R_AL, REGS);
- R_FLAGS |= PSL_C; /* Flag an error */
- R_AX = 0xff;
- return;
- }
-
- /* call the handler */
- error = int21_table[idx].handler(REGS);
- debug(D_DOSCALL, "msdos call %02x (%s) returns %d (%s)\n",
- int21_table[idx].func, int21_table[idx].desc, error,
- ((error >= 0) && (error <= dos_ret_size)) ? dos_return[error] : "unknown");
-
- if (error) {
- doserrno = error;
- R_FLAGS |= PSL_C;
-
- /* XXX is this entirely legitimate? */
- if (R_AH >= 0x2f)
- R_AX = error;
- else
- R_AX = 0xff;
- } else {
- R_FLAGS &= ~PSL_C;
- }
- return;
-}
-
-static void
-int67(regcontext_t *REGS)
-{
- ems_entry(REGS);
-}
-
-static u_char upcase_trampoline[] = {
- 0xf4, /* HLT */
- 0xcb, /* RETF */
-};
-
-/*
-** initialise thyself
-*/
-void
-dos_init(void)
-{
- u_long vec;
-
- /* hook vectors */
- vec = insert_softint_trampoline();
- ivec[0x20] = vec;
- register_callback(vec, int20, "int 20");
-
- vec = insert_softint_trampoline();
- ivec[0x21] = vec;
- register_callback(vec, int21, "int 21");
-
- vec = insert_softint_trampoline();
- ivec[0x29] = vec;
- register_callback(vec, int29, "int 29");
-
- vec = insert_softint_trampoline();
- ivec[0x67] = vec;
- register_callback(vec, int67, "int 67 (EMS)");
-
- vec = insert_null_trampoline();
- ivec[0x28] = vec; /* dos idle */
- ivec[0x2b] = vec; /* reserved */
- ivec[0x2c] = vec; /* reserved */
- ivec[0x2d] = vec; /* reserved */
-
- upcase_vector = insert_generic_trampoline(
- sizeof(upcase_trampoline), upcase_trampoline);
- register_callback(upcase_vector, upcase_entry, "upcase");
-
- /* build fastlookup index into the monster table of interrupts */
- intfunc_init(int21_table, int21_fastlookup);
-
- ems_init();
-}
+++ /dev/null
-/*
- * 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 dos.h,v 2.2 1996/04/08 19:32:28 bostic Exp
- *
- * $FreeBSD: src/usr.bin/doscmd/dos.h,v 1.2.2.1 2002/04/25 11:04:51 tg Exp $
- * $DragonFly: src/usr.bin/doscmd/dos.h,v 1.3 2008/10/03 19:56:11 swildner Exp $
- */
-
-/*
- * DOS Error codes
- */
-/* MS-DOS version 2 error codes */
-#define FUNC_NUM_IVALID 0x01
-#define FILE_NOT_FOUND 0x02
-#define PATH_NOT_FOUND 0x03
-#define TOO_MANY_OPEN_FILES 0x04
-#define ACCESS_DENIED 0x05
-#define HANDLE_INVALID 0x06
-#define MEM_CB_DEST 0x07
-#define INSUF_MEM 0x08
-#define MEM_BLK_ADDR_IVALID 0x09
-#define ENV_INVALID 0x0a
-#define FORMAT_INVALID 0x0b
-#define ACCESS_CODE_INVALID 0x0c
-#define DATA_INVALID 0x0d
-#define UNKNOWN_UNIT 0x0e
-#define DISK_DRIVE_INVALID 0x0f
-#define ATT_REM_CUR_DIR 0x10
-#define NOT_SAME_DEV 0x11
-#define NO_MORE_FILES 0x12
-/* mappings to critical-error codes */
-#define WRITE_PROT_DISK 0x13
-#define UNKNOWN_UNIT_CERR 0x14
-#define DRIVE_NOT_READY 0x15
-#define UNKNOWN_COMMAND 0x16
-#define DATA_ERROR_CRC 0x17
-#define BAD_REQ_STRUCT_LEN 0x18
-#define SEEK_ERROR 0x19
-#define UNKNOWN_MEDIA_TYPE 0x1a
-#define SECTOR_NOT_FOUND 0x1b
-#define PRINTER_OUT_OF_PAPER 0x1c
-#define WRITE_FAULT 0x1d
-#define READ_FAULT 0x1e
-#define GENERAL_FAILURE 0x1f
-
-/* MS-DOS version 3 and later extended error codes */
-#define SHARING_VIOLATION 0x20
-#define FILE_LOCK_VIOLATION 0x21
-#define DISK_CHANGE_INVALID 0x22
-#define FCB_UNAVAILABLE 0x23
-#define SHARING_BUF_EXCEEDED 0x24
-
-#define NETWORK_NAME_NOT_FOUND 0x35
-
-#define FILE_ALREADY_EXISTS 0x50
-
-#define DUPLICATE_REDIR 0x55
-
-/*
- * dos attribute byte flags
- */
-#define REGULAR_FILE 0x00
-#define READ_ONLY_FILE 0x01
-#define HIDDEN_FILE 0x02
-#define SYSTEM_FILE 0x04
-#define VOLUME_LABEL 0x08
-#define DIRECTORY 0x10
-#define ARCHIVE_NEEDED 0x20
-
-/*
- * Internal structure used for get_space()
- */
-typedef struct {
- long bytes_sector;
- long sectors_cluster;
- long total_clusters;
- long avail_clusters;
-} fsstat_t;
-
-/*
- * Several DOS structures used by the file redirector
- */
-
-typedef struct {
- DIR *dp;
- u_char *searchend;
- u_char searchdir[1024];
-} search_t;
-
-/*
- * This is really the format of the DTA. The file redirector will only
- * use the first 21 bytes.
- */
-typedef struct {
- u_char drive;
- u_char pattern[11];
- u_char flag;
- u_char reserved1[4];
- search_t *searchptr;
- u_char attr;
- u_short time;
- u_short date;
- u_long size;
- u_char name[13];
-} __packed find_block_t;
-
-/*
- * DOS directory entry structure
- */
-typedef struct {
- u_char name[8];
- u_char ext[3];
- u_char attr;
- u_char reserved[10];
- u_short time;
- u_short date;
- u_short start;
- u_long size;
-} __packed dosdir_t;
-
-/*
- * The Current Drive Structure
- */
-typedef struct {
- u_char path[0x43];
- u_short flag;
- u_short dpb_off;
- u_short dpb_seg;
- u_short redirector_off;
- u_short redirector_seg;
- u_char paramter_int21[2];
- u_short offset;
- u_char dummy;
- u_char ifs_driver[4];
- u_char dummy2[2];
-} __packed CDS;
-
-#define CDS_remote 0x8000
-#define CDS_ready 0x4000
-#define CDS_joined 0x2000
-#define CDS_substed 0x1000
-
-#define CDS_notnet 0x0080
-
-/*
- * The List of Lists (used to get the CDS and a few other numbers)
- */
-typedef struct {
- u_char dummy1[0x16];
- u_short cds_offset;
- u_short cds_seg;
- u_char dummy2[6];
- u_char numberbdev;
- u_char lastdrive;
-} __packed LOL;
-
-/*
- * The System File Table
- */
-typedef struct {
-/*00*/ u_short nfiles; /* Number file handles referring to this file */
-/*02*/ u_short open_mode; /* Open mode (bit 15 -> by FCB) */
-/*04*/ u_char attribute;
-/*05*/ u_short info; /* 15 -> remote, 14 -> dont set date */
-/*07*/ u_char ddr_dpb[4]; /* Device Driver Header/Drive Paramter Block */
-/*0b*/ u_short fd;
-/*0d*/ u_short time;
-/*0f*/ u_short date;
-/*11*/ u_long size;
-/*15*/ u_long offset;
-/*19*/ u_short rel_cluster;
-/*1b*/ u_short abs_cluster;
-/*1d*/ u_char dir_sector[2];
-/*1f*/ u_char dir_entry;
-/*20*/ u_char name[8];
-/*28*/ u_char ext[3];
-/*2b*/ u_char sharesft[4];
-/*2f*/ u_char sharenet[2];
-/*31*/ u_short psp;
-/*33*/ u_char share_off[2];
-/*35*/ u_char local_end[2];
-/*37*/ u_char ifd_driver[4];
-} __packed SFT;
-
-/*
- * Format of PCDOS 4.01 swappable data area
- * (Sorry, but you need a wide screen to make this look nice)
- */
-typedef struct {
- u_char err_crit; /* 00h BYTE critical error flag */
- u_char InDOS; /* 01h BYTE InDOS flag (count of active INT 21 calls) */
- u_char err_drive; /* 02h BYTE ??? drive number or FFh */
- u_char err_locus; /* 03h BYTE locus of last error */
- u_short err_code; /* 04h WORD extended error code of last error */
- u_char err_suggest; /* 06h BYTE suggested action for last error */
- u_char err_class; /* 07h BYTE class of last error */
- u_short err_di;
- u_short err_es; /* 08h DWORD ES:DI pointer for last error */
- u_short dta_off;
- u_short dta_seg; /* 0Ch DWORD current DTA */
- u_short psp; /* 10h WORD current PSP */
- u_short int_23_sp; /* 12h WORD stores SP across an INT 23 */
- u_short wait_status; /* 14h WORD return code from last process termination (zerod after reading with AH=4Dh) */
- u_char current_drive; /* 16h BYTE current drive */
- u_char break_flag; /* 17h BYTE extended break flag */
- u_char unknown1[2]; /* 18h 2 BYTEs ??? */
- u_short int_21_ax; /* 1Ah WORD value of AX on call to INT 21 */
- u_short net_psp; /* 1Ch WORD PSP segment for sharing/network */
- u_short net_number; /* 1Eh WORD network machine number for sharing/network (0000h = us) */
- u_short first_mem; /* 20h WORD first usable memory block found when allocating memory */
- u_short best_mem; /* 22h WORD best usable memory block found when allocating memory */
- u_short last_mem; /* 24h WORD last usable memory block found when allocating memory */
- u_char unknown[10]; /* 26h 2 BYTEs ??? (don't seem to be referenced) */
- u_char monthday; /* 30h BYTE day of month */
- u_char month; /* 31h BYTE month */
- u_short year; /* 32h WORD year - 1980 */
- u_short days; /* 34h WORD number of days since 1-1-1980 */
- u_char weekday; /* 36h BYTE day of week (0 = Sunday) */
- u_char unknown2[3]; /* 37h BYTE ??? */
- u_char ddr_head[30]; /* 38h 30 BYTEs device driver request header */
- u_short ddre_ip;
- u_short ddre_cs; /* 58h DWORD pointer to device driver entry point (used in calling driver) */
- u_char ddr_head2[22]; /* 5Ch 22 BYTEs device driver request header */
- u_char ddr_head3[30]; /* 72h 30 BYTEs device driver request header */
- u_char unknown3[6]; /* 90h 6 BYTEs ??? */
- u_char clock_xfer[6]; /* 96h 6 BYTEs CLOCK$ transfer record (see AH=52h) */
- u_char unknown4[2]; /* 9Ch 2 BYTEs ??? */
- u_char filename1[128]; /* 9Eh 128 BYTEs buffer for filename */
- u_char filename2[128]; /* 11Eh 128 BYTEs buffer for filename */
- u_char findfirst[21]; /* 19Eh 21 BYTEs findfirst/findnext search data block (see AH=4Eh) */
- u_char foundentry[32]; /* 1B3h 32 BYTEs directory entry for found file */
- u_char cds[88]; /* 1D3h 88 BYTEs copy of current directory structure for drive being accessed */
- u_char fcbname[11]; /* 22Bh 11 BYTEs ??? FCB-format filename */
- u_char unknown5; /* 236h BYTE ??? */
- u_char wildcard[11]; /* 237h 11 BYTEs wildcard destination specification for rename (FCB format) */
- u_char unknown6[11]; /* 242h 2 BYTEs ??? */
- u_char attrmask; /* 24Dh BYTE attribute mask for directory search??? */
- u_char open_mode; /* 24Eh BYTE open mode */
- u_char unknown7[3]; /* 24fh BYTE ??? */
- u_char virtual_dos; /* 252h BYTE flag indicating how DOS function was invoked (00h = direct INT 20/INT 21, FFh = server call AX=5D00h) */
- u_char unknown8[9]; /* 253h BYTE ??? */
- u_char term_type; /* 25Ch BYTE type of process termination (00h-03h) */
- u_char unknown9[3]; /* 25Dh BYTE ??? */
- u_short dpb_off;
- u_short dpb_seg; /* 260h DWORD pointer to Drive Parameter Block for critical error invocation */
- u_short int21_sf_off;
- u_short int21_sf_seg; /* 264h DWORD pointer to stack frame containing user registers on INT 21 */
- u_short store_sp; /* 268h WORD stores SP??? */
- u_short dosdpb_off;
- u_short dosdpb_seg; /* 26Ah DWORD pointer to DOS Drive Parameter Block for ??? */
- u_short disk_buf_seg; /* 26Eh WORD segment of disk buffer */
- u_short unknown10[4]; /* 270h WORD ??? */
- u_char media_id; /* 278h BYTE Media ID byte returned by AH=1Bh,1Ch */
- u_char unknown11; /* 279h BYTE ??? (doesn't seem to be referenced) */
- u_short unknown12[2]; /* 27Ah DWORD pointer to ??? */
- u_short sft_off;
- u_short sft_seg; /* 27Eh DWORD pointer to current SFT */
- u_short cds_off;
- u_short cds_seg; /* 282h DWORD pointer to current directory structure for drive being accessed */
- u_short fcb_off;
- u_short fcb_seg; /* 286h DWORD pointer to caller's FCB */
- u_short unknown13[2]; /* 28Ah WORD ??? */
- u_short jft_off;
- u_short jft_seg; /* 28Eh DWORD pointer to a JFT entry in process handle table (see AH=26h) */
- u_short filename1_off; /* 292h WORD offset in DOS CS of first filename argument */
- u_short filename2_off; /* 294h WORD offset in DOS CS of second filename argument */
- u_short unknown14[12]; /* 296h WORD ??? */
- u_short file_offset_lo;
- u_short file_offset_hi; /* 2AEh DWORD offset in file??? */
- u_short unknown15; /* 2B2h WORD ??? */
- u_short partial_bytes; /* 2B4h WORD bytes in partial sector */
- u_short number_sectors; /* 2B6h WORD number of sectors */
- u_short unknown16[3]; /* 2B8h WORD ??? */
- u_short nbytes_lo;
- u_short nbytes_hi; /* 2BEh DWORD number of bytes appended to file */
- u_short qpdb_off;
- u_short qpdb_seg; /* 2C2h DWORD pointer to ??? disk buffer */
- u_short asft_off;
- u_short asft_seg; /* 2C6h DWORD pointer to ??? SFT */
- u_short int21_bx; /* 2CAh WORD used by INT 21 dispatcher to store caller's BX */
- u_short int21_ds; /* 2CCh WORD used by INT 21 dispatcher to store caller's DS */
- u_short temporary; /* 2CEh WORD temporary storage while saving/restoring caller's registers */
- u_short prevcall_off;
- u_short prevcall_seg; /* 2D0h DWORD pointer to prev call frame (offset 264h) if INT 21 reentered also switched to for duration of INT 24 */
- u_char unknown17[9]; /* 2D4h WORD ??? */
- u_short ext_action; /* 2DDh WORD multipurpose open action */
- u_short ext_attr; /* 2DFh WORD multipurpose attribute */
- u_short ext_mode; /* 2E1h WORD multipurpose mode */
- u_char unknown17a[9];
- u_short lol_ds; /* 2ECh WORD stores DS during call to [List-of-Lists + 37h] */
- u_char unknown18[5]; /* 2EEh WORD ??? */
- u_char usernameptr[4]; /* 2F3h DWORD pointer to user-supplied filename */
- u_char unknown19[4]; /* 2F7h DWORD pointer to ??? */
- u_char lol_ss[2]; /* 2FBh WORD stores SS during call to [List-of-Lists + 37h] */
- u_char lol_sp[2]; /* 2FDh WORD stores SP during call to [List-of-Lists + 37h] */
- u_char lol_flag; /* 2FFh BYTE flag, nonzero if stack switched in calling [List-of-Lists+37h] */
- u_char searchdata[21]; /* 300h 21 BYTEs FindFirst search data for source file(s) of a rename operation (see AH=4Eh) */
- u_char renameentry[32];/* 315h 32 BYTEs directory entry for file being renamed */
- u_char errstack[331]; /* 335h 331 BYTEs critical error stack */
- u_char diskstack[384]; /* 480h 384 BYTEs disk stack (functions greater than 0Ch, INT 25, INT 26) */
- u_char iostack[384]; /* 600h 384 BYTEs character I/O stack (functions 01h through 0Ch) */
- u_char int_21_08_flag; /* 780h BYTE flag affecting AH=08h (see AH=64h) */
- u_char unknown20[11]; /* 781h BYTE ??? looks like a drive number */
-} __packed SDA;
-
-struct exehdr {
- u_short magic;
- u_short bytes_on_last_page;
- u_short size; /* 512 byte blocks */
- u_short nreloc;
- u_short hdr_size; /* paragraphs */
- u_short min_memory; /* paragraphs */
- u_short max_memory; /* pargraphs */
- u_short init_ss;
- u_short init_sp;
- u_short checksum;
- u_short init_ip;
- u_short init_cs;
- u_short reloc_offset;
- u_short overlay_num;
-};
-
-struct reloc_entry {
- u_short off;
- u_short seg;
-};
-
-
-/*
-** DOS-related shrapnel
-*/
-
-static inline int
-from_dos_attr(int attr)
-{
- return((attr & READ_ONLY_FILE) ? 0444 : 0666);
-}
-
-static inline int
-to_dos_attr(int mode)
-{
- int attr;
-
- attr = (mode & 0200) ? 0:READ_ONLY_FILE;
- attr |= S_ISDIR(mode) ? DIRECTORY:0;
- return(attr);
-}
-
-/* prototypes */
-
-extern const char *dos_return[]; /* names of DOS return codes */
-extern const int dos_ret_size; /* length of above */
-extern char *InDOS;
-extern int diskdrive; /* current drive */
-unsigned long disk_transfer_addr;
-
-extern void encode_dos_file_time (time_t, u_short *, u_short *);
-extern time_t decode_dos_file_time(u_short dosdate, u_short dostime);
-extern int translate_filename(u_char *dname, u_char *uname, int *drivep);
-extern int parse_filename(int flag, char *str, char *fcb, int *nb);
-extern void dos_init(void);
-
-/* from exe.c */
-extern int pspseg; /* segment # of PSP */
-extern int curpsp;
-
-extern void exec_command(regcontext_t *REGS, int run, int fd, char *cmdname, u_short *param);
-extern void load_overlay(int fd, int start_segment, int reloc_segment);
-extern void load_command(regcontext_t *REGS, int run, int fd, char *cmdname,
- u_short *param, char **argv, char **envs);
-extern void exec_return(regcontext_t *REGS, int code);
-extern int get_env(void);
+++ /dev/null
-.\"
-.\" 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: src/usr.bin/doscmd/doscmd.1,v 1.12.2.11 2002/06/20 23:45:41 charnier Exp $
-.\"
-.Dd January 30, 1995
-.Dt DOSCMD 1
-.Os
-.Sh NAME
-.Nm doscmd
-.Nd run a subset of real-mode DOS programs
-.Sh SYNOPSIS
-.Nm
-.Fl 23AbDEfGHIMOPRrtVvXxYz
-.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 Op Ar args ...
-.Sh DESCRIPTION
-The
-.Nm
-utility 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 .
-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
-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
-are:
-.Bl -tag -width indent
-.It Fl 2
-Enable debugging traces of every trap to the
-.Nm
-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 G
-Enable debugging of the video (graphics) 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
-to pause just prior to jumping to the DOS program.
-Very little use except for developing
-.Nm .
-.El
-.Pp
-When starting up,
-.Nm
-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
-.Bsx
-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.
-Its 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"
-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 .
-Note that
-.Nm
-will not change the way
-it works, just the way it reports. By default this value is
-.Cm 410 ,
-which corresponds to
-.Tn "MS-DOS"
-version 4.1.
-To change it to version 3.2 (the default in previous versions of
-.Nm )
-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.
-.El
-.Sh FILE TRANSLATION
-The
-.Nm
-utility translates
-.Bsx
-file names into
-.Tn 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 unix2dos 1
-(part of the
-.Xr pkgsrc 7
-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
-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.,
-.Dq 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
-.Dx
-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
-If
-.Nm
-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 HISTORY
-The
-.Nm
-program first appeared in
-.Tn BSD/386 .
-.Sh AUTHORS
-.An Pace Willisson ,
-.An Paul Borman
+++ /dev/null
-/*
- * 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.c,v 2.3 1996/04/08 19:32:30 bostic Exp
- *
- * $FreeBSD: src/usr.bin/doscmd/doscmd.c,v 1.13.2.6 2002/04/25 11:04:51 tg Exp $
- */
-
-#include <sys/types.h>
-#include <sys/param.h>
-#include <sys/mman.h>
-#include <sys/time.h>
-
-#include <ctype.h>
-#include <err.h>
-#include <errno.h>
-#include <limits.h>
-#include <paths.h>
-#include <pwd.h>
-#include <signal.h>
-#include <unistd.h>
-
-#include <machine/param.h>
-#include <machine/vmparam.h>
-
-#include <machine/sysarch.h>
-#include <machine/vm86.h>
-
-#include "doscmd.h"
-#include "cwd.h"
-#include "trap.h"
-#include "tty.h"
-#include "video.h"
-
-/* exports */
-int capture_fd = -1;
-int dead = 0;
-int xmode = 0;
-int booting = 0;
-int raw_kbd = 0;
-int timer_disable = 0;
-struct timeval boot_time;
-unsigned long *ivec = NULL;
-
-#ifndef USE_VM86
-#define PRB_V86_FORMAT 0x4242
-
-struct vconnect_area vconnect_area = {
- 0, /* Interrupt state */
- PRB_V86_FORMAT, /* Magic number */
- { 0, }, /* Pass through ints */
- { 0x00000000, 0x00000000 } /* Magic iret location */
-};
-#endif
-
-/* local prototypes */
-static void setup_boot(regcontext_t *REGS);
-static int try_boot(int);
-static void setup_command(int argc, char *argv[], regcontext_t *REGS);
-static FILE *find_doscmdrc(void);
-static int do_args(int argc, char *argv[]);
-static void usage(void);
-static int open_name(char *name, char *ext);
-
-/* Local option flags &c. */
-static int zflag = 0;
-
-/* DOS environment emulation */
-static unsigned ecnt = 0;
-static char *envs[256];
-
-/* Search path and command name */
-static char *dos_path = NULL;
-char cmdname[256]; /* referenced from dos.c */
-
-static struct vm86_init_args kargs;
-
-/* lobotomise */
-int
-main(int argc, char **argv)
-{
-#ifndef USE_VM86
- ucontext_t uc;
-#else
- struct vm86_struct vm86s;
-#define sc vm86s.substr.regs.vmsc
-#endif
- regcontext_t *REGS = (regcontext_t *)&uc.uc_mcontext;
- int fd;
- int i;
- sigset_t sigset;
-
- sigemptyset(&sigset);
- sigaddset(&sigset, SIGIO);
- sigaddset(&sigset, SIGALRM);
- sigprocmask(SIG_BLOCK, &sigset, 0);
-
- init_ints();
-
- debugf = stderr;
- /* XXX should only be for tty mode */
- fd = open (_PATH_DEVNULL, O_RDWR);
- if (fd != 3)
- dup2 (fd, 3); /* stdaux */
- if (fd != 4)
- dup2 (fd, 4); /* stdprt */
- if (fd != 3 && fd != 4)
- close (fd);
- fd = -1;
-
- debug_set(0); /* debug any D_TRAPS without intnum */
-
- /* perform option argument processing */
- do_args(argc, argv);
- argc -= optind;
- argv += optind;
-
- if (vflag && debugf == stderr) {
- debugf = stdout;
- setbuf (stdout, NULL);
- }
-
- initHMA();
-
- /* This needs to happen before the executable is loaded */
- mem_init();
-
-#ifdef USE_VM86
- memset(&vm86s, 0, sizeof(vm86s));
-#endif
-
- /*
- * With no other arguments we will assume we must boot DOS
- */
- if (argc <= 0)
- booting = 1;
-
-#if 1
- /*
- * Nominate interrupts to handle here when the kernel is
- * performing interrupt handling.
- *
- * I would like to let INT 2F pass through as well, but I
- * need to get my hands on INT 2F:11 to do file redirection.
- */
- for (i = 0; i <= 0xff; ++i) {
- switch (i) {
- case 0x2f:
- case 0xff:
-#if 1
- kargs.int_map[i >> 3] |= (1 << (i & 7));
-#ifndef USE_VM86
- vconnect_area.passthru[i >> 5] &= ~(1 << (i & 0x1f));
-#else
- vm86s.int_byuser[i >> 3] |= (1 << (i & 0x07));
-#endif
-#endif
- break;
- default:
-#if 1
- kargs.int_map[i >> 3] &= ~(1 << (i & 7));
-#ifndef USE_VM86
- vconnect_area.passthru[i >> 5] |= (1 << (i & 0x1f));
-#else
- vm86s.int_byuser[i >> 3] |= (1 << (i & 0x07));
-#endif
-#endif
- break;
- }
- }
-#endif
-
- if (booting) { /* are we booting? */
- setup_boot(REGS);
- } else { /* no, load a command */
- setup_command(argc, argv, REGS);
- }
-
- /* install signal handlers */
- setsignal(SIGFPE, sigfpe); /* */
- setsignal(SIGALRM, sigalrm); /* */
- setsignal(SIGILL, sigill); /* */
- setsignal(SIGTRAP, sigtrap); /* */
- setsignal(SIGUSR2, sigtrace); /* */
- setsignal(SIGINFO, sigtrace); /* */
-#ifdef USE_VM86
- setsignal(SIGURG, sigurg); /* entry from NetBSD vm86 */
-#else
- setsignal(SIGBUS, sigbus); /* entry from FreeBSD, BSD/OS vm86 */
-#endif
-
- /* Call init functions */
- if (raw_kbd)
- console_init();
- init_io_port_handlers();
- bios_init();
- cpu_init();
- kbd_init();
- kbd_bios_init();
- video_init();
- if (xmode)
- mouse_init();
- video_bios_init();
- disk_bios_init();
- cmos_init();
- xms_init();
- dos_init();
- net_init();
- speaker_init();
- timer_init();
- /* iomap_init(); */
-
- gettimeofday(&boot_time, 0);
-
- if (zflag) for (;;) pause(); /* spin if requested */
-
- if (raw_kbd) {
- /*
- * If we have a raw keyboard, and hence, video,
- * sneak in a call to the video BIOS to reinit the
- * the video display.
- */
- u_long video_vector;
- static u_char video_trampoline[] = {
- 0x60, /* pusha */
- 0xB8, 0x03, 0x00, /* mov ax,00003h */
- 0xCD, 0x10, /* int 010h */
- 0x61, /* popa */
- 0xCF, /* iret */
- };
-
- video_vector = insert_generic_trampoline(
- sizeof(video_trampoline), video_trampoline);
-
- PUSH(R_FLAGS, REGS);
- PUSH(R_CS, REGS);
- PUSH(R_IP, REGS);
- PUTVEC(R_CS, R_IP, video_vector);
- }
-
- sigemptyset(&uc.uc_sigmask);
- sigaltstack(NULL, &uc.uc_stack);
- uc.uc_mcontext.mc_onstack = 0;
-
- if (tmode)
- tracetrap(REGS);
-
-#ifndef USE_VM86
- R_EAX = (booting || raw_kbd) ? (int)&vconnect_area : -1;
- R_EFLAGS |= PSL_VM | PSL_VIF; /* request VM86 mode */
-
- i386_vm86(VM86_INIT, &kargs);
-
- sigreturn(&uc);
- debug(D_ALWAYS,"sigreturn failed : %s\n", strerror(errno));
-#else
- vm86s.cpu_type = VCPU_586;
- i386_vm86(&vm86s);
-#endif
-
- /* shouldn't get here */
- if (vflag) dump_regs(REGS);
- fatal ("vm86 returned (no kernel support?)\n");
-#undef sc
- /* quiet -Wall */
- return 0;
-}
-
-/*
-** setup_boot
-**
-** Setup to boot DOS
-*/
-static void
-setup_boot(regcontext_t *REGS)
-{
- FILE *fp; /* doscmdrc handle */
- int fd; /* don't close this! */
-
- fp = find_doscmdrc(); /* get doscmdrc */
- if (!fp) {
- fprintf(stderr, "You must have a doscmdrc to boot\n");
- quit(1);
- }
-
- booting = read_config(fp); /* where to boot from? */
- fclose(fp);
- if (booting < 0) { /* not specified */
- if ((fd = try_boot(booting = 0)) < 0) /* try A: */
- fd = try_boot(booting = 2); /* try C: */
- } else {
- fd = try_boot(booting); /* do like the man says */
- }
-
- if (fd < 0)
- errx(1, "Failed to boot");
-
- /* initialise registers for entry to bootblock */
- R_EFLAGS = 0x20202;
- R_CS = 0x0000;
- R_IP = 0x7c00;
- R_SS = 0x9800;
- R_SP = 0x8000 - 2;
- R_DS = 0x0000;
- R_ES = 0x0000;
-
- R_AX = R_BX = R_CX = R_DX = R_SI = R_DI = R_BP = 0;
-
-#if defined(__FreeBSD__) || defined(__NetBSD__) || defined (__DragonFly__)
- /*
- ** init a few other context registers
- */
- R_FS = 0x0000;
- R_GS = 0x0000;
-#endif
-}
-
-/*
-** try_boot
-**
-** try to read the boot sector from the specified disk
-*/
-static int
-try_boot(int bootdrv)
-{
- int fd;
-
- fd = disk_fd(bootdrv);
- if (fd < 0) { /* can we boot it? */
- debug(D_DISK, "Cannot boot from %c\n", drntol(bootdrv));
- return -1;
- }
-
- /* read bootblock */
- if (read(fd, (char *)0x7c00, 512) != 512) {
- debug(D_DISK, "Short read on boot block from %c:\n", drntol(bootdrv));
- return -1;
- }
-
- return fd;
-}
-
-/*
-** setup_command
-**
-** Setup to run a single command and emulate DOS
-*/
-static void
-setup_command(int argc, char *argv[], regcontext_t *REGS)
-{
- FILE *fp;
- u_short param[7] = {0, 0, 0, 0, 0, 0, 0};
- const char *p;
- char prog[1024];
- char buffer[PATH_MAX];
- unsigned i;
- int fd;
-
- fp = find_doscmdrc(); /* dig up a doscmdrc */
- if (fp) {
- read_config(fp); /* load config for non-boot mode */
- fclose(fp);
- }
-
- if (argc <= 0) /* need some arguments */
- usage();
-
- /* look for a working directory XXX ??? */
- if (dos_getcwd(drlton('C')) == NULL) {
-
- /* try to get our current directory, use '/' if desperate */
- p = getcwd(buffer, sizeof(buffer));
- if (!p || !*p) p = getenv("PWD");
- if (!p || !*p) p = "/";
- init_path(drlton('C'), "/", p);
-
- /* look for PATH= already set, learn from it if possible */
- for (i = 0; i < ecnt; ++i) {
- if (!strncmp(envs[i], "PATH=", 5)) {
- dos_path = envs[i] + 5;
- break;
- }
- }
- /* no PATH in DOS environment? put current directory there*/
- if (i >= ecnt) {
- static char path[256];
- snprintf(path, sizeof(path), "PATH=C:%s", dos_getcwd(drlton('C')));
- put_dosenv(path);
- dos_path = envs[ecnt-1] + 5;
- }
- }
-
- /* add a COMSPEC if required */
- for (i = 0; i < ecnt; ++i) {
- if (!strncmp(envs[i], "COMSPEC=", 8))
- break;
- }
- if (i >= ecnt)
- put_dosenv("COMSPEC=C:\\COMMAND.COM");
-
- /* look for PATH already set, learn from it if possible */
- for (i = 0; i < ecnt; ++i) {
- if (!strncmp(envs[i], "PATH=", 5)) {
- dos_path = envs[i] + 5;
- break;
- }
- }
- /* No PATH, default to c:\ */
- if (i >= ecnt) {
- put_dosenv("PATH=C:\\");
- dos_path = envs[ecnt-1] + 5;
- }
-
- /* if no PROMPT, default to 'DOS>' */
- for (i = 0; i < ecnt; ++i) {
- if (!strncmp(envs[i], "PROMPT=", 7))
- break;
- }
- if (i >= ecnt)
- put_dosenv("PROMPT=DOS> ");
-
- /* terminate environment */
- envs[ecnt] = NULL;
-
- /* XXX ??? */
- if (dos_getcwd(drlton('R')) == NULL)
- init_path(drlton('R'), "/", 0);
-
- /* get program name */
- strncpy(prog, *argv++, sizeof(prog) -1);
- prog[sizeof(prog) -1] = '\0';
-
- /* try to open program */
- if ((fd = open_prog(prog)) < 0) {
- fprintf (stderr, "%s: command not found\n", prog);
- quit(1);
- }
-
- /* load program */
- load_command(REGS, 1, fd, cmdname, param, argv, envs);
- close(fd);
-}
-
-/*
-** find_doscmdrc
-**
-** Try to find a doscmdrc file
-*/
-static FILE *
-find_doscmdrc(void)
-{
- FILE *fp;
- char buffer[4096];
-
- if ((fp = fopen(".doscmdrc", "r")) == NULL) {
- struct passwd *pwd = getpwuid(geteuid());
- if (pwd) {
- snprintf(buffer, sizeof(buffer), "%s/.doscmdrc", pwd->pw_dir);
- fp = fopen(buffer, "r");
- }
- if (!fp) {
- char *home = getenv("HOME");
- if (home) {
- snprintf(buffer, sizeof(buffer), "%s/.doscmdrc", home);
- fp = fopen(buffer, "r");
- }
- }
- if (!fp)
- fp = fopen("/etc/doscmdrc", "r");
- }
- return(fp);
-}
-
-/*
-** do_args
-**
-** commandline argument processing
-*/
-static int
-do_args(int argc, char *argv[])
-{
- int i,c,p;
- FILE *fp;
- char *col;
-
- while ((c = getopt(argc, argv, "234AbCc:Dd:EGHIi:kLMOo:Pp:RrS:TtU:vVxXYz")) != -1) {
- switch (c) {
- case '2':
- debug_flags |= D_TRAPS2;
- break;
- case '3':
- debug_flags |= D_TRAPS3;
- break;
- case '4':
- debug_flags |= D_DEBUGIN;
- break;
- case 'A':
- debug_flags |= D_TRAPS | D_ITRAPS;
- for (c = 0; c < 256; ++c)
- debug_set(c);
- break;
- case 'b':
- booting = 1;
- break;
- case 'C':
- debug_flags |= D_DOSCALL;
- break;
- case 'c':
- if ((capture_fd = creat(optarg, 0666)) < 0) {
- perror(optarg);
- quit(1);
- }
- break;
- case 'D':
- debug_flags |= D_DISK | D_FILE_OPS;
- break;
- case 'd':
- if ((fp = fopen(optarg, "w")) != NULL) {
- debugf = fp;
- setbuf (fp, NULL);
- } else
- perror(optarg);
- break;
- case 'E':
- debug_flags |= D_EXEC;
- break;
- case 'G':
- debug_flags |= D_VIDEO;
- break;
- case 'H':
- debug_flags |= D_HALF;
- break;
- case 'I':
- debug_flags |= D_ITRAPS;
- for (c = 0; c < 256; ++c)
- debug_set(c);
- break;
- case 'i':
- i = 1;
- if ((col = strchr(optarg, ':')) != NULL) {
- *col++ = 0;
- i = strtol(col, 0, 0);
- }
- p = strtol(optarg, 0, 0);
- iomap_port(p, i);
-
- while (i-- > 0)
- define_input_port_handler(p++, inb_traceport);
- break;
- case 'k':
- kargs.debug = 1;
- break;
- case 'L':
- debug_flags |= D_PRINTER;
- break;
- case 'M':
- debug_flags |= D_MEMORY;
- break;
- case 'O':
- debugf = stdout;
- setbuf (stdout, NULL);
- break;
- case 'o':
- i = 1;
- if ((col = strchr(optarg, ':')) != NULL) {
- *col++ = 0;
- i = strtol(col, 0, 0);
- }
- p = strtol(optarg, 0, 0);
- iomap_port(p, i);
-
- while (i-- > 0)
- define_output_port_handler(p++, outb_traceport);
- break;
- case 'P':
- debug_flags |= D_PORT;
- break;
- case 'p':
- i = 1;
- if ((col = strchr(optarg, ':')) != NULL) {
- *col++ = 0;
- i = strtol(col, 0, 0);
- }
- p = strtol(optarg, 0, 0);
- iomap_port(p, i);
-
- while (i-- > 0) {
- define_input_port_handler(p++, inb_port);
- define_output_port_handler(p++, outb_port);
- }
- break;
- case 'R':
- debug_flags |= D_REDIR;
- break;
- case 'r':
- raw_kbd = 1;
- break;
- case 'S':
- debug_flags |= D_TRAPS | D_ITRAPS;
- debug_set(strtol(optarg, 0, 0));
- break;
- case 'T':
- timer_disable = 1;
- break;
- case 't':
- tmode = 1;
- break;
- case 'U':
- debug_unset(strtol(optarg, 0, 0));
- break;
- case 'V':
- vflag = 1;
- break;
- case 'v':
- debug_flags |= D_TRAPS | D_ITRAPS | D_HALF | 0xff;
- break;
- case 'X':
- debug_flags |= D_XMS;
- break;
- case 'x':
-#ifdef NO_X
- fatal("X11 support not compiled in.\n");
-#endif
- xmode = 1;
- break;
- case 'Y':
- debug_flags |= D_EMS;
- break;
- case 'z':
- zflag = 1;
- break;
- default:
- usage ();
- }
- }
- return(optind);
-}
-
-/*
-** Very helpful 8(
-*/
-void
-usage (void)
-{
- fprintf (stderr, "usage: doscmd cmd args...\n");
- quit (1);
-}
-
-/*
-** look up a DOS command name
-**
-** XXX ordering is wrong!
-*/
-static int
-open_name(char *name, char *ext)
-{
- int fd;
- char *p = name + strlen(name);
- char *q;
-
- *ext = 0;
-
- q = strrchr(name, '/');
- if (q)
- q++;
- else
- q = name;
-
- if (!strchr(q, '.')) {
- strcpy(ext, ".exe");
- strcpy(p, ".exe");
-
- if ((fd = open (name, O_RDONLY)) >= 0)
- return (fd);
-
- strcpy(ext, ".com");
- strcpy(p, ".com");
-
- if ((fd = open (name, O_RDONLY)) >= 0)
- return (fd);
- } else {
- if ((fd = open (name, O_RDONLY)) >= 0)
- return (fd);
- }
-
- return (-1);
-}
-
-/*
-** look up a DOS command, search the path as well.
-*/
-int
-open_prog(char *name)
-{
- int fd;
- char fullname[1024], tmppath[1024];
- char *p;
- char *e;
- char ext[5];
- int error;
- int drive;
- char *path;
-
- if (strpbrk(name, ":/\\")) {
- error = translate_filename(name, fullname, &drive);
- if (error)
- return (-1);
-
- fd = open_name(fullname, ext);
-
- strcpy(cmdname, name);
- if (*ext)
- strcat(cmdname, ext);
- return (fd);
- }
-
- path = dos_path;
-
- while (*path) {
- p = path;
- while (*p && *p != ';')
- ++p;
-
- memcpy(tmppath, path, p - path);
- e = tmppath + (p - path);
- *e++ = '\\';
- strcpy(e, name);
-
- path = *p ? p + 1 : p;
-
- error = translate_filename(tmppath, fullname, &drive);
- if (error)
- continue;
-
- fd = open_name(fullname, ext);
-
- if (fd >= 0) {
- strcpy(cmdname, tmppath);
- if (*ext)
- strcat(cmdname, ext);
- return (fd);
- }
- }
-
- return (-1);
-}
-
-/*
-** append a value to the DOS environment
-*/
-void
-put_dosenv(const char *value)
-{
- if (ecnt < sizeof(envs)/sizeof(envs[0])) {
- if ((envs[ecnt++] = strdup(value)) == NULL) {
- perror("put_dosenv");
- quit(1);
- }
- } else {
- fprintf(stderr, "Environment full, ignoring %s\n", value);
- }
-}
-
-/*
-** replicate a fd up at the top of the range
-*/
-int
-squirrel_fd(int fd)
-{
- int sfd = sysconf(_SC_OPEN_MAX);
- struct stat sb;
-
- do {
- errno = 0;
- fstat(--sfd, &sb);
- } while (sfd > 0 && errno != EBADF);
-
- if (errno == EBADF && dup2(fd, sfd) >= 0) {
- close(fd);
- return(sfd);
- }
- return(fd);
-}
-
-/*
-** Exit-time stuff
-*/
-
-/*
-** Going away time
-**
-** XXX belongs somewhere else perhaps
-*/
-void
-done(regcontext_t *REGS, int val)
-{
- if (curpsp < 2) {
- if (xmode) {
- const char *m;
-
- tty_move(24, 0);
- for (m = "END OF PROGRAM"; *m; ++m)
- tty_write(*m, 0x8400);
-
- for (m = "(PRESS <CTRL-ALT> ANY MOUSE BUTTON TO exit)"; *m; ++m)
- tty_write(*m, 0x0900);
- tty_move(-1, -1);
- for (;;)
- tty_pause();
- } else {
- quit(val);
- }
- }
- exec_return(REGS, val);
-}
-
-typedef struct COQ {
- void (*func)(void *);
- void *arg;
- struct COQ *next;
-} COQ;
-
-COQ *coq = NULL;
-
-void
-quit(int status)
-{
- while (coq) {
- COQ *c = coq;
- coq = coq->next;
- c->func(c->arg);
- }
- if (!xmode) /* XXX not for bootmode */
- puts("\n");
- exit(status);
-}
-
-void
-call_on_quit(void (*func)(void *), void *arg)
-{
- COQ *c = (COQ *)malloc(sizeof(COQ));
- if (!c) {
- perror("call_on_quit");
- quit(1);
- }
- c->func = func;
- c->arg = arg;
- c->next = coq;
- coq = c;
-}
-
-struct io_range {
- u_int start;
- u_int length;
- int enable;
-};
-
-/* This is commented out as it is never called. Turn it back on if needed.
- */
-#if COMMENTED_OUT
-static void
-iomap_init(void)
-{
- int i;
- struct io_range io[] = {
-#if 0
- { 0x200, 0x200, 1 }, /* 0x200 - 0x400 */
- { 0x1c80, 2, 1 }, /* 0x1c80 - 0x1c81 */
- { 0x2c80, 2, 1 }, /* 0x2c80 - 0x2c81 */
- { 0x3c80, 2, 1 }, /* 0x3c80 - 0x3c81 */
- { 0x378, 8, 1 }, /* 0x378 - 0x37F */
- { 0x3c4, 2, 1 }, /* 0x3c4 - 0x3c5 */
- { 0x3c5, 2, 1 }, /* 0x3ce - 0x3cf */
-#else
- { 0x0, 0x10000, 1 }, /* entire i/o space */
-#endif
- { 0, 0, 0 }
- };
-
- for (i = 0; io[i].length; i++)
- if (i386_set_ioperm(io[i].start, io[i].length, io[i].enable) < 0)
- err(1, "i386_set_ioperm");
-}
-#endif
-
-/* This is used to map in only the specified port range, instead of all
- the ports or only certain port ranges.
- */
-void
-iomap_port(int port, int count)
-{
- if (i386_set_ioperm(port, count, 1) < 0)
- err(1, "i386_set_ioperm");
-
- debug(D_PORT,"mapped I/O port: port=%#x count=%d\n", port, count);
-}
+++ /dev/null
-/*
- * 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.h,v 2.3 1996/04/08 19:32:32 bostic Exp
- *
- * $FreeBSD: src/usr.bin/doscmd/doscmd.h,v 1.7.2.1 2002/04/25 11:04:51 tg Exp $
- * $DragonFly: src/usr.bin/doscmd/doscmd.h,v 1.2 2003/06/17 04:29:26 dillon Exp $
- */
-
-
-#ifdef __NetBSD__
-#define USE_VM86
-#endif
-
-#include <sys/param.h>
-#include <sys/types.h>
-#include <sys/time.h>
-#include <sys/stat.h>
-
-#include <dirent.h>
-#include <fcntl.h>
-#include <signal.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <ucontext.h>
-#include <errno.h>
-
-#include <sys/signalvar.h>
-#include <machine/sigframe.h>
-
-#include <machine/frame.h>
-#include <machine/psl.h>
-#include <machine/npx.h>
-#ifdef USE_VM86
-#include <machine/vm86.h>
-#endif
-
-#include "register.h"
-#include "dos.h"
-#include "callback.h"
-
-#define drlton(a) ((islower((a)) ? toupper((a)) : (a)) - 'A')
-#define drntol(a) ((a) + 'A')
-
-/*
-** assorted hardware/scope constants
-*/
-
-#define MAX_AVAIL_SEG 0xa000
-
-#define MAXPORT 0x400
-
-#define N_PARALS_MAX 3
-#define N_COMS_MAX 4 /* DOS restriction (sigh) */
-
-struct vconnect_area {
- int int_state;
- int magic; /* 0x4242 -> PRB format */
- u_long passthru[256>>5]; /* bitmap of INTs to handle */
- u_long magiciret[2]; /* Bounds of "magic" IRET */
-};
-extern struct vconnect_area vconnect_area;
-#define IntState vconnect_area.int_state
-
-/* ParseBuffer.c */
-int ParseBuffer(char *, char **, int);
-
-/* bios.c */
-#define BIOSDATA ((u_char *)0x400)
-extern unsigned long rom_config;
-extern int nfloppies;
-extern int ndisks;
-extern int nserial;
-extern int nparallel;
-
-extern volatile int poll_cnt;
-void bios_init(void);
-void wakeup_poll(void);
-void reset_poll(void);
-void sleep_poll(void);
-
-/* cmos.c */
-extern time_t delta_clock;
-
-void cmos_init(void);
-
-/* config.c */
-int read_config(FILE *fp);
-
-/* cpu.c */
-void cpu_init(void);
-int emu_instr(regcontext_t *);
-void int00(regcontext_t *);
-void int01(regcontext_t *);
-void int03(regcontext_t *);
-void int0d(regcontext_t *);
-
-/* debug.c */
-extern int vflag;
-extern int tmode;
-extern FILE *debugf;
-extern int debug_flags;
-
-/* Lower 8 bits are int number */
-#define D_ALWAYS 0x0000100 /* always emit this message */
-#define D_TRAPS 0x0000200 /* trap-related activity */
-#define D_FILE_OPS 0x0000400 /* file-related activity */
-#define D_MEMORY 0x0000800 /* memory-related activity */
-#define D_HALF 0x0001000 /* "half-implemented" system calls */
-#define D_FLOAT 0x0002000 /* ??? */
-#define D_DISK 0x0004000 /* disk (not file) operations */
-#define D_TRAPS2 0x0008000
-#define D_PORT 0x0010000 /* port accesses */
-#define D_EXEC 0x0020000
-#define D_ITRAPS 0x0040000
-#define D_REDIR 0x0080000 /* redirector functions */
-#define D_PRINTER 0x0100000
-#define D_TRAPS3 0x0200000
-#define D_DEBUGIN 0x0400000
-#define D_DOSCALL 0x0800000 /* MS-DOS function results */
-#define D_XMS 0x1000000 /* XMS calls */
-#define D_EMS 0x2000000 /* EMS calls */
-#define D_VIDEO 0x4000000 /* video-related activity */
-
-#define TTYF_ECHO 0x00000001
-#define TTYF_ECHONL 0x00000003
-#define TTYF_CTRL 0x00000004
-#define TTYF_BLOCK 0x00000008
-#define TTYF_POLL 0x00000010
-#define TTYF_REDIRECT 0x00010000 /* Cannot have 0xffff bits set */
-
-#define TTYF_ALL (TTYF_ECHO | TTYF_CTRL | TTYF_REDIRECT)
-#define TTYF_BLOCKALL (TTYF_ECHO | TTYF_CTRL | TTYF_REDIRECT | TTYF_BLOCK)
-
-void unknown_int2(int, int, regcontext_t *);
-void unknown_int3(int, int, int, regcontext_t *);
-void unknown_int4(int, int, int, int, regcontext_t *);
-void fatal(const char *, ...) __printflike(1, 2);
-void debug(int, const char *, ...) __printflike(2, 3);
-void dump_regs(regcontext_t *);
-void debug_set(int);
-void debug_unset(int);
-u_long debug_isset(int);
-
-/* disktab.c */
-int map_type(int, int *, int *, int *);
-
-/* doscmd.c */
-extern int capture_fd;
-extern int dead;
-extern int xmode;
-extern int booting;
-extern int raw_kbd;
-extern int timer_disable;
-extern char cmdname[];
-extern struct timeval boot_time;
-extern unsigned long *ivec;
-
-int _prog(char *);
-void call_on_quit(void (*)(void *), void *);
-void done(regcontext_t *, int);
-void iomap_port(int, int);
-int open_prog(char *);
-void put_dosenv(const char *);
-void quit(int);
-int squirrel_fd(int);
-
-/* ems.c */
-int ems_init(void);
-void ems_entry(regcontext_t *);
-
-/* emuint.c */
-extern void emuint(regcontext_t *REGS);
-
-/* i386-pinsn.c */
-extern int i386dis(unsigned short, unsigned short,
- unsigned char *, char *, int);
-
-/* int.c */
-void init_ints(void);
-int isinhardint(int);
-void softint(int);
-void hardint(int);
-void resume_interrupt(void);
-void unpend(int);
-void send_eoi(void);
-void set_eoir(int, void (*)(void *), void *);
-
-/* int10.c */
-extern void int10(regcontext_t *);
-
-/* int13.c */
-extern int init_hdisk(int drive, int cyl, int head, int tracksize,
- char *file, char *boot_sector);
-extern int init_floppy(int drive, int type, char *file);
-extern int disk_fd(int drive);
-extern void make_readonly(int drive);
-extern int search_floppy(int i);
-extern void disk_bios_init(void);
-
-/* int16.c */
-void int16(regcontext_t *);
-
-/* int17.c */
-void int17(regcontext_t *);
-void lpt_poll(void);
-void printer_direct(int printer);
-void printer_spool(int printer, char *print_queue);
-void printer_timeout(int printer, char *time_out);
-
-/* int1a.c */
-void int1a(regcontext_t *);
-
-/* int2f.c */
-extern void int2f(regcontext_t *);
-
-/* intff.c */
-extern int int2f_11(regcontext_t *REGS);
-extern void intff(regcontext_t *REGS);
-
-/* mem.c */
-extern char *dosmem;
-
-extern void mem_init(void);
-extern int mem_alloc(int size, int owner, int *biggestp);
-extern int mem_adjust(int addr, int size, int *availp);
-extern void mem_free_owner(int owner);
-extern void mem_change_owner(int addr, int owner);
-
-/* mouse.c */
-void int33(regcontext_t *);
-void mouse_init(void);
-
-/* net.c */
-void net_init(void);
-
-/* port.c */
-void define_input_port_handler(int, unsigned char (*)(int));
-void define_output_port_handler(int, void (*)(int, unsigned char));
-void inb(regcontext_t *, int);
-unsigned char inb_port(int);
-unsigned char inb_speaker(int);
-unsigned char inb_traceport(int);
-void init_io_port_handlers(void);
-void insb(regcontext_t *, int);
-void insx(regcontext_t *, int);
-void inx(regcontext_t *, int);
-void outb(regcontext_t *, int);
-void outb_port(int, unsigned char);
-void outb_speaker(int, unsigned char);
-void outb_traceport(int, unsigned char);
-void outsb(regcontext_t *, int);
-void outsx(regcontext_t *, int);
-void outx(regcontext_t *, int);
-void speaker_init(void);
-
-/* setver.c */
-extern void setver(char *, short);
-extern short getver(char *);
-
-/* signal.c */
-extern struct sigframe *saved_sigframe;
-extern regcontext_t *saved_regcontext;
-extern int saved_valid;
-extern void setsignal(int s, void (*h)(struct sigframe *));
-
-/* timer.c */
-extern void timer_init(void);
-
-/* trace.c */
-extern int resettrace(regcontext_t *);
-extern void tracetrap(regcontext_t *);
-
-/* xms.c */
-extern void get_raw_extmemory_info(regcontext_t *REGS);
-extern int int2f_43(regcontext_t *REGS);
-extern void initHMA(void);
-extern void xms_init(void);
-extern u_long xms_maxsize;
-
-/****************************** dirty below here *****************************/extern int nmice;
+++ /dev/null
-/*
- * 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_loader.c,v 2.3 1996/04/08 19:32:33 bostic Exp
- *
- * $FreeBSD: src/usr.bin/doscmd/doscmd_loader.c,v 1.2.2.1 2002/04/25 11:04:51 tg Exp $
- * $DragonFly: src/usr.bin/doscmd/doscmd_loader.c,v 1.4 2004/01/22 03:22:52 rob Exp $
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <a.out.h>
-
-/*
- * reserve space in "low" memory for the interrupt vector table
- */
-static const char filler[4096] = { 0, };
-
-#define _PATH_DOS_KERNEL_DIR "/usr/libexec/"
-#define _PATH_DOS_KERNEL "doscmd.kernel"
-
-int
-load_kernel(void)
-{
- FILE *fp;
- struct exec exec;
- int start_address;
-
- if ((fp = fopen(_PATH_DOS_KERNEL, "r")) == NULL &&
- (fp = fopen("obj/" _PATH_DOS_KERNEL, "r")) == NULL &&
- (fp = fopen(_PATH_DOS_KERNEL_DIR _PATH_DOS_KERNEL, "r")) == NULL &&
- (fp = fopen(getenv("DOS_KERNEL"), "r")) == NULL)
- err(1, "load_kernel");
-
- if (fread(&exec, sizeof(exec), 1, fp) != 1 || N_GETMAGIC(exec) != OMAGIC)
- errx(1, "bad kernel file format");
-
- start_address = exec.a_entry & (~(getpagesize() - 1));
- if (brk(start_address + exec.a_text + exec.a_data + exec.a_bss) < 0)
- err(1, "load_kernel");
- fread((char *)start_address, exec.a_text + exec.a_data, 1, fp);
- bzero((char *)(start_address + exec.a_text + exec.a_data), exec.a_bss);
- fclose(fp);
- return(exec.a_entry);
-}
-
-void
-main(int argc, char **argv, char **environ)
-{
- void (*entry_point)();
-#ifndef __DragonFly__
- int fd = open("/dev/mem", 0);
-#endif
- setgid(getgid());
- setuid(getuid());
-
-#ifndef __DragonFly__
- if (fd < 0)
- err(1, "/dev/mem");
-#endif
-
- entry_point = (void (*)()) load_kernel();
-
-#ifndef __DragonFly__
- if (read(fd, 0, 0x500 != 0x500))
- err(1, "/dev/mem");
-
- close(fd);
-#endif
-
- (*entry_point)(argc, argv, environ);
- errx(1, "return from doscmd kernel???");
-}
+++ /dev/null
-/*-
- * Copyright (c) 1997 Helmut Wirth <hfwirth@ping.at>
- * 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 immediately at the beginning of the file, witout modification,
- * 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. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 THE AUTHOR 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.
- *
- * $FreeBSD: src/usr.bin/doscmd/ems.c,v 1.3.2.2 2002/04/25 11:04:51 tg Exp $
- * $DragonFly: src/usr.bin/doscmd/ems.c,v 1.4 2005/10/30 23:00:57 swildner Exp $
- */
-
-/*
- * EMS memory emulation
- *
- * To emulate Expanded Memory we use a DOS driver (emsdriv.sys) which
- * routes calls to int 0x67 to this emulator routine. The main entry point
- * is ems_entry(..). The emulator needs to be initialized before the first
- * call. The first step of the initialization is done during program startup
- * the second part is done during DOS boot, from a call of the DOS driver.
- * The DOS driver is neccessary because DOS programs look for it to
- * determine if EMS is available.
- *
- * To emulate a configurable amount of EMS memory we use a file created
- * at startup with the size of the configured EMS memory. This file is
- * mapped into the EMS window like any DOS memory manager would do, using
- * mmap calls.
- *
- * The emulation follows the LIM EMS 4.0 standard. Not all functions of it
- * are implemented yet. The "alter page map and jump" and "alter page map
- * and call" functions are not implemented, because they are rather hard to
- * do. (It would mean a call to the emulator executes a routine in EMS
- * memory and returns to the emulator, the emulator switches the page map
- * and then returns to the DOS program.) LINUX does not emulate this
- * functions and I think they were very rarely used by DOS applications.
- *
- * Credits: To the writers of LINUX dosemu, I looked at their code
- */
-
-#include <sys/types.h>
-#include <sys/param.h>
-#include <sys/mman.h>
-#include <unistd.h>
-
-#include "doscmd.h"
-#include "ems.h"
-
-/* Will be configurable */
-u_long ems_max_size = EMS_MAXSIZE * 1024;
-u_long ems_frame_addr = EMS_FRAME_ADDR;
-
-/*
- * Method for EMS: Allocate a mapfile with the size of EMS memory
- * and map the needed part into the page frame
- */
-
-#define EMS_MAP_PATH "/var/tmp/" /* Use a big file system */
-#define EMS_MAP_FILE "doscmd.XXXXXX"
-static int mapfile_fd = -1;
-
-/* Pages are always 16 kB in size. The page frame is 64 kB, there are
- * 4 positions (0..3) for a page to map in. The pages are numbered from 0 to
- * the highest 16 kB page in the mapfile, depending on the EMS size
- */
-
-EMS_mapping_context ems_mapping_context;
-
-/* Handle and page management (see ems.h) */
-
-/* The handle array. If the pointer is NULL, the handle is unallocated */
-static EMS_handle *ems_handle[EMS_NUM_HANDLES];
-static u_long ems_alloc_handles;
-/* The active handle, if any */
-static short active_handle;
-
-/* The page array. It is malloced at runtime, depending on the total
- * allocation size
- */
-
-static EMS_page *ems_page = NULL;
-static u_long ems_total_pages;
-static u_long ems_alloc_pages;
-static u_long ems_free_pages;
-
-/* Local structure used for region copy and move operations */
-
-struct copydesc {
-#define SRC_EMS 1
-#define DST_EMS 2
- short copytype; /* Type of source and destination memory */
- EMS_addr src_addr; /* Combined pointer for source */
- EMS_addr dst_addr; /* Combined pointer for destination */
- u_long rest_len; /* Lenght to copy */
-};
-
-
-/* Local prototypes */
-static int init_mapfile(void);
-static void map_page(u_long, u_char, short, int);
-static EMS_handle *get_new_handle(long);
-static void context_to_handle(short);
-static long find_next_free_handle(void);
-static short lookup_handle(Hname *hp);
-static void allocate_pages_to_handle(u_short, long);
-static void allocate_handle(short, long);
-static void reallocate_pages_to_handle(u_short, long);
-static void free_handle(short);
-static void free_pages_of_handle(short);
-static void restore_context(EMS_mapping_context *);
-static void save_context_to_dos(EMScontext *);
-static int check_saved_context(EMScontext *);
-static void *get_valid_pointer(u_short, u_short, u_long);
-static u_long move_ems_to_conv(short, u_short, u_short, u_long, u_long);
-static u_long move_conv_to_ems(u_long, u_short, u_short, u_short, u_long);
-static u_long move_ems_to_ems(u_short, u_short, u_short, u_short,
- u_short, u_short, u_long);
-
-/*
- * EMS initialization routine: Return 1, if successful, return 0 if
- * init problem or EMS disabled
- */
-
-int
-ems_init(void)
-{
- unsigned i;
-
- if (ems_max_size == 0)
- return 0;
- if (init_mapfile() == 0)
- return 0;
- /* Sanity */
- bzero((void *)(&ems_handle[0]), sizeof(ems_handle));
- ems_total_pages = ems_max_size / EMS_PAGESIZE;
- ems_alloc_pages = 0;
- ems_free_pages = ems_total_pages;
- ems_alloc_handles = 0;
- active_handle = 0;
- /* Malloc the page array */
- ems_page = (EMS_page *)malloc(sizeof(EMS_page) * ems_total_pages);
- if (ems_page == NULL) {
- debug(D_ALWAYS, "Could not malloc page array, EMS disabled\n");
- ems_frame_addr = 0;
- ems_max_size = 0;
- ems_total_pages = 0;
- return 0;
- }
- for (i = 0; i < ems_total_pages; i++) {
- ems_page[i].handle = 0;
- ems_page[i].status = EMS_FREE;
- }
- debug(D_EMS, "EMS: Emulation init OK.\n");
- return 1;
-}
-
-
-/* Main entry point */
-
-void
-ems_entry(regcontext_t *REGS)
-{
- /*
- * If EMS is not enabled, the DOS ems.exe module should not have
- * been loaded. If it is loaded anyway, report software malfunction
- */
- if (ems_max_size == 0) {
- R_AH = EMS_SW_MALFUNC;
- debug(D_EMS, "EMS emulation not enabled\n");
- return;
- }
-
- switch (R_AH)
- {
- case GET_MANAGER_STATUS:
- debug(D_EMS, "EMS: Get manager status\n");
- R_AH = EMS_SUCCESS;
- break;
-
- case GET_PAGE_FRAME_SEGMENT:
- debug(D_EMS, "EMS: Get page frame segment\n");
- R_BX = ems_frame_addr >> 4;
- R_AH = EMS_SUCCESS;
- break;
-
- case GET_PAGE_COUNTS:
- R_BX = ems_total_pages - ems_alloc_pages;
- R_DX = ems_total_pages;
- debug(D_EMS, "EMS: Get page count: Returned total=%d, free=%d\n",
- R_DX, R_BX);
- R_AH = EMS_SUCCESS;
- break;
-
- case GET_HANDLE_AND_ALLOCATE:
- {
- u_short npages;
- short handle;
-
- npages = R_BX;
- debug(D_EMS, "EMS: Get handle and allocate %d pages: ", npages);
-
- /* Enough handles? */
- if ((handle = find_next_free_handle()) < 0) {
- debug(D_EMS,"Return error:No handles\n");
- R_AH = EMS_OUT_OF_HANDLES;
- break;
- }
- /* Enough memory for this request ? */
- if (npages > ems_free_pages) {
- debug(D_EMS,"Return error:Request too big\n");
- R_AH = EMS_OUT_OF_LOG;
- break;
- }
- if (npages > ems_total_pages) {
- debug(D_EMS,"Return error:Request too big\n");
- R_AH = EMS_OUT_OF_PHYS;
- break;
- }
- /* Not allowed to allocate zero pages with this function */
- if (npages == 0) {
- debug(D_EMS,"Return error:Cannot allocate 0 pages\n");
- R_AH = EMS_ZERO_PAGES;
- break;
- }
- /* Allocate the handle */
- allocate_handle(handle, npages);
-
- /* Allocate the pages */
- allocate_pages_to_handle(handle, npages);
- R_DX = handle;
- R_AH = EMS_SUCCESS;
- debug(D_EMS,"Return success:Handle = %d\n", handle);
- break;
- }
-
- case MAP_UNMAP:
- {
- u_char position;
- u_short hpagenum, spagenum;
- short handle;
-
- debug(D_EMS, "EMS: Map/Unmap handle=%d, pos=%d, pagenum=%d ",
- R_DX, R_AL, R_BX);
- handle = R_DX;
- position = R_AL;
- if (position > 3) {
- debug(D_EMS, "invalid position\n");
- R_AH = EMS_ILL_PHYS;
- break;
- }
- hpagenum = R_BX;
- /* This succeeds without a valid handle ! */
- if (hpagenum == 0xffff) {
- /* Unmap only */
- map_page(0, position, handle, 1);
- debug(D_EMS, "(unmap only) success\n");
- R_AH = EMS_SUCCESS;
- break;
- }
- if (handle > 255 || handle == 0 || ems_handle[handle] == NULL) {
- R_AH = EMS_INV_HANDLE;
- debug(D_EMS, "invalid handle\n");
- break;
- }
- if (hpagenum >= ems_handle[handle]->npages) {
- R_AH = EMS_LOGPAGE_TOOBIG;
- debug(D_EMS, "invalid pagenumber\n");
- break;
- }
- spagenum = ems_handle[handle]->pagenum[hpagenum];
- map_page(spagenum, position, handle, 0);
- debug(D_EMS, "success\n");
- R_AH = EMS_SUCCESS;
- break;
- }
-
- case DEALLOCATE_HANDLE:
- {
- short handle;
-
- /* Handle valid ? */
- handle = R_DX;
- debug(D_EMS, "EMS: Deallocate handle %d\n", handle);
- if (handle > 255 || ems_handle[handle] == NULL) {
- R_AH = EMS_INV_HANDLE;
- break;
- }
- /* Mapping context saved ? */
- if (ems_handle[handle]->mcontext != NULL) {
- R_AH = EMS_SAVED_MAP;
- break;
- }
-
- free_pages_of_handle(handle);
- free_handle(handle);
- R_AH = EMS_SUCCESS;
- break;
- }
-
- case GET_EMM_VERSION:
- debug(D_EMS, "EMS: Get version\n");
- R_AL = EMS_VERSION;
- R_AH = EMS_SUCCESS;
- break;
-
- case SAVE_PAGE_MAP:
- {
- short handle;
-
- debug(D_EMS, "EMS: Save page map\n");
- handle = R_DX;
- if (handle > 255 || handle == 0 || ems_handle[handle] == NULL) {
- R_AH = EMS_INV_HANDLE;
- break;
- }
- if (ems_handle[handle]->mcontext != NULL) {
- /* There is already a context saved */
- if (memcmp((void *)ems_handle[handle]->mcontext,
- (void *)&ems_mapping_context,
- sizeof(EMS_mapping_context)) == 0)
- R_AH = EMS_ALREADY_SAVED;
- else
- R_AH = EMS_NO_ROOM_TO_SAVE;
- break;
- }
- context_to_handle(handle);
- R_AH = EMS_SUCCESS;
- break;
- }
-
- case RESTORE_PAGE_MAP:
- {
- short handle;
-
- debug(D_EMS, "EMS: Restore page map\n");
- handle = R_DX;
- if (handle > 255 || handle == 0 || ems_handle[handle] == NULL) {
- R_AH = EMS_INV_HANDLE;
- break;
- }
- if (ems_handle[handle]->mcontext == NULL) {
- R_AH = EMS_NO_SAVED_CONTEXT;
- break;
- }
- restore_context(ems_handle[handle]->mcontext);
- free((void *)ems_handle[handle]->mcontext);
- ems_handle[handle]->mcontext = NULL;
- R_AH = EMS_SUCCESS;
- break;
- }
-
- case RESERVED_1:
- case RESERVED_2:
- debug(D_ALWAYS, "Reserved function called: %02x\n", R_AH);
- R_AH = EMS_FUNC_NOSUP;
- break;
-
- case GET_HANDLE_COUNT:
- debug(D_EMS, "EMS: Get handle count\n");
- R_BX = ems_alloc_handles + 1;
- R_AH = EMS_SUCCESS;
- break;
-
- case GET_PAGES_OWNED:
- {
- short handle;
-
- debug(D_EMS, "EMS: Get pages owned\n");
- /* Handle valid ? */
- handle = R_DX;
- if (handle > 255 || ems_handle[handle] == NULL) {
- R_AH = EMS_INV_HANDLE;
- break;
- }
- if (handle == 0)
- R_BX = 0;
- else
-