summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert de Bath <rdebath@poboxes.com>1999-06-11 14:11:38 +0200
committerLubomir Rintel <lkundrak@v3.sk>2013-10-23 23:41:25 +0200
commit3d4957c86ff239b24b43933924ec72a3fd288518 (patch)
treeda8225a4d7bb2d9123e10d558cdc3eebae6254c8
parente62b35169cdcd13632ae353b1e5ffde7dec44201 (diff)
downloaddev86-3d4957c86ff239b24b43933924ec72a3fd288518.tar.gz
Import Dev86src-0.14.8.tar.gzv0.14.8
-rw-r--r--Changes10
-rw-r--r--Libc_version2
-rw-r--r--Makefile4
-rw-r--r--README46
-rw-r--r--as/as.c13
-rw-r--r--as/assemble.c3
-rw-r--r--as/genobj.c5
-rw-r--r--as/proto.h1
-rw-r--r--as/readsrc.c2
-rw-r--r--bcc/exptree.c3
-rw-r--r--bin86/ChangeLog14
-rw-r--r--bin86/Makefile1
-rw-r--r--bootblocks/Makefile1
-rw-r--r--bootblocks/README25
-rw-r--r--bootblocks/bzimage.c4
-rw-r--r--bootblocks/cprintf.c32
-rw-r--r--bootblocks/fs.c10
-rw-r--r--bootblocks/fs_dos.c12
-rw-r--r--bootblocks/fs_min.c215
-rw-r--r--bootblocks/fs_tar.c5
-rw-r--r--bootblocks/lsys.c8
-rw-r--r--bootblocks/makeboot.c8
-rw-r--r--bootblocks/min_buf.c11
-rw-r--r--bootblocks/minix.c42
-rw-r--r--bootblocks/minix.h1
-rw-r--r--bootblocks/monitor.c13
-rw-r--r--bootblocks/monitor.h17
-rw-r--r--bootblocks/msdos.s4
-rw-r--r--bootblocks/skip.s3
-rw-r--r--bootblocks/trk_buf.c94
-rw-r--r--copt/rules.i16
-rw-r--r--ld/bindef.h4
-rw-r--r--ld/objdump86.c4
-rw-r--r--ld/writebin.c33
-rw-r--r--libc/Makefile2
-rw-r--r--libc/bcc/__ldivmod.c2
-rw-r--r--libc/getent/utent.c98
-rw-r--r--libc/include/bios.h2
-rw-r--r--libc/include/msdos/fcntl.h29
-rw-r--r--libc/include/stddef.h2
-rw-r--r--libc/include/stdio.h2
-rw-r--r--libc/include/utmp.h6
-rw-r--r--libc/msdos/Makefile4
-rw-r--r--libc/msdos/TODO8
-rw-r--r--libc/msdos/conio.c14
-rw-r--r--libc/msdos/dirent.c8
-rw-r--r--libc/msdos/dosound.c10
-rw-r--r--libc/msdos/i86.c177
-rw-r--r--libc/msdos/intr.c82
-rw-r--r--libc/msdos/msdos.c47
-rw-r--r--libc/msdos/mslib.c67
-rw-r--r--libc/msdos/new86.c13
-rw-r--r--libc/msdos/sound.c27
-rw-r--r--libc/msdos/time.c5
-rw-r--r--libc/stdio2/stdio.c18
-rw-r--r--libc/stdio2/stdio.h2
-rw-r--r--libc/string/string.c15
-rw-r--r--man/as86.165
-rw-r--r--man/bcc.111
-rw-r--r--man/index.btbin8192 -> 0 bytes
-rw-r--r--man/ld86.112
-rw-r--r--tests/env.c2
-rw-r--r--tests/xx27
63 files changed, 1080 insertions, 343 deletions
diff --git a/Changes b/Changes
index bb39b23..6708e02 100644
--- a/Changes
+++ b/Changes
@@ -1,5 +1,7 @@
For version 0.15.0.
+> Bugfixes on utmpent and friends.
+
> A bit more in the manpages on how to use the assembler etc.
> Bug fixes in stdio, fp->mode cached too much, buffer type mixup.
@@ -7,9 +9,15 @@ For version 0.15.0.
> Altered initial make variables, you only need to modify 'PREFIX=' to allow
installs into /usr/local.
+> The BIOS library has a simple MSDOS fs file reader now, based on the code
+ from monitor.out.
+
> Added bin86-0.... source distribution archive.
-> Fixed bug in -t option to as
+> Fixed bug in -t option to as/bcc (for moving the text segment)
+
+> Lines that have a unexpected character are now listed by the assembler
+ not just ignored.
> Added assembly externals in as86_encap generated code.
diff --git a/Libc_version b/Libc_version
index c24a395..f3cc26b 100644
--- a/Libc_version
+++ b/Libc_version
@@ -1 +1 @@
-0.14.7
+0.14.8
diff --git a/Makefile b/Makefile
index 67a0e63..f870366 100644
--- a/Makefile
+++ b/Makefile
@@ -71,6 +71,10 @@ Uninstall: phony
@# TO HERE
distribution:
+ @[ `id -u` -eq 0 ] || fakeroot --nomixedlibhack -c $(MAKE) do_dist
+ @[ `id -u` -ne 0 ] || $(MAKE) do_dist
+
+do_dist:
@rm -f /tmp/linux-86 || true
@[ ! -f Copy_dist ] || sh Copy_dist
mkdir -p -m 0777 /tmp/Dist
diff --git a/README b/README
index 2d9c661..5f78e61 100644
--- a/README
+++ b/README
@@ -39,30 +39,48 @@ You use the other libraries like this:
Standalone $ bcc -Ms prog.c -o prog.sys
Linux-i386 $ bcc -Ml prog.c -o prog
-The Linux-i386 version generates static Linux a.out programs, they need
-neither elksemu nor a.out shared libries to run. If you want you can
-convert them to an odd ELF executable with:
- $ bcc -Ml prog.c -o prog
- $ objcopy -O elf32-i386 prog
+The 'Fast' and 'Caller saves' versions alter the function call assember
+in an effort to make it smaller and faster.
+
+The 'MSDOS' version creates _small_ model (64k+64k) COM files. Because
+of DOS limitations the filesize is limited to about 65000 bytes but
+the BSS and Stack can be upto 64k on top of that.
+
+The 'standalone' version creates executables like normal ELKS a.out
+files but with no operating system calls, just BIOS ones. These
+files are suitable for running on a bare machine started by one of
+the boot blocks in the bootblocks subdirectory.
+
+The Linux-i386 version generates static Linux OMAGIC a.out programs,
+they need neither elksemu nor a.out shared libraries to run. Unfortunatly
+these can no longer be converted to ELF executables as Linux will not
+execute unpageable ELF executables. To allow conversion to ELF if you
+pass the '-z' flag to 'bcc -Ml' the linker will now create QMAGIC a.out
+executables, these are somewhat larger but can be converted with objcopy.
If you want to install everything in one go just login as root an do:
$ make install-all
-The as86 and ld86 with this are _different_ from the ones needed for the
-linux-i386 kernel but can replace them, the kernel-i386 ones _will_ _not_
-work correctly here!
+The as86 and ld86 with this are _different_ from the minimum version
+needed for the linux-i386 kernel and can replace them, versions before
+0.12.0 will not work with this version of bcc.
+
+I _strongly_ suggest you install the kernel patch or load the module
+to allow transparent execution of elks executables. If you're using
+a post 2.1.43 or 2.0.36 kernel the module you need is the binfmt_misc
+driver configured like this:
+
+echo ':i86-elks:M::\x01\x03\x20\x00:\xff\xff\xff\x83:/lib/elksemu:' \
+ > /proc/sys/fs/binfmt_misc/register
-I _strongly_ suggest you install the kernel patch or load the module in
-the elksemu directory in your Linux-i386 kernel, it makes things _much_
-easier. If you're using a post 2.1.43 kernel the module you need is
-the binfmt_misc driver as described in elksemu/README.
+Previous versions need a special module or patch described in elksemu/README
(All the options need the elksemu executable installed correctly)
Copyrights
----------
The `bcc', 'as' and `ld' parts of the distribution are now covered by
the GPL. The `bccfp' library now in the libc/i386fp directory is under
-the LGPL. (Copyright holder Bruce Evans)
+the LGPL. (Primary copyright holder Bruce Evans)
The contents of the libc and libbsd subdirectories are under the LGPL
with a few noted exceptions. The programs in 'tests', elksemu, copt
@@ -77,7 +95,7 @@ not under LGPL, the former is 'freely distributable' the latter is public
domain.
See the COPYING file in this directory for the GPL and the COPYING file
-in the libc directories for the LGPL.
+in the libc directory for the LGPL.
--
Rob. (Robert de Bath <rdebath@poboxes.com>)
diff --git a/as/as.c b/as/as.c
index 8c26b71..d86d917 100644
--- a/as/as.c
+++ b/as/as.c
@@ -61,13 +61,14 @@ char **argv;
inst_keywords();
initbin();
initobj();
- initsource(); /* only nec to init for unsupported mem file */
+ initsource();
typeconv_init(INT_BIG_ENDIAN, LONG_BIG_ENDIAN);
as_warn.global = TRUE; /* constant */
as_warn.semaphore = -1;
last_pass=1;
process_args(argc, argv);
initscan();
+ line_zero();
assemble(); /* doesn't return, maybe use setjmp */
@@ -133,8 +134,12 @@ PUBLIC void initp1p2()
lcp->data = lcdata = RELBIT; /* lc relocatable until 1st ORG */
lcp->lc = lc = 0;
}
- if( textseg > 0 )
- lcdata |= textseg;
+}
+
+PUBLIC void line_zero()
+{
+ if( textseg >= 0 )
+ ptext();
}
PRIVATE int my_creat(name, message)
@@ -297,8 +302,6 @@ char **argv;
#ifdef I80386
origcpuid = cpuid;
#endif
- if( textseg > 0 )
- lcdata |= textseg;
inidata = (~binaryg & inidata) | (RELBIT | UNDBIT);
} /* IMPBIT from inidata unless binaryg */
diff --git a/as/assemble.c b/as/assemble.c
index 5ae7319..2b92c76 100644
--- a/as/assemble.c
+++ b/as/assemble.c
@@ -216,7 +216,8 @@ PRIVATE void asline()
getsym();
if (sym != IDENT) /* expect label, mnemonic or macro */
{
- if( sym != EOLSYM )
+ /* Warn if not a comment marker or a hash (for /lib/cpp) */
+ if( sym != EOLSYM && sym != IMMEDIATE )
list_force = TRUE;
return; /* anything else is a comment */
}
diff --git a/as/genobj.c b/as/genobj.c
index 09eda1c..abe140a 100644
--- a/as/genobj.c
+++ b/as/genobj.c
@@ -565,10 +565,7 @@ PUBLIC void objheader()
}
putobj1(0);
}
- if( textseg >= 0 )
- putobj1(OBJ_SET_SEG | textseg); /* default segment, |0010|SEGM| */
- else
- putobj1(OBJ_SET_SEG | 0); /* default segment 0, |0010|SEGM| */
+ putobj1(OBJ_SET_SEG | 0); /* default segment 0, |0010|SEGM| */
}
/* write trailer to object file */
diff --git a/as/proto.h b/as/proto.h
index b4fb82b..9cc6446 100644
--- a/as/proto.h
+++ b/as/proto.h
@@ -5,6 +5,7 @@ int main P((int argc, char **argv));
void as_abort P((char *message));
void finishup P((void));
void initp1p2 P((void));
+void line_zero P((void));
/* assemble.c */
void assemble P((void));
diff --git a/as/readsrc.c b/as/readsrc.c
index 557ca5d..6cfbaf5 100644
--- a/as/readsrc.c
+++ b/as/readsrc.c
@@ -275,6 +275,8 @@ PUBLIC void pproceof()
if(pass==last_pass)
binheader();
+
+ line_zero();
}
else
finishup();
diff --git a/bcc/exptree.c b/bcc/exptree.c
index d3e6386..427b5f4 100644
--- a/bcc/exptree.c
+++ b/bcc/exptree.c
@@ -940,11 +940,12 @@ struct nodestruct *nodeptr;
}
nodeptr->left.nodeptr = left = unconvert(left);
nodeptr->right = right = unconvert(right);
+ targtype = left->nodetype;
if (
#ifdef I80386
i386_32 ||
#endif
- ((targtype = left->nodetype)->scalar & FLOAT ) == 0)
+ ( targtype->scalar & FLOAT ) == 0)
if (targtype == right->nodetype)
return targtype; /* XXX - reduced from promote(targtype) */
if ((lscalar = targtype->scalar) != 0 &&
diff --git a/bin86/ChangeLog b/bin86/ChangeLog
index a09114b..d8939ea 100644
--- a/bin86/ChangeLog
+++ b/bin86/ChangeLog
@@ -1,3 +1,17 @@
+Fri Jun 11 13:08:27 BST 1999 Robert de Bath (rdebath@poboxes.com)
+
+ * objdump86 program included.
+
+ * Updated for libc6
+
+ * As86 fixes for multi-segment (The linker can't really cope tho)
+
+Sat Mar 13 16:45:42 GMT 1999 Robert de Bath (rdebath@poboxes.com)
+
+ * Vsn 0.15.0, more documentation!
+
+ * Linker can now generate QMAGIC 386 executables.
+
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
diff --git a/bin86/Makefile b/bin86/Makefile
index 4d1a185..f5889c9 100644
--- a/bin86/Makefile
+++ b/bin86/Makefile
@@ -46,4 +46,5 @@ grab:
mkdir man
cp -p ../man/ld86.1 man
cp -p ../man/as86.1 man
+ touch -r ChangeLog . as ld man
diff --git a/bootblocks/Makefile b/bootblocks/Makefile
index ebdcf08..bf081ba 100644
--- a/bootblocks/Makefile
+++ b/bootblocks/Makefile
@@ -42,6 +42,7 @@ monitor.out: $(MOBJ)
$(CC) $(CFLAGS) -H0x10000 $(MOBJ) -o monitor.out -M > monitor.sym
$(MOBJ): $(MINC) version.h
+fs_min.o: minix.h
monitor: $(MSRC) $(MINC)
@rm -f $(MOBJ)
diff --git a/bootblocks/README b/bootblocks/README
index d5054c6..f51bcd3 100644
--- a/bootblocks/README
+++ b/bootblocks/README
@@ -37,12 +37,13 @@ Contents
1.2 ) Dosfs boot sector
- Install with makeboot, there is also a version for 16 bit FAT floppies
- (eg LS-120 disks) This boot sector loads and executes a binary
- BOOTFILE.SYS from the root directory of the floppy. The file can
- be any length and is loaded at $07C00. Because of the load address
- this boot sector can be configured to load another boot sector,
- for example LILO can be succesfully used in this way.
+ Install with makeboot, there is also a version for 16 bit FAT
+ filesystems for big floppies (eg LS-120 disks) or hard disk
+ partitions. This boot sector loads and executes a binary BOOTFILE.SYS
+ from the root directory of the floppy. The file can be any length
+ and is loaded at $07C00. Because of the load address this boot sector
+ can be configured to load another boot sector, for example LILO can
+ be succesfully used in this way.
In fact LILO can be succesfully used in this way on a 2M disk, but
you must create the floppy with the real dos 2M package as superformat
@@ -53,8 +54,8 @@ Contents
as my testing has gone this is only significant on 8086 machines, all
others (286 8Mhz +) are fast enough to keep up at a 1-1 interleve.
- Unfortunatly the most recent versions of superformat (5.0+) defeat this
- because they do not correctly calculate intersector gaps.
+ But beware some older versions of superformat defeat this because
+ they do not correctly calculate intersector gaps.
1.3 ) Minixfs boot block
@@ -74,9 +75,9 @@ Contents
1.4 ) Tar boot sector -- Cool Man!!
- This boot sector converts a tar file with a GNU Volume lable into a
+ This boot sector converts a tar file with a GNU Volume label into a
bootable floppy image. The boot sector loads and executes the first
- item in the tar file after the lable:
+ item in the tar file after the label:
$ tar cvfV the_file.tar ENIAC monitor.out item2 item3
$ makeboot tar the_file.tar
@@ -119,9 +120,9 @@ Contents
None of the boot blocks can _directly_ boot a Linux-i386 kernel the
program 'monitor.out' must loaded by the boot sector and this can
- load a zimage or bzimage from an MSDOS or Tar floppy.
+ load a zimage or bzimage from an MSDOS, Minix or Tar floppy.
- This example is for and MSDOS floppy, Tar is very similer except that
+ This example is for and MSDOS floppy, Tar is very similar except that
'monitor.out' must be the first file in the tar and can have any name.
Note also for a tar file the 'ramdisk.gz' file must start on the first
diff --git a/bootblocks/bzimage.c b/bootblocks/bzimage.c
index 1d7ff73..89d5ef1 100644
--- a/bootblocks/bzimage.c
+++ b/bootblocks/bzimage.c
@@ -103,7 +103,7 @@ char * command_line;
(int)(len/1024), (int)(len*10/1024%10));
return -1;
}
- if( main_mem_top <= 3072 )
+ if( main_mem_top < 3072 )
printf("RTFM warning: Linux needs at least 4MB of memory.\n");
#endif
@@ -191,7 +191,7 @@ char * command_line;
close_file();
#ifdef CALC_CRC
- load_crc = display_crc(0);
+ load_crc = display_crc("Loaded crc =");
#endif
#ifdef CALC_CRC
diff --git a/bootblocks/cprintf.c b/bootblocks/cprintf.c
index 3fefda3..de622fc 100644
--- a/bootblocks/cprintf.c
+++ b/bootblocks/cprintf.c
@@ -18,23 +18,21 @@ cprintf(char * fmt, ...)
long val;
char * cp;
char padch=' ';
- int minsize = 0;
+ int minsize, maxsize;
va_list ap;
va_start(ap, fmt);
while(c=*fmt++)
{
+ count++;
if(c!='%')
- {
cputchar(c);
- count++;
- }
else
{
type=1;
padch = *fmt;
- minsize=0;
+ maxsize=minsize=0;
if(padch == '-') fmt++;
for(;;)
@@ -44,7 +42,13 @@ cprintf(char * fmt, ...)
minsize*=10; minsize+=c-'0';
}
- while( c=='.' || (c>='0' && c<='9')) { c=*fmt++; }
+ if( c == '.' )
+ for(;;)
+ {
+ c=*fmt++;
+ if( c<'0' || c>'9' ) break;
+ maxsize*=10; maxsize+=c-'0';
+ }
if( padch == '-' ) minsize = -minsize;
else
@@ -79,16 +83,22 @@ cprintf(char * fmt, ...)
case 's':
cp=va_arg(ap, char *);
}
+ count--;
+ c = strlen(cp);
+ if( !maxsize ) maxsize = c;
if( minsize > 0 )
{
- minsize -= strlen(cp);
- while(minsize>0) { cputchar(padch); minsize--; }
+ minsize -= c;
+ while(minsize>0) { cputchar(padch); count++; minsize--; }
minsize=0;
}
- if( minsize < 0 ) minsize= -minsize-strlen(cp);
- while(*cp)
+ if( minsize < 0 ) minsize= -minsize-c;
+ while(*cp && maxsize-->0 )
+ {
cputchar(*cp++);
- while(minsize>0) { cputchar(' '); minsize--; }
+ count++;
+ }
+ while(minsize>0) { cputchar(' '); count++; minsize--; }
break;
case 'c':
cputchar(va_arg(ap, int));
diff --git a/bootblocks/fs.c b/bootblocks/fs.c
index 037f8a4..47faffc 100644
--- a/bootblocks/fs.c
+++ b/bootblocks/fs.c
@@ -8,7 +8,7 @@ int fs_type = 0;
open_file(fname)
char * fname;
{
-#ifdef __ELKS__
+#ifdef DEBUG
fprintf(stderr, "Open file %s\n", fname);
#endif
if( fs_type ) close_file();
@@ -21,7 +21,7 @@ char * fname;
rewind_file()
{
-#ifdef __ELKS__
+#ifdef DEBUG
fprintf(stderr, "Rewind file (%d)\n", fs_type);
#endif
switch(fs_type)
@@ -36,7 +36,7 @@ rewind_file()
close_file()
{
int rv = -1;
-#ifdef __ELKS__
+#ifdef DEBUG
fprintf(stderr, "Close file (%d)\n", fs_type);
#endif
switch(fs_type)
@@ -52,7 +52,7 @@ close_file()
long
file_length()
{
-#ifdef __ELKS__
+#ifdef DEBUG
fprintf(stderr, "File length (%d)\n", fs_type);
#endif
switch(fs_type)
@@ -67,7 +67,7 @@ file_length()
read_block(buffer)
char * buffer;
{
-#ifdef __ELKS__
+#ifdef DEBUG
fprintf(stderr, "read block into (%d) (%d)\n", buffer, fs_type);
#endif
switch(fs_type)
diff --git a/bootblocks/fs_dos.c b/bootblocks/fs_dos.c
index 6b0638e..0ad6af6 100644
--- a/bootblocks/fs_dos.c
+++ b/bootblocks/fs_dos.c
@@ -117,6 +117,10 @@ char * fname;
use_fatbuf = 0;
#endif
+#ifndef NOCOMMAND
+ more_char(-1);
+#endif
+
/* Scan the root directory for the file */
for(i=0; i<dir_nentry; i++)
{
@@ -129,8 +133,6 @@ char * fname;
break;
#else
int dtime = 0;
- char lbuf[90];
- *lbuf = 0;
if( *d > ' ' && *d <= '~' ) switch(d[11]&0x18)
{
@@ -151,14 +153,16 @@ char * fname;
break;
}
if( dtime )
- printf(dtime, " %02d/%02d/%04d %02d:%02d\n",
+ {
+ printf(" %02d/%02d/%04d %02d:%02d",
(get_uint(d,24)&0x1F),
((get_uint(d,24)>>5)&0xF),
((get_uint(d,24)>>9)&0x7F)+1980,
((get_uint(d,22)>>11)&0x1F),
((get_uint(d,22)>>5)&0x3F)
);
- if( more_strn(lbuf, sizeof(lbuf)) < 0 ) break;
+ if( more_char('\n') < 0 ) break;
+ }
#endif
}
else if( memcmp(d, conv_name, 11) == 0 && (d[11]&0x18) == 0 )
diff --git a/bootblocks/fs_min.c b/bootblocks/fs_min.c
index 4f4c33e..7ddc402 100644
--- a/bootblocks/fs_min.c
+++ b/bootblocks/fs_min.c
@@ -1,31 +1,238 @@
#include "monitor.h"
+#include "minix.h"
+
+/* #define DEBUG 1 /**/
+
+#define SECTOR_SIZE 512
+
+block_nr inode_tbl = 0; /* super.s_imap_blocks+super.s_zmap_blocks+2 */
+static int fs_dir32 = 0; /* Using 30 char filenames ? */
+
+struct file_pos {
+ inode_nr inode;
+ zone_nr seek_addr;
+ file_pos i_size; /* current file size in bytes */
+ mask_bits i_mode; /* File type */
+ zone_nr i_zone[NR_ZONE_NUMS]; /* block numbers from inode */
+} current_file = { 0,0 };
+
+static int first_time = 1;
+static inode_nr current_dir = ROOT_INODE;
+
+static block_nr fs_ind = 0;
+static block_nr fs_block = 0;
+static char fs_buf[BLOCK_SIZE]; /* For storing inodes and ind sectors */
+
+static min_inode_open();
+
+#define b_super(x) ((struct super_block *)(x))
+#define b_dir(x) ((dir_struct*)(x))
min_open_file(fname)
char * fname;
{
+ char * sptr;
+
+ if( disk_heads == 0 ) return -1;
+
+ if( (sptr = read_sector(SUPER_BLOCK*BLOCK_SIZE/SECTOR_SIZE)) == 0 )
+ return -1;
+
+ /* Check super */
+ if(b_super(sptr)->s_magic == SUPER_MAGIC )
+ fs_dir32 = 0;
+ else if(b_super(sptr)->s_magic == SUPER_MAGIC2 )
+ fs_dir32 = 16;
+ else
+ return -1;
+
+ inode_tbl = b_super(sptr)->s_imap_blocks+b_super(sptr)->s_zmap_blocks+2;
+
+ /* Check for boot directory */
+ current_dir = ROOT_INODE;
+ if( min_name_open("boot") >= 0 && current_file.i_mode == I_DIRECTORY )
+ current_dir = current_file.inode;
+#ifdef DEBUG
+ fprintf(stderr, "Opening minix file <%d>/%s[1,%d]\n",
+ current_dir,fname,fs_dir32+14);
+#endif
+ return min_name_open(fname);
+}
+
+static
+min_name_open(fname)
+char * fname;
+{
+ int do_dir = 0;
+ char dirbuf[1024];
+ long len;
+ int v;
+ inode_nr file_inode = 0;
+
+ if( strcmp(fname, ".") == 0 ) do_dir = 1;
+
+ /* open current_dir inode */
+ if( min_inode_open(current_dir) < 0 ) return -1;
+
+ /* scan for file */
+ for(len = min_file_length(); len>0; len-=1024)
+ {
+ if( min_read_block(dirbuf) < 0 ) break;
+
+ for(v=0; v<1024; v+= 16+fs_dir32)
+ {
+ if( b_dir(dirbuf+v)->d_inum == 0 )
+ continue;
+
+#ifndef NOCOMMAND
+ if( do_dir )
+ {
+ if( b_dir(dirbuf+v)->d_name[0] == '.' )
+ continue;
+
+ if( fs_dir32 ) printf("%.30s\n", b_dir(dirbuf+v)->d_name);
+ else printf("%.14s\n", b_dir(dirbuf+v)->d_name);
+ }
+ else
+#endif
+ if( strncmp(b_dir(dirbuf+v)->d_name, fname,14+fs_dir32) ==0)
+ {
+ file_inode = b_dir(dirbuf+v)->d_inum;
+ break;
+ }
+ }
+ }
+
+ /* open */
+ if( file_inode )
+ {
+ if( min_inode_open(file_inode) >= 0 ) return 0;
+ }
+
return -1;
}
+static
+min_inode_open(inode)
+int inode;
+{
+ int inode_sector = inode_tbl*BLOCK_SIZE/SECTOR_SIZE;
+ d_inode * sptr = 0;
+ int i;
+
+ min_close_file();
+
+ inode--;
+ inode_sector += inode/(SECTOR_SIZE/sizeof(d_inode));
+ if( (sptr = read_sector(inode_sector)) == 0 ) return -1;
+
+ sptr += inode%(SECTOR_SIZE/sizeof(d_inode));
+
+ current_file.i_mode = (sptr->i_mode & I_TYPE);
+
+ if( current_file.i_mode != I_REGULAR &&
+ current_file.i_mode != I_DIRECTORY )
+ return -1;
+
+ current_file.i_size = sptr->i_size;
+ for(i=0; i<NR_ZONE_NUMS; i++)
+ current_file.i_zone[i] = sptr->i_zone[i];
+
+ current_file.inode = inode+1;
+
+ return 0;
+}
+
min_rewind_file()
{
- return -1;
+ current_file.seek_addr = 0;
+ return 0;
}
min_close_file()
{
- return -1;
+ if( current_file.inode == 0 ) return -1;
+ current_file.inode = 0;
+ current_file.seek_addr = 0;
+ fs_ind = 0;
+ return 0;
}
long
min_file_length()
{
- return -1;
+ if( current_file.inode == 0 ) return -1;
+ return current_file.i_size;
}
min_read_block(buffer)
char * buffer;
{
- return -1;
+ block_nr block_no;
+
+ if( current_file.seek_addr < NR_DZONE_NUM )
+ block_no = current_file.i_zone[current_file.seek_addr];
+ else if( current_file.seek_addr < NR_DZONE_NUM + NR_INDIRECTS )
+ {
+ if( fs_block != current_file.i_zone[NR_DZONE_NUM] )
+ {
+ block_no = current_file.i_zone[NR_DZONE_NUM];
+ read_fs_block(block_no, fs_buf);
+ fs_block = current_file.i_zone[NR_DZONE_NUM];
+ fs_ind = 0;
+ }
+
+ block_no = ((zone_nr*)fs_buf)[current_file.seek_addr-NR_DZONE_NUM];
+ }
+ else
+ {
+ int ind_block;
+
+ ind_block = current_file.seek_addr - NR_DZONE_NUM - NR_INDIRECTS;
+
+ if( fs_ind != ind_block/NR_INDIRECTS + 1 )
+ {
+ block_no = current_file.i_zone[NR_DZONE_NUM+1];
+ read_fs_block(block_no, fs_buf);
+ fs_block = current_file.i_zone[NR_DZONE_NUM+1];
+
+ block_no = ((zone_nr*)fs_buf)[ind_block/NR_INDIRECTS];
+
+ read_fs_block(block_no, fs_buf);
+ fs_block = current_file.i_zone[NR_DZONE_NUM];
+ fs_ind = ind_block/NR_INDIRECTS + 1;
+ }
+
+ block_no = ((zone_nr*)fs_buf)[ind_block%NR_INDIRECTS];
+ }
+
+ current_file.seek_addr++;
+
+ read_fs_block(block_no, buffer);
+ return 0;
}
+read_fs_block(block_no, buffer)
+block_nr block_no;
+char * buffer;
+{
+ long sector_no;
+ char * sptr;
+
+ if( block_no == 0 ) goto zappit;
+
+ sector_no = ((long)block_no) * BLOCK_SIZE/SECTOR_SIZE;
+
+ sptr = read_sector(sector_no);
+ if( sptr ) memcpy(buffer, sptr, SECTOR_SIZE);
+ else goto zappit;
+
+ sptr = read_sector(sector_no+1);
+ if( sptr ) memcpy(buffer+SECTOR_SIZE, sptr, SECTOR_SIZE);
+ else goto zappit;
+
+ return;
+zappit:;
+ memset(buffer, '\0', 1024);
+}
diff --git a/bootblocks/fs_tar.c b/bootblocks/fs_tar.c
index a5cd55d..ccab3b5 100644
--- a/bootblocks/fs_tar.c
+++ b/bootblocks/fs_tar.c
@@ -54,11 +54,6 @@ char * fname;
#endif
int sectno;
-#ifdef __STANDALONE__
- if( disk_drive != __argr.h.dl ) return -1; /* Only the one booted off */
- if( __argr.x.si < 9 || __argr.x.si > 63 ) return -1; /* SPT good */
-#endif
-
sptr = read_sector(0);
/* Is it a tar disk ? */
diff --git a/bootblocks/lsys.c b/bootblocks/lsys.c
index 442e920..adcd4a0 100644
--- a/bootblocks/lsys.c
+++ b/bootblocks/lsys.c
@@ -63,16 +63,16 @@ char ** argv;
if( memcmp(buffer+DOS4_FATTYPE, "FAT16", 5) )
{
- for(i=0; i<msdos_dosfs_stat; i++)
+ for(i=0; i<msdos_dosfs_stat - msdos_start; i++)
buffer[i] = msdos_data[i];
- for(i=msdos_codestart; i<512; i++)
+ for(i=msdos_codestart - msdos_start; i<512; i++)
buffer[i] = msdos_data[i];
}
else
{
- for(i=0; i<msdos16_dosfs_stat; i++)
+ for(i=0; i<msdos16_dosfs_stat - msdos_start; i++)
buffer[i] = msdos16_data[i];
- for(i=msdos_codestart; i<512; i++)
+ for(i=msdos_codestart - msdos_start; i<512; i++)
buffer[i] = msdos16_data[i];
}
diff --git a/bootblocks/makeboot.c b/bootblocks/makeboot.c
index c749d20..e45fa4a 100644
--- a/bootblocks/makeboot.c
+++ b/bootblocks/makeboot.c
@@ -25,7 +25,7 @@ unsigned char buffer[1024];
#define FS_MBR 6 /* Boot sector is an MBR */
#ifndef __MSDOS__
-#define NOT_HAS_2M20
+#define X_HAS_2M20
#endif
struct bblist {
@@ -43,7 +43,7 @@ struct bblist {
{ "dosfs","Boot file BOOTFILE.SYS from dos floppy",
msdos_data, msdos_size,
1, msdos_boot_name-msdos_start, FS_DOS, 12},
-{ "dos16","Boot file BOOTFILE.SYS from 16 bit dos floppy",
+{ "dos16","Boot file BOOTFILE.SYS from 16 bit dos filesystem",
msdos16_data, msdos16_size,
1, msdos16_boot_name-msdos16_start, FS_DOS, 16},
{ "none", "No OS bootblock, just message",
@@ -628,8 +628,8 @@ static char * fieldnames[] = {
for(j=0; j<dosflds[i].length; j++)
{
ch = bootsect[dosflds[i].offset+j];
- if( ch <= ' ' || ch > '~' ) putchar('.');
- else putchar(ch);
+ if( ch < ' ' || ch > '~' ) putchar('.');
+ else putchar(ch);
}
putchar('\n');
}
diff --git a/bootblocks/min_buf.c b/bootblocks/min_buf.c
index 797ee7b..ff58d55 100644
--- a/bootblocks/min_buf.c
+++ b/bootblocks/min_buf.c
@@ -22,6 +22,15 @@ void reset_disk()
disk_heads = 0;
disk_cyls = 0;
bad_track = -1;
+
+#ifdef __STANDALONE__
+ if( disk_drive == __argr.h.dl && __argr.x.si >= 9 && __argr.x.si <= 63 )
+ {
+ disk_spt = __argr.x.si;
+ disk_heads = 2;
+ disk_cyls = 80;
+ }
+#endif
}
char * read_lsector(sectno)
@@ -35,7 +44,7 @@ long sectno;
int phy_c = 0;
int ltrack;
- if( sectno == 0 ) reset_disk();
+ if( sectno == 0 || disk_heads == 0 ) reset_disk();
if( buf_len != disk_spt ) track_no = -1;
if( disk_spt < 1 || disk_heads < 1 )
diff --git a/bootblocks/minix.c b/bootblocks/minix.c
index 22795ef..62b3031 100644
--- a/bootblocks/minix.c
+++ b/bootblocks/minix.c
@@ -4,6 +4,10 @@
*
* Copyright (C) 1990-1998 Robert de Bath, distributed under the GPL Version 2
* Based on minix filesystem definitions.
+ *
+ * TODO:
+ * Alter nogood() to do a mov sp,... so the helper program can override
+ * the panic message.
*/
#include <a.out.h>
@@ -55,7 +59,7 @@ org start ! The lowest available address, again.
j skip_vars
org dos_sysid
- .ascii "MINIXFS BOOT (C) 1990-1997, Robert de Bath"
+ .ascii "MINIXFS BOOT (C) 1990-1999, Robert de Bath"
org codestart
#endif
@@ -76,7 +80,7 @@ _dinode: .word 1 ! ROOT_INODE
#endif
export bootfile ! File to boot, make this whatever you like,
-bootfile: ! 'boot' is good too.
+bootfile: ! 'boot' is good, 'linux' too.
_bootfile:
.ascii "boot"
.byte 0,0,0,0,0,0,0,0,0,0
@@ -95,7 +99,7 @@ skip_vars:
#ifndef HARDDISK
loopy:
- mov ax,#$0204 ! Read 4 sectors, code + superblock.
+ mov ax,#$0203 ! Read 3 sectors, code + superblock.
mov bx,#start ! Where this _should_ be
mov cx,#$0001 ! From sector 1
xor dx,dx ! Of the floppy drive head zero
@@ -113,11 +117,11 @@ loopy:
mov [bootpart],bx ! Save the partition sector offset (and drive)
mov [bootpart+2],dx
- ! Read first 3 sectors of hd.
+ ! Read next 2 sectors of hd.
xor dx,dx
mov cx,#1
mov bx,#ORGADDR+$200
- mov al,#3
+ mov al,#2
call load_sect
#endif
@@ -153,6 +157,7 @@ extern unsigned ldaddr;
/* Directory reading */
extern dir_struct * dirptr;
extern unsigned flength;
+extern unsigned dir_32;
#ifndef HARDDISK
/* The 'shape' of the floppy - intuit from superblock or try to read max */
@@ -182,7 +187,7 @@ _lastsect: .word 0
#endif
block start+0x400
-_b_super: .blkb 1024
+_b_super: .blkb 512
#ifndef MIN_SPACE
export helper
@@ -524,6 +529,12 @@ got_sectors:
ret
#endasm
+#else
+probe_sectors()
+{
+ /* Guess the number of sectors based on the size of the file system */
+ if( (n_sectors = b_super.s_nzones / 40) > 11 ) n_sectors /= 2;
+}
#endif
#endif
@@ -705,7 +716,12 @@ loadprog()
#ifdef DOTS
prt_dot();
#endif
- if( b_super.s_magic != SUPER_MAGIC ) nogood();
+ if( b_super.s_magic == SUPER_MAGIC2 )
+ dir_32 = 1;
+ else if( b_super.s_magic == SUPER_MAGIC )
+ dir_32 = 0;
+ else
+ nogood();
#ifdef zone_shift
if( zone_shift != b_super.s_log_zone_size) nogood();
@@ -714,11 +730,9 @@ loadprog()
#endif
#ifndef HARDDISK
-#ifdef TRY_FLOPPY
probe_sectors();
-#else
- if( (n_sectors = b_super.s_nzones / 40) > 11 ) n_sectors /= 2;
-#endif
+
+ /* if( (n_sectors = b_super.s_nzones / 40) > 11 ) n_sectors /= 2; */
set_bpb();
#endif
@@ -800,6 +814,11 @@ register char * p = dirptr->d_name;
}
flength -= 16;
dirptr++;
+ if( dir_32 )
+ {
+ flength -= 16;
+ dirptr++;
+ }
}
nogood();
}
@@ -897,6 +916,7 @@ _indirect: .blkw 1
_ldaddr: .blkw 1
_dirptr: .blkw 1
_flength: .blkw 1
+_dir_32: .blkw 1
varend:
#ifdef MIN_SPACE
endb
diff --git a/bootblocks/minix.h b/bootblocks/minix.h
index 984a6bc..57f0b30 100644
--- a/bootblocks/minix.h
+++ b/bootblocks/minix.h
@@ -61,6 +61,7 @@ typedef char gid; /* group id */
/* Miscellaneous constants */
#define SUPER_MAGIC 0x137F /* magic number contained in super-block */
+#define SUPER_MAGIC2 0x138F /* Secondary magic 30 char names */
#define BOOT_BLOCK (block_nr)0 /* block number of boot block */
#define SUPER_BLOCK (block_nr)1 /* block number of super block */
diff --git a/bootblocks/monitor.c b/bootblocks/monitor.c
index 4fecfd7..1ba93ec 100644
--- a/bootblocks/monitor.c
+++ b/bootblocks/monitor.c
@@ -33,19 +33,19 @@ static char minibuf[2] = " ";
init_prog();
#ifdef __STANDALONE__
-#if 0
#ifndef NOCOMMAND
if( __get_ds() != 0x1000 )
{
+ /* First to top of RAM */
relocator(-1);
- relocator(1);
+ /* Then align DS to 64k boundry -> DMA is simple. */
+ relocator(0x1000-__get_ds()+__get_cs());
+
+ /* Oops, relocate down didn't work, try a little higher. */
if( __get_ds() > 0x1000 ) relocator(2);
printf("Relocated to CS=$%04x DS=$%04x\n", __get_cs(), __get_ds());
}
#endif
-#else
- printf("Loaded at CS=$%04x DS=$%04x\n", __get_cs(), __get_ds());
-#endif
if( (__argr.x.dx & 0xFF) == 0 )
#endif
@@ -54,9 +54,8 @@ static char minibuf[2] = " ";
cmd_type("help.txt");
#else
display_help(0);
- if( x86 > 2 && !x86_emu ) /* Check some basics */
#endif
- cmd_bzimage((void*)0);
+ cmd_bzimage((void*)0);
}
#ifdef NOCOMMAND
diff --git a/bootblocks/monitor.h b/bootblocks/monitor.h
index 7674afd..7283c10 100644
--- a/bootblocks/monitor.h
+++ b/bootblocks/monitor.h
@@ -12,7 +12,7 @@
#define X_CALC_CRC
#ifdef __STANDALONE__
-#define COLOUR
+#define NO_COLOUR
extern union REGS __argr;
#endif
@@ -30,6 +30,19 @@ extern union REGS __argr;
#define read_block tar_read_block
#endif
+#ifdef MINFLOPPY
+#define SINGLEFS
+#define NOMONITOR
+#define NOCOMMAND
+#define MINI_BUF
+
+#define open_file min_open_file
+#define rewind_file min_rewind_file
+#define close_file min_close_file
+#define file_length min_file_length
+#define read_block min_read_block
+#endif
+
#ifdef DOSFLOPPY
#define SINGLEFS
#define NOMONITOR
@@ -44,7 +57,7 @@ extern union REGS __argr;
#define read_block dos_read_block
#endif
-#if 1
+#ifdef __STANDALONE__
#undef putchar
#define putchar cputchar
#define printf cprintf
diff --git a/bootblocks/msdos.s b/bootblocks/msdos.s
index 11a4fe4..7f691ff 100644
--- a/bootblocks/msdos.s
+++ b/bootblocks/msdos.s
@@ -49,6 +49,9 @@ org ORGADDR
start:
include sysboot.s
+org dos_sysid
+ .ascii "DOSFS" ! System ID
+
!---------------------------------------------------------------------------
! Data into the temp area, 30 clear bytes
org floppy_temp
@@ -333,6 +336,7 @@ maincode:
xor dx,dx ! DX=0 => floppy drive
push dx ! CX=0 => partition offset = 0
+ mov si,[dos_spt] ! SI=Sectors pet track
mov bx,#LOADSEG
mov ds,bx ! DS = loadaddress
diff --git a/bootblocks/skip.s b/bootblocks/skip.s
index 0c1184d..aed4e40 100644
--- a/bootblocks/skip.s
+++ b/bootblocks/skip.s
@@ -10,6 +10,9 @@ org ORGADDR
start:
include sysboot.s
+org dos_sysid
+ .ascii "BOOT C" ! System ID
+
org codestart
cli ! Assume _nothing_!
cld
diff --git a/bootblocks/trk_buf.c b/bootblocks/trk_buf.c
index 69c7eaa..86a6721 100644
--- a/bootblocks/trk_buf.c
+++ b/bootblocks/trk_buf.c
@@ -3,13 +3,15 @@
#ifndef MINI_BUF
-/* #define DEBUG 1 */
+/* #define DEBUG 1 /**/
int disk_drive = 0;
int disk_spt = 7;
-int disk_heads = 2;
+int disk_heads = 0;
int disk_cyls = 0;
-long disk_partition_offset = 0; /* FIXME: fetch from __argr */
+long disk_partition_offset = 0;
+
+int check_motor = 1;
static int last_drive = -1;
static int data_len = 0;
@@ -24,17 +26,32 @@ static long get_dpt();
void reset_disk()
{
+#ifdef DEBUG
+ fprintf(stderr, "Reset Disk: ");
+#endif
if( data_buf1 ) free(data_buf1);
if( data_buf2 ) free(data_buf2);
data_buf1 = data_buf2 = 0;
last_drive = disk_drive;
bad_track = -1;
+ disk_spt = 7; /* Defaults for reading floppy boot area. */
+ disk_heads = 0;
+ disk_cyls = 0;
+
if( !(disk_drive & 0x80 ) )
{
- disk_spt = 7; /* Defaults for reading Boot area. */
- disk_heads = 2;
- disk_cyls = 0;
+#ifdef __STANDALONE__
+ if( disk_drive == __argr.h.dl && __argr.x.si >= 9 && __argr.x.si <= 63 )
+ {
+ disk_spt = __argr.x.si;
+ disk_heads = 2;
+ disk_cyls = 80;
+ }
+#endif
+
+ /* Floppy -> no partitions */
+ /* Even if there were we couldn't deal with it anyway! */
disk_partition_offset = 0;
}
#if defined(__MSDOS__) || defined(__STANDALONE__)
@@ -51,24 +68,25 @@ void reset_disk()
}
#endif
- disk_spt = 17; /* Defaults for reading Boot area. */
- disk_heads = 1;
- disk_cyls = 0;
-
dpt = get_dpt(disk_drive);
v = ((dpt>>16) & 0xFF);
- if( v == 0xFF || v <= (disk_drive&0x7F) ) return; /* Bad dpt */
-
- disk_spt = (dpt & 0x3F); /* Max sector number 1-63 */
- if( disk_spt == 0 ) disk_spt = 64; /* 1-64 ? */
- disk_heads = ((dpt>>24) & 0xFF) + 1; /* Head count 1-256 */
- disk_cyls = ((dpt>>8) & 0xFF) + ((dpt<<2) & 0x300) + 1;
-
- /* Cyls count, unchecked, only needs != 0, if AMI 386 bios can be
- * upto 4096 cylinder, otherwise BIOS limit is 1024 cyl.
- */
+ if( v != 0xFF && v > (disk_drive&0x7F) )
+ {
+ disk_spt = (dpt & 0x3F); /* Max sector number 1-63 */
+ if( disk_spt == 0 ) disk_spt = 64; /* 1-64 ? */
+ disk_heads = ((dpt>>24) & 0xFF) + 1; /* Head count 1-256 */
+ disk_cyls = ((dpt>>8) & 0xFF) + ((dpt<<2) & 0x300) + 1;
+
+ /* Cyls count, unchecked, only needs != 0, if AMI 386 bios can be
+ * upto 4096 cylinder, otherwise BIOS limit is 1024 cyl.
+ */
+ }
}
#endif
+
+#ifdef DEBUG
+ fprintf(stderr, "%d/%d/%d\n", disk_spt, disk_heads, disk_cyls);
+#endif
}
char * read_lsector(sectno)
@@ -81,7 +99,11 @@ long sectno;
int phy_h = 0;
int phy_c = 0;
- if( disk_drive != last_drive || sectno == 0 ) reset_disk();
+ rv = 0;
+ if( disk_drive != last_drive ) rv = 1;
+ else if( check_motor ) rv = ( motor_running() == 0 );
+ else if( sectno == 0 ) rv = 1;
+ if( rv ) reset_disk();
if( disk_partition_offset > 0 )
sectno += disk_partition_offset;
@@ -89,8 +111,6 @@ long sectno;
if( disk_spt < 0 || disk_spt > 63 || disk_heads < 1 )
{
phy_s = sectno;
- reset_disk();
-
#if DEBUG > 1
fprintf(stderr, "read_sector(%ld = %d,%d,%d)\n",
sectno, phy_c, phy_h, phy_s+1);
@@ -121,10 +141,6 @@ long sectno;
}
#ifdef DEBUG
- fprintf(stderr, "WARNING: Single sector read\n");
-#endif
-
-#ifdef DEBUG
fprintf(stderr, "phy_read(%d,%d,%d,%d,%d,0x%x)\n",
disk_drive, phy_c, phy_h, phy_s+1, 1, data_buf1);
#endif
@@ -138,6 +154,8 @@ long sectno;
if( rv ) printf("Disk error 0x%02x %d:%d:%d:%d[%2d] -> 0x%04x[]\n",
rv, disk_drive, phy_c, phy_h, phy_s+1, 1, data_buf1);
+ check_motor = motor_running();
+
if(rv) return 0; else return data_buf1;
}
@@ -146,7 +164,7 @@ int phy_c, phy_h, phy_s;
{
long trk_no, t;
char * p;
- int tries = 3;
+ int tries = 6;
int rv, nlen;
/* Big tracks get us short of memory so limit it. */
@@ -158,7 +176,7 @@ int phy_c, phy_h, phy_s;
trk_no = (long)(phy_c*disk_heads+phy_h)*((disk_spt+4)/nlen)+phy_s/nlen+1;
-#if DEBUG > 1
+#if DEBUG > 2
fprintf(stderr, "Info len=%d,%d trk=%ld,%ld,%ld\n",
data_len,nlen, trk_no,data_trk1,data_trk2);
#endif
@@ -232,6 +250,8 @@ int phy_c, phy_h, phy_s;
if( rv ) printf("Disk error 0x%02x %d:%d:%d:%d[%2d] -> 0x%04x[]\n",
rv, disk_drive, phy_c, phy_h, phy_s/data_len+1, data_len, data_buf1);
+ check_motor = motor_running();
+
/* Disk error, it'll try one at a time, _very_ slowly! */
if(rv)
{
@@ -280,6 +300,8 @@ phy_read(drive, cyl, head, sect, length, buffer)
jc read_err
mov ax,#0
read_err:
+ xchg ah,al
+ xor ah,ah
pop es
pop bp
@@ -311,6 +333,20 @@ func_ok:
pop bp
#endasm
}
+
+motor_running()
+{
+#asm
+ push es
+ mov ax,#$40
+ mov es,ax
+ seg es
+ mov al,[$3f]
+ xor ah,ah
+ and al,#$0F
+ pop es
+#endasm
+}
#endif
#endif
diff --git a/copt/rules.i b/copt/rules.i
index 9506bd9..3cb8aca 100644
--- a/copt/rules.i
+++ b/copt/rules.i
@@ -192,6 +192,14 @@ pop ax
seg es
mov [%1],al
+pmov ax,%[#|*]0%1
+push ax
+call ___poke_es
+add sp,*4
+=
+seg es
+mov [%1],al
+
push %0[%1]
call ___poke_es
add sp,*4
@@ -235,6 +243,14 @@ pop ax
seg es
mov [%1],ax
+pmov ax,%[#|*]0%1
+push ax
+call ___doke_es
+add sp,*4
+=
+seg es
+mov [%1],ax
+
push %0[%1]
call ___doke_es
add sp,*4
diff --git a/ld/bindef.h b/ld/bindef.h
index dbacfcd..0ccbdf9 100644
--- a/ld/bindef.h
+++ b/ld/bindef.h
@@ -26,12 +26,12 @@
#ifndef STANDARD_GNU_A_OUT
# ifndef C_EXT
- #define BSD_A_OUT
+# define BSD_A_OUT
# endif
/* Not sure about this one ... it works here ... */
# if defined(BSD_A_OUT) && defined(N_MAGIC)
- #define STANDARD_GNU_A_OUT
+# define STANDARD_GNU_A_OUT
# endif
#endif
diff --git a/ld/objdump86.c b/ld/objdump86.c
index 58a935f..f9f32a3 100644
--- a/ld/objdump86.c
+++ b/ld/objdump86.c
@@ -16,7 +16,7 @@
#include <malloc.h>
#include <string.h>
-FILE * ifd = stdin;
+FILE * ifd;
char * ifname;
#ifdef __STDC__
@@ -63,6 +63,8 @@ char ** argv;
int ar;
char * p;
+ ifd = stdin; /* In Libc6 stdin is weird */
+
p = strrchr(argv[0], '/');
if(p) p++; else p=argv[0];
diff --git a/ld/writebin.c b/ld/writebin.c
index 6945eee..ef1cb7f 100644
--- a/ld/writebin.c
+++ b/ld/writebin.c
@@ -157,7 +157,11 @@ bool_pt arguzp;
if (uzp)
{
if (btextoffset == 0)
+#ifdef QMAGIC
+ btextoffset = page_size()+HEADERLEN;
+#else
btextoffset = page_size();
+#endif
if (bdataoffset == 0 && sepid)
bdataoffset = page_size();
}
@@ -284,6 +288,14 @@ bool_pt arguzp;
etextpadoff = ld_roundup(etextoffset, 0x10, bin_off_t);
segadj[1] += etextpadoff - bdataoffset;
}
+#ifdef QMAGIC
+ else if (uzp && bdataoffset == 0)
+ {
+ bdataoffset = ld_roundup(etextoffset, page_size(), bin_off_t);
+ etextpadoff = ld_roundup(etextoffset, page_size(), bin_off_t);
+ segadj[1] += etextpadoff - bdataoffset;
+ }
+#endif
else if (bdataoffset == 0)
bdataoffset = etextpadoff;
segpos[1] = segbase[1] = edataoffset = bdataoffset;
@@ -318,6 +330,15 @@ bool_pt arguzp;
& ~(bin_off_t) 0xFF;
}
#endif
+
+#ifdef QMAGIC
+ if(seg==3 && uzp && !stripflag) /* XXX Stripped last seek needed */
+ {
+ bin_off_t val;
+ val = ld_roundup(segbase[seg]+segsz[seg], page_size(), bin_off_t);
+ segsz[seg] = val - segbase[seg];
+ }
+#endif
combase[seg] = segbase[seg] + segsz[seg];
segadj[seg] = segadj[seg - 1];
}
@@ -944,6 +965,11 @@ PRIVATE void writeheader()
memset(&header, 0, sizeof header);
#ifdef STANDARD_GNU_A_OUT
#ifdef N_SET_MAGIC
+#ifdef QMAGIC
+ if(uzp)
+ N_SET_MAGIC(header, QMAGIC);
+ else
+#endif
N_SET_MAGIC(header, OMAGIC);
#else
*(unsigned short *) &header.a_magic = OMAGIC; /* XXX - works for 386BSD */
@@ -984,12 +1010,19 @@ PRIVATE void writeheader()
#ifndef STANDARD_GNU_A_OUT
header.a_hdrlen = FILEHEADERLENGTH;
#endif
+#ifdef QMAGIC
+ if (uzp)
+ offtocn((char *) &header.a_text, etextpadoff - btextoffset+HEADERLEN,
+ sizeof header.a_text);
+ else
+#endif
offtocn((char *) &header.a_text, etextpadoff - btextoffset,
sizeof header.a_text);
offtocn((char *) &header.a_data, edataoffset - bdataoffset,
sizeof header.a_data);
offtocn((char *) &header.a_bss, endoffset - edataoffset,
sizeof header.a_bss);
+
#ifdef REL_OUTPUT
if (!reloc_output)
#endif
diff --git a/libc/Makefile b/libc/Makefile
index 2e1ffd3..0b18d17 100644
--- a/libc/Makefile
+++ b/libc/Makefile
@@ -11,7 +11,7 @@ endif
VERMAJOR=0
VERMINOR=14
-VERPATCH=7
+VERPATCH=8
VER=$(VERMAJOR).$(VERMINOR).$(VERPATCH)
CC=bcc
diff --git a/libc/bcc/__ldivmod.c b/libc/bcc/__ldivmod.c
index 359c692..dbde4b8 100644
--- a/libc/bcc/__ldivmod.c
+++ b/libc/bcc/__ldivmod.c
@@ -21,7 +21,7 @@
! let dividend = a, divisor = b, quotient = q, remainder = r
-! a = b * q + r mod 2^32
+! a = b * q + r mod 2**32
! where:
! if b = 0, q = 0 and r = a
diff --git a/libc/getent/utent.c b/libc/getent/utent.c
index 7f9e19a..f4c2ebc 100644
--- a/libc/getent/utent.c
+++ b/libc/getent/utent.c
@@ -19,10 +19,13 @@ static const char * ut_name=_PATH_UTMP;
static int ut_fd=-1;
struct utmp *
-__getutent(int utmp_fd)
+getutent(void)
{
static struct utmp utmp;
- if (read(utmp_fd, (char *) &utmp, sizeof(struct utmp))!=sizeof(struct utmp))
+ if (ut_fd==-1) setutent();
+ if (ut_fd==-1) return NULL;
+
+ if (read(ut_fd, (char *) &utmp, sizeof(struct utmp))!=sizeof(struct utmp))
return NULL;
return &utmp;
}
@@ -30,13 +33,20 @@ __getutent(int utmp_fd)
void
setutent(void)
{
+ int xerrno = errno;
if (ut_fd!=-1)
- close(ut_fd);
- if ((ut_fd=open(ut_name, O_RDONLY))<0)
+ close(ut_fd); /* ... Should this be an Lseek ? */
+
+ if ((ut_fd=open(ut_name, O_RDWR))<0)
{
- perror("setutent: Can't open utmp file");
- ut_fd=-1;
+ if (errno!=EACCES || (ut_fd=open(ut_name, O_RDONLY))<0)
+ {
+ /* No, this is a library function, it should not do this! */
+ /* perror("setutent: Can't open utmp file"); */
+ ut_fd=-1;
+ }
}
+ if (ut_fd!= -1) errno=xerrno;
}
void
@@ -48,26 +58,11 @@ endutent(void)
}
struct utmp *
-getutent(void)
-{
- if (ut_fd==-1)
- setutent();
- if (ut_fd==-1)
- return NULL;
- return __getutent(ut_fd);
-}
-
-struct utmp *
-getutid(struct utmp * utmp_entry)
+getutid(const struct utmp * utmp_entry)
{
struct utmp * utmp;
- if (ut_fd==-1)
- setutent();
- if (ut_fd==-1)
- return NULL;
-
- while ((utmp=__getutent(ut_fd))!=NULL)
+ while ((utmp=getutent())!=NULL)
{
if ((utmp_entry->ut_type==RUN_LVL ||
utmp_entry->ut_type==BOOT_TIME ||
@@ -79,7 +74,7 @@ getutid(struct utmp * utmp_entry)
utmp_entry->ut_type==DEAD_PROCESS ||
utmp_entry->ut_type==LOGIN_PROCESS ||
utmp_entry->ut_type==USER_PROCESS) &&
- !strcmp(utmp->ut_id, utmp_entry->ut_id))
+ !strncmp(utmp->ut_id, utmp_entry->ut_id,sizeof(utmp->ut_id)))
return utmp;
}
@@ -87,21 +82,17 @@ getutid(struct utmp * utmp_entry)
}
struct utmp *
-getutline(struct utmp * utmp_entry)
+getutline(const struct utmp * utmp_entry)
{
struct utmp * utmp;
- if (ut_fd==-1)
- setutent();
- if (ut_fd==-1)
- return NULL;
-
#if 0 /* This is driving me nuts. It's not an implementation problem -
it's a matter of how things _SHOULD_ behave. Groan. */
- lseek(ut_fd, SEEK_CUR, -sizeof(struct utmp));
+ if (ut_fd!=-1)
+ lseek(ut_fd, (off_t) -sizeof(struct utmp), SEEK_CUR);
#endif
- while ((utmp=__getutent(ut_fd))!=NULL)
+ while ((utmp=getutent())!=NULL)
{
if ((utmp->ut_type==USER_PROCESS ||
utmp->ut_type==LOGIN_PROCESS) &&
@@ -113,40 +104,47 @@ getutline(struct utmp * utmp_entry)
}
struct utmp *
-pututline(struct utmp * utmp_entry)
+pututline(const struct utmp * utmp_entry)
{
struct utmp * ut;
+ int xerrno=errno;
+#if 0
/* Ignore the return value. That way, if they've already positioned
the file pointer where they want it, everything will work out. */
- (void) lseek(ut_fd, (off_t) -sizeof(utmp_entry), SEEK_CUR);
+ if (ut_fd!=-1)
+ (void) lseek(ut_fd, (off_t) -sizeof(struct utmp), SEEK_CUR);
+#endif
if ((ut=getutid(utmp_entry))!=NULL)
- {
- lseek(ut_fd, (off_t) -sizeof(utmp_entry), SEEK_CUR);
- if (write(ut_fd, (char *) utmp_entry, sizeof(utmp_entry))
- != sizeof(utmp_entry))
- return NULL;
- }
+ lseek(ut_fd, (off_t) -sizeof(struct utmp), SEEK_CUR);
+ else if( ut_fd==-1 )
+ return NULL;
else
- {
lseek(ut_fd, (off_t) 0, SEEK_END);
- if (write(ut_fd, (char *) utmp_entry, sizeof(utmp_entry))
- != sizeof(utmp_entry))
- return NULL;
- }
+ /*
+ * At this point I could make sure the offset we're at is an exact multiple
+ * of the sizeof struct utmp. Should I? Up or down? --RdB
+ */
+
+ if (write(ut_fd, (char *) utmp_entry, sizeof(struct utmp))
+ != sizeof(struct utmp))
+ return NULL;
+
+ /* I think this final lseek gets the result Nat was after ... RdB */
+ lseek(ut_fd, (off_t) -sizeof(struct utmp), SEEK_CUR);
+
+ /* Ignoring untrapped errors */
+ errno=xerrno;
return utmp_entry;
}
void
utmpname(const char * new_ut_name)
{
+ endutent();
+
if (new_ut_name!=NULL)
ut_name=new_ut_name;
-
- if (ut_fd!=-1)
- close(ut_fd);
}
-
-
diff --git a/libc/include/bios.h b/libc/include/bios.h
index 4cfcd6a..20aa5ca 100644
--- a/libc/include/bios.h
+++ b/libc/include/bios.h
@@ -5,7 +5,7 @@
union REGS
{
- struct { unsigned int ax, bx, cx, dx, si, di, cflag; } x;
+ struct { unsigned int ax, bx, cx, dx, si, di, cflag, flags; } x;
struct { unsigned char al, ah, bl, bh, cl, ch, dl, dh; } h;
};
diff --git a/libc/include/msdos/fcntl.h b/libc/include/msdos/fcntl.h
index 8cf076c..f92ff2a 100644
--- a/libc/include/msdos/fcntl.h
+++ b/libc/include/msdos/fcntl.h
@@ -1,16 +1,27 @@
#ifndef __MSDOS_FCNTL_H
#define __MSDOS_FCNTL_H
-/* Definitions taken from the i386 Linux kernel. */
+/* Definitions taken from Ralf Brown interrupt list and Linux kernel */
-#define O_ACCMODE 0003
-#define O_RDONLY 00
-#define O_WRONLY 01
-#define O_RDWR 02
-#define O_CREAT 0100 /* not fcntl */
-#define O_EXCL 0200 /* not fcntl */
-#define O_TRUNC 01000 /* not fcntl */
-#define O_APPEND 02000
+#define O_ACCMODE 0x03
+#define O_RDONLY 0x00
+#define O_WRONLY 0x01
+#define O_RDWR 0x02
+
+#define O_DENYMODE 0x70
+#define O_DENYALL 0x10
+#define O_DENYWRITE 0x20
+#define O_DENYREAD 0x30
+#define O_DENYNONE 0x40
+#define O_SETFD 0x80 /* Close on exec flag for open */
+
+#define O_CREAT 0x100 /* Moved on DOS to avoid DENY's */
+#define O_TRUNC 0x200
+#define O_APPEND 0x400
+#define O_EXCL 0x800
+
+#define O_BINARY 0x0000
+#define O_TEXT 0x8000 /* This right ? Who cares! */
#define F_DUPFD 0 /* dup */
#define F_GETFD 1 /* get f_flags */
diff --git a/libc/include/stddef.h b/libc/include/stddef.h
index f26997a..3b446ac 100644
--- a/libc/include/stddef.h
+++ b/libc/include/stddef.h
@@ -10,7 +10,7 @@
#include <sys/types.h>
#ifndef NULL
-#define NULL 0
+#define NULL ((void*)0)
#endif
#endif /* __STDDEF_H */
diff --git a/libc/include/stdio.h b/libc/include/stdio.h
index 98ca38a..fd10923 100644
--- a/libc/include/stdio.h
+++ b/libc/include/stdio.h
@@ -56,7 +56,7 @@ struct __stdio_file {
#define EOF (-1)
#ifndef NULL
-#define NULL (0)
+#define NULL ((void*)0)
#endif
typedef struct __stdio_file FILE;
diff --git a/libc/include/utmp.h b/libc/include/utmp.h
index 9fe0e87..baf6f9e 100644
--- a/libc/include/utmp.h
+++ b/libc/include/utmp.h
@@ -39,9 +39,9 @@ struct utmp
extern void setutent __P ((void));
extern void utmpname __P ((__const char *));
extern struct utmp * getutent __P ((void));
-extern struct utmp * getutid __P ((struct utmp *));
-extern struct utmp * getutline __P ((struct utmp *));
-extern struct utmp * pututline __P ((struct utmp *));
+extern struct utmp * getutid __P ((__const struct utmp *));
+extern struct utmp * getutline __P ((__const struct utmp *));
+extern struct utmp * pututline __P ((__const struct utmp *));
extern void endutent __P ((void));
#ifdef __LIBC__
diff --git a/libc/msdos/Makefile b/libc/msdos/Makefile
index 06d999a..0a53679 100644
--- a/libc/msdos/Makefile
+++ b/libc/msdos/Makefile
@@ -11,11 +11,11 @@ AOBJ= \
BSRC=i86.c
BOBJ= __seg_regs.o __peek_es.o __poke_es.o __deek_es.o __doke_es.o \
- __strnget_es.o __strchr_es.o __strlen_es.o
+ __strnget_es.o __strchr_es.o __strlen_es.o int86.o int86x.o segread.o
ifeq ($(LIB_CPU),i86)
ifeq ($(LIB_OS),DOS)
-OBJ=$(AOBJ) $(BOBJ) time.o
+OBJ=$(AOBJ) $(BOBJ) time.o sound.o
else
OBJ=$(BOBJ)
endif
diff --git a/libc/msdos/TODO b/libc/msdos/TODO
index f2664a2..c9f57e1 100644
--- a/libc/msdos/TODO
+++ b/libc/msdos/TODO
@@ -1,3 +1,11 @@
#define remove(x) unlink(x)
+opendir
+
+closedir
+
+readdir
+
+rewinddir
+
See also the other files, many parts are incomplete.
diff --git a/libc/msdos/conio.c b/libc/msdos/conio.c
index 1abfa40..f6f9105 100644
--- a/libc/msdos/conio.c
+++ b/libc/msdos/conio.c
@@ -1,4 +1,12 @@
-/* Is this BIOS keyboard io ? */
+/* Copyright (C) 1999 Robert de Bath <rdebath@cix.compulink.co.uk>
+ * This file is part of the Linux-8086 C library and is distributed
+ * under the GNU Library General Public License.
+ */
+
+/*
+ * I'm not sure if these should be BIOS or dos calls, so I'll assume they're
+ * BIOS calls but I may have to do something about Ctrl-C.
+ */
getch()
{
@@ -50,6 +58,8 @@ char * str;
while(*str) putch(*str++);
}
+#if 0
+
cgets()
{
}
@@ -70,4 +80,4 @@ gotoxy()
{
}
-
+#endif
diff --git a/libc/msdos/dirent.c b/libc/msdos/dirent.c
deleted file mode 100644
index 00d774e..0000000
--- a/libc/msdos/dirent.c
+++ /dev/null
@@ -1,8 +0,0 @@
-
-opendir
-
-closedir
-
-readdir
-
-rewinddir
diff --git a/libc/msdos/dosound.c b/libc/msdos/dosound.c
deleted file mode 100644
index 80f49d6..0000000
--- a/libc/msdos/dosound.c
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
-nosound()
-{
-}
-
-sound(freq)
-int freq
-{
-}
diff --git a/libc/msdos/i86.c b/libc/msdos/i86.c
index 6c613b2..3cab105 100644
--- a/libc/msdos/i86.c
+++ b/libc/msdos/i86.c
@@ -218,4 +218,181 @@ char * str;
}
#endif
+#ifdef L_int86
+int
+int86(intr, in_regs, out_regs)
+int intr;
+union REGS* in_regs;
+union REGS* out_regs;
+{
+#asm
+ push bp
+ mov bp,sp
+ push ds ! save ds
+ ! es too ?
+ push bp ! same for new bp
+
+ pushf ! iret flags
+ mov ax,[bp-6] ! flags for simulated int
+ push cs ! iret address segment
+ mov bx,#ret_addr ! iret address offset
+ push bx
+ and ah,#$0C ! simulate interrupt flags
+ push ax ! flags are pushed first
+
+ xor bx,bx
+ mov es,bx ! interrupt vectors in seg 0
+ mov bl,[bp+4]
+ shl bx,#1
+ shl bx,#1 ! intr*4 => interrupt vector address
+ seg es
+ push [bx+2] ! fetch interrupt segment
+ seg es
+ push [bx] ! fetch interrupt offset
+ mov bx,[bp+6] ! input union REGS*
+
+ mov ax,[bx]
+ mov cx,[bx+4]
+ mov dx,[bx+6]
+ mov si,[bx+8]
+ mov di,[bx+10]
+ mov bx,[bx+2]
+ ! Ignore cflag/flags ?
+
+ iret ! simulate interrupt.
+ ! But won't be nice for protected mode ...
+ret_addr:
+ ! Int $25/6 would need resetting sp:ss too ... should I ?
+
+ pop bp ! unzapped versions
+ pop ds ! paranoia
+
+ pushf ! save interrupt flags
+ push bx ! save pointer register
+ mov bx,[bp+8] ! output union REGS*
+
+ mov [bx],ax
+ pop [bx+2]
+ mov [bx+4],cx
+ mov [bx+6],dx
+ mov [bx+8],si
+ mov [bx+10],di
+ mov word [bx+12],#0 ! cflag
+ jnc no_carry
+ mov byte [bx+12],#1
+no_carry:
+ pop [bx+14] ! flags
+
+ pop bp
+#endasm
+}
+
+#endif
+
+#ifdef L_int86x
+int
+int86x(intr, in_regs, out_regs, segr)
+int intr;
+union REGS* in_regs;
+union REGS* out_regs;
+struct SREGS * segr;
+{
+#asm
+ push bp
+ mov bp,sp
+ push ds ! save ds
+ ! es too ?
+ push bp ! same for new bp
+
+ pushf ! iret flags
+ mov ax,[bp-6] ! flags for simulated int
+ push cs ! iret address segment
+ mov bx,#ret_addr ! iret address offset
+ push bx
+ and ah,#$0C ! simulate interrupt flags
+ push ax ! flags are pushed first
+
+ xor bx,bx
+ mov es,bx ! interrupt vectors in seg 0
+ mov bl,[bp+4]
+ shl bx,1
+ shl bx,1 ! intr*4 => interrupt vector address
+ seg es
+ push word [bx+2] ! fetch interrupt segment
+ seg es
+ push word [bx] ! fetch interrupt offset
+
+ mov bx,[bp+10] ! struct SREGS*
+ mov es,[bx]
+ push [bx+6] ! ds
+
+ mov bx,[bp+6] ! input union REGS*
+
+ mov ax,[bx]
+ mov cx,[bx+4]
+ mov dx,[bx+6]
+ mov si,[bx+8]
+ mov di,[bx+10]
+ mov bx,[bx+2]
+ ! Ignore cflag/flags ?
+
+ pop ds
+
+ iret ! simulate interrupt
+ ! But won't be nice for protected mode ...
+
+ret_addr:
+ ! Int $25/6 would need resetting sp:ss too ... should I ?
+
+ pop bp ! in case it was zapped
+
+ pushf ! save interrupt flags
+
+ push cx ! save work register
+ mov cx,ds
+ push bx ! save pointer register
+
+ mov ds,word [bp-2] ! restore original ds
+ mov bx,[bp+10] ! struct SREGS*
+ mov [bx],es
+ mov [bx+6],cx
+
+ mov bx,[bp+8] ! output union REGS*
+ mov [bx],ax
+ pop [bx+2] ! bx
+ pop [bx+4] ! cx
+ mov [bx+6],dx
+ mov [bx+8],si
+ mov [bx+10],di
+ mov word [bx+12],#0 ! cflag
+ jnc no_carry
+ mov byte [bx+12],#1
+no_carry:
+ pop [bx+14] ! flags
+
+ pop ds
+ pop bp
+#endasm
+}
+#endif
+
+#ifdef L_segread
+segread(segp)
+struct SREGS * segp;
+{
+#asm
+#if __FIRST_ARG_IN_AX__
+ mov bx,ax
+#else
+ mov bx,sp
+ mov bx,[bx+2]
+#endif
+ mov [bx],es
+ mov [bx+2],cs
+ mov [bx+4],ss
+ mov [bx+6],ds
+#endasm
+}
+#endif
+
#endif /* __AS386_16__ */
diff --git a/libc/msdos/intr.c b/libc/msdos/intr.c
new file mode 100644
index 0000000..22de042
--- /dev/null
+++ b/libc/msdos/intr.c
@@ -0,0 +1,82 @@
+
+struct REGPACK
+{
+ unsigned r_ax, r_bx, r_cx, r_dx;
+ unsigned r_bp, r_si, r_di, r_ds, r_es, r_flags;
+};
+
+/* DANGER DANGER -- Self modifying code! */
+
+#asm
+.text
+save_sp:
+ dw 0
+#endasm
+
+intr(intr, regs)
+int intr;
+struct REGPACK * regs;
+{
+#asm
+ mov bx,sp
+ push bp
+ push si
+ push di
+ push es
+ push ds
+
+ mov ax,[bx+2]
+ seg cs
+ mov [intr_inst+1],al
+ seg cs
+ mov [save_sp],sp
+
+ mov bx,[bx+4]
+
+ mov ah,[bx+18] ! Flags low byte
+ sahf
+
+ mov ax,[bx]
+ push [bx+2]
+ mov cx,[bx+4]
+ mov dx,[bx+6]
+ mov bp,[bx+8]
+ mov si,[bx+10]
+ mov di,[bx+12]
+ mov es,[bx+16]
+ mov ds,[bx+14]
+ pop bx
+
+intr_inst:
+ int $FF ! Must be a real int .. consider protected mode.
+
+ seg cs ! Could be SS as DS==SS
+ mov sp,[save_sp]
+ seg cs
+ mov [save_sp],ds
+ pop ds
+ push [save_sp]
+
+ push bx
+ mov bx,sp
+ mov bx,[bx+12]
+
+ mov [bx],ax
+ pop [bx+2]
+ mov [bx+4],cx
+ mov [bx+6],dx
+ mov [bx+8],bp
+ mov [bx+10],si
+ mov [bx+12],di
+ pop [bx+14]
+ mov [bx+16],es
+ pushf
+ pop [bx+18]
+
+ pop es
+ pop di
+ pop si
+ pop bp
+
+#endasm
+}
diff --git a/libc/msdos/msdos.c b/libc/msdos/msdos.c
index 77100ae..ae10b39 100644
--- a/libc/msdos/msdos.c
+++ b/libc/msdos/msdos.c
@@ -180,7 +180,7 @@ int __argc;
char ** __argv;
{
int length, i, argc=1, s=0;
- char *ptr, *p;
+ unsigned char *ptr, *p;
__set_es(__psp); /* Pointer to the args */
length = __peek_es(0x80); /* Length of cmd line */
if( length > 0 )
@@ -190,25 +190,25 @@ char ** __argv;
for(i=0; i<length; i++) /* Copy it in. */
{
ptr[i] = __peek_es(0x81+i);
-/* Replaced because freedos adds \r to args.
- if( ptr[i] != ' ' && s == 0 ) { argc++; s=1; }
- if( ptr[i] == ' ' && s == 1 ) s=0;
- */
- if( (ptr[i]&0xE0) != 0 && s == 0 ) { argc++; s=1; }
- if( (ptr[i]&0xE0) == 0 && s == 1 ) s=0;
+ if( ptr[i] > ' ' && s == 0 ) { argc++; s=1; }
+ if( ptr[i] <= ' ' && s == 1 ) s=0;
}
ptr[length]=0;
p= __argv[0];
__argv = (char**) sbrk((argc+1)*sizeof(char*));
- __argv[0] = p; /* FIXME: The real command can be found */
+ __argv[0] = p; /* TODO: The real command can be found */
__argc=argc;
+ /*
+ * TODO: This needs to understand quoting and wildcards
+ */
+
argc=1; s=0;
for(i=0; i<length; i++)
{
- if( ptr[i] != ' ' && s == 0 ) { __argv[argc++] = ptr+i; s=1; }
- if( ptr[i] == ' ' && s == 1 ) { ptr[i] = '\0'; s=0; }
+ if( ptr[i] > ' ' && s == 0 ) { __argv[argc++] = ptr+i; s=1; }
+ if( ptr[i] <= ' ' && s == 1 ) { ptr[i] = '\0'; s=0; }
}
__argv[argc] = 0;
}
@@ -233,7 +233,10 @@ int __argc;
char ** __argv;
char ** __envp;
{
- /* FIXME !!! */
+ /* FIXME !!!
+ *
+ * Note must write to __envp argument but not touch __argv or __argc
+ */
}
#endif
@@ -383,6 +386,19 @@ int cmode;
int creat_mode = 0;
int rv;
+static int xlate_mode[] = {
+#ifdef OPEN_LIKE_UNIX
+ O_RDONLY|O_DENYNONE,
+ O_WRONLY|O_DENYNONE,
+ O_RDWR|O_DENYNONE,
+#else
+ O_RDONLY|O_DENYNONE,
+ O_WRONLY|O_DENYWRITE,
+ O_RDWR|O_DENYALL,
+#endif
+ 3
+};
+
if( (cmode & 0222) == 0 ) creat_mode = 1;
/* BzzzT. Assume these flags both mean the merge of them */
@@ -391,8 +407,13 @@ int cmode;
rv = __dos_creat(nname, creat_mode);
else
- /* Warn, this assumes the standard vals for O_RDWR, O_RDONLY, O_WRONLY */
- rv = __dos_open(nname, type&O_ACCMODE);
+ {
+ /* If we would open in compatibility mode make it a little more unixy */
+ if( type & O_DENYMODE )
+ rv = __dos_open(nname, type&(O_ACCMODE|O_DENYMODE|O_SETFD));
+ else
+ rv = __dos_open(nname, xlate_mode[type&O_ACCMODE]);
+ }
return rv;
}
diff --git a/libc/msdos/mslib.c b/libc/msdos/mslib.c
index c1dfb30..90e23ef 100644
--- a/libc/msdos/mslib.c
+++ b/libc/msdos/mslib.c
@@ -79,6 +79,44 @@ char * path;
}
#endif
+/*************************************************************************
+ TO TEST ...
+*/
+
+#ifdef L_sleep
+sleep(secs)
+unsigned secs;
+{
+ int counter = 0;
+ int es = __get_es();
+
+ __set_es(0x40);
+
+ while(secs>0)
+ {
+ int c = __peek_es(0x6C);
+ while( c == __peek_es(0x6C) ) ;
+
+ counter += 549;
+ if( counter > 10000 )
+ {
+ secs--;
+ counter -= 10000;
+ }
+
+ /* Interrupt on ctrl-break */
+ if( __peek_es(0x71) & 0x80 ) break;
+ }
+ __set_es(es);
+
+ return secs;
+}
+#endif
+
+/*************************************************************************
+ TODO ...
+*/
+
#ifdef L_dos_access
access(filename, amode)
char * filename;
@@ -89,7 +127,8 @@ int amode;
#endif
#ifdef L__dos_allocmem
-_dos_allocmem(size
+_dos_allocmem(size ...)
+{
}
#endif
@@ -263,14 +302,6 @@ getpid()
}
#endif
-#ifdef L_int86
- XXX;
-#endif
-
-#ifdef L_int86x
- XXX;
-#endif
-
#ifdef L_rename
rename(oldname, newpath)
char *oldpath, *newpath;
@@ -279,14 +310,6 @@ char *oldpath, *newpath;
}
#endif
-#ifdef L_segread
-segread(segp)
-struct SREGS * segp;
-{
- XXX;
-}
-#endif
-
#ifdef L_setmode
setmode(fd, amode)
int fd, amode;
@@ -295,13 +318,6 @@ int fd, amode;
}
#endif
-#ifdef L_sleep
-sleep(secs)
-unsigned secs;
-{
- XXX;
-}
-#endif
#ifdef L_system
system(cmd)
@@ -316,6 +332,9 @@ umask(mode)
int mode;
{
XXX;
+ /*
+ * save umask value for open() use it for read-only bit.
+ */
}
#endif
diff --git a/libc/msdos/new86.c b/libc/msdos/new86.c
index cc139bb..1c1e218 100644
--- a/libc/msdos/new86.c
+++ b/libc/msdos/new86.c
@@ -31,11 +31,11 @@ int portno;
{
}
-outp(
+outp(...)
{
}
-outpw(
+outpw(...)
{
}
@@ -58,12 +58,3 @@ pokeb(segment, offset, value)
unsigned segment, offset, value;
{
}
-
-
-
-
-
-
-
-
-
diff --git a/libc/msdos/sound.c b/libc/msdos/sound.c
new file mode 100644
index 0000000..90c474c
--- /dev/null
+++ b/libc/msdos/sound.c
@@ -0,0 +1,27 @@
+
+#include <bios.h>
+
+static int port_val = -1;
+
+sound(freq)
+unsigned freq; /* freq is in hertz */
+{
+ if(port_val == -1 )
+ port_val = inp(0x61);
+
+ freq = 1193180L / freq;
+
+ outp(0x61, port_val|3);
+ outp(0x43, 0xb6);
+ outp(0x42, freq&0xFF);
+ outp(0x42, (freq>>8)&0xFF);
+}
+
+nosound()
+{
+ if( port_val )
+ outp(0x61, port_val);
+ else
+ outp(0x61, inp(0x61)&~3);
+}
+
diff --git a/libc/msdos/time.c b/libc/msdos/time.c
index 271ea05..7f7b183 100644
--- a/libc/msdos/time.c
+++ b/libc/msdos/time.c
@@ -53,9 +53,10 @@ time_t *timer;
rv >>= 8; year = (rv & 0xFFFF) - 1970;
if (month <= 1 || year & 3) /* if before Feb or not a leap year */
- day--; /* don't add day for leap year */
+ day--; /* don't add day for this leap year */
day += mdays[month]; /* day in year */
- day += (year + 3) >> 2; /* add a day for each leap year */
+ day += (year + 3) >> 2; /* add a day for each leap year, but */
+ /* don't worry about 2100 */
t += ((year * 365L) + day) * SECSPERDAY;
if (timer)
*timer = t;
diff --git a/libc/stdio2/stdio.c b/libc/stdio2/stdio.c
index c317859..6b0dba0 100644
--- a/libc/stdio2/stdio.c
+++ b/libc/stdio2/stdio.c
@@ -675,6 +675,11 @@ char *mode;
{
if (nfp)
free(nfp);
+ if (fp)
+ {
+ fp->mode |= fopen_mode;
+ fclose(fp); /* Deallocate if required */
+ }
return 0;
}
@@ -730,12 +735,15 @@ FILE *fp;
errno = EINVAL;
return EOF;
}
- if (fflush(fp))
- return EOF;
+ if (fp->fd != -1)
+ {
+ if (fflush(fp))
+ return EOF;
- if (close(fp->fd))
- rv = EOF;
- fp->fd = -1;
+ if (close(fp->fd))
+ rv = EOF;
+ fp->fd = -1;
+ }
if (fp->mode & __MODE_FREEBUF)
{
diff --git a/libc/stdio2/stdio.h b/libc/stdio2/stdio.h
index 98ca38a..fd10923 100644
--- a/libc/stdio2/stdio.h
+++ b/libc/stdio2/stdio.h
@@ -56,7 +56,7 @@ struct __stdio_file {
#define EOF (-1)
#ifndef NULL
-#define NULL (0)
+#define NULL ((void*)0)
#endif
typedef struct __stdio_file FILE;
diff --git a/libc/string/string.c b/libc/string/string.c
index ffce96c..705ec55 100644
--- a/libc/string/string.c
+++ b/libc/string/string.c
@@ -382,8 +382,9 @@ size_t l;
mov ax,di
#endif
- ; If di is odd mov 1 byte before doing word move
- ; this will speed slightly but
+ ; If di is odd we could mov 1 byte before doing word move
+ ; as this would speed the copy slightly but its probably
+ ; too rare to be worthwhile.
; NB 8086 has no problem with mis-aligned access.
shr cx,#1 ; Do this faster by doing a mov word
@@ -647,8 +648,16 @@ unsigned int srcseg, srcoff, destseg, destoff, len;
mov di,[bp+8]
mov cx,[bp+10]
#endif
+
+ ; Would it me a good idea to normalise the pointers ?
+ ; How about allowing for overlapping moves ?
+
+ shr cx,#1 ; Do this faster by doing a mov word
rep
- movsb
+ movsw
+ adc cx,cx ; Retrieve the leftover 1 bit from cflag.
+ rep
+ movsb
! cli ! Are we _really_ paranoid ?
diff --git a/man/as86.1 b/man/as86.1
index 02d9652..f03ce27 100644
--- a/man/as86.1
+++ b/man/as86.1
@@ -1,5 +1,5 @@
-.TH as86 1 "Oct, 1997"
-.BY Bruce Evans
+.TH as86 1 "Mar, 1999"
+.BY Bruce Evans, Robert de Bath
.nh
.SH NAME
as86 \- Assembler for 8086..80386 processors
@@ -357,36 +357,45 @@ The 'near and 'far' do not allow multi-segment programming, all 'far'
operations are specified explicitly through the use of the instructions:
jmpi, jmpf, callf, retf, etc. The 'Near' operator can be used to force
the use of 80386 16bit conditional branches. The 'Dword' and 'word'
-operators can control the size of operands on far jumps and calls.
-
+operators can control the size of operands on far jumps and calls.
.TP
General instructions.
These are in general the same as the instructions found in any 8086 assembler,
the main exceptions being a few 'Bcc' (BCC, BNE, BGE, etc) instructions
-which are shorthands for a short branch plus a long jump.
-.sp
-AAA AAD AAM AAS ADC ADD AND ARPL BCC BCS BEQ BGE BGT BHI BHIS BLE BLO
-BLOS BLT BMI BNE BOUND BPC BPL BPS BR BVC BVS CALL CALLF CALLI CBW CLC
-CLD CLI CMC CMP CMPS CMPSB CMPSD CMPSW CMPW CSEG CWD CWDE CDQ DAA DAS
-DSEG DEC DIV ENTER ESEG FSEG GSEG HLT IDIV IMUL IN INC INS INSB INSD
-INSW INT INTO INW IRET IRETD J JA JAE JB JBE JC JCXE JCXZ JECXE JECXZ JE
-JG JGE JL JLE JMP JMPF JMPI JNA JNAE JNB JNBE JNC JNE JNG JNGE JNL JNLE
-JNO JNP JNS JNZ JO JP JPE JPO JS JZ LAHF LDS LEA LEAVE LES LOCK LODB
-LODS LODSB LODSD LODSW LODW LOOP LOOPE LOOPNE LOOPNZ LOOPZ MOV MOVS
-MOVSB MOVSD MOVSW MOVW MUL NEG NOP NOT OR OUT OUTS OUTSB OUTSD OUTSW
-OUTW POP POPA POPAD POPF POPFD PUSH PUSHA PUSHAD PUSHF PUSHFD RCL RCR
-ROL ROR REP REPE REPNE REPNZ REPZ RET RETF RETI SAHF SAL SAR SBB SCAB
-SCAS SCASB SCASD SCASW SCAW SEG SHL SHR SSEG STC STD STI STOB STOS STOSB
-STOSD STOSW STOW SUB TEST WAIT XCHG XLAT XLATB XOR
-.TP
-And more...
-BSF BSR BSWAP BT BTC BTR BTS CLTS CMPXCHG INVD INVLPG LAR LFS LGDT LGS
-LIDT LLDT LMSW LSL LSS LTR MOVSX MOVZX SETA SETAE SETB SETBE SETC SETE
-SETG SETGE SETL SETLE SETNA SETNAE SETNB SETNBE SETNC SETNE SETNG SETNGE
-SETNL SETNLE SETNO SETNP SETNS SETNZ SETO SETP SETPE SETPO SETS SETZ
-SGDT SIDT SHLD SHRD SLDT SMSW STR VERR VERW WBINVD XADD ADCB ADDB ANDB
-CMPB DECB DIVB IDIVB IMULB INB INCB MOVB MULB NEGB NOTB ORB OUTB RCLB
-RCRB ROLB RORB SALB SARB SHLB SHRB SBBB SUBB TESTB XCHGB XORB
+which are shorthands for a short branch plus a long jump and 'BR' which
+is the longest unconditional jump (16 or 32 bit).
+.TP
+Long branches
+BCC BCS BEQ BGE BGT BHI BHIS BLE BLO BLOS BLT BMI BNE BPC BPL BPS BVC BVS
+BR
+.TP
+Intersegment
+CALLI CALLF JMPI JMPF
+.TP
+Segment modifier instructions
+ESEG FSEG GSEG SSEG
+.TP
+Byte operation instructions
+ADCB ADDB ANDB CMPB DECB DIVB IDIVB IMULB INB INCB MOVB MULB NEGB NOTB ORB
+OUTB RCLB RCRB ROLB RORB SALB SARB SHLB SHRB SBBB SUBB TESTB XCHGB XORB
+.TP
+Standard instructions
+AAA AAD AAM AAS ADC ADD AND ARPL BOUND BSF BSR BSWAP BT BTC BTR BTS CALL
+CBW CDQ CLC CLD CLI CLTS CMC CMP CMPS CMPSB CMPSD CMPSW CMPW CMPXCHG
+CSEG CWD CWDE DAA DAS DEC DIV DSEG ENTER HLT IDIV IMUL IN INC INS INSB
+INSD INSW INT INTO INVD INVLPG INW IRET IRETD J JA JAE JB JBE JC JCXE
+JCXZ JE JECXE JECXZ JG JGE JL JLE JMP JNA JNAE JNB JNBE JNC JNE JNG JNGE
+JNL JNLE JNO JNP JNS JNZ JO JP JPE JPO JS JZ LAHF LAR LDS LEA LEAVE LES
+LFS LGDT LGS LIDT LLDT LMSW LOCK LODB LODS LODSB LODSD LODSW LODW LOOP
+LOOPE LOOPNE LOOPNZ LOOPZ LSL LSS LTR MOV MOVS MOVSB MOVSD MOVSW MOVSX
+MOVW MOVZX MUL NEG NOP NOT OR OUT OUTS OUTSB OUTSD OUTSW OUTW POP POPA
+POPAD POPF POPFD PUSH PUSHA PUSHAD PUSHF PUSHFD RCL RCR REP REPE REPNE
+REPNZ REPZ RET RETF RETI ROL ROR SAHF SAL SAR SBB SCAB SCAS SCASB SCASD
+SCASW SCAW SEG SETA SETAE SETB SETBE SETC SETE SETG SETGE SETL SETLE
+SETNA SETNAE SETNB SETNBE SETNC SETNE SETNG SETNGE SETNL SETNLE SETNO
+SETNP SETNS SETNZ SETO SETP SETPE SETPO SETS SETZ SGDT SHL SHLD SHR SHRD
+SIDT SLDT SMSW STC STD STI STOB STOS STOSB STOSD STOSW STOW STR SUB TEST
+VERR VERW WAIT WBINVD XADD XCHG XLAT XLATB XOR
.TP
Floating point
F2XM1 FABS FADD FADDP FBLD FBSTP FCHS FCLEX FCOM FCOMP FCOMPP FCOS
diff --git a/man/bcc.1 b/man/bcc.1
index 5e7d85f..1050cc9 100644
--- a/man/bcc.1
+++ b/man/bcc.1
@@ -36,7 +36,7 @@ from the source file.
.TP
.B -ansi
Pass the C source through
-.B unprotoize(1)
+.B unprotoize
after preprocessing and before code generation. This will allow
.I some
ansi C to be compiled but it is definitly
@@ -112,6 +112,9 @@ to produce standalone Linux-86 executables
.TP
.B -Ml
switches to i386-Linux code generator and library.
+This configuration accepts the
+.B -z
+flag to generate QMAGIC a.out files instead of the normal OMAGIC.
.TP
.B -N
makes the linker produce a native a.out file (Linux OMAGIC) if combined
@@ -340,12 +343,8 @@ and
are in /usr/bin.
.SH SEE ALSO
-unprotoize(1), as86(1), ld86(1), elksemu(1)
+as86(1), ld86(1), elksemu(1)
.SH BUGS
-The compiler cannot generate 8086 floating point code, if it's made to
-try it produces a nasty mixture of 8086 and 80386 code that really
-upsets the assembler.
-
The bcc.c compiler driver source is very untidy.
The linker, ld86, produces a broken a.out object file if given one input and
diff --git a/man/index.bt b/man/index.bt
deleted file mode 100644
index e295941..0000000
--- a/man/index.bt
+++ /dev/null
Binary files differ
diff --git a/man/ld86.1 b/man/ld86.1
index 77953a8..8ca5362 100644
--- a/man/ld86.1
+++ b/man/ld86.1
@@ -5,7 +5,7 @@
ld86 \- Linker for as86(1)
.SH SYNOPSIS
.BR ld86
-.RB [ -03MNdimrstz [-]]
+.RB [ -03MNdimrstyz [-]]
.RB [ -llib_extension ]
.RB [ -o\ outfile ]
.RB [ -Ccrtfile ]
@@ -59,7 +59,9 @@ print symbols linked on stdout
.TP
.B -N
Create a native Linux OMAGIC output file. If the contents are i386 code the
-binary can be either linked by GCC or executed by linux.
+binary can be either linked by GCC or executed by linux. If the
+.B -z
+option is also included the linker can generate a QMAGIC executable.
.TP
.B -Ox
add library libdir-from-search/x to list of files linked
@@ -90,8 +92,12 @@ if possible.
.B -t
trace modules being looked at on stdout
.TP
+.B -y
+Alter the symbol tables to add label 'extensions' so that labels with
+more than 8 characters can be stored in elks executables.
+.TP
.B -z
-produce "unmapped zero page" executables
+produce "unmapped zero page" or "QMAGIC" executables
.P
All the options not taking an argument may be turned off by following the
option letter by a '-', as for cc1.
diff --git a/tests/env.c b/tests/env.c
index c904969..3dc57f7 100644
--- a/tests/env.c
+++ b/tests/env.c
@@ -34,6 +34,8 @@ char ** envp;
p = (char*) &argc;
putstr("ARGC="); phex(argc); putstr("\n");
+ putstr("ARGV="); phex(argv); putstr("\n");
+ putstr("ENVP="); phex(envp); putstr("\n");
for(i=0; i<argc; i++)
{
phex(argv[i]);
diff --git a/tests/xx b/tests/xx
deleted file mode 100644
index 5451b81..0000000
--- a/tests/xx
+++ /dev/null
@@ -1,27 +0,0 @@
-# Reconstructed via infocmp from file: /etc/terminfo/x/xterm
-xterm|xterm with color support,
- am, km, mir, msgr, xenl, xon,
- colors#8, cols#80, it#8, lines#65, ncv#3, pairs#64,
- acsc=``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~..--++\,\,II00,
- bel=^G, bold=\E[1m, clear=\E[H\E[2J, cr=^M,
- csr=\E[%i%p1%d;%p2%dr, cub=\E[%p1%dD, cub1=^H,
- cud=\E[%p1%dB, cud1=^J, cuf=\E[%p1%dC, cuf1=\E[C,
- cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\E[A,
- dch=\E[%p1%dP, dch1=\E[P, dl=\E[%p1%dM, dl1=\E[M, ed=\E[J,
- el=\E[K, enacs=\E(B\E)0, home=\E[H, ht=^I, ich=\E[%p1%d@,
- ich1=\E[@, il=\E[%p1%dL, il1=\E[L, ind=^J,
- is2=\E[r\E[m\E[2J\E[H\E[?7h\E[?1;3;4;6l\E[4l, kbs=^H,
- kcub1=\EOD, kcud1=\EOB, kcuf1=\EOC, kcuu1=\EOA, kend=\EOe,
- kent=\EOM, kf1=\EOP, kf10=\E[21~, kf11=\E[23~, kf12=\E[24~,
- kf2=\EOQ, kf3=\EOR, kf4=\EOS, kf5=\E[15~, kf6=\E[17~,
- kf7=\E[18~, kf8=\E[19~, kf9=\E[20~, khome=\EO\200,
- kich1=\E[2~, kmous=\E[M, knp=\E[6~, kpp=\E[5~,
- op=\E[49;39m, rc=\E8, rev=\E[7m, ri=\EM, rmacs=^O,
- rmam=\E[?7l, rmcup=\E[2J\E[?47l\E8, rmir=\E[4l,
- rmkx=\E[?1l\E>, rmso=\E[m, rmul=\E[m, rs1=^O,
- rs2=\E[r\E[m\E[2J\E[H\E[?7h\E[?1;3;4;6l\E[4l\E<,
- sc=\E7, setab=\E[4%p1%dm, setaf=\E[3%p1%dm,
- setb=\E[%p1%{40}%+%dm, setf=\E[%p1%{30}%+%dm,
- sgr0=\E[m, smacs=^N, smam=\E[?7h, smcup=\E7\E[?47h,
- smir=\E[4h, smkx=\E[?1h\E=, smso=\E[7m, smul=\E[4m,
- tbc=\E[3k, u6=\E[%i%d;%dR, u7=\E[6n, u8=\E[?1;2c, u9=\E[c,