summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Changes37
-rw-r--r--Libc_version2
-rw-r--r--Makefile18
-rw-r--r--README12
-rw-r--r--as/Makefile2
-rw-r--r--bcc/Makefile7
-rw-r--r--bin86/ChangeLog111
-rw-r--r--bin86/Makefile49
-rw-r--r--bin86/README27
-rw-r--r--bin86/README-0.479
-rw-r--r--bootblocks/Makefile32
-rw-r--r--bootblocks/bzimage.c238
-rw-r--r--bootblocks/commands.c210
-rw-r--r--bootblocks/fs.c9
-rw-r--r--bootblocks/fs_dos.c27
-rw-r--r--bootblocks/fs_min.c2
-rw-r--r--bootblocks/fs_tar.c8
-rw-r--r--bootblocks/help.c3
-rw-r--r--bootblocks/i86_funcs.c32
-rw-r--r--bootblocks/i86_funcs.h2
-rw-r--r--bootblocks/lsys.c134
-rw-r--r--bootblocks/makeboot.c42
-rw-r--r--bootblocks/mbr.s5
-rw-r--r--bootblocks/min_buf.c105
-rw-r--r--bootblocks/monitor.c334
-rw-r--r--bootblocks/monitor.h47
-rw-r--r--bootblocks/relocate.c11
-rw-r--r--bootblocks/sysboot.s15
-rw-r--r--bootblocks/tich.s2
-rw-r--r--bootblocks/trk_buf.c9
-rw-r--r--bootblocks/unix.c11
-rw-r--r--dis88/Makefile6
-rw-r--r--ld/Makefile5
-rw-r--r--libc/Makefile2
-rw-r--r--libc/bios/bios_vid.c2
-rw-r--r--libc/msdos/conio.c66
-rw-r--r--libc/termios/ttyname.c2
-rw-r--r--makefile.in21
-rw-r--r--man/Makefile4
-rw-r--r--man/as86.16
-rw-r--r--man/bcc.12
-rw-r--r--man/index.btbin0 -> 8192 bytes
42 files changed, 1208 insertions, 530 deletions
diff --git a/Changes b/Changes
index da2386b..b296ed5 100644
--- a/Changes
+++ b/Changes
@@ -1,3 +1,40 @@
+For version 0.15.0.
+
+> Altered initial make variables, you only need to modify 'PREFIX=' to allow
+ installs into /usr/local.
+
+> Added bin86-0.... source distribution archive.
+
+> Fixed bug in -t option to as
+
+> Added assembly externals in as86_encap generated code.
+
+> I appear to have bcc generating a consistant set of code fragments for
+ floating point operations. No floating libs though ...
+
+> Added lsys.com to install the dosfs boot sector under dos.
+
+> monitor.out now (finally!) loads zImage files.
+
+> Monitor.out now works with a TAR "filesystem" on a floppy.
+
+> Added two conpile time options (-DTARFLOPPY and -DDOSFLOPPY) for smaller
+ executables to only boot linux-386 from a floppy.
+
+> Makeboot can install the mbr.
+
+> Removed the ELKS specific code from the minixfs loader, added a helper
+ program to load and relocate ELKS.
+
+> Fixed/avoided some problems with the optimiser breaking hand optimised code.
+
+> I've made some alterations to the header files in an effort to merge the
+ ELKS kernel files with fewer problems.
+
+> Oops, Claudio says that qsort went the wrong way, hmm.
+
+> Added some more library code for MSDOS programs, there's still more to go.
+
For version 0.14.0.
> Objdump86 utility added, also includes nm86 and size86 that work on
diff --git a/Libc_version b/Libc_version
index ac4a796..436d0ce 100644
--- a/Libc_version
+++ b/Libc_version
@@ -1 +1 @@
-0.14.3
+0.14.5
diff --git a/Makefile b/Makefile
index 4ba277d..4f4adf8 100644
--- a/Makefile
+++ b/Makefile
@@ -10,9 +10,10 @@ TARGETS= \
config other tests dis88 doselks bootblocks ld86r
ELKSSRC= /usr/src/elks
-PREFIX= /usr/bcc
-BINDIR= /usr/bin
-LIBDIR= $(PREFIX)/lib/bcc
+PREFIX= /usr
+LIBPRE= $(PREFIX)/bcc
+BINDIR= $(PREFIX)/bin
+LIBDIR= $(LIBPRE)/lib/bcc
CFLAGS= -O
# Some makes take the last of a list as the default ...
@@ -34,7 +35,9 @@ realclean:
make.fil: ifdef makefile.in
./ifdef -MU makefile.in >tmp.mak
- sed -e "s:%PREFIX%:$(PREFIX):" \
+ sed \
+ -e "s:%PREFIX%:$(PREFIX):" \
+ -e "s:%LIBPRE%:$(LIBPRE):" \
-e "s:%BINDIR%:$(BINDIR):" \
-e "s:%LIBDIR%:$(LIBDIR):" \
-e "s:%ELKSSRC%:$(ELKSSRC):" \
@@ -88,6 +91,13 @@ distribution:
rm as86/as86.1 as86
gzip -f9 /tmp/Dist/as86-*.tar &
+ cd /tmp/linux-86 &&\
+ VER=`cat Libc_version` &&\
+ make -C bin86 grab &&\
+ tar cf /tmp/Dist/bin86-$$VER.tar bin86 &&\
+ make -C bin86 ungrab
+ gzip -f9 /tmp/Dist/bin86-*.tar &
+
cd /tmp &&\
VER=`cat linux-86/Libc_version` &&\
ln -s linux-86/libc libc-$$VER &&\
diff --git a/README b/README
index 95afbe8..2d9c661 100644
--- a/README
+++ b/README
@@ -10,9 +10,9 @@ Use 'make Uninstall' to remove everything (Beware with this though!)
Some other bits can be built by 'make other' and installed with
'make install-other'.
-If you don't want it to install some bits in /usr/bin you can override
-the bindir on the first make ie: 'make BINDIR=/usr/local/bin' this
-is remembered until 'make.fil' is rebuilt.
+If you want it to install under /usr/local instead you can specify
+the prefix on the first make ie: 'make PREFIX=/usr/local' this is
+remembered until 'make.fil' is rebuilt.
The manual pages in the man subdirectory are matched to these programs,
there are also some hints for using as86 well. The tests and bootblocks
@@ -20,11 +20,15 @@ directories give some example code.
The bcc command defaults to using /usr/bcc/include and /usr/bcc/lib/bcc
the libraries _and_ include files are copied to these locations by
-install. This can be changed by overriding 'PREFIX=/usr/bcc' or
+install. This can be changed by overriding 'PREFIX=/usr' or
'LIBDIR=/usr/bcc/lib/bcc' on the initial make. Also available in the
same way the 'ELKSSRC=/usr/src/elks' variable can be altered if you
have ELKS on a different path.
+In the unlikely event you're makeing a non-cross development environment
+you can, on the initial make, do "make LIBPRE=/usr' to have the libraries
+and include files directly under /usr rather than /usr/bcc.
+
All the versions of the library are built by make; 'normal', 'fast',
'MSDOS', 'standalone' and Linux-i386.
diff --git a/as/Makefile b/as/Makefile
index 647d977..2928397 100644
--- a/as/Makefile
+++ b/as/Makefile
@@ -27,7 +27,7 @@ install: all
install -m 755 as86_encap $(BINDIR)/as86_encap
-@rm -f tmp
-clean realclean:
+clean realclean clobber:
rm -f *.o as86 as86_encap
as.o: const.h type.h byteord.h macro.h file.h flag.h globvar.h
diff --git a/bcc/Makefile b/bcc/Makefile
index 2bffe68..3b84f5a 100644
--- a/bcc/Makefile
+++ b/bcc/Makefile
@@ -4,12 +4,13 @@
#
PREFIX=/usr
+LIBPRE=$(PREFIX)
CFLAGS =-O
LDFLAGS =-s
-BINDIR =/usr/bin
-LIBDIR =/usr/lib/bcc
-BCCDEFS =-DLOCALPREFIX=$(PREFIX) -DBINDIR=$(BINDIR) -DDEFARCH=0
+BINDIR =$(PREFIX)/bin
+LIBDIR =$(LIBPRE)/lib/bcc
+BCCDEFS =-DLOCALPREFIX=$(LIBPRE) -DBINDIR=$(BINDIR) -DDEFARCH=0
OBJS = bcc-cc1.o codefrag.o debug.o declare.o express.o exptree.o floatop.o \
function.o gencode.o genloads.o glogcode.o hardop.o input.o label.o \
diff --git a/bin86/ChangeLog b/bin86/ChangeLog
new file mode 100644
index 0000000..a09114b
--- /dev/null
+++ b/bin86/ChangeLog
@@ -0,0 +1,111 @@
+Fri Jul 31 09:33:18 BST 1998 Robert de Bath (rdebath@poboxes.com)
+
+ * version 0.14.4, This package is based on the ELKS dev86 package
+ of the same version number.
+
+ * Improved documentation (There's actually a man page!)
+
+ * The linker will produce either Linux-8086, DOS-COM
+ or Native Linux-386 OMAGIC executable files.
+
+ * The assembler has many instruction fixes:
+ jmp near, jmpi dword x,y, org, use32/use16 ... etc
+ and can also read source from stdin.
+
+ * Assembler macros work.
+
+ * The assembler command 'include' works.
+
+ * Conditionals and string conditionals work.
+
+ * Various additions for multi-segment work.
+
+ * The assembler can create bare binary files with simple ASCII symbol
+ files, these are ideal for generating encapsulated binaries and a
+ simple script for doing this is included.
+
+ * The assembler will generate warning messages when 386
+ instructions are used with the assembler in an 8086 mode.
+
+ * Many minor bug fixes and portability fixes.
+
+Sat Nov 16 18:38:14 1995 H.J. Lu (hjl@gnu.ai.mit.edu)
+
+ * version 0.4 is released.
+
+ * Makefile (CFLAGS): add _POSIX_SOURCE.
+
+ * as/as.c, as/flag.h, as/genlist.c, as/pops.c,v,
+ as/readsrc.c: change warn to warning.
+
+Fri Jun 16 02:02:03 1995 Michael Shields (shields@tembel.org)
+
+ * as/Makefile (endian.h): Don't rely on . being in $PATH.
+
+Tue May 16 22:01:05 1995 H.J. Lu (hjl@nynexst.com)
+
+ * version 0.3 is released.
+
+ * Makefile: fix a few typos.
+
+ * as/const.h: include "endian.h".
+ (LOW_BYTE): check the byte order.
+
+ * as/Makefile (endian.h): new target.
+ (const.h): depend on endian.h.
+
+ * as/det_endian.c: new from glibc.
+
+Sat Mar 18 16:39:19 1995 Francois-Rene Rideau (rideau@clipper.ens.fr)
+
+ * as/pops.c (doif): support nested conditionals.
+
+Mon Nov 21 22:48:26 1994 H.J. Lu (hlu@nighthawk)
+
+ * version 0.2 is released.
+
+ * Makefile (MFLAGS): new. add BINDIR and CC.
+
+Fri Nov 18 22:25:24 1994 Package Maintainer (opt@calum.csclub.uwaterloo.ca)
+
+ * ./as/Makefile:
+ * ./as/const.h:
+ * ./as/proto.h:
+ * ./as/readsrc.c:
+ * ./as/type.h:
+ * ./ld/Makefile:
+ * ./ld/align.h:
+ * ./ld/config.h:
+ * ./ld/type.h:
+ * ./ld/typeconv.c: remove endian dependency.
+
+Thu Mar 3 15:12:23 1994 H.J. Lu (hlu@nighthawk)
+
+ * version 0.1 is released.
+
+ * Makefile: new.
+
+ * a.out.h/bsd-a.out.h (struct exec): use short form if
+ __linux__ is defined.
+
+ * as/Makefile: minor changes.
+ (CLFAGS): add -I../a.out.h.
+
+ * ld/Makefile: minor changes.
+ (CLFAGS): add -I../a.out.h.
+
+ * ld/io.c (MY_STAT_H): don't define it if __linux__ is
+ defined.
+
+ * ld/ld.c (flag['z']): initialized to 0 if __linux__ is
+ defined.
+
+ * ld/obj.h (roundup):
+ * ld/writebin.c (roundup):
+ ld/readobj.c (roundup): change that to ld_roundup to avoid the
+ conflict with the system's roundup.
+
+ * ld/writebin.c: cleanup for the latest Linux C library.
+ (FILEHEADERLENGTH): change to sizeof (struct exec).
+ don't write a_trsize and its friends.
+
diff --git a/bin86/Makefile b/bin86/Makefile
new file mode 100644
index 0000000..5cd0ce8
--- /dev/null
+++ b/bin86/Makefile
@@ -0,0 +1,49 @@
+
+CFLAGS=-O2 -D_POSIX_SOURCE
+LDFLAGS=
+DIRS=ld as
+
+PREFIX=/usr/local
+BINDIR=$(PREFIX)/bin
+LIBDIR=$(PREFIX)/lib
+MANDIR=$(PREFIX)/man/man1
+SUF=86
+
+INSTALL_OPT=-m 755 -s
+MAN_OPTS =-m 644
+
+MFLAGS= "LIBS=$(LIBS)" \
+ "CFLAGS=$(CFLAGS)" \
+ "LDFLAGS=$(LDFLAGS)" \
+ "BINDIR=$(BINDIR)" \
+ "LIBDIR=$(LIBDIR)" \
+ "CC=$(CC)"
+
+all:
+ for d in $(DIRS); do \
+ (cd $$d; $(MAKE) $(MFLAGS) $@;); \
+ done
+
+install: all
+ install $(INSTALL_OPTS) as/as86 $(BINDIR)/as$(SUF)
+ install $(INSTALL_OPTS) as/as86_encap $(BINDIR)/as$(SUF)_encap
+ install $(INSTALL_OPTS) ld/ld86 $(BINDIR)/ld$(SUF)
+ install $(INSTALL_OPTS) ld/objdump86 $(BINDIR)/objdump$(SUF)
+ install $(MAN_OPTS) man/*.1 $(MANDIR)
+ ln -s objdump$(SUF) $(BINDIR)/nm$(SUF)
+ ln -s objdump$(SUF) $(BINDIR)/size$(SUF)
+
+depend clean clobber:
+ for d in $(DIRS); do \
+ (cd $$d; $(MAKE) $(MFLAGS) $@;); \
+ done
+
+ungrab:
+ rm -rf as ld man
+grab:
+ cp -a ../as ../ld .
+ rm -f ld/ar.h ; cp -p ../libc/include/ar.h ld/ar.h
+ mkdir man
+ cp -p ../man/ld86.1 man
+ cp -p ../man/as86.1 man
+
diff --git a/bin86/README b/bin86/README
new file mode 100644
index 0000000..b6fb3ff
--- /dev/null
+++ b/bin86/README
@@ -0,0 +1,27 @@
+
+This is a simple assember and linker for 8086 - 80386 machine code.
+There have been a large number of changes since bin86-0.4 so I strongly
+suggest you read the manpages.
+
+To install:
+ make PREFIX=/usr install
+or
+ make PREFIX=/usr/local install
+
+This version has been tested under Linux, older versions were also tested
+and working under SunOS and AIX.
+
+-------------
+
+This is based on the as86 and ld86 distribution written by Bruce Evans.
+Bruce has released this under the GPL and the changes I've made are
+also under the same license
+
+The BCC components that were distributed in this package are now in
+the dev86 package along with a working C compiler and libc for 8086
+ELKS, DOS and standalone code.
+
+The most recent address I have for Bruce is <bde@FreeBSD.org>
+
+Robert de Bath <rdebath@poboxes.com>
+1998/7/31
diff --git a/bin86/README-0.4 b/bin86/README-0.4
new file mode 100644
index 0000000..f91a9dc
--- /dev/null
+++ b/bin86/README-0.4
@@ -0,0 +1,79 @@
+To build this real mode as/ld for x86, just edit Makefile and then
+do
+
+make install
+
+It is only tested under SunOS 4.1.3 and Linux.
+
+H.J. Lu
+hjl@nynexst.com
+11/21/94
+------
+We seem to have cross bin86 for Solaris working. The most important
+changes involve alignment (it needs to be on) and byte ordering.
+Some of the patches just eliminate compiler warnings (conversion of
+pointer to integer without a cast, etc.) and some (in the Makefiles)
+reflect the local setup, and can probably be ignored (the change to $BINDIR,
+for example).
+
+ - Ian (iagoldbe@csclub.uwaterloo.ca)
+
+----
+I modified it for the latest Linux C library 4.5.21 and released it as
+bin86 0.1. It is only tested for building the Linux kernel and is not
+intended for any other purposes. To build it under Linux, just type
+
+make all
+make install
+
+It is not tested for cross-compiling. If you have any patches for
+cross-compiling, please send them to me.
+
+Thanks.
+
+
+H.J. Lu
+hjl@nynexst.com
+03/03/94
+-------------
+This is the as86 and ld86 distribution written by Bruce Evans. It's
+copyright Bruce Evans, all rights reserved although you may use and copy
+it for your personal use. It's a complete 8086 assembler and loader
+which can make 32-bit code for the 386+ processors (under linux it's
+used only to create the 16-bit bootsector and setup binaries). The
+syntax is not compatible with the GNU assembler, but closer to intel
+syntax ("wrong" order of operands etc).
+
+Hints for compiling:
+
+ - you'll need the a.out.h-files from the a.out.h directory for the
+linker. These aren't really part of the distribution, but I included
+them for ease of setup (in case you need to crosscompile etc). Do a
+ cp a.out.h/* ld/
+or similar before compiling the linker.
+
+ - the assembler needs the typeconv.o file produced by the linker
+compilation. So compile the linker first, and then do a
+ cp ld/typeconv.o as/
+before making the assembler.
+
+This distribution also contains some test-files etc that aren't actually
+needed, but as they also give some idea of the assembler syntax, I left
+them in. The directories are as follows:
+
+ as - the assembler sources (minus typeconv.c)
+ ld - linker sources
+ bcc - bruce evans' cc frontend sources (the actual compiler isn't
+ included).
+ bccfp - assembly floating point routines written by bruce evans. Note
+ that these use integer register returns, and won't work with the
+ linux libraries. They can be used as examples of as86 code.
+ a.out.h - header files for crosscompilation.
+
+Note that I am NOT the author of this package, but I'll forward any
+comments to bruce evans and I'll try to answer any questions about the
+assembler/linker I can. I just made it available as bde doesn't have
+ftp capability right now. Bruce Evans does have mail as
+<bde@runx.oz.au>.
+
+ Linus Torvalds
diff --git a/bootblocks/Makefile b/bootblocks/Makefile
index c37f35c..7ad0907 100644
--- a/bootblocks/Makefile
+++ b/bootblocks/Makefile
@@ -4,10 +4,11 @@ HOSTCCFLAGS=-O
BCC=bcc
CC=$(BCC)
-CFLAGS=-ansi -Ms -Oi -O -s
+CFLAGS=-ansi -Ms -Oi -O -s $(MONDEFS)
# CFLAGS=-ansi -Ms
ASFLAGS=-0 -w
-MDEFS=-DDOTS
+MINIXDEFS=-DDOTS
+MONDEFS=
# LST=-l $*.lst
# CLST=-A-l -A$*.lst
@@ -23,46 +24,49 @@ SSRC=sysboot.s \
encap: $(SSRC:s=v) $(CSRC:c=v) minixhd.v
bin: $(SSRC:s=bin) $(CSRC:c=bin) minixhd.bin
-MOBJ=monitor.o i86_funcs.o relocate.o help.o bzimage.o trk_buf.o unix.o \
- fs.o fs_tar.o fs_min.o fs_dos.o
-MSRC=monitor.c i86_funcs.c relocate.c help.c bzimage.c trk_buf.c unix.c \
- fs.c fs_tar.c fs_min.c fs_dos.c
-MINC=i86_funcs.h readfs.h
+MOBJ=monitor.o commands.o i86_funcs.o relocate.o help.o bzimage.o \
+ trk_buf.o min_buf.o unix.o fs.o fs_tar.o fs_min.o fs_dos.o
+MSRC=monitor.c commands.c i86_funcs.c relocate.c help.c bzimage.c \
+ trk_buf.c min_buf.c unix.c fs.c fs_tar.c fs_min.c fs_dos.c
+MINC=i86_funcs.h readfs.h monitor.h
BOOTBLOCKS=sysboot.v noboot.v skip.v msdos.v tarboot.v minix.v minixhd.v mbr.v
EXTRAS=minix.h elf_info.c elf_info.h standalone.c li86.s \
- zimage.s minix_elks.c crc.c
+ zimage.s minix_elks.c crc.c lsys.c
install:
monitor.out: $(MOBJ)
- $(CC) $(CFLAGS) -H0x10000 $(MOBJ) -o monitor.out
+ $(CC) $(CFLAGS) -H0x10000 $(MOBJ) -o monitor.out -M > monitor.sym
$(MOBJ): $(MINC) version.h
monitor: $(MSRC) $(MINC)
@rm -f $(MOBJ)
- make 'CFLAGS=-ansi -H0x8000' monitor.out
+ make 'CFLAGS=-ansi -H0x8000 $(MONDEFS)' monitor.out
mv monitor.out monitor
@rm -f $(MOBJ)
bzimage.o: bzimage.c zimage.v
minix.s: minix.c Makefile
- $(BCC) -Mf -O -DTRY_FLOPPY $(MDEFS) -S minix.c
+ $(BCC) -Mf -O -DTRY_FLOPPY $(MINIXDEFS) -S minix.c
minix_elks.s: minix_elks.c Makefile minix.v
- $(BCC) -Mf -O $(MDEFS) -S minix_elks.c
+ $(BCC) -Mf -O $(MINIXDEFS) -S minix_elks.c
minixhd.s: minix.c Makefile
- $(BCC) -Mf -O -DHARDDISK $(MDEFS) -S minix.c -o minixhd.s
+ $(BCC) -Mf -O -DHARDDISK $(MINIXDEFS) -S minix.c -o minixhd.s
makeboot: makeboot.c $(BOOTBLOCKS)
$(HOSTCC) $(HOSTCCFLAGS) -o makeboot makeboot.c
makeboot.com: makeboot.c $(BOOTBLOCKS)
- $(BCC) -Md -o makeboot.com makeboot.c
+ $(BCC) -Md -O -o makeboot.com makeboot.c
+
+lsys.com: lsys.c msdos.v
+ $(BCC) -Md -O -o lsys.com lsys.c
version.h:
head -1 ../Libc_version | \
diff --git a/bootblocks/bzimage.c b/bootblocks/bzimage.c
index afb6dde..cb713d7 100644
--- a/bootblocks/bzimage.c
+++ b/bootblocks/bzimage.c
@@ -3,13 +3,9 @@
* friends use.
*/
-#include <stdio.h>
-#include <dos.h>
-#include "i86_funcs.h"
-#include "readfs.h"
+#include "monitor.h"
int auto_flag = 1;
-char * append_line = 0; /* A preset append line value */
static char * initrd_name = 0; /* Name of init_ramdisk to load */
static long initrd_start = 0;
@@ -17,6 +13,7 @@ static long initrd_length = 0;
static int vga_mode = -1; /* SVGA_MODE = normal */
static int is_zimage = 0;
+static char * image_name = 0;
static int image_length; /* Length of image in sectors */
static long image_size; /* Length of image file in bytes */
@@ -25,11 +22,12 @@ static char * input_cmd();
#define ZIMAGE_LOAD_SEG 0x10000 /* Segment that zImage data is loaded */
#define COMMAND_LINE_POS 0x4000 /* Offset in segment 0x9000 of command line */
-#define CALC_CRC
-int has_command_line = 0;
+static char * linux_command_line = 0;
int load_crc = 0;
+static char buffer[1024];
+
cmd_bzimage(ptr)
char * ptr;
{
@@ -57,7 +55,6 @@ bzimage(fname, command_line)
char * fname;
char * command_line;
{
- char buffer[1024];
long len;
char * ptr;
int low_sects;
@@ -67,19 +64,24 @@ char * command_line;
initrd_start = initrd_length = 0;
vga_mode = -1;
is_zimage = 0;
+ image_name = strdup(fname);
- if( open_file(fname) < 0 )
+ /* Ok, deal with the command line */
+ if( build_linuxarg(fname, command_line) < 0 )
+ return -1;
+
+ if( open_file(image_name) < 0 )
{
if( auto_flag == 0 )
- printf("Cannot find file %s\n", fname);
+ printf("Cannot find file %s\n", image_name);
return -1;
}
- printf("Loading %s\n", fname);
+ printf("Loading %s\n", image_name);
- if( read_block(buffer) < 0 || check_magics(fname, buffer) < 0 )
+ if( read_block(buffer) < 0 || check_magics(image_name, buffer) < 0 )
{
- printf("Cannot execute file %s\n", fname);
+ printf("Cannot execute file %s\n", image_name);
return -1;
}
@@ -97,8 +99,8 @@ char * command_line;
len = (image_size=file_length()) * 3 / 1024;
if( main_mem_top < len )
{
- printf("This kernel needs at least %ld.%ldM of main memory\n",
- len/1024, len*10/1024%10);
+ printf("This kernel needs at least %d.%dM of main memory\n",
+ (int)(len/1024), (int)(len*10/1024%10));
return -1;
}
if( main_mem_top < 3072 )
@@ -115,8 +117,8 @@ char * command_line;
{
if( image_length > 0x7FF0/32 )
{
- printf("This zImage file is too large, maximum is %ld bytes\n",
- (0x7FF0/32 + low_sects)*512L );
+ printf("This zImage file is too large, maximum is %dk bytes\n",
+ (0x7FF0/32 + low_sects)/2 );
return -1;
}
}
@@ -127,8 +129,8 @@ char * command_line;
if( image_length > (__get_cs()>>5) - ZIMAGE_LOAD_SEG/32 )
{
- printf("This zImage file is too large, maximum is %ld bytes\n",
- ((__get_cs()>>5) - ZIMAGE_LOAD_SEG/32 + low_sects)*512L );
+ printf("This zImage file is too large, maximum is %dk bytes\n",
+ ((__get_cs()>>5) - ZIMAGE_LOAD_SEG/32 + low_sects)/2 );
return -1;
}
}
@@ -144,8 +146,9 @@ char * command_line;
{
int v;
- printf("%ldk to go \r", len/1024); fflush(stdout);
+ printf("%dk to go \r", (int)(len/1024)); fflush(stdout);
+#ifndef NOCOMMAND
v = (bios_khit()&0x7F);
if( v == 3 || v == 27 )
{
@@ -153,10 +156,11 @@ char * command_line;
bios_getc();
return -1;
}
+#endif
if( read_block(buffer) < 0 )
{
- printf("Error loading %s\n", fname);
+ printf("Error loading %s\n", image_name);
return -1;
}
@@ -184,6 +188,8 @@ char * command_line;
}
}
}
+ close_file();
+
#ifdef CALC_CRC
load_crc = display_crc(0);
#endif
@@ -192,12 +198,7 @@ char * command_line;
if( check_crc() < 0 && !keep_going() ) return -1;
#endif
- /* Yesss, loaded! */
- printf("Loaded, "); fflush(stdout);
-
- /* Ok, deal with the command line */
- if( build_linuxarg(auto_flag, fname, append_line, command_line) < 0 )
- return -1;
+ printf(" \r"); fflush(stdout);
if( initrd_name )
if( load_initrd(address) < 0 )
@@ -207,14 +208,20 @@ char * command_line;
if( check_crc() < 0 && !keep_going() ) return -1;
#endif
- printf("Starting ...\n");
-
- if( x86 < 3 )
+ if( x86 < 3 || x86_emu )
{
- printf("RTFM error: Linux-i386 needs a CPU >= 80386\n");
+ if( x86 < 3 )
+ printf("RTFM error: Linux-i386 needs a CPU >= 80386\n");
+ else if( x86_emu )
+ printf("RTFM error: Linux-i386 cannot be run in an emulator.\n");
if( !keep_going() ) return -1;
}
+ printf("linux ");
+ if( linux_command_line )
+ printf("%s", linux_command_line);
+ fflush(stdout);
+
if( a20_closed() ) open_a20();
if( a20_closed() )
{
@@ -228,20 +235,19 @@ char * command_line;
if( !keep_going() ) return -1;
}
-#ifdef __ELKS__
- printf("Cannot start.\n");
- return -1;
-#endif
-
__set_es(0x9000);
/* Save pointer to command line */
- if( has_command_line )
+ if( linux_command_line )
{
__doke_es(0x0020, 0xA33F);
__doke_es(0x0022, COMMAND_LINE_POS);
+ __movedata(__get_ds(), (unsigned)linux_command_line+1, 0x9000, COMMAND_LINE_POS, strlen(linux_command_line));
+ free(linux_command_line);
}
+ __set_es(0x9000);
+
#if ZIMAGE_LOAD_SEG != 0x10000
#if ZIMAGE_LOAD_SEG != 0x1000
if( is_zimage )
@@ -261,7 +267,7 @@ char * command_line;
#endif
#endif
- /* Tell the kernel where it is */
+ /* Tell the kernel where ramdisk is */
if( initrd_name )
{
__set_es(0x9000);
@@ -312,27 +318,27 @@ char * command_line;
}
}
-check_magics(fname, buffer)
+check_magics(fname, image_buf)
char * fname;
-char * buffer;
+char * image_buf;
{
is_zimage = 0;
/* Boot sector magic number */
- if( *(unsigned short*)(buffer+510) != 0xAA55 ||
+ if( *(unsigned short*)(image_buf+510) != 0xAA55 ||
/* Setup start */
- memcmp(buffer+0x202, "HdrS", 4) != 0 ||
+ memcmp(image_buf+0x202, "HdrS", 4) != 0 ||
/* Setup version */
- *(unsigned short*)(buffer+0x206) < 0x200 )
+ *(unsigned short*)(image_buf+0x206) < 0x200 )
{
printf("File %s is not a linux Image file\n", fname);
return -1;
}
/* Code 32 start address for zImage */
- if( *(unsigned long*)(buffer+0x214) == 0x1000 )
+ if( *(unsigned long*)(image_buf+0x214) == 0x1000 )
{
printf("File %s is a zImage file\n", fname);
is_zimage = 1;
@@ -340,9 +346,9 @@ char * buffer;
}
else
/* Code 32 start address bzImage */
- if( *(unsigned long*)(buffer+0x214) != 0x100000 )
+ if( *(unsigned long*)(image_buf+0x214) != 0x100000 )
{
- printf("File %s is not a bzImage file\n", fname);
+ printf("File %s is a strange Image file\n", fname);
return -1;
}
printf("File %s is a bzImage file\n", fname);
@@ -351,26 +357,26 @@ char * buffer;
}
#ifndef __ELKS__
-putsect(buffer, address)
-char * buffer;
+putsect(put_buf, address)
+char * put_buf;
unsigned int address;
{
int rv, tc=3;
/* In real mode memory, just put it directly */
if( address < 0xA00 )
{
- __movedata(__get_ds(), buffer, address*16, 0, 512);
+ __movedata(__get_ds(), put_buf, address*16, 0, 512);
return 0;
}
retry:
tc--;
-#if 0
- if( x86_emu )
+ /*
+ if( x86_test )
return 0; /* In an EMU we can't write to high mem but
we'll pretend we can for debuggering */
-#endif
- if( (rv=ext_put(buffer, address, 512)) != 0 )
+
+ if( (rv=ext_put(put_buf, address, 512)) != 0 )
{
switch(rv)
{
@@ -391,10 +397,6 @@ retry:
printf("Error %d while copying to extended memory\n", rv);
break;
}
- if( x86 < 3 )
- printf("RTFM error: Linux-i386 needs a CPU >= 80386\n");
- else if( x86_emu )
- printf("RTFM error: Linux-i386 cannot be run in an emulator.\n");
return -1;
}
return 0;
@@ -402,29 +404,21 @@ retry:
#endif
static char *
-read_cmdfile(iname, extno)
+read_cmdfile(iname)
char * iname;
-int extno;
{
- char buffer[1024];
char buf[16];
long len;
char * ptr = strchr(iname, '.');
buf[8] = '\0';
strncpy(buf, iname, 8);
- switch(extno)
- {
- case 1: strcat(buf, ".cmd"); break;
- case 2: strcat(buf, ".app"); break;
- case 3: strcat(buf, ".dfl"); break;
- default: return 0;
- }
+ strcat(buf, ".cfg");
if( ptr == 0 && open_file(buf) >= 0 )
{
/* Ah, a command line ... */
- if( extno == 1 ) printf("Loading %s\n", buf);
+ printf("Loading %s\n", buf);
len = file_length();
if( len > 1023 )
{
@@ -438,9 +432,11 @@ int extno;
if( buffer[i] < ' ' ) buffer[i] = ' ';
buffer[len] = '\0';
+ close_file(); /* Free up loads a room */
return strdup(buffer);
}
}
+ close_file(); /* Free up loads a room */
return 0;
}
@@ -448,7 +444,6 @@ char *
input_cmd(iname)
char * iname;
{
- char buffer[1024];
char lbuf[20];
int cc;
@@ -479,50 +474,46 @@ char * iname;
return strdup(buffer);
}
-build_linuxarg(auto_flg, image, append, cmd)
-int auto_flg;
-char *image, *append, *cmd;
+build_linuxarg(image, cmd)
+char *image, *cmd;
{
static char * auto_str = "auto";
static char * image_str = "BOOT_IMAGE=";
int len = 0;
char * ptr, *s, *d;
-
char * free_cmd = 0;
- char * free_app = 0;
- char * free_dfl = 0;
+ char * free_inp = 0, * inp = 0;
- has_command_line = 0;
+ image_name = strdup(image);
- if( append == 0 )
- append = free_app = read_cmdfile(image, 2);
+ if( linux_command_line ) free(linux_command_line);
+ linux_command_line = 0;
if( cmd == 0 )
- cmd = free_cmd = read_cmdfile(image, 1);
-
- if( cmd == 0 )
- free_dfl = read_cmdfile(image, 3);
-
- close_file(); /* Free up loads a room */
+ cmd = free_cmd = read_cmdfile(image);
if( cmd == 0 )
{
- cmd = free_cmd = input_cmd(image);
- auto_flg = 0;
+ if( auto_flag ) return 0;
+ printf("No such command file\n");
+ return -1;
}
- if( cmd == 0 )
+ if( auto_flag )
{
- printf("Aborted execution\n");
- return -1;
+ ptr = strdup(cmd);
+ for(s=strtok(ptr, " "); s; s=strtok((char*)0, " "))
+ {
+ if( strncasecmp(s, "prompt",6) == 0 && free_inp == 0)
+ inp = free_inp = input_cmd(image);
+ }
+ free(ptr);
}
- else if( *cmd == 0 )
- cmd = free_dfl;
- if( auto_flg ) len += strlen(auto_str) + 1;
+ if( auto_flag ) len += strlen(auto_str) + 1;
if( image ) len += strlen(image_str) + strlen(image) + 1;
- if( append ) len += strlen(append) + 1;
if( cmd ) len += strlen(cmd) + 1;
+ if( inp ) len += strlen(inp) + 1;
if( len == 0 ) return 0;
@@ -531,20 +522,17 @@ static char * image_str = "BOOT_IMAGE=";
{
printf("Unable to create linux command line\n");
if( free_cmd ) free(free_cmd);
- if( free_app ) free(free_app);
- if( free_dfl ) free(free_dfl);
+ if( free_inp ) free(free_inp);
return -1;
}
*ptr = 0; ptr[1] = 0;
- if( auto_flg ) { strcat(ptr, " "); strcat(ptr, auto_str); }
- if( image ) { strcat(ptr, " "); strcat(ptr, image_str); strcat(ptr, image); }
- if( append ) { strcat(ptr, " "); strcat(ptr, append); }
+ if( auto_flag ) { strcat(ptr, " "); strcat(ptr, auto_str); }
if( cmd ) { strcat(ptr, " "); strcat(ptr, cmd); }
+ if( inp ) { strcat(ptr, " "); strcat(ptr, inp); }
if( free_cmd ) free(free_cmd);
- if( free_app ) free(free_app);
- if( free_dfl ) free(free_dfl);
+ if( free_inp ) free(free_inp);
if( (d = malloc(len+1)) == 0 )
{
@@ -555,16 +543,16 @@ static char * image_str = "BOOT_IMAGE=";
*d = '\0';
for(s=strtok(ptr, " "); s; s=strtok((char*)0, " "))
{
- if( strncmp(s, "vga=",4) == 0 )
+ if( strncasecmp(s, "vga=",4) == 0 )
{
- if( strncmp(s+4, "ask", 3) == 0 )
+ if( strncasecmp(s+4, "ask", 3) == 0 )
vga_mode = -3;
else
{
s+=4; getnum(&s, &vga_mode);
}
}
- else if( strncmp(s, "ramdisk_file=", 13) == 0 )
+ else if( strncasecmp(s, "ramdisk_file=", 13) == 0 )
{
if( initrd_name ) free(initrd_name);
if( s[13] )
@@ -572,6 +560,16 @@ static char * image_str = "BOOT_IMAGE=";
else
initrd_name = 0;
}
+ else if( strncasecmp(s, image_str, 11) == 0 )
+ {
+ if( image_name ) free(image_name);
+ if( s[11] )
+ image_name = strdup(s+11);
+ else
+ image_name = strdup(image);
+ }
+ else if( strncasecmp(s, "prompt",6) == 0 )
+ ;
else
{
strcat(d, " ");
@@ -579,6 +577,8 @@ static char * image_str = "BOOT_IMAGE=";
}
}
free(ptr); ptr = d;
+
+ strcat(ptr, " "); strcat(ptr, image_str); strcat(ptr, image_name);
len = strlen(ptr);
if( len > 2048 )
@@ -590,18 +590,9 @@ static char * image_str = "BOOT_IMAGE=";
#ifdef __ELKS__
fprintf(stderr, "Command line: '%s'\n", ptr+1);
-#else
-/* Commented to allow for CRC check.
- __set_es(0x9000);
- __doke_es(0x0020, 0xA33F);
- __doke_es(0x0022, COMMAND_LINE_POS);
-*/
-
- __movedata(__get_ds(), (unsigned)ptr+1, 0x9000, COMMAND_LINE_POS, len);
- has_command_line = 1;
#endif
- free(ptr);
+ linux_command_line = ptr;
return 0;
}
@@ -609,18 +600,26 @@ static char * image_str = "BOOT_IMAGE=";
keep_going()
{
static int burning = 0;
- char buf[1];
+ char buf[4];
int cc;
printf("Keep going ? "); fflush(stdout);
+#ifdef __STANDALONE__
cc = read(0, buf, 1);
- if( cc == 1 && (*buf == 'Y' || *buf == 'y') )
+#else
+ cc = read(0, buf, 4);
+#endif
+ if( cc >= 1 && (*buf == 'Y' || *buf == 'y') )
{
printf("Yes, Ok%s\n", burning?"":", burn baby burn!");
return burning=1;
}
+#ifdef NOCOMMAND
+ printf("No, Ok press enter to reboot\n");
+#else
printf("No, Ok returning to monitor prompt\n");
+#endif
return 0;
}
@@ -631,8 +630,6 @@ unsigned int k_top;
long file_len;
char * fname = initrd_name;
- char buffer[1024];
-
/* Top of accessable memory */
if( main_mem_top >= 15360 ) address = 0xFFFF;
else address = 0x1000 + main_mem_top*4;
@@ -668,6 +665,7 @@ unsigned int k_top;
for( ; rd_len>0 ; rd_len--)
{
+#ifndef NOCOMMAND
int v = (bios_khit()&0x7F);
if( v == 3 || v == 27 )
{
@@ -675,6 +673,7 @@ unsigned int k_top;
bios_getc();
return -1;
}
+#endif
printf("%dk to go \r", rd_len); fflush(stdout);
if( read_block(buffer) < 0 )
@@ -687,7 +686,9 @@ unsigned int k_top;
if( putsect(buffer+512, address) < 0 ) return -1;
address+=2;
}
- printf("Loaded, ");
+ printf(" \r"); fflush(stdout);
+
+ close_file();
initrd_start = ((long) rd_start <<8);
initrd_length = file_len;
@@ -698,7 +699,6 @@ unsigned int k_top;
#ifdef CALC_CRC
check_crc()
{
- char buffer[512];
int low_sects;
unsigned int address = 0x900;
long len;
diff --git a/bootblocks/commands.c b/bootblocks/commands.c
new file mode 100644
index 0000000..459430d
--- /dev/null
+++ b/bootblocks/commands.c
@@ -0,0 +1,210 @@
+
+#include "monitor.h"
+
+#ifndef NOCOMMAND
+extern unsigned int current_address;
+extern int number_base;
+
+int cmd_quit(args)
+char * args;
+{
+ printf("Bye\n");
+ exit(0);
+}
+
+int cmd_nop(ptr)
+char * ptr;
+{
+}
+
+int cmd_dir(ptr)
+char * ptr;
+{
+ open_file(".");
+ return 0;
+}
+
+int cmd_type(ptr)
+char * ptr;
+{
+ char * fname;
+ char buffer[1024];
+ long len;
+
+ while(*ptr == ' ') ptr++;
+ if( (fname=ptr) == 0 ) return 0;
+ while(*ptr & *ptr != ' ') ptr++;
+
+ if( open_file(fname) >= 0 ) for(len=file_length(); len>0; len-=1024)
+ {
+ if( read_block(buffer) < 0 ) break;
+ if( len > 1024 )
+ write(1, buffer, 1024);
+ else
+ write(1, buffer, len);
+ }
+ else
+ printf("Cannot open file '%s'\n", fname);
+ close_file();
+ return 0;
+}
+
+int cmd_more(ptr)
+char * ptr;
+{
+ char * fname;
+ char buffer[1024];
+ long len;
+ int cc;
+ char * sptr;
+
+ while(*ptr == ' ') ptr++;
+ if( (fname=ptr) == 0 ) return 0;
+ while(*ptr & *ptr != ' ') ptr++;
+
+ more_char(-1);
+
+ if( open_file(fname) >= 0 ) for(len=file_length(); len>0; len-=1024)
+ {
+ if( read_block(buffer) < 0 ) break;
+ if( len > 1024 ) cc = 1024; else cc = len;
+ for(sptr=buffer; cc>0 ; cc--,sptr++)
+ {
+ if( more_char(*sptr & 0xFF) < 0 ) goto break_break;
+ }
+ }
+ else
+ printf("Cannot open file '%s'\n", fname);
+break_break:;
+ close_file();
+ return 0;
+}
+
+more_char(ch)
+int ch;
+{
+static int line_number = 0;
+
+ if( ch == -1 ) { line_number = 0; return 0; }
+
+ if( (ch & 0xE0 ) || ch == '\n' )
+ putchar(ch);
+ if( ch == '\n' && ++line_number == 24)
+ {
+ char buf[4];
+ printf("More ?"); fflush(stdout);
+ if( read(0, buf, 1) <= 0 ) return -1;
+ if( buf[0] == 3 || buf[0] == '\033'
+ || buf[0] == 'q' || buf[0] == 'Q' ) return -1;
+ if( buf[0] == '\r' ) line_number--;
+ if( buf[0] == ' ' ) line_number=2;
+ printf("\r \r");
+ }
+ return 0;
+}
+
+more_strn(str, len)
+char * str;
+int len;
+{
+ for(; len>0 && *str ; len--,str++)
+ if( more_char( *str & 0xFF ) < 0 ) return -1;
+ return 0;
+}
+#endif
+
+/**************************************************************************/
+
+#ifndef NOMONITOR
+
+cmd_regs()
+{
+#ifdef __STANDALONE__
+ printf("REGS: AX=%04x BX=%04x CX=%04x DX=%04x SI=%04x DI=%04x\n",
+ __argr.x.ax, __argr.x.bx, __argr.x.cx, __argr.x.dx,
+ __argr.x.si, __argr.x.di);
+#else
+ printf("Only in standalone\n");
+#endif
+}
+
+int cmd_memdump(ptr)
+char * ptr;
+{
+ int count = 128;
+ int i,j;
+ int es = __get_es();
+
+#define rmem(x) __peek_es( (x)+current_address )
+
+ getnum(&ptr, &current_address);
+ getnum(&ptr, &count);
+
+ for(i=0; i<count; i+=16)
+ {
+ printf("%04x:%04x:", es, current_address);
+ for(j=0; j<16; j++)
+ printf(" %s%02x", (j==8)?" ":"", rmem(j));
+ printf(" ");
+ for(j=0; j<16; j++)
+ if( rmem(j) >= ' ' && rmem(j) <= '~' )
+ putchar(rmem(j));
+ else
+ putchar('.');
+ putchar('\n');
+ current_address += 16;
+ current_address &= 0xFFFF;
+ }
+
+#undef rmem
+}
+
+int cmd_seg(ptr)
+char * ptr;
+{
+ int es = __get_es();
+
+ if( getnum(&ptr, &es) )
+ {
+ __set_es(es);
+ current_address = 0;
+ }
+ else
+ printf("Current segment 0x%04x\n", es);
+ return 0;
+}
+
+int cmd_set_base(ptr)
+{
+ int obase = number_base;
+ int nbase;
+ number_base = 10;
+
+ if( getnum(&ptr, &nbase) )
+ {
+ if( nbase < 2 || nbase > 36 )
+ printf("Can't use that base\n");
+ else
+ obase = nbase;
+ }
+ else printf("Current base is %d\n", obase);
+
+ number_base = obase;
+ return 0;
+}
+
+int cmd_rel(ptr)
+char * ptr;
+{
+ int nseg = 0xFFFF;
+ int cs = __get_cs();
+
+ getnum(&ptr, &nseg);
+
+ relocator(nseg);
+ if( __get_cs() == cs )
+ printf("Didn't relocate; CS=$%04x DS=$%04x\n", __get_cs(), __get_ds());
+ else
+ printf("Relocated to CS=$%04x DS=$%04x\n", __get_cs(), __get_ds());
+}
+#endif
diff --git a/bootblocks/fs.c b/bootblocks/fs.c
index ee81c55..037f8a4 100644
--- a/bootblocks/fs.c
+++ b/bootblocks/fs.c
@@ -1,8 +1,7 @@
-#ifdef __ELKS__
-#include <stdio.h>
-#endif
-#include "readfs.h"
+#include "monitor.h"
+
+#ifndef SINGLEFS
int fs_type = 0;
@@ -79,3 +78,5 @@ char * buffer;
}
return -1;
}
+
+#endif
diff --git a/bootblocks/fs_dos.c b/bootblocks/fs_dos.c
index d2ca5eb..bc223fc 100644
--- a/bootblocks/fs_dos.c
+++ b/bootblocks/fs_dos.c
@@ -1,10 +1,9 @@
-#include <stdio.h>
-#include <ctype.h>
-#include <malloc.h>
-#include "readfs.h"
+#include "monitor.h"
-#define DONT_BUFFER_FAT
+#ifdef MINI_BUF
+#define BUFFER_FAT
+#endif
#define DOS_SECT(P) get_uint(P,0x0B)
#define DOS_CLUST(P) get_byte(P,0x0D)
@@ -28,7 +27,7 @@
static int read_bootblock();
static int dir_nentry, dir_sect;
-static int dos_clust0, dos_spc, dos_fatpos;
+static int dos_clust0, dos_spc, dos_fatpos, dos_fatlen;
static int last_serial = 0;
#ifdef BUFFER_FAT
@@ -87,22 +86,17 @@ char * fname;
memset(&cur_file, '\0', sizeof(cur_file));
#ifdef BUFFER_FAT
- s = read_sector(0);
-
if( !dodir )
{
/* Read in and buffer the FAT */
if( fat_buf ) free(fat_buf);
- fat_buf = malloc(DOS_FATLEN(s) * 512);
+ fat_buf = malloc(dos_fatlen * 512);
if( fat_buf == 0 ) return -1;
else
{
- int fatsec = DOS_RESV(s);
- int nsec = DOS_FATLEN(s);
-
- for(i=0; i<nsec; i++)
+ for(i=0; i<dos_fatlen; i++)
{
- s = read_sector(fatsec+i);
+ s = read_sector(dos_fatpos+i);
if(s == 0) return -1;
memcpy(fat_buf+i*512, s, 512);
}
@@ -118,6 +112,9 @@ char * fname;
d = s + (i%16)*32;
if( dodir )
{
+#ifdef NOCOMMAND
+ break;
+#else
char dtime[20];
char lbuf[90];
*lbuf = 0;
@@ -143,6 +140,7 @@ char * fname;
break;
}
if( more_strn(lbuf, sizeof(lbuf)) < 0 ) break;
+#endif
}
else if( memcmp(d, conv_name, 11) == 0 && (d[11]&0x18) == 0 )
{ /* Name matches and is normal file */
@@ -303,6 +301,7 @@ static int read_bootblock()
dir_nentry = DOS_NROOT(sptr);
dos_fatpos = DOS_RESV(sptr);
+ dos_fatlen = DOS_FATLEN(sptr);
dos_spc = DOS_CLUST(sptr);
if( dos_spc < 1 ) dos_spc = 1;
dos_clust0 = dir_sect + (dir_nentry+15)/16 - 2*dos_spc;
diff --git a/bootblocks/fs_min.c b/bootblocks/fs_min.c
index 78a5fc9..4f4c33e 100644
--- a/bootblocks/fs_min.c
+++ b/bootblocks/fs_min.c
@@ -1,5 +1,5 @@
-#include "readfs.h"
+#include "monitor.h"
min_open_file(fname)
char * fname;
diff --git a/bootblocks/fs_tar.c b/bootblocks/fs_tar.c
index 2a30ee2..1dac3a4 100644
--- a/bootblocks/fs_tar.c
+++ b/bootblocks/fs_tar.c
@@ -1,7 +1,5 @@
-#include <stdio.h>
-#include <dos.h>
-#include "readfs.h"
+#include "monitor.h"
#define HEADER_SIZE 512
#define NAME_SIZE 100
@@ -38,10 +36,6 @@ void tar_set_drive();
static int disk_size = 0;
-#ifdef __STANDALONE__
-extern union REGS __argr;
-#endif
-
struct tx {
char name[NAME_SIZE];
int first_sectno;
diff --git a/bootblocks/help.c b/bootblocks/help.c
index 5083fdc..3d53fad 100644
--- a/bootblocks/help.c
+++ b/bootblocks/help.c
@@ -5,8 +5,7 @@
* previous and next page.
*/
-#include <stdio.h>
-#include "readfs.h"
+#include "monitor.h"
struct keys {
int key;
diff --git a/bootblocks/i86_funcs.c b/bootblocks/i86_funcs.c
index 90fbbbc..b45343e 100644
--- a/bootblocks/i86_funcs.c
+++ b/bootblocks/i86_funcs.c
@@ -1,24 +1,21 @@
-#include <stdio.h>
-#include <errno.h>
-#include <dos.h>
-#include "i86_funcs.h"
+#include "monitor.h"
int x86 = 0; /* CPU major number */
char *x86_name = ""; /* and it's name */
int x86_emu = 0; /* Is this a PC emulator ? */
int x86_a20_closed = 1; /* Is the A20 gate closed ? */
-int x86_test = 0; /* In test mode */
int x86_fpu = 0;
+int x86_test = 0; /* In test mode */
+
unsigned boot_mem_top = 0x2000; /* Default 128k, the minimum */
long main_mem_top = 0; /* K of extended memory */
int a20_closed()
{
register int v, rv = 0;
- if (x86_test)
- return 1; /* If not standalone don't try */
+ if (x86_test) return 1; /* If not standalone don't try */
__set_es(0);
v = __peek_es(512);
@@ -36,7 +33,7 @@ int a20_closed()
return x86_a20_closed = rv;
}
-void open_a20()
+static void asm_open_a20()
{
#asm
call empty_8042
@@ -53,10 +50,12 @@ empty_8042:
#endasm
}
+void open_a20() { if(!x86_test) asm_open_a20(); }
+
/* This calls the BIOS to open the A20 gate, officially this is only supported
on PS/2s but if the normal routine fails we may as well try this.
*/
-void bios_open_a20()
+void asm_bios_open_a20()
{
#asm
mov ax,#$2401
@@ -69,6 +68,8 @@ bios_failed_a20:
#endasm
}
+void bios_open_a20() { if(!x86_test) asm_bios_open_a20(); }
+
void cpu_check()
{
static char *name_808x[] =
@@ -105,11 +106,22 @@ void cpu_check()
x86_name = cpubuf;
if (c & 0x01) x86_emu = 1; /* Already in protected mode !!! */
}
+
+#ifdef __STANDALONE__
+ x86_test = x86_emu;
+#else
+ x86_test = 1;
+#endif
}
void mem_check()
{
- if (x86_test) return; /* If not standalone don't try */
+ if (x86_test)
+ {
+ main_mem_top = 16384;
+ return; /* If not standalone don't try */
+ }
+
{
#asm
int 0x12 ! Amount of boot memory
diff --git a/bootblocks/i86_funcs.h b/bootblocks/i86_funcs.h
index 9eb1b05..2fdb860 100644
--- a/bootblocks/i86_funcs.h
+++ b/bootblocks/i86_funcs.h
@@ -6,8 +6,8 @@ extern int x86; /* CPU major number (0-3) */
extern char *x86_name; /* and it's name */
extern int x86_emu; /* Is this a PC emulator ? */
extern int x86_a20_closed; /* Is the A20 gate closed ? */
-extern int x86_test; /* In test mode */
extern int x86_fpu;
+extern int x86_test; /* Running in test mode ? */
extern unsigned boot_mem_top; /* Top of RAM below 1M */
extern long main_mem_top; /* Top of RAM above 1M */
diff --git a/bootblocks/lsys.c b/bootblocks/lsys.c
new file mode 100644
index 0000000..77f3931
--- /dev/null
+++ b/bootblocks/lsys.c
@@ -0,0 +1,134 @@
+
+#include "msdos.v"
+
+#define DOS_SYSID 0x03
+#define DOS_SECT 0x0B
+#define DOS_CLUST 0x0D
+#define DOS_RESV 0x0E
+#define DOS_NFAT 0x10
+#define DOS_NROOT 0x11
+#define DOS_MAXSECT 0x13
+#define DOS_MEDIA 0x15
+#define DOS_FATLEN 0x16
+#define DOS_SPT 0x18
+#define DOS_HEADS 0x1A
+#define DOS_HIDDEN 0x1C
+#define DOS4_MAXSECT 0x20
+#define DOS4_PHY_DRIVE 0x24
+#define DOS4_SERIAL 0x27
+#define DOS4_LABEL 0x2B
+#define DOS4_FATTYPE 0x36
+
+unsigned char buffer[1024];
+
+int drive = 0;
+
+main(argc, argv)
+int argc;
+char ** argv;
+{
+ int tries, rv, i;
+
+ if( argc > 1 )
+ {
+ static char * s = "Usage: sys a:";
+ if( argc == 1 && argv[1][1] == ':' && argv[1][2] == 0 )
+ {
+ if( argv[1][0] == 'a' || argv[1][0] == 'A' )
+ drive = 0;
+ else if( argv[1][0] == 'b' || argv[1][0] == 'B' )
+ drive = 1;
+ else
+ fatal(s);
+ }
+ else
+ fatal(s);
+ }
+
+ for(tries=0; tries<6; tries++)
+ if( (rv = dos_sect_read(drive, 0, 0, 1, buffer)) == 0 )
+ break;
+ if( rv == 0 )
+ for(tries=0; tries<6; tries++)
+ if( (rv = dos_sect_read(drive, 0, 0, 2, buffer+512)) == 0 )
+ break;
+ if( rv ) fatal("Cannot read bootsector");
+
+ if( buffer[DOS_MEDIA] != buffer[512] ||
+ buffer[DOS_MEDIA] < 0xF0 ||
+ buffer[DOS_NFAT] > 2 ||
+ buffer[DOS_SECT+1] != 2 ||
+ buffer[DOS_HEADS] != 2 )
+ fatal("Floppy has invalid format");
+
+ for(i=0; i<msdos_dosfs_stat; i++)
+ buffer[i] = msdos_data[i];
+ for(i=msdos_codestart; i<512; i++)
+ buffer[i] = msdos_data[i];
+
+ for(tries=0; tries<6; tries++)
+ if( (rv = dos_sect_read(drive, 0, 0, 1, buffer)) == 0 )
+ break;
+ if( rv ) fatal("Cannot write bootsector");
+
+ return 0;
+}
+
+fatal(str)
+{
+ write(0, str, strlen(str));
+ exit(1);
+}
+
+dos_sect_write(drv, track, head, sector, loadaddr)
+{
+#asm
+ push bp
+ mov bp,sp
+
+ push ds
+ pop es
+
+ mov dh,[bp+2+_dos_sect_write.head]
+ mov dl,[bp+2+_dos_sect_write.drv]
+ mov cl,[bp+2+_dos_sect_write.sector]
+ mov ch,[bp+2+_dos_sect_write.track]
+
+ mov bx,[bp+2+_dos_sect_write.loadaddr]
+
+ mov ax,#$0301
+ int $13
+ jc write_err
+ mov ax,#0
+write_err:
+
+ pop bp
+#endasm
+}
+
+dos_sect_read(drv, track, head, sector, loadaddr)
+{
+#asm
+ push bp
+ mov bp,sp
+
+ push ds
+ pop es
+
+ mov dh,[bp+2+_dos_sect_read.head]
+ mov dl,[bp+2+_dos_sect_read.drv]
+ mov cl,[bp+2+_dos_sect_read.sector]
+ mov ch,[bp+2+_dos_sect_read.track]
+
+ mov bx,[bp+2+_dos_sect_read.loadaddr]
+
+ mov ax,#$0201
+ int $13
+ jc read_err
+ mov ax,#0
+read_err:
+
+ pop bp
+#endasm
+}
+
diff --git a/bootblocks/makeboot.c b/bootblocks/makeboot.c
index 53b5a82..4eda4c6 100644
--- a/bootblocks/makeboot.c
+++ b/bootblocks/makeboot.c
@@ -22,6 +22,10 @@ unsigned char buffer[1024];
#define FS_ZERO 5 /* Boot sector must be Zapped */
#define FS_MBR 6 /* Boot sector is an MBR */
+#ifndef __MSDOS__
+#define NOT_HAS_2M20
+#endif
+
struct bblist {
char * name;
char * desc;
@@ -192,6 +196,7 @@ char * diskname;
#endif
disktype = 0;
diskfd = fopen(diskname, "r+");
+ if( diskfd == 0 ) diskfd = fopen(diskname, "r");
if( diskfd == 0 )
{
fprintf(stderr, "Cannot open %s\n", diskname);
@@ -243,6 +248,7 @@ char * loadaddr;
fprintf(stderr, "Cannot write sector %d\n", sectno);
return -1;
}
+ printf("Wrote sector %d\n", sectno);
return 0;
}
@@ -649,9 +655,17 @@ check_msdos()
( dosflds[DOS_MEDIA].value != (0xFF&buffer[512])
&& dosflds[DOS_RESV].value == 1 ) )
{
- printf("Bad 2nd boot block - reloading first\n");
- if( read_sector(0, buffer) != 0 )
- exit(1);
+ if( force )
+ {
+ printf("Bad 2nd boot block - reloading first\n");
+ if( read_sector(0, buffer) != 0 )
+ exit(1);
+ }
+ else
+ {
+ printf("Bad 2nd boot block\n");
+ exit(1);
+ }
}
check_msdos();
}
@@ -735,6 +749,8 @@ char * mbr_data;
/**************************************************************************/
+#ifdef HAS_2M20
+
char boot_sector_2m_23_82[] = {
0xe9,0x7d,0x00,0x32,0x4d,0x2d,0x53,0x54,0x56,0x30,0x34,0x00,0x02,0x01,0x01,0x00,
0x02,0xe0,0x00,0xbc,0x0e,0xfa,0x0b,0x00,0x17,0x00,0x02,0x00,0x00,0x00,0x00,0x00,
@@ -968,21 +984,28 @@ char program_2m_vsn_20[] = {
0x26,0x88,0x26,0x43,0x00,0xbf,0xfc,0x09,0xbe,0x4c,0x00,0xfc,0xfa,0xa5,0xa5,0xc7,
0x44,0xfc,0x5b,0x00,0x8c,0x44,0xfe,0xfb,0x1f,0xcb,0x00,0x00,0xd9,0x09,0x55,0xaa
};
+#endif
+
+char program_2m_magic[] = {
+0x2b,0x00,0x43,0x00,0x32,0x30,0x32,0x4d,0x2d,0x53,0x54,0x56,0x00,0x00,0x00,0x00
+};
do_2m_write()
{
int i;
+ char * mbr;
if( read_sector(bs_offset+1, buffer+512) != 0 )
exit(1);
- if( memcmp(buffer+512, program_2m_vsn_20, 16) == 0 )
+ if( memcmp(buffer+512, program_2m_magic, 16) == 0 )
{
/* Seems to be properly formatted already */
write_sector(bs_offset, buffer);
return;
}
+#ifdef HAS_2M20
else if( disk_trck != 82 || disk_sect != 22 )
{
fprintf(stderr, "To be bootable a 2M disk must be 22 sectors 82 tracks or formatted with 2m20.\n");
@@ -994,10 +1017,13 @@ do_2m_write()
/* This needs to be altered to allow for the disk format description to
be copied from the old boot sector */
+ if( disk_sect == 23 ) mbr = boot_sector_2m_23_82;
+ else mbr = boot_sector_2m_22_82;
+
for(i=0; i<sysboot_dosfs_stat; i++)
- buffer[i] = boot_sector_2m_22_82[i];
+ buffer[i] = mbr[i];
for(i=sysboot_codestart; i<512; i++)
- buffer[i] = boot_sector_2m_22_82[i];
+ buffer[i] = mbr[i];
write_sector(0, buffer);
@@ -1005,4 +1031,8 @@ do_2m_write()
{
write_sector(bs_offset+i/512+1, program_2m_vsn_20+i);
}
+#else
+ fprintf(stderr, "To be bootable a 2M disk must be formatted with the 2m20 device driver.\n");
+ exit(1);
+#endif
}
diff --git a/bootblocks/mbr.s b/bootblocks/mbr.s
index c0fa542..0d8560e 100644
--- a/bootblocks/mbr.s
+++ b/bootblocks/mbr.s
@@ -180,14 +180,11 @@ pre_boot_table:
endif
if diskman
- if *>ORGADDR+0xfc
- fail! Disk manager partition overlap
- endif
org ORGADDR+0xFC
public diskman_magic
diskman_magic:
- .word $55AA
+ .word 0xAA55
low_partition:
public partition_16
partition_16 = low_partition+0x00
diff --git a/bootblocks/min_buf.c b/bootblocks/min_buf.c
new file mode 100644
index 0000000..97324f3
--- /dev/null
+++ b/bootblocks/min_buf.c
@@ -0,0 +1,105 @@
+
+#include "monitor.h"
+
+#ifdef MINI_BUF
+#ifndef MAXTRK
+#define MAXTRK 21
+#endif
+
+int disk_drive = 0;
+int disk_spt = 7;
+int disk_heads = 2;
+int disk_cyls = 0;
+int bad_track = -1;
+
+static int track_no = -1;
+static char buffer[MAXTRK*512];
+
+void reset_disk()
+{
+ disk_spt = 7;
+ disk_heads = 2;
+ disk_cyls = 0;
+ bad_track = -1;
+}
+
+char * read_lsector(sectno)
+long sectno;
+{
+ int tries = 5;
+ int rv = 0;
+
+ int phy_s = 1;
+ int phy_h = 0;
+ int phy_c = 0;
+ int ltrack;
+
+ if( sectno == 0 ) reset_disk();
+
+ if( disk_spt < 1 || disk_heads < 1 )
+ phy_s = sectno;
+ else
+ {
+ phy_s = sectno%disk_spt;
+ phy_h = sectno/disk_spt%disk_heads;
+ phy_c = sectno/disk_spt/disk_heads;
+ }
+
+#ifdef __ELKS__
+ fprintf(stderr, "read_sector(%ld = %d,%d,%d)\n", sectno, phy_c, phy_h, phy_s);
+#endif
+
+ ltrack = phy_c*disk_heads+phy_h;
+ if( disk_spt > 7 && disk_spt <= MAXTRK
+ && track_no != ltrack && ltrack != bad_track)
+ {
+ rv = phy_read(disk_drive, phy_c, phy_h, 1, disk_spt, buffer);
+ if( rv == 0 )
+ track_no = ltrack;
+ else
+ bad_track = ltrack;
+ }
+ if( track_no == phy_c*disk_heads+phy_h )
+ return buffer + phy_s * 512;
+
+ do
+ {
+ rv = phy_read(disk_drive, phy_c, phy_h, phy_s+1, 1, buffer);
+ tries--;
+ if( rv ) printf("Error in phy_read(%d,%d,%d,%d,%d,%d);\n",
+ disk_drive, phy_c, phy_h, phy_s+1, 1, buffer);
+ }
+ while(rv && tries > 0);
+
+ if(rv) return 0; else return buffer;
+}
+
+#if defined(__MSDOS__) || defined(__STANDALONE__)
+phy_read(drive, cyl, head, sect, length, buffer)
+{
+#asm
+ push bp
+ mov bp,sp
+
+ push ds
+ pop es
+
+ mov dl,[bp+2+_phy_read.drive]
+ mov ch,[bp+2+_phy_read.cyl]
+ mov dh,[bp+2+_phy_read.head]
+ mov cl,[bp+2+_phy_read.sect]
+ mov al,[bp+2+_phy_read.length]
+ mov bx,[bp+2+_phy_read.buffer]
+
+ mov ah,#$02
+ int $13
+ jc read_err
+ mov ax,#0
+read_err:
+
+ pop bp
+#endasm
+}
+#endif
+
+#endif
diff --git a/bootblocks/monitor.c b/bootblocks/monitor.c
index 4b7b75c..a44bad7 100644
--- a/bootblocks/monitor.c
+++ b/bootblocks/monitor.c
@@ -1,22 +1,15 @@
-#include <stdio.h>
-#include <errno.h>
-#include <ctype.h>
-#include <dos.h>
-#include "i86_funcs.h"
-#include "readfs.h"
+#include "monitor.h"
#include "version.h"
-#ifdef __STANDALONE__
-#define NOT_VT52COLOUR
-#define NOT_ANSICOLOUR
-#endif
-
char command_buf[256];
typedef int (*proc)();
-int cmd_quit(), cmd_dump(), cmd_seg(), cmd_rel();
+int cmd_quit(), cmd_dump(), cmd_seg(), cmd_rel(), cmd_bzimage(), cmd_help();
+int cmd_nop(), cmd_memdump(), cmd_set_base(), cmd_dir(), cmd_type(), cmd_more();
+int cmd_regs();
+
void init_prog();
extern struct t_cmd_list {
@@ -24,19 +17,10 @@ extern struct t_cmd_list {
proc func;
} cmd_list[];
-static unsigned int current_address;
-static int number_base = 16;
-#ifdef __STANDALONE__
- extern union REGS __argr;
-#endif
+unsigned int current_address;
+int number_base = 16;
-#ifdef __STANDALONE__
main()
-#else
-main(argc, argv)
-int argc;
-char ** argv;
-#endif
{
static char minibuf[2] = " ";
int ch, i;
@@ -45,11 +29,11 @@ static char minibuf[2] = " ";
#ifdef __STANDALONE__
printf("\r");
-#else
- if( argc > 1 && strcmp(argv[1], "-t") == 0 ) x86_test=0; else x86_test=1;
#endif
init_prog();
+#ifdef __STANDALONE__
+#ifndef NOCOMMAND
if( __get_ds() != 0x1000 )
{
relocator(-1);
@@ -57,27 +41,26 @@ static char minibuf[2] = " ";
if( __get_ds() > 0x1000 ) relocator(2);
printf("Relocated to CS=$%04x DS=$%04x\n", __get_cs(), __get_ds());
}
+#endif
-#ifdef __STANDALONE__
if( (__argr.x.dx & 0xFF) == 0 )
#endif
{
display_help(0);
-
+#ifndef NOCOMMAND
if( x86 > 2 && !x86_emu ) /* Check some basics */
- cmd_bzimage((void*)0);
-#if 0
- else
- printf("System is not an 80386 compatible in real mode, load aborted.\nUse 'bzimage' command to attempt load.\n");
#endif
+ cmd_bzimage((void*)0);
}
+#ifdef NOCOMMAND
+ printf("Unable to boot, sorry\nreboot:");
+ fflush(stdout);
+ read(0, command_buf, sizeof(command_buf)-1) ;
+#else
for (;;)
{
-#ifdef ANSICOLOUR
- printf("\033[36m");
-#endif
-#ifdef VT52COLOUR
+#ifdef COLOUR
printf("\033S \033R+\033Sa\033Rc");
#endif
printf(">");
@@ -120,10 +103,7 @@ static char minibuf[2] = " ";
if( strcmp(cptr->command, cmd) == 0 )
break;
}
-#ifdef ANSICOLOUR
- printf("\033[37m");
-#endif
-#ifdef VT52COLOUR
+#ifdef COLOUR
printf("\033S \033Sa\033Rg");
#endif
fflush(stdout);
@@ -132,23 +112,34 @@ static char minibuf[2] = " ";
else
printf("Command not found.\n");
}
+#endif
}
/****************************************************************************/
void init_prog()
{
-#ifdef ANSICOLOUR
- printf("\033[H\033[0;44;37m\033[2J");
-#endif
-#ifdef VT52COLOUR
+#ifdef COLOUR
printf("\033E\033Rg\033Sa\033J");
#endif
-#ifdef VERSION
- printf("Linux x86 boot monitor, Version %s.\n", VERSION);
+ printf("Linux x86");
+#ifdef NOCOMMAND
+#ifdef TARFLOPPY
+ printf(" TAR floppy booter");
+#else
+#ifdef DOSFLOPPY
+ printf(" DOS floppy booter");
#else
- printf("Linux x86 boot monitor.\n");
+ printf(" floppy booter");
#endif
+#endif
+#else
+ printf(" boot monitor");
+#endif
+#ifdef VERSION
+ printf(", Version %s", VERSION);
+#endif
+ printf(".\n");
cpu_check();
mem_check();
@@ -156,7 +147,7 @@ void init_prog()
printf("Processor: %s", x86_name);
if(x86_fpu) printf(" with FPU");
if(x86_emu) printf(" in protected mode");
- if(!x86_test && x86 > 1)
+ if(x86 > 1)
{
printf(", A20 gate ");
if( a20_closed() )
@@ -174,41 +165,15 @@ void init_prog()
printf("There is %dk of boot memory", boot_mem_top/64);
if( main_mem_top )
{
- printf(" %ld.%ldM %sof main memory",
- main_mem_top/1024,
- (10*main_mem_top)/1024%10,
+ printf(" %d.%dM %sof main memory",
+ (int)(main_mem_top/1024),
+ (int)((10*main_mem_top)/1024%10),
main_mem_top >= 0xFC00L ?"(perhaps more) ":""
);
}
printf("\n");
}
-#ifdef __STANDALONE__
-reg_line()
-{
- printf("REGS: AX=%04x BX=%04x CX=%04x DX=%04x SI=%04x DI=%04x\n",
- __argr.x.ax, __argr.x.bx, __argr.x.cx, __argr.x.dx,
- __argr.x.si, __argr.x.di);
-}
-#endif
-
-#ifdef VT52COLOUR
-colour_line()
-{
- printf("Colours: \033S ");
- printf("\033R_UNL\033S ");
- printf("\033R*BLK\033S ");
- printf("\033R+BLD\033S ");
- printf("\033R!REV\033S ");
- printf("\033Sa\033Rg ");
- printf("\033R@@\033Raa\033Rbb\033Rcc\033Rdd\033Ree\033Rff\033Rgg");
- printf("\033Rhh\033Rii\033Rjj\033Rkk\033Rll\033Rmm\033Rnn\033Roo");
- printf("\033Sa\033Rg\n");
-
- printf("\033S \033Sa\033Rg");
-}
-#endif
-
/****************************************************************************/
int
@@ -264,216 +229,25 @@ unsigned int * valptr;
return flg;
}
-more_char(ch)
-int ch;
-{
-static int line_number = 0;
-
- if( ch == -1 ) { line_number = 0; return 0; }
-
- if( (ch & 0xE0 ) || ch == '\n' )
- putchar(ch);
- if( ch == '\n' && ++line_number == 24)
- {
- char buf[4];
- printf("More ?"); fflush(stdout);
- if( read(0, buf, 1) <= 0 ) return -1;
- if( buf[0] == 3 || buf[0] == '\033'
- || buf[0] == 'q' || buf[0] == 'Q' ) return -1;
- if( buf[0] == '\r' ) line_number--;
- if( buf[0] == ' ' ) line_number=2;
- printf("\r \r");
- }
- return 0;
-}
-
-more_strn(str, len)
-char * str;
-int len;
-{
- for(; len>0 && *str ; len--,str++)
- if( more_char( *str & 0xFF ) < 0 ) return -1;
- return 0;
-}
-
-/****************************************************************************/
-
-int cmd_quit(args)
-char * args;
-{
- printf("Bye\n");
- exit(0);
-}
-
-cmd_memdump(ptr)
-char * ptr;
-{
- int count = 128;
- int i,j;
- int es = __get_es();
-
-#define rmem(x) __peek_es( (x)+current_address )
-
- getnum(&ptr, &current_address);
- getnum(&ptr, &count);
-
- for(i=0; i<count; i+=16)
- {
- printf("%04x:%04x:", es, current_address);
- for(j=0; j<16; j++)
- printf(" %s%02x", (j==8)?" ":"", rmem(j));
- printf(" ");
- for(j=0; j<16; j++)
- if( rmem(j) >= ' ' && rmem(j) <= '~' )
- putchar(rmem(j));
- else
- putchar('.');
- putchar('\n');
- current_address += 16;
- current_address &= 0xFFFF;
- }
-
-#undef rmem
-}
-
-int cmd_nop(ptr)
-char * ptr;
-{
-}
-
-int cmd_seg(ptr)
-char * ptr;
-{
- int es = __get_es();
-
- if( getnum(&ptr, &es) )
- {
- __set_es(es);
- current_address = 0;
- }
- else
- printf("Current segment 0x%04x\n", es);
- return 0;
-}
-
-int cmd_set_base(ptr)
-{
- int obase = number_base;
- int nbase;
- number_base = 10;
-
- if( getnum(&ptr, &nbase) )
- {
- if( nbase < 2 || nbase > 36 )
- printf("Can't use that base\n");
- else
- obase = nbase;
- }
- else printf("Current base is %d\n", obase);
-
- number_base = obase;
- return 0;
-}
-
-int cmd_rel(ptr)
-char * ptr;
-{
- int nseg = 0xFFFF;
- int cs = __get_cs();
-
- getnum(&ptr, &nseg);
-
- relocator(nseg);
- if( __get_cs() == cs )
- printf("Didn't relocate; CS=$%04x DS=$%04x\n", __get_cs(), __get_ds());
- else
- printf("Relocated to CS=$%04x DS=$%04x\n", __get_cs(), __get_ds());
-}
-
-int cmd_dir(ptr)
-char * ptr;
-{
- open_file(".");
- return 0;
-}
-
-int cmd_type(ptr)
-char * ptr;
-{
- char * fname;
- char buffer[1024];
- long len;
-
- while(*ptr == ' ') ptr++;
- if( (fname=ptr) == 0 ) return 0;
- while(*ptr & *ptr != ' ') ptr++;
-
- if( open_file(fname) >= 0 ) for(len=file_length(); len>0; len-=1024)
- {
- if( read_block(buffer) < 0 ) break;
- if( len > 1024 )
- write(1, buffer, 1024);
- else
- write(1, buffer, len);
- }
- else
- printf("Cannot open file '%s'\n", fname);
- close_file();
- return 0;
-}
-
-int cmd_more(ptr)
-char * ptr;
-{
- char * fname;
- char buffer[1024];
- long len;
- int cc;
- char * sptr;
-
- while(*ptr == ' ') ptr++;
- if( (fname=ptr) == 0 ) return 0;
- while(*ptr & *ptr != ' ') ptr++;
-
- more_char(-1);
-
- if( open_file(fname) >= 0 ) for(len=file_length(); len>0; len-=1024)
- {
- if( read_block(buffer) < 0 ) break;
- if( len > 1024 ) cc = 1024; else cc = len;
- for(sptr=buffer; cc>0 ; cc--,sptr++)
- {
- if( more_char(*sptr & 0xFF) < 0 ) goto break_break;
- }
- }
- else
- printf("Cannot open file '%s'\n", fname);
-break_break:;
- close_file();
- return 0;
-}
-
-/****************************************************************************/
-
-/* Others */
-extern int cmd_bzimage();
-extern int cmd_help();
-
/****************************************************************************/
+#ifndef NOCOMMAND
struct t_cmd_list cmd_list[] =
{
+ {"zimage", cmd_bzimage}, /* Load and run 386 zimage file */
+ {"bzimage",cmd_bzimage}, /* Load and run 386 bzimage file */
+ {"=", cmd_bzimage}, /* Load and run 386 bzimage file */
+
{"exit", cmd_quit}, {"quit", cmd_quit}, {"q", cmd_quit},
{"#", cmd_nop},
{"help", cmd_help}, /* Display from help.txt */
{"?", cmd_help}, /* Display from help.txt */
- {"zimage", cmd_bzimage}, /* Load and run 386 zimage file */
- {"bzimage",cmd_bzimage}, /* Load and run 386 bzimage file */
- {"=", cmd_bzimage}, /* Load and run 386 bzimage file */
{"dir", cmd_dir}, /* Display directory */
{"cat", cmd_type}, /* Cat/Type a file to the screen */
+ {"type", cmd_type}, /* Cat/Type a file to the screen */
{"more", cmd_more}, /* More a file to the screen */
+#ifndef NOMONITOR
/* Debugger/monitor commands */
{"memdump",cmd_memdump}, {"mem",cmd_memdump}, {"m", cmd_memdump},
/* Display bytes */
@@ -482,14 +256,9 @@ struct t_cmd_list cmd_list[] =
{"base", cmd_set_base},
{"n", cmd_set_base},
-#ifdef VT52COLOUR
- {"colour", colour_line},
-#endif
{"init", init_prog},
-#ifdef __STANDALONE__
- {"reg", reg_line},
- {"r", reg_line},
-#endif
+ {"reg", cmd_regs},
+ {"r", cmd_regs},
/*
{"edit", cmd_edit}, Alter memory
@@ -505,5 +274,8 @@ struct t_cmd_list cmd_list[] =
{"call", cmd_call}, load and run a bcc linux-8086 program.
*/
+#endif
+
{0,0}
};
+#endif
diff --git a/bootblocks/monitor.h b/bootblocks/monitor.h
new file mode 100644
index 0000000..de42a20
--- /dev/null
+++ b/bootblocks/monitor.h
@@ -0,0 +1,47 @@
+
+#include <stdio.h>
+#include <errno.h>
+#include <ctype.h>
+#include <dos.h>
+#include <malloc.h>
+#include "i86_funcs.h"
+#include "readfs.h"
+
+#define X_TARFLOPPY
+#define X_DOSFLOPPY
+#define X_CALC_CRC
+
+
+#ifdef __STANDALONE__
+#define COLOUR
+
+extern union REGS __argr;
+#endif
+
+
+#ifdef TARFLOPPY
+#define SINGLEFS
+#define NOMONITOR
+#define NOCOMMAND
+#define MINI_BUF
+
+#define open_file tar_open_file
+#define rewind_file tar_rewind_file
+#define close_file tar_close_file
+#define file_length tar_file_length
+#define read_block tar_read_block
+#endif
+
+#ifdef DOSFLOPPY
+#define SINGLEFS
+#define NOMONITOR
+#define NOCOMMAND
+#define MINI_BUF
+#define MAXTRK 24
+
+#define open_file dos_open_file
+#define rewind_file dos_rewind_file
+#define close_file dos_close_file
+#define file_length dos_file_length
+#define read_block dos_read_block
+#endif
diff --git a/bootblocks/relocate.c b/bootblocks/relocate.c
index 7f8b124..5e14d0e 100644
--- a/bootblocks/relocate.c
+++ b/bootblocks/relocate.c
@@ -1,7 +1,5 @@
-#include <stdio.h>
-#include <dos.h>
-#include "i86_funcs.h"
+#include "monitor.h"
static unsigned memseg = 0, memlen = 0;
@@ -21,11 +19,10 @@ void
relocator(newseg)
unsigned newseg;
{
+#ifdef __STANDALONE__
unsigned moved, codelen;
unsigned es = __get_es();
- if( x86_test ) return; /* I don't think so! */
-
/* Where do we start */
if(memseg == 0)
{
@@ -90,3 +87,7 @@ unsigned newseg;
L_x:
retf
#endasm
+
+#else
+}
+#endif
diff --git a/bootblocks/sysboot.s b/bootblocks/sysboot.s
index c7be509..558d02e 100644
--- a/bootblocks/sysboot.s
+++ b/bootblocks/sysboot.s
@@ -57,30 +57,25 @@ public bootblock_magic
.blkb sysboot_start+0x1BE-*
partition_1:
-.byte 0 ! IN
-.blkb 7 ! SH,SS,ST,OS,EH,ES,ET
+.blkb 8 ! IN,SH,SS,ST,OS,EH,ES,ET
.blkw 2 ! Linear position (0 based)
.blkw 2 ! Linear length
.blkb sysboot_start+0x1CE-*
partition_2:
-.byte 0 ! IN
-.blkb 7 ! SH,SS,ST,OS,EH,ES,ET
+.blkb 8 ! IN,SH,SS,ST,OS,EH,ES,ET
.blkw 2 ! Linear position (0 based)
.blkw 2 ! Linear length
.blkb sysboot_start+0x1DE-*
partition_3:
-.byte 0 ! IN
-.blkb 7 ! SH,SS,ST,OS,EH,ES,ET
+.blkb 8 ! IN,SH,SS,ST,OS,EH,ES,ET
.blkw 2 ! Linear position (0 based)
.blkw 2 ! Linear length
.blkb sysboot_start+0x1EE-*
partition_4:
-.byte 0 ! IN
-.blkb 7 ! SH,SS,ST,OS,EH,ES,ET
+.blkb 8 ! IN,SH,SS,ST,OS,EH,ES,ET
.blkw 2 ! Linear position (0 based)
.blkw 2 ! Linear length
-bootblock_magic:
.blkb sysboot_start+0x1FE-*
+bootblock_magic:
.word 0xAA55
-
diff --git a/bootblocks/tich.s b/bootblocks/tich.s
index 830f742..15bc238 100644
--- a/bootblocks/tich.s
+++ b/bootblocks/tich.s
@@ -35,4 +35,4 @@ mesg:
emesg:
org 510
- .word 0xAA55
+ .word 0
diff --git a/bootblocks/trk_buf.c b/bootblocks/trk_buf.c
index 7fbb4c9..f9ae3c8 100644
--- a/bootblocks/trk_buf.c
+++ b/bootblocks/trk_buf.c
@@ -1,9 +1,7 @@
-#include <stdio.h>
-#include <dos.h>
-#include <ctype.h>
-#include <malloc.h>
-#include "readfs.h"
+#include "monitor.h"
+
+#ifndef MINI_BUF
int disk_drive = 0;
int disk_spt = 7;
@@ -273,3 +271,4 @@ func_ok:
}
#endif
+#endif
diff --git a/bootblocks/unix.c b/bootblocks/unix.c
index e6eb41e..455d9b1 100644
--- a/bootblocks/unix.c
+++ b/bootblocks/unix.c
@@ -1,7 +1,7 @@
-#ifdef __ELKS__
+#include "monitor.h"
-#include <stdio.h>
+#ifdef __ELKS__
bios_khit() {
return 0;
@@ -31,11 +31,16 @@ extern long lseek();
int rv = 0;
long offset;
int i;
+extern int disk_spt;
+ int spt = 18;
if( phy_fd == -1 ) open_fd();
if( phy_fd < 0 ) return -1;
+ if( len <= 0 ) return -1;
+
+ if( disk_spt > 1 ) spt = disk_spt;
- offset = (((cyl*2 + head)*18L + sect-1)*512L);
+ offset = (((cyl*2 + head)*(long)spt + sect-1)*512L);
fprintf(stderr, "PHY_READ(d%d, c%d, h%d, s%d, l%d, b%d) (Sect=%ld)\n",
drive, cyl, head, sect, len, buffer, offset/512);
diff --git a/dis88/Makefile b/dis88/Makefile
index 520becc..91dba39 100644
--- a/dis88/Makefile
+++ b/dis88/Makefile
@@ -27,7 +27,7 @@
#CC=bcc
CFLAGS=-O
LDFLAGS=
-BINDIR=/usr/bin
+PREFIX=/usr
OBJ = disrel.o dismain.o distabs.o dishand.o disfp.o
@@ -37,8 +37,8 @@ dis88: $(OBJ)
$(CC) $(LDFLAGS) -o dis88 $(OBJ)
install: dis88
- install -m 755 -s dis88 $(DIST)$(BINDIR)/dis86
- install -m 644 dis88.1 $(DIST)/usr/man/man1/dis86.1
+ install -m 755 -s dis88 $(DIST)$(PREFIX)/bin/dis86
+ install -m 644 dis88.1 $(DIST)$(PREFIX)/man/man1/dis86.1
$(OBJ): dis.h a.out.h
diff --git a/ld/Makefile b/ld/Makefile
index 6dad38a..ec4e91e 100644
--- a/ld/Makefile
+++ b/ld/Makefile
@@ -27,14 +27,15 @@ install: ld86
install -d $(LIBDIR)
install -m 755 ld86 $(LIBDIR)
-clean realclean:
+clean realclean clobber:
rm -f *.o ld86 ld86r objchop catimage objdump86
$(OBJS): align.h ar.h bindef.h byteord.h config.h const.h globvar.h obj.h \
syshead.h type.h x86_aout.h
ar.h:
- ln -s ../libc/include/ar.h . || \
+ [ -f ar.h ] || \
+ { rm -f ar.h ; ln -s ../libc/include/ar.h . ; } || \
ln ../libc/include/ar.h .
writebin.o: writebin.c
diff --git a/libc/Makefile b/libc/Makefile
index 0494400..640c468 100644
--- a/libc/Makefile
+++ b/libc/Makefile
@@ -11,7 +11,7 @@ endif
VERMAJOR=0
VERMINOR=14
-VERPATCH=3
+VERPATCH=5
VER=$(VERMAJOR).$(VERMINOR).$(VERPATCH)
CC=bcc
diff --git a/libc/bios/bios_vid.c b/libc/bios/bios_vid.c
index ec3c603..cc49736 100644
--- a/libc/bios/bios_vid.c
+++ b/libc/bios/bios_vid.c
@@ -108,6 +108,7 @@ static int vidcnt = 0;
static int ansi_2 = 0;
static int ansi_argc = 0;
static int ansi_argv[MAX_ARGS];
+static void do_ansi();
bios_putc(c)
int c;
@@ -169,6 +170,7 @@ int c;
}
}
+void
do_ansi(ctrl, argc, argv)
int ctrl, argc, *argv;
{
diff --git a/libc/msdos/conio.c b/libc/msdos/conio.c
index 3c51c92..1abfa40 100644
--- a/libc/msdos/conio.c
+++ b/libc/msdos/conio.c
@@ -1,23 +1,73 @@
/* Is this BIOS keyboard io ? */
-cgets()
-
-cputs()
-
getch()
+{
+#asm
+ xor ax,ax
+ int $16
+#endasm
+}
getche()
+{
+ int i = getch();
+ if( i & 0xFF) putch(i);
+ return i;
+}
+
+kbhit()
+{
+#asm
+ mov ah,#1
+ int $16
+ jz nokey
+ cmp ax,#0
+ jnz dort
+ mov ax,#3
+dort:
+ ret
+nokey:
+ xor ax,ax
+#endasm
+}
+
+putch()
+{
+#asm
+#if !__FIRST_ARG_IN_AX__
+ mov bx,sp
+ mov ax,[bx+2]
+#endif
+ mov ah,#$0E
+ mov bx,#7
+ int $10
+#endasm
+}
+
+cputs(str)
+char * str;
+{
+ while(*str) putch(*str++);
+}
+
+cgets()
+{
+}
cprintf()
+{
+}
cscanf()
+{
+}
getpass()
+{
+}
gotoxy()
-
-kbhit()
-
-putch()
+{
+}
diff --git a/libc/termios/ttyname.c b/libc/termios/ttyname.c
index 5993a2a..f3c05b6 100644
--- a/libc/termios/ttyname.c
+++ b/libc/termios/ttyname.c
@@ -30,7 +30,7 @@ int fd;
while ((d = readdir(fp)) != 0)
{
- if( strlen(d->d_name) > sizeof(name) - sizeof(dev) - 1);
+ if( strlen(d->d_name) > sizeof(name) - sizeof(dev) - 1)
continue;
strcpy(name + sizeof(dev), d->d_name);
if (stat(name, &dst) == 0
diff --git a/makefile.in b/makefile.in
index 7c71599..d4ebbc2 100644
--- a/makefile.in
+++ b/makefile.in
@@ -17,7 +17,7 @@ CC =%CC%
CFLAGS =%CFLAGS%
LDFLAGS =
MAKEARG =CC='$(CC)' CFLAGS='$(CFLAGS)' LDFLAGS='$(LDFLAGS)' PREFIX=$(PREFIX) \
- LIBDIR='$(LIBDIR)' BINDIR='$(BINDIR)' ANSI='$(ANSI)'
+ LIBPRE='$(LIBPRE)' LIBDIR='$(LIBDIR)' BINDIR='$(BINDIR)' ANSI='$(ANSI)'
MAKEC=$(MAKE) -C
MAKEX=
@@ -33,7 +33,7 @@ WALL =-Wstrict-prototypes
CC =gcc
#ifdef __i386__
-CFLAGS =$(GCCFLAG) -Wall $(WALL) -O2 -m486 -fno-strength-reduce -g
+CFLAGS =$(GCCFLAG) -Wall $(WALL) -O2 -m486 -g
#else
CFLAGS =$(GCCFLAG) -Wall $(WALL) -O6 -g
#endif
@@ -90,6 +90,7 @@ LIBARGS= CC=ncc CCFLAGS= ARFLAGS=$(ARFLAGS)
# Season in the top makefile
ELKSSRC= %ELKSSRC%
PREFIX= %PREFIX%
+LIBPRE= %LIBPRE%
BINDIR= %BINDIR%
LIBDIR= %LIBDIR%
@@ -99,7 +100,7 @@ export ELKSSRC
DISTBIN= $(DIST)$(BINDIR)
DISTLIB= $(DIST)$(LIBDIR)
-DISTPRE= $(DIST)$(PREFIX)
+DISTPRE= $(DIST)$(LIBPRE)
# Others to install
OTHERS= tests dis88 doselks bootblocks
@@ -156,7 +157,7 @@ elksemu: bindir
#ifndef __AS386_16__
#ifdef __i386__
$(MAKEC) elksemu \
- CC='$(CC)' PREFIX=$(PREFIX) LIBDIR='$(LIBDIR)' BINDIR='$(BINDIR)' \
+ CC='$(CC)' PREFIX=$(PREFIX) LIBPRE='$(LIBPRE)' LIBDIR='$(LIBDIR)' BINDIR='$(BINDIR)' \
elksemu
#else
$(MAKEC) elksemu CC='ncc' elksemu
@@ -173,8 +174,8 @@ install-ln: bcc unproto copt as86 ld86 elksemu
#ifndef __AS386_16__
ln -fs `pwd`/bin/elksemu $(DIST)/lib/elksemu
#endif
- install -d $(DIST)/usr/lib
- install $(INDAT) libc/error/liberror.txt $(DIST)/usr/lib/liberror.txt
+ -install -d $(DIST)/usr/lib
+ -install $(INDAT) libc/error/liberror.txt $(DIST)/usr/lib/liberror.txt
install-bcc: bcc unproto copt as86 ld86 objdump86
install -d $(DISTBIN) $(DISTLIB) $(DISTLIB)/i86
@@ -200,7 +201,7 @@ install-emu: elksemu
#endif
install-man:
- -$(MAKEC) man MANDIR=$(DIST)/usr/man install
+ -$(MAKEC) man MANDIR=$(DIST)$(PREFIX)/man install
install-lib: lib/lib0-done lib/lib2-done
install -d $(DISTLIB)/i86
@@ -208,8 +209,8 @@ install-lib: lib/lib0-done lib/lib2-done
install $(INDAT) lib/crt0.o $(DISTLIB)/i86/crt0.o
install $(INDAT) lib/libc.a $(DISTLIB)/i86/libc.a
install $(INDAT) lib/libbsd.a $(DISTLIB)/i86/libbsd.a
- install -d $(DIST)/usr/lib
- install $(INDAT) libc/error/liberror.txt $(DIST)/usr/lib/liberror.txt
+ -install -d $(DIST)/usr/lib
+ -install $(INDAT) libc/error/liberror.txt $(DIST)/usr/lib/liberror.txt
install-lib2: lib/lib1-done
install -d $(DISTLIB)/i86
@@ -307,7 +308,7 @@ makec:
install-other: phony
@for i in $(OTHERS) ; do \
- $(MAKEC) $$i BCC=ncc DIST=$(DIST) install || exit 1 ; \
+ $(MAKEC) $$i BCC=ncc DIST=$(DIST) PREFIX=$(PREFIX) install || exit 1 ; \
done
other: $(OTHERS)
diff --git a/man/Makefile b/man/Makefile
index b4557a0..3177b61 100644
--- a/man/Makefile
+++ b/man/Makefile
@@ -6,7 +6,7 @@ MAN1DIR=$(MANDIR)/man1
all:
install:
- install -m 755 -o man -g other -d $(MAN1DIR)
- install -m 644 -o man -g other $(MAN1PG) $(MAN1DIR)
+ install -m 755 -d $(MAN1DIR)
+ install -m 644 $(MAN1PG) $(MAN1DIR)
clean:
diff --git a/man/as86.1 b/man/as86.1
index 25c1515..84a1626 100644
--- a/man/as86.1
+++ b/man/as86.1
@@ -214,8 +214,10 @@ Set current segment. These can be preceded by the keyword
.B .SECT
.TP
.B LOC
-Set numeric segment 0=TEXT, 3=DATA,ROM,BSS, 15=MAX. Only segment zero is
-in the text segment, all others are data.
+Set numeric segment 0=TEXT, 3=DATA,ROM,BSS, 14=MAX.
+The segment order set by the linker is now 0,4,5,6,7,8,9,A,B,C,D,E,1,2,3.
+Segment 0 and all segments above 3 are assumed to be text segment.
+Note the 64k size restrictions are not imposed for segments 3-14.
.P
Label type definition
.TP
diff --git a/man/bcc.1 b/man/bcc.1
index fab6275..5e7d85f 100644
--- a/man/bcc.1
+++ b/man/bcc.1
@@ -168,7 +168,7 @@ output file name follows (assembler, object or executable) (as usual)
.B -p
error (profiling not supported)
.TP
-.B -t
+.B -t1
pass to the assembler to renumber the text segment for multi-segment programs.
.TP
.B -v
diff --git a/man/index.bt b/man/index.bt
new file mode 100644
index 0000000..7f83633
--- /dev/null
+++ b/man/index.bt
Binary files differ