summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert de Bath <rdebath@poboxes.com>2003-07-31 21:29:34 +0200
committerLubomir Rintel <lkundrak@v3.sk>2013-10-23 23:48:49 +0200
commit5613ba3c0749fa494d35c4dc36b57c5b4e6edb55 (patch)
tree501d9fdeed78d55ee8464338fab230f628382018
parentded00c0d1c0dc38e63b2c48ff8cbb12c1b60c70f (diff)
downloaddev86-5613ba3c0749fa494d35c4dc36b57c5b4e6edb55.tar.gz
Import Dev86src-0.16.12.tar.gzv0.16.12
-rw-r--r--Changes17
-rw-r--r--Makefile2
-rw-r--r--bcc/proto.h2
-rw-r--r--bootblocks/Makefile43
-rw-r--r--bootblocks/README19
-rw-r--r--bootblocks/bb_init1.s4
-rw-r--r--bootblocks/boot_win.c286
-rw-r--r--bootblocks/bzimage.c209
-rw-r--r--bootblocks/i86_funcs.c44
-rw-r--r--bootblocks/killhd.s36
-rw-r--r--bootblocks/makeboot.c59
-rw-r--r--bootblocks/mbr.s301
-rw-r--r--bootblocks/monitor.c20
-rw-r--r--bootblocks/monitor.h2
-rw-r--r--bootblocks/msdos.s11
-rw-r--r--bootblocks/relocate.c12
-rw-r--r--bootblocks/unix.c12
-rw-r--r--ld/writex86.c2
-rw-r--r--libc/bios/Makefile4
-rw-r--r--libc/bios/bios.c13
-rw-r--r--libc/error/Makefile7
-rw-r--r--libc/include/assert.h2
22 files changed, 784 insertions, 323 deletions
diff --git a/Changes b/Changes
index faabcdd..ba73fba 100644
--- a/Changes
+++ b/Changes
@@ -3,6 +3,7 @@ For version 0.16.*.
> Hitting bcc.c again, bcc-cpp now the default.
> Some bugfixes for DEC Alpha -- 64 bit longs!
+ Constant folding still done with 64bit longs though.
> The fopen function (and friends) is now a real function not a macro.
@@ -24,16 +25,14 @@ For version 0.16.*.
> Conditional assembler added around push and pop of 'si' and 'di' if the
optimiser (and as86's optimiser) are to be run.
-> Signed keyward added to bcc-cc1 for 'signed char' also words with other
+> Signed keyword added to bcc-cc1 for 'signed char' also works with other
int types but is usually just a noiseword.
-> As86 macro syntax altered, you new don't have to include any brackets.
-
-> Various test and old document files removed.
+> As86 macro syntax altered, you now don't have to include any brackets.
> Gcc warnings in ar86 cleaned up.
-> Mk_dist now make incremental patch files too.
+> Mk_dist now makes incremental patch files too.
> Update magic file.
@@ -43,13 +42,13 @@ For version 0.16.*.
> Added -v (version)
-> as86 and ld86 now delete thier binary outputs if there were errors.
+> as86 and ld86 now delete their binary outputs if there were errors.
> Added more 'set' commands generated by '#asm' lines. The new ones begin
with '.' rather than '_' an are based off the 'bp' register rather than
the 'sp' register.
-> General clean out of some files that are no longer needed.
+> Various unused, test and old document files removed.
> as86 modified to use normal malloc routines - no longer has limited
input file size.
@@ -144,7 +143,7 @@ For version 0.15.0.
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
+ Added two compile 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
@@ -196,7 +195,7 @@ For version 0.14.0.
> Added -x option to bcc to prevent it linking in crt0.o.
> Added various improvemnts to the optimiser, I don't think it'll generate
- illegal code now for "-O", "-O1", or "-Oi". the last inlines the functions
+ illegal code now for "-O", "-O1", or "-Oi". The last inlines the functions
__get_es(), __seg_es(), __poke_es(), __peek_es() etc.
> Code generator improvement for integer multiply and shifts. (Including
diff --git a/Makefile b/Makefile
index af6625e..175bfb2 100644
--- a/Makefile
+++ b/Makefile
@@ -2,7 +2,7 @@
# This file is part of the Linux-8086 Development environment and is
# distributed under the GNU General Public License.
-VERSION=0.16.11
+VERSION=0.16.12
TARGETS= \
clean bcc unproto copt as86 ld86 elksemu \
diff --git a/bcc/proto.h b/bcc/proto.h
index 36d5bdc..f1055d7 100644
--- a/bcc/proto.h
+++ b/bcc/proto.h
@@ -276,8 +276,10 @@ void outshex P((offset_T num));
void outstr P((char *s));
void outtab P((void));
void outudec P((unsigned num));
+#ifndef I8088
void outuvalue P((uvalue_t num));
void outvalue P((value_t num));
+#endif
char *pushudec P((char *s, unsigned num));
void setoutbufs P((void));
diff --git a/bootblocks/Makefile b/bootblocks/Makefile
index 9a97468..9622817 100644
--- a/bootblocks/Makefile
+++ b/bootblocks/Makefile
@@ -6,17 +6,18 @@ AS86=as86
DEFS=
CC=$(BCC)
-CFLAGS=-ansi -Ms -Oi -O -s $(DEFS)
-# CFLAGS=-ansi -Ms -s $(DEFS)
+CFLAGS=-ansi -Ms -Oi -O $(DEFS)
+LDFLAGS=-s -i -H0x10000
ASFLAGS=-0 -w
MINIXDEFS=-DDOTS
+# CFLAGS=-ansi -Ms $(DEFS)
# LST=-l $*.lst
-default: makeboot makeboot.com monitor.out minix_elks.bin lsys.com
+default: makeboot makeboot.com monitor.sys minix_elks.bin lsys.com
all: bootbin bootsys default tgz
-bootsys: bootfile.sys boottar.sys bootminix.sys monitor.sys
+bootsys: bootfile.sys boottar.sys bootminix.sys monitor.sys boot_win.sys
CSRC=minix.c
SSRC=sysboot.s tarboot.s skip.s mbr.s msdos.s noboot.s \
@@ -34,46 +35,46 @@ MINC=i86_funcs.h readfs.h monitor.h
BOOTBLOCKS=sysboot.v noboot.v skip.v msdos.v msdos16.v \
tarboot.v minix.v minixhd.v mbr.v killhd.v
-EXTRAS=minix.h zimage.s minix_elks.c lsys.c
+EXTRAS=minix.h zimage.s minix_elks.c lsys.c boot_win.c
install:
monitor.com: $(MOBJ)
- $(CC) $(CFLAGS) $(MONDEFS) -H0x10000 -d $(MOBJ) -o monitor.com -M > monitor.sym
+ $(CC) $(CFLAGS) $(LDFLAGS) $(MONDEFS) -d $(MOBJ) -o monitor.com -M > monitor.sym
monitor.out: $(MOBJ)
- $(CC) $(CFLAGS) $(MONDEFS) -H0x10000 $(MOBJ) -o monitor.out -M > monitor.sym
+ $(CC) $(CFLAGS) $(LDFLAGS) $(MONDEFS) $(MOBJ) -o monitor.out -M > monitor.sym
$(MOBJ): $(MINC)
fs_min.o: minix.h
bootfile.sys: $(MSRC) $(MINC)
@rm -f $(MOBJ)
- make 'CFLAGS=$(CFLAGS) -i -DDOSFLOPPY -d' monitor.out
+ make 'CFLAGS=$(CFLAGS) -DDOSFLOPPY' monitor.out
mv monitor.out bootfile.sys
@rm -f $(MOBJ)
boottar.sys: $(MSRC) $(MINC) tarboot.bin
@rm -f $(MOBJ)
- make 'CFLAGS=$(CFLAGS) -i -DTARFLOPPY' monitor.out
+ make 'CFLAGS=$(CFLAGS) -DTARFLOPPY' monitor.out
mv monitor.out boottar.sys
@rm -f $(MOBJ)
bootminix.sys: $(MSRC) $(MINC) minix.bin
@rm -f $(MOBJ)
- make 'CFLAGS=$(CFLAGS) -i -DMINFLOPPY' monitor.out
+ make 'CFLAGS=$(CFLAGS) -DMINFLOPPY' monitor.out
mv monitor.out bootminix.sys
@rm -f $(MOBJ)
monitor.sys: $(MSRC) $(MINC)
@rm -f $(MOBJ)
- make 'CFLAGS=$(CFLAGS) -DNOMONITOR' monitor.out
+ make monitor.out
mv monitor.out monitor.sys
@rm -f $(MOBJ)
monitor: $(MSRC) $(MINC)
@rm -f $(MOBJ)
- make 'CFLAGS=-ansi -H0x8000' monitor.out
+ make 'CFLAGS=-ansi $(DEFS)' monitor.out
mv monitor.out monitor
@rm -f $(MOBJ)
@@ -91,6 +92,16 @@ minixhd.s: minix.c Makefile
msdos16.s: msdos.s
sed 's/^fatbits=12/fatbits=16/' < msdos.s > msdos16.s
+mbr_dm.s: mbr.s
+ sed -e 's/^diskman=0/diskman=1/' \
+ -e 's/^message=1/message=0/' \
+ -e 's/^mbrkey=1/mbrkey=0/' \
+ -e 's/^preboot=1/preboot=0/' \
+ < mbr.s > mbr_dm.s
+
+boot_win.sys: boot_win.c
+ $(CC) -Ms -H0x6000 -s boot_win.c -o boot_win.sys
+
makeboot: makeboot.c $(BOOTBLOCKS)
$(HOSTCC) $(HOSTCCFLAGS) -o makeboot makeboot.c
@@ -101,13 +112,13 @@ lsys.com: lsys.c msdos.v msdos16.v
$(CC) -Md -O -o lsys.com lsys.c
clean realclean:
- rm -f bootfile.sys boottar.sys bootminix.sys monitor.sys
+ rm -f bootfile.sys boottar.sys bootminix.sys monitor.sys boot_win.sys
rm -f monitor makeboot bootblocks.tar.gz
- rm -f minix.s minixhd.s minix_elks.s msdos16.s
+ rm -f minix.s minixhd.s minix_elks.s msdos16.s mbr_dm.s
rm -f *.com *.o *.bin *.out *.lst *.sym *.v *.tmp
-tgz: minix.bin monitor.out makeboot.com makeboot
- tar cfV bootblocks.tar ENIAC monitor.out \
+tgz: minix.bin monitor.sys makeboot.com makeboot
+ tar cfV bootblocks.tar ENIAC monitor.sys \
README Makefile \
$(MSRC) \
$(MINC) \
diff --git a/bootblocks/README b/bootblocks/README
index 26abd97..21b60b2 100644
--- a/bootblocks/README
+++ b/bootblocks/README
@@ -87,12 +87,12 @@ Contents
bootable floppy image. The boot sector loads and executes the first
item in the tar file after the label:
- $ tar cvfV the_file.tar ENIAC monitor.out item2 item3
+ $ tar cvfV the_file.tar ENIAC monitor.sys item2 item3
$ makeboot tar the_file.tar
$ cp the_file.tar /dev/fd0
This sequence makes a bootable floppy that tar sees as a normal labeled
- tar file but when booted from will load and execute 'monitor.out' at
+ tar file but when booted from will load and execute 'monitor.sys' at
location $00800 (Yes thats 2k!)
Warning: the tar boot sector moves the BPB to the location $666.
@@ -127,12 +127,12 @@ Contents
2.3 ) Booting Linux-i386 [b]zImage
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
+ program 'monitor.sys' must loaded by the boot sector and this can
load a zimage or bzimage from an MSDOS, Minix or Tar floppy. It can
also load the image from a minix hard disk filesystem.
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.
+ 'monitor.sys' 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
disk but can extend across as many floppies as is needed.
@@ -140,15 +140,18 @@ Contents
$ mformat a:
$ makeboot dos /dev/fd0
$ mount -t msdos /dev/fd0 /mnt
- $ cp monitor.out /mnt/bootfile.sys
+ $ cp monitor.sys /mnt/bootfile.sys
$ cp /usr/src/linux/arch/i386/boot/zImage /mnt/vmlinuz
$ echo 'root=/dev/ram ramdisk_file=ramdisk.gz mem=80M' > /mnt/vmlinuz.cfg
$ cp /archive/ramdisk.gz /mnt/ramdisk.gz
$ umount /dev/fd0
- The stuff about ramdisk is only if you want an init ramdisk, if the ramdisk
- name begins with a '+' the program will ask for another disk first.
+ The stuff about ramdisk is only if you want an init ramdisk. If
+ the ramdisk isn't on this floppy monitor.sys will ask for the
+ right floppy. If you specify multiple ramdisk files then will be
+ concatenated and passed to the kernel as one ramdisk, each file
+ can be on a different floppy.
If the file isn't called 'vmlinuz' you can still boot it by typing "=linux"
at the prompt '>' where 'linux' is the name of the bzImage file.
@@ -162,4 +165,4 @@ Contents
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
-Robert de Bath <rdebath@poboxes.com> 31 Dec 1998
+Robert de Bath <robert@mayday.cix.co.uk>
diff --git a/bootblocks/bb_init1.s b/bootblocks/bb_init1.s
index b7e6a6d..41c39cb 100644
--- a/bootblocks/bb_init1.s
+++ b/bootblocks/bb_init1.s
@@ -4,12 +4,13 @@ ORGADDR=0x0600
entry start
public start
start:
+ cld
xor ax,ax
mov si,#$7C00
mov di,#ORGADDR
mov ss,ax
- mov sp,di ! Or ax or si
+ mov sp,si ! ax, di or si
push ax
pop ds
@@ -17,7 +18,6 @@ start:
pop es
mov cx,#256
- cld
rep
movsw
jmpi go,#0
diff --git a/bootblocks/boot_win.c b/bootblocks/boot_win.c
new file mode 100644
index 0000000..6dafdd8
--- /dev/null
+++ b/bootblocks/boot_win.c
@@ -0,0 +1,286 @@
+/*
+ * This program is designed to be put onto an MSDOS filesystem floppy or
+ * a floppy image on a CD-ROM.
+ *
+ * The hexdump at the end is from Windows 95 boot sector and can be used
+ * to start a Windows 9X io.sys.
+ *
+ * This program runs first and if the hard disk appears bootable will load
+ * and start that unless you press return.
+ *
+ * If you press a key you have the option of Zapping the MBR!
+ *
+ */
+
+#include <stdio.h>
+
+#define sysboot_dosfs_stat 0x000B
+#define sysboot_codestart 0x003E
+#define sysboot_bootblock_magic 0x01FE
+
+extern char win95_bb[512];
+char bs_buf[512];
+char buf2[512];
+unsigned memseg, memlen;
+
+fatal(str)
+ char * str;
+{
+ cprintf(str);
+ getch();
+ exit(0);
+}
+
+main()
+{
+ int i, rv;
+
+ reset_screen();
+ cprintf("...\n");
+ relocate();
+ if (__get_cs() != 0x80)
+ fatal("ERROR - program incorrectly compiled.\n");
+
+ for(i=0; i<6; i++)
+ if (!(rv = _bios_disk_read(0x80, 0, 0, 1, 1, bs_buf))) break;
+
+ if (rv != 0 || bs_buf[510] != 0x55 || bs_buf[511] != (char)0xAA) {
+ cprintf("Hard disk not bootable.\n");
+ boot_floppy();
+ }
+
+ for(rv=-1, i=0x1BE; i<0x1FE; i+= 16) {
+ if (bs_buf[i] == (char)0x80)
+ rv = 0;
+ }
+
+ if (rv) {
+ cprintf("Hard disk has no active partition.\n");
+ boot_floppy();
+ }
+
+ cprintf("Press return to skip hard disk boot: ");
+
+ __set_es(0x40);
+ for(i=0; ; i++) {
+ unsigned int tv = __deek_es(0x6c);
+ while (tv == __deek_es(0x6c))
+ if (kbhit()) {
+ getch();
+ cprintf(" Skipping HD.\n");
+ goto break_break;
+ }
+ if (i%10 == 0) cprintf(".");
+
+ if (i>= 18*5) {
+ cprintf(" Booting HD.\n");
+ boot_hd();
+ }
+ }
+break_break:;
+
+ cprintf("Do you want to leave the hard disk intact?\n");
+ cprintf("(Y/n) ");
+ i = (getch() & 0xFF);
+ if (i == 'n' || i == 'N') {
+ cprintf("No\n");
+
+ cprintf("WARNING: This WILL delete everything on the hard disk!\n");
+ cprintf("Do you want to clear the hard disk MBR?\n");
+ cprintf("(N/y) ");
+
+ i = (getch() & 0xFF);
+ if (i == 'y' || i == 'Y') {
+ cprintf("Yes\n");
+ memset(bs_buf, 0, sizeof(bs_buf));
+
+ for(i=0; i<6; i++)
+ if (!(rv = _bios_disk_write(0x80, 0, 0, 1, 1, bs_buf))) break;
+
+ if (rv) {
+ cprintf("Disk error 0x%2x on disk write:", rv);
+ getch();
+ cprintf("\n");
+ } else {
+ cprintf("Hard disk MBR wiped!\n");
+ }
+ } else
+ cprintf("No -- Disk is still untouched\n");
+ } else
+ cprintf("Ok -- Disk is untouched\n");
+
+ boot_floppy();
+}
+
+reset_screen()
+{
+#asm
+ mov ah,#$0F
+ int $10
+ cmp al,#$07
+ je dont_touch
+ mov ax,#$0003
+ int $10
+dont_touch:
+#endasm
+}
+
+boot_floppy()
+{
+ _bios_disk_read(0, 0, 0, 1, 1, bs_buf);
+ make_floppy_bb();
+
+#asm
+ mov ax,#$00
+ push ax
+ pop ds
+ mov bx,#$7c00
+ mov dx,#$0000 ! Of the floppy drive
+ jmpi $7c00,0
+#endasm
+}
+
+boot_hd()
+{
+ int i;
+ /* If we're booting from a CD we want to turn off the floppy emulation */
+ buf2[0] = 0x13; /* Sizeof a 'Specification packet' */
+
+#asm
+ mov ax,#$4B01
+ mov dl,#$7F
+ mov si,#_buf2
+ int $13
+ ! Ignore the return value; it's meaningless if we aren't on a CD
+#endasm
+
+ /* Now boot the hard disk */
+ __set_es(0x07c0);
+ for(i=0; i<512; i++) __poke_es(i, bs_buf[i]);
+
+#asm
+ mov ax,#$00
+ push ax
+ pop ds
+ mov bx,#$7c00
+ mov dx,#$0080 ! Of the hard drive
+ jmpi $7c00,0
+#endasm
+}
+
+make_floppy_bb()
+{
+ int i;
+ __set_es(0x07c0);
+ for(i=0; i<sysboot_dosfs_stat; i++)
+ __poke_es(i, win95_bb[i]);
+ for(i=sysboot_dosfs_stat; i<sysboot_codestart; i++)
+ __poke_es(i, bs_buf[i]);
+ for(i=sysboot_codestart; i<512; i++)
+ __poke_es(i, win95_bb[i]);
+}
+
+relocate()
+{
+#ifdef __STANDALONE__
+ unsigned moved, codelen;
+ unsigned es = __get_es();
+ unsigned newseg;
+
+ /* Where do we start */
+ if(memseg == 0)
+ {
+ extern int _heap_top;
+ memseg = __get_cs();
+ codelen = __get_ds()-memseg;
+ __set_es(memseg-2);
+
+ memlen = (((int)&_heap_top) >> 4);
+
+ /*
+ if (__deek_es(0) == 0x0301 ) memlen = (__deek_es(24) >> 4);
+ */
+
+ if( memlen == 0 ) memlen = 0x1000;
+ memlen += codelen;
+ __set_es(es);
+ }
+
+ newseg = 0x80;
+
+ /* If the old area overlaps the new then fail */
+ if( newseg >= memseg && newseg < memseg+memlen ) return;
+ if( memseg >= newseg && memseg < newseg+memlen ) return;
+
+ /* Copy segments, done in 32k chunks */
+ for(moved=0; moved < memlen; )
+ {
+ unsigned int lump;
+ if( memlen-moved <= 0x800 ) lump = memlen-moved; else lump = 0x800;
+
+ __movedata(memseg+moved, 0, newseg+moved, 0, (lump<<4));
+ moved += lump;
+ }
+
+ /* re-link int 0x80, this one is only an example (used by 'standalone.c') */
+ /* __set_es(0); __doke_es(0x80*4+2, newseg); __set_es(es); */
+
+ /* The actual jump ... */
+ memseg = newseg;
+
+#asm
+ mov ax,ds
+ mov bx,cs
+ sub ax,bx
+ mov bx,[_memseg]
+ add ax,bx
+ push bx
+ call L_x
+ mov ds,ax
+ mov ss,ax
+ mov [_memseg],bx
+#endasm
+}
+#asm
+L_x:
+ retf
+#endasm
+
+#else
+}
+#endif
+
+char win95_bb[512] = {
+0xeb,0x3c,0x90,0x29,0x69,0x71,0x22,0x5a,0x49,0x48,0x43,0x00,0x02,0x01,0x01,0x00,
+0x02,0xe0,0x00,0x40,0x0b,0xf0,0x09,0x00,0x12,0x00,0x02,0x00,0x00,0x00,0x00,0x00,
+0x40,0x0b,0x00,0x00,0x00,0x00,0x29,0xfa,0x16,0x58,0x2c,0x4e,0x4f,0x20,0x4e,0x41,
+0x4d,0x45,0x20,0x20,0x20,0x20,0x46,0x41,0x54,0x31,0x32,0x20,0x20,0x20,0xfa,0x33,
+0xc9,0x8e,0xd1,0xbc,0xfc,0x7b,0x16,0x07,0xbd,0x78,0x00,0xc5,0x76,0x00,0x1e,0x56,
+0x16,0x55,0xbf,0x22,0x05,0x89,0x7e,0x00,0x89,0x4e,0x02,0xb1,0x0b,0xfc,0xf3,0xa4,
+0x06,0x1f,0xbd,0x00,0x7c,0xc6,0x45,0xfe,0x0f,0x8b,0x46,0x18,0x88,0x45,0xf9,0x38,
+0x4e,0x24,0x7d,0x22,0x8b,0xc1,0x99,0xe8,0x77,0x01,0x72,0x1a,0x83,0xeb,0x3a,0x66,
+0xa1,0x1c,0x7c,0x66,0x3b,0x07,0x8a,0x57,0xfc,0x75,0x06,0x80,0xca,0x02,0x88,0x56,
+0x02,0x80,0xc3,0x10,0x73,0xed,0x33,0xc9,0x8a,0x46,0x10,0x98,0xf7,0x66,0x16,0x03,
+0x46,0x1c,0x13,0x56,0x1e,0x03,0x46,0x0e,0x13,0xd1,0x8b,0x76,0x11,0x60,0x89,0x46,
+0xfc,0x89,0x56,0xfe,0xb8,0x20,0x00,0xf7,0xe6,0x8b,0x5e,0x0b,0x03,0xc3,0x48,0xf7,
+0xf3,0x01,0x46,0xfc,0x11,0x4e,0xfe,0x61,0xbf,0x00,0x07,0xe8,0x23,0x01,0x72,0x39,
+0x38,0x2d,0x74,0x17,0x60,0xb1,0x0b,0xbe,0xd8,0x7d,0xf3,0xa6,0x61,0x74,0x39,0x4e,
+0x74,0x09,0x83,0xc7,0x20,0x3b,0xfb,0x72,0xe7,0xeb,0xdd,0xbe,0x7f,0x7d,0xac,0x98,
+0x03,0xf0,0xac,0x84,0xc0,0x74,0x17,0x3c,0xff,0x74,0x09,0xb4,0x0e,0xbb,0x07,0x00,
+0xcd,0x10,0xeb,0xee,0xbe,0x82,0x7d,0xeb,0xe5,0xbe,0x80,0x7d,0xeb,0xe0,0x98,0xcd,
+0x16,0x5e,0x1f,0x66,0x8f,0x04,0xcd,0x19,0xbe,0x81,0x7d,0x8b,0x7d,0x1a,0x8d,0x45,
+0xfe,0x8a,0x4e,0x0d,0xf7,0xe1,0x03,0x46,0xfc,0x13,0x56,0xfe,0xb1,0x04,0xe8,0xc1,
+0x00,0x72,0xd6,0xea,0x00,0x02,0x70,0x00,0xb4,0x42,0xeb,0x2d,0x60,0x66,0x6a,0x00,
+0x52,0x50,0x06,0x53,0x6a,0x01,0x6a,0x10,0x8b,0xf4,0x74,0xec,0x91,0x92,0x33,0xd2,
+0xf7,0x76,0x18,0x91,0xf7,0x76,0x18,0x42,0x87,0xca,0xf7,0x76,0x1a,0x8a,0xf2,0x8a,
+0xe8,0xc0,0xcc,0x02,0x0a,0xcc,0xb8,0x01,0x02,0x8a,0x56,0x24,0xcd,0x13,0x8d,0x64,
+0x10,0x61,0x72,0x0a,0x40,0x75,0x01,0x42,0x03,0x5e,0x0b,0x49,0x75,0x77,0xc3,0x03,
+0x18,0x01,0x27,0x0d,0x0a,0x49,0x6e,0x76,0x61,0x6c,0x69,0x64,0x20,0x73,0x79,0x73,
+0x74,0x65,0x6d,0x20,0x64,0x69,0x73,0x6b,0xff,0x0d,0x0a,0x44,0x69,0x73,0x6b,0x20,
+0x49,0x2f,0x4f,0x20,0x65,0x72,0x72,0x6f,0x72,0xff,0x0d,0x0a,0x52,0x65,0x70,0x6c,
+0x61,0x63,0x65,0x20,0x74,0x68,0x65,0x20,0x64,0x69,0x73,0x6b,0x2c,0x20,0x61,0x6e,
+0x64,0x20,0x74,0x68,0x65,0x6e,0x20,0x70,0x72,0x65,0x73,0x73,0x20,0x61,0x6e,0x79,
+0x20,0x6b,0x65,0x79,0x0d,0x0a,0x00,0x00,0x49,0x4f,0x20,0x20,0x20,0x20,0x20,0x20,
+0x53,0x59,0x53,0x4d,0x53,0x44,0x4f,0x53,0x20,0x20,0x20,0x53,0x59,0x53,0x7f,0x01,
+0x00,0x41,0xbb,0x00,0x07,0x80,0x7e,0x02,0x0e,0xe9,0x40,0xff,0x00,0x00,0x55,0xaa
+};
diff --git a/bootblocks/bzimage.c b/bootblocks/bzimage.c
index 9221bb4..38d864f 100644
--- a/bootblocks/bzimage.c
+++ b/bootblocks/bzimage.c
@@ -6,9 +6,13 @@
#define __MINI_MALLOC__
#include "monitor.h"
+#define MAXRDPART 32
+
int auto_flag = 1;
-static char * initrd_name = 0; /* Name of init_ramdisk to load */
+/* Names of init_ramdisk files to load */
+static char *initrd_names[MAXRDPART];
+static int initrd_count = 0;
static long initrd_start = 0;
static long initrd_length = 0;
static int vga_mode = -1; /* SVGA_MODE = normal */
@@ -21,7 +25,12 @@ static long image_size; /* Length of image file in bytes */
static char * read_cmdfile();
static char * input_cmd();
-#define ZIMAGE_LOAD_SEG 0x10000 /* Segment that zImage data is loaded */
+/* ZIMAGE_LOAD_SEG: Segment that zImage data is loaded
+ * 0x10000 For largest possible zImage
+ * 0x1000 Normal load address, smallest monitor.sys
+ * 0x100 Largest zImage without using extended memory
+ */
+#define ZIMAGE_LOAD_SEG 0x10000
#define COMMAND_LINE_POS 0x4000 /* Offset in segment 0x9000 of command line */
static char * linux_command_line = 0;
@@ -61,7 +70,7 @@ char * command_line;
int low_sects;
unsigned int address;
- initrd_name = 0;
+ initrd_count = 0;
initrd_start = initrd_length = 0;
vga_mode = -1;
is_zimage = 0;
@@ -115,6 +124,7 @@ char * command_line;
#ifndef __ELKS__
#if ZIMAGE_LOAD_SEG == 0x10000
+#if 0 /* Don't warn about this limit, the format is old. */
if( is_zimage )
{
if( image_length > 0x7FF0/32 )
@@ -124,11 +134,10 @@ char * command_line;
return -1;
}
}
+#endif
#else
if( is_zimage )
{
- relocator(8); /* Need space in low memory */
-
if( image_length > (__get_cs()>>5) - ZIMAGE_LOAD_SEG/32 )
{
printf("This zImage file is too large, maximum is %dk bytes\n",
@@ -171,8 +180,11 @@ char * command_line;
#endif
for(v=0; v<1024; v+=512)
{
- if( putsect(buffer+v, address) < 0 )
+ int rv;
+ if( (rv=mem_write(buffer+v, 0L, address/2, 1)) != 0 ) {
+ printf("Error 0x%02x while copying to extended memory\n", rv);
return -1;
+ }
address += 2;
@@ -202,7 +214,7 @@ char * command_line;
printf(" \r"); fflush(stdout);
- if( initrd_name )
+ if( initrd_count )
if( load_initrd(address) < 0 )
return -1;
@@ -260,7 +272,7 @@ char * command_line;
#endif
/* Tell the kernel where ramdisk is */
- if( initrd_name )
+ if( initrd_count )
{
__set_es(0x9000);
@@ -272,7 +284,7 @@ char * command_line;
}
- if( !is_zimage || initrd_name )
+ if( !is_zimage || initrd_count )
__poke_es(0x210, 0xFF); /* Patch setup to deactivate safety switch */
/* Set SVGA_MODE if not 'normal' */
@@ -349,60 +361,13 @@ register char * image_buf;
is_zimage = 1;
printf("File %s is an old Image file\n", fname);
-#if ZIMAGE_LOAD_SEG == 0x10000
+#if ZIMAGE_LOAD_SEG == 0x10000 || ZIMAGE_LOAD_SEG == 0x1000
return 0;
#else
return -1;
#endif
}
-#ifndef __ELKS__
-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(), put_buf, address*16, 0, 512);
- return 0;
- }
-
-retry:
- tc--;
-
- if( x86_test )
- return 0; /* In an EMU we can't write to high mem but
- we'll pretend we can for debuggering */
-
- if( (rv=ext_put(put_buf, address, 512)) != 0 )
- {
- switch(rv)
- {
- case 1:
- printf("Parity error while copying to extended memory\n");
- break;
- case 2:
- printf("Interrupt error while copying to extended memory\n");
- if ( tc>0 ) goto retry;
- break;
- case 3:
- printf("BIOS cannot open A20 Gate\n");
- break;
- case 0x80: case 0x86:
- printf("BIOS has no extended memory support\n");
- break;
- default:
- printf("Error %d while copying to extended memory\n", rv);
- break;
- }
- return -1;
- }
- return 0;
-}
-#endif
-
static char *
read_cmdfile(iname)
char * iname;
@@ -568,11 +533,11 @@ static char * image_str = "BOOT_IMAGE=";
}
else if( strncasecmp(s, "ramdisk_file=", 13) == 0 )
{
- if( initrd_name ) free(initrd_name);
- if( s[13] )
- initrd_name = strdup(s+13);
- else
- initrd_name = 0;
+ if (initrd_count >= MAXRDPART) {
+ printf("Too many ramdisk files\n");
+ return -1;
+ }
+ initrd_names[initrd_count++] = strdup(s+13);
}
else if( strncasecmp(s, image_str, 11) == 0 )
{
@@ -629,79 +594,84 @@ static int burning = 0;
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
+ printf("No\n");
return 0;
}
load_initrd(k_top)
unsigned int k_top;
{
- unsigned int address, rd_start, rd_len;
+ char * fname;
+ long baseaddress;
long file_len;
- char * fname = initrd_name;
+ unsigned sectcount, sectno;
+ int fno;
- /* Top of accessable memory */
- if( main_mem_top >= 15360 ) address = 0xFFFF;
- else address = 0x1000 + main_mem_top*4;
+ initrd_length = 0;
+ baseaddress = (long)k_top * 256;
- if( *fname == '+' ) fname++;
-
- while( open_file(fname) < 0 )
+ for(fno = 0; fno <initrd_count; fno++)
{
- char buf[2];
+ fname = initrd_names[fno];
+ if( *fname == '+' ) fname++;
+ while( open_file(fname) < 0 )
+ {
+ char buf[2];
+ close_file();
+ printf("Please insert disk containing '%s' and press return:", fname);
+ fflush(stdout);
+ if( read(0, buf, 2) <=0 ) return -1;
+ }
+
+ file_len = file_length();
+ sectcount = (file_len+511)/512;
+
+ printf("Loading %s\n", fname);
+
+ for(sectno=0; sectno<sectcount; sectno+=2) {
+#ifndef NOCOMMAND
+ int v = (kbhit()&0x7F);
+ if( v == 3 || v == 27 ) {
+ printf("User interrupt!\n");
+ getch();
+ return -1;
+ }
+#endif
+ printf("%dk to go \r", (sectcount-sectno)/2); fflush(stdout);
+ if( read_block(buffer) < 0 ) {
+ printf("Read error loading ramdisk\n");
+ return -1;
+ }
+ if( mem_write(buffer, baseaddress, sectno, 2) != 0 ) return -1;
+ }
close_file();
- printf("Cannot open %s, insert next disk and press return:", fname);
- fflush(stdout);
- if( read(0, buf, 2) <=0 ) return -1;
- }
- file_len = file_length();
- rd_len = (file_len+1023)/1024;
- if( file_len > 15000000L || k_top + rd_len*4 > address )
- {
- printf("Ramdisk file %s is too large to load\n", fname);
- return -1;
+ baseaddress += file_len;
+ initrd_length += file_len;
}
- rd_start = address - rd_len*4;
- rd_start &= -16; /* Page boundry */
- address = rd_start;
+ /* Move ramdisk to top of accessable memory. */
+ baseaddress = (long)k_top * 256;
- printf("Loading %s at 0x%x00\n", fname, rd_start);
+ if( main_mem_top >= 15360 ) initrd_start = 0x1000000L;
+ else initrd_start = 0x100000 + main_mem_top*1024;
- for( ; rd_len>0 ; rd_len--)
- {
-#ifndef NOCOMMAND
- int v = (kbhit()&0x7F);
- if( v == 3 || v == 27 )
- {
- printf("User interrupt!\n");
- getch();
- return -1;
- }
-#endif
+ sectcount = (initrd_length+511)/512;
+ initrd_start -= (long)sectcount *512;
+ initrd_start &= -4096;
- printf("%dk to go \r", rd_len); fflush(stdout);
- if( read_block(buffer) < 0 )
+ printf("Moving ramdisk to 0x%06lx..0x%06lx, (%ld)\n",
+ initrd_start, initrd_start + initrd_length, initrd_length);
+
+ while(sectcount>0) {
+ sectcount--;
+ if ( mem_read(buffer, baseaddress, sectcount) != 0 ||
+ mem_write(buffer, initrd_start, sectcount, 1) != 0)
{
- printf("Read error loading ramdisk\n");
+ printf("Error moving ramdisk\n");
return -1;
}
- if( putsect(buffer, address) < 0 ) return -1;
- address+=2;
- if( putsect(buffer+512, address) < 0 ) return -1;
- address+=2;
}
- printf(" \r"); fflush(stdout);
-
- close_file();
-
- initrd_start = ((long) rd_start <<8);
- initrd_length = file_len;
return 0;
}
@@ -722,16 +692,11 @@ check_crc()
for(len=image_size; len>0; len-=512)
{
- if( address >= 0xA00 )
+ if (mem_read(buffer, 0L, address/2) != 0)
{
- if( ext_get(address, buffer, 512) != 0 )
- {
- printf("Unable to read back for CRC check\n");
- return;
- }
+ printf("Unable to read back for CRC check\n");
+ return;
}
- else
- __movedata(address*16, 0, __get_ds(), buffer, 512);
if( len > 512 ) addcrc(buffer, 512); else addcrc(buffer, (int)len);
diff --git a/bootblocks/i86_funcs.c b/bootblocks/i86_funcs.c
index 7d010f5..5f89650 100644
--- a/bootblocks/i86_funcs.c
+++ b/bootblocks/i86_funcs.c
@@ -164,26 +164,40 @@ static struct {
""
};
-ext_put(from, to, length)
-unsigned int from, to, length;
+mem_write(buffer, baseaddr, sectno, sectcount)
+void * buffer;
+long baseaddr;
+unsigned sectno, sectcount;
{
- if(x86_test) return 3;
- GDT.src_seg = RIGHTS + from + ((long)__get_ds()<<4);
- GDT.dst_seg = RIGHTS + ((long)to<<8);
- if( length == 0xFFFF ) length = 0x8000;
- else length = ((length+1)>>1);
- return asm_copy(length);
+ if(x86_test) return 0;
+ /* In an EMU we can't write to high mem but
+ we'll pretend we can for debuggering */
+
+ baseaddr += ((long)sectno<<9);
+ if( baseaddr < 0xA0000L )
+ {
+ __movedata(__get_ds(), buffer,
+ (unsigned)(baseaddr>>4), (unsigned)(baseaddr&0xF),
+ sectcount * 512);
+ return 0;
+ }
+
+ GDT.src_seg = RIGHTS + (unsigned)buffer + ((long)__get_ds()<<4);
+ GDT.dst_seg = RIGHTS + baseaddr;
+ return asm_copy(sectcount << 8);
}
-ext_get(from, to, length)
-unsigned int from, to, length;
+mem_read(buffer, baseaddr, sectno)
+void * buffer;
+long baseaddr;
+int sectno;
{
if(x86_test) return 3;
- GDT.src_seg = RIGHTS + ((long)from<<8);
- GDT.dst_seg = RIGHTS + to + ((long)__get_ds()<<4);
- if( length == 0xFFFF ) length = 0x8000;
- else length = ((length+1)>>1);
- return asm_copy(length);
+ baseaddr += ((long)sectno<<9);
+
+ GDT.dst_seg = RIGHTS + (unsigned)buffer + ((long)__get_ds()<<4);
+ GDT.src_seg = RIGHTS + baseaddr;
+ return asm_copy(256);
}
static asm_copy(length)
diff --git a/bootblocks/killhd.s b/bootblocks/killhd.s
index b4cd3b5..da2b3f7 100644
--- a/bootblocks/killhd.s
+++ b/bootblocks/killhd.s
@@ -20,23 +20,45 @@ org dos_sysid
mov sp,ax
mov di,#$8000
- mov cx,#$0400
+ mov cx,#$0800
rep
stosw ! Zap a space.
mov dx,#$0080
mov cx,#$0001
mov bx,#$8000
- mov ax,#$0301
- int $13 ! Zap the MBR
+ mov ax,#$0308
+ int $13 ! Zap the MBR (and a disk manager?)
mov dx,#$0180
mov cx,#$0001
mov bx,#$8000
- mov ax,#$0304
+ mov ax,#$0308
int $13 ! Zap the first partition boot and super.
- xor ax,ax ! Wait for key
- int $16
- jmpi $0,$FFFF ! Reboot
+!----------------------------------------------------------------
+
+prtmsg: ! SI = pointer to error message
+ mov si,#boot_message
+
+nextc:
+ lodsb
+ cmp al,#0
+ jz eos
+ mov bx,#7
+ mov ah,#$E ! Can't use $13 cause that's AT+ only!
+ int $10
+ jmp nextc
+
+!----------------------------------------------------------------
+
+eos: ! Wait for a key then reboot
+reboot:
+ xor ax,ax
+ int $16
+ jmpi $0,$FFFF ! Wam! Try or die!
+
+export boot_message
+boot_message:
+ .asciz "PANIC! OS Destroyed!\r\n"
diff --git a/bootblocks/makeboot.c b/bootblocks/makeboot.c
index a7a02ac..fa3773f 100644
--- a/bootblocks/makeboot.c
+++ b/bootblocks/makeboot.c
@@ -61,14 +61,40 @@ struct bblist {
2, minixhd_bootfile-minixhd_start, FS_ZERO},
{ "killhd", "Deletes MBR from hard disk when booted",
killhd_data, killhd_size,
- 0, 0, FS_ADOS},
+ 2, killhd_boot_message-killhd_start, FS_ADOS},
+#if __STDC__
+{ "mbr", "Master boot record for HD"
+#if defined(mbr_Banner) || mbr_diskman || mbr_linear || mbr_mbrkey || mbr_preboot
+ ", Options:"
#ifdef mbr_Banner
-{ "mbr", "Master boot record for HD (with optional message)",
+ " Banner"
+#endif
+#if mbr_diskman
+ " DiskMan"
+#endif
+#if mbr_linear
+ " LBA"
+#if !mbr_useCHS
+ "-Only"
+#endif
+#endif
+#if mbr_mbrkey
+ " BootKeys"
+#endif
+#if mbr_preboot
+ " PreBoot"
+#endif
+#endif
+ ,
mbr_data,mbr_size,
+#ifdef mbr_Banner
2, mbr_Banner-mbr_start, FS_MBR},
#else
-{ "mbr", "Master boot record for HD",
- mbr_data,mbr_size, 0, 0, FS_MBR},
+ 0, 0, FS_MBR},
+#endif
+#else
+{ "mbr", "Master boot record for HD",
+ mbr_data,mbr_size, 0, 0, FS_MBR},
#endif
{ "stat", "Display dosfs superblock",
0, 0, 0, 0, FS_STAT},
@@ -761,6 +787,14 @@ struct bootfields {
{ 0x30, 2, 0},
{ 0x32, 2, 0},
+ { 0x40, 1, 0},
+ { 0x43, 4, 0},
+ { 0x47, 11, 0},
+ { 0x52, 8, 0},
+
+ { 0x3e8, 4, 0},
+ { 0x3ec, 4, 0},
+
{ -1,0,0}
};
@@ -781,13 +815,13 @@ static char * fieldnames[] = {
"Heads",
"Hidden sectors (Partition offset)",
- "Large FS sector count",
+ "Large Filesystem sector count",
"Phys drive",
"Serial number",
"Disk Label (DOS 4+)",
"FAT type",
- "FAT32 FS sector count",
+ "Large Filesystem sector count",
"FAT32 FAT length",
"FAT32 Flags",
"FAT32 version",
@@ -795,6 +829,14 @@ static char * fieldnames[] = {
"FAT32 Info Sector",
"FAT32 Backup Boot",
+ "FAT32 Phys Drive",
+ "FAT32 Serial number",
+ "FAT32 Disk Label",
+ "FAT32 FAT Type",
+
+ "FAT32 Free clusters",
+ "FAT32 Next free cluster",
+
0
};
int i;
@@ -1087,9 +1129,10 @@ check_mbr()
break;
/* Check for Disk Manager partition tables */
- if( buffer[252] == 0xAA && buffer[253] == 0x55 )
+ if( buffer[252] == 0x55 && buffer[253] == 0xAA )
{
- if( (unsigned char)mbr_data[252] != 0xAA || mbr_data[253] != 0x55 )
+ if( (unsigned char)mbr_data[252] != 0x55 ||
+ (unsigned char)mbr_data[253] != 0xAA )
i = 252;
}
diff --git a/bootblocks/mbr.s b/bootblocks/mbr.s
index a5a3923..fdfadca 100644
--- a/bootblocks/mbr.s
+++ b/bootblocks/mbr.s
@@ -2,27 +2,32 @@
! This is a 'Master Boot Record' following the MSDOS 'standards'.
! This BB successfully boots MSDOS or Linux.
!
-! In addition it has the facility to load and execute a small program
-! before the boot blocks are checked.
+! In addition it can:
+! Display a message configure at install time.
+! Load and execute a small program before the boot blocks are checked.
!
! Or
!
-! Space for 12 extra partitions in the 'DiskManager' form that Linux
-! _does_ understand.
+! Space for 12 extra partitions in the 'Old Disk Manager' form that Linux
+! _does_ understand (unfortunatly there doesn't appear to be an fdisk that
+! understands them.)
!
-! NB: This needs as86 0.15.2 or later
+! NB: This needs as86 0.16.0 or later
! Lowest available is $0500, MSDOS appears to use $0600 ... I wonder why?
ORGADDR=$0500
+copyright=1 ! Add in the copyright message; if room.
preboot=0 ! Include the pre-boot loader.
-mbrkey=0 ! Option to choose the boot record base on keystroke
+mbrkey=0 ! Option to choose the boot record based on keystroke
message=1 ! Display boot message
use512=0 ! Put the end marker at byte 510..512
+markptab=1 ! Put an end marker just below the partition table.
diskman=0 ! Disk manager partitions, allows 16 partitions but
! don't overwrite this with a LILO BB.
-linear=0 ! Use the linear addresses not the CHS ones
+linear=1 ! Use the linear addresses not the CHS ones (if available)
+useCHS=1 ! Disable CHS if you need space.
partition_start=ORGADDR+0x1BE
partition_size=0x10
@@ -36,6 +41,12 @@ partition_end=ORGADDR+0x1FE
table_start=partition_start
endif
+export linear
+export diskman
+export useCHS
+export mbrkey
+export preboot
+
org ORGADDR
cli ! Assume _nothing_!
cld
@@ -54,7 +65,7 @@ org ORGADDR
cont:
sti ! Let the interrupts back in.
-! Next check for a pre-boot load or a keypress
+! Next check for a pre-boot message, load or keypress
if message
call disp_message
endif
@@ -65,23 +76,39 @@ cont:
call key_wait
endif
+ if (linear|useCHS)
+
! Now check the partition table, must use SI as pointer cause that's what the
! partition boot blocks expect.
+! If we're using diskman and we're short of space check the partitions in
+! physical order. (Order. 4,3,2,1,5,6,7,8,9,10,11,12,13,14,15,16)
+
+ if (diskman&linear&useCHS)
+
+ mov si,#partition_end
+check_next:
+ sub si,#partition_size
+ cmp byte [si],#$80 ! Flag for activated partition
+ jz found_active
+ cmp si,#low_partition
+ jnz check_next
+
+ else
+
+! Normal active partition check, (Order: 1,2,3,4)
mov si,#partition_start
check_active:
cmp byte [si],#$80 ! Flag for activated partition
jz found_active
- if mbrkey=0
-bad_boot:
- endif
+try_next_part:
add si,#partition_size
cmp si,#partition_end
jnz check_active
- ! Check for Disk manager partitions in the order that Linux numbers them.
- if diskman
- cmp word ptr diskman_magic,#$55AA
+! Check for Disk manager partitions in the order that Linux numbers them.
+ if diskman&~(linear&useCHS)
+ cmp word ptr diskman_magic,#$AA55
jnz no_diskman
mov si,#partition_start
check_next:
@@ -93,26 +120,78 @@ check_next:
no_diskman:
endif
+ endif
+ if mbrkey=0
+bad_boot:
+ endif
mov si,#no_bootpart ! Message & boot
jmp no_boot
+! Active partition found, boot it.
found_active:
+ mov di,#6 ! Max retries, int doc says 3 ... double it
+ movb [$7DFE],#0 ! Clear magic for dosemu
+retry:
+
+! If the BIOS has LBA extensions use them.
if linear
- call linearise
+ if useCHS
+ mov ah,#$41
+ mov bx,#$55AA
+ mov dx,[si] ! dh = Drive head, dl = $80 ie HD drive 0
+ push si ! Save SI on read.
+ if mbrkey
+ test dl,#$80
+ jz do_CHS
+ endif
+ int $13
+ jc do_CHS
+ cmp bx,#$AA55
+ jnz do_CHS
else
- mov di,#6 ! Max retries, int list says 3 ... double it
+ mov dx,[si] ! dh = Drive head, dl = $80 ie HD drive 0
+ push si ! Save SI
+ endif
+ mov bx,#disk_address
+ mov ax,[si+8]
+ mov [bx],ax
+ mov ax,[si+10]
+ mov [bx+2],ax
+ mov si,#disk_packet
+ mov ah,#$42
+ int $13
+ pop si
+ jc retry_error
+ j sector_loaded
+disk_packet:
+ .byte $10
+ .byte 0
+ .word 1
+ .word $7C00
+ .word 0
+disk_address:
+ .long 0
+ .long 0
+
+ if useCHS
+do_CHS:
+ pop si
+ endif
+ endif
+
+if useCHS
mov dx,[si] ! dh = Drive head, dl = $80 ie HD drive 0
mov cx,[si+2] ! cx = Sector & head encoded for int $13
! bx is correct at $7C00
- endif
-retry:
- movb [$7DFE],#0 ! Clear magic for dosemu
+
mov ax,#$0201 ! Read 1 sector
int $13 ! Disk read.
jnc sector_loaded
+endif
! Error, reset and retry
+retry_error:
xor ax,ax
int $13 ! Disk reset
@@ -125,11 +204,19 @@ retry:
sector_loaded:
mov di,#$7DFE ! End of sector loaded
cmp [di],#$AA55 ! Check for magic
- jnz bad_boot ! No? Try next partition.
+ if diskman
+ jnz bad_boot ! Can't try again, two places to return to.
+ else
+ jnz try_next_part ! No? Try next partition.
+ endif
mov bp,si ! LILO says some BBs use bp rather than si
jmpi #$7C00,#0 ! Go!
+ else
+ mov si,#no_bootpart ! Message & boot
+ endif !(linear|useCHS)
+
! Fatal errors ...........
if mbrkey
bad_boot:
@@ -138,9 +225,7 @@ no_boot: ! SI now has pointer to error message
call puts
mov si,#crlf
call puts
-tick:
- call key_pause
- j tick
+ j key_pause
else
@@ -169,36 +254,32 @@ press_end:
endif
no_bootpart:
- .asciz "No active partition"
+ .asciz "Bad partition"
disk_read_error:
- .asciz "Disk read error"
-
-!-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
-! Instead of loading using the CHS data in the ptbl use the linear addr
-!
- if linear
-linearise:
- mov di,#6 ! Max retries, int list says 3 ... double it
- mov dx,[si] ! dh = Drive head, dl = $80 ie HD drive 0
- mov cx,[si+2] ! cx = Sector & head encoded for int $13
- ! bx is correct at $7C00
-
- fail! Todo ...
- ret
- endif
+ .asciz "Read error"
!-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
! Choose the partition based on a pressed key ...
if mbrkey
+key_wait:
+ mov si,#Prompt
+ call puts
+ call wait_key
+ jnz key_pause
+
+ mov si,#Unprompt ! Nothing has happened, return.
+ call puts
+ ret
+
key_pause:
mov si,#Pause
call puts
- j wait_key
-key_wait:
- mov si,#Prompt
- call puts
+key_tick:
+ call wait_key
+ jz key_tick
+ j Got_key
wait_key:
mov di,#19 ! Wait for 18-19 ticks
@@ -206,7 +287,7 @@ wait_key:
next_loop:
mov ah,#1
int $16
- jnz Got_key
+ jnz done_wait
mov ah,#0
int $1A ! Get current tick
cmp dx,si ! If changed DEC our counter.
@@ -215,43 +296,39 @@ next_loop:
dec di
jnz next_loop
- mov si,#Unprompt ! Nothing has happened, return.
- call puts
-
-bad_key:
+done_wait:
ret
Got_key:
mov ah,#0 ! Clean the kbd buffer.
int $16
+ cmp al,#0x20
+ jz key_tick
- cmp al,#$20
- jz key_pause ! Recursion !?
-
+ push ax
mov Showkey,al
mov si,#Showkey
call puts
- mov al,Showkey
+ pop ax
! ... Now we use our key ...
! 0 => Floppy
! 1 .. 4 => Hard disk partition.
- mov di,#-1
- cmp al,#$20
- jz next_loop
+ if useCHS
+ cmp al,#'F
+ jz is_floppy
+ cmp al,#'f
+ jz is_floppy
+ endif
- and ax,#0xF
+ cmp al,#'1
+ jb key_pause
+ cmp al,#'4
+ ja key_pause
- jnz not_floppy
- mov si,#floppy_part
- br found_active
-
-not_floppy:
+ and ax,#0x7
dec ax
- test ax,#0xC
- jnz bad_key
-
mov cl,#4
shl ax,cl
add ax,#partition_start
@@ -259,8 +336,18 @@ not_floppy:
! Set active flag for disk interrupt.
or byte [si],#$80
+ br found_active
+ if useCHS
+is_floppy:
+ mov si,#floppy_part
br found_active
+ endif
+
+ if message
+disp_message:
+ mov si,#Banner
+ endif
puts:
lodsb
@@ -276,11 +363,15 @@ EOS:
ret
Prompt:
- .asciz "\rMBR 0-4: "
+ .asciz "\rMBR: "
Unprompt:
- .asciz "\r \r"
+ .asciz "\r \r"
Pause:
- .asciz "\rMBR 0-4> "
+ if useCHS
+ .asciz "\rMBR F1234> "
+ else
+ .asciz "\rMBR 1234> "
+ endif
Showkey:
.ascii " "
crlf:
@@ -291,33 +382,6 @@ floppy_part:
endif
!-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
-!
- if message
-disp_message:
- mov si,#Banner
-
- if mbrkey
- br puts
- else
-
-puts:
- lodsb
- cmp al,#0
- jz .EOS
- push bx
- mov bx,#7
- mov ah,#$E ! Can't use $13 cause that's AT+ only!
- int $10
- pop bx
- jmp puts
-.EOS:
- ret
- endif
-export Banner
-Banner:
- .asciz ""
- endif
-!-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
! This is the pre-boot loader it uses CHS but that's ok for track 0
!
if preboot
@@ -372,7 +436,34 @@ pre_boot_table:
endif
!-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
+!
+ if message&~mbrkey
+disp_message:
+ mov si,#Banner
+
+puts:
+ lodsb
+ cmp al,#0
+ jz .EOS
+ push bx
+ mov bx,#7
+ mov ah,#$E ! Can't use $13 cause that's AT+ only!
+ int $10
+ pop bx
+ jmp puts
+.EOS:
+ ret
+ endif
+
+ if message
+export Banner
+Banner:
+ .blkb 16 ! 16 bytes for the message at least.
+ endif
+
+!-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
! Now make sure this isn't too big!
+end_of_code:
if *>table_start
fail! Partition table overlaps
endif
@@ -380,29 +471,43 @@ pre_boot_table:
!-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
! The diskman magic number and empty DM partitions.
if diskman
- org ORGADDR+0xFC
+ org table_start
public diskman_magic
diskman_magic:
.word 0xAA55
.blkb 12*partition_size-1
- .byte 0
endif
!-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
-! And finally a copyright message if there's room.
+! And a copyright message if there's room.
+ if copyright
if *<ORGADDR+0x180
org ORGADDR+0x180
.asciz "ELKS MBR "
.asciz "Robert de Bath,"
.asciz "Copyright "
-.asciz "1996-2002. "
+.asciz "1996-2003. "
org partition_start-1
.byte 0xFF
endif
+ endif
+
+!-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
+! Clear the sector to the bottom of the partition table.
+ if markptab
+ if *<partition_start-1
+ org partition_start-1
+ .byte 0xFF
+ endif
+ endif
if use512
org ORGADDR+0x1FE
.word 0xAA55
endif
+ if 1&~(useCHS|linear|preboot)
+ fail! Errm, you can't boot anything without 'linear' or 'useCHS'
+ endif
+
!THE END
diff --git a/bootblocks/monitor.c b/bootblocks/monitor.c
index 8c79c1c..d139cf6 100644
--- a/bootblocks/monitor.c
+++ b/bootblocks/monitor.c
@@ -36,15 +36,15 @@ static char minibuf[2] = " ";
{
#ifdef __STANDALONE__
#ifndef NOCOMMAND
- if( __get_ds() != 0x1000 )
- {
- /* First out of the way. */
- relocator(3);
- /* Then align DS to 64k boundry -> DMA is simple. */
- relocator(0x1000-__get_ds()+__get_cs());
-
- printf("Relocated to CS=$%04x DS=$%04x\n", __get_cs(), __get_ds());
- }
+#if 0
+ /* First out of the way. */
+ relocator(3);
+ /* Then align DS to 64k boundry -> DMA is simple. */
+ relocator(0x1000-__get_ds()+__get_cs());
+#else
+ relocator(-1); /* Top of available memory */
+#endif
+ printf("Relocated to CS=$%04x DS=$%04x\n", __get_cs(), __get_ds());
#endif
disk_drive = __argr.h.dl;
@@ -124,7 +124,7 @@ static char minibuf[2] = " ";
void init_prog()
{
- int offt;
+ char offt;
#ifdef COLOUR
vt52_putch(0);
printf("\033E\033Rg\033Sa\033J");
diff --git a/bootblocks/monitor.h b/bootblocks/monitor.h
index e229d48..4e499f0 100644
--- a/bootblocks/monitor.h
+++ b/bootblocks/monitor.h
@@ -48,7 +48,7 @@ extern union REGS __argr;
#endif
#ifdef SINGLEFS
-#define NOCOMMAND
+/* #define NOCOMMAND */
#define NOMONITOR
#endif
diff --git a/bootblocks/msdos.s b/bootblocks/msdos.s
index 7f8156e..971975e 100644
--- a/bootblocks/msdos.s
+++ b/bootblocks/msdos.s
@@ -14,7 +14,7 @@
! of the msdos files system:
!
! 1) All of the first 12 bit FAT must be on the first track.
-! 2) The FAT must be 12 bit
+! 2) The FAT must be 12 bit or 16 bit. (known at install time)
! 3) The value of the hidden sectors field must be zero
!
! All these are true for mtools created floppies on normal PC drives.
@@ -340,11 +340,9 @@ got_fsect:
!---------------------------------------------------------------------------
! File is now loaded, execute it.
maincode:
- if harddisk=0
mov bx,#7
- mov ax,#$0E3E
+ mov ax,#$0E + ':
int $10 ! Marker printed to say bootblock succeeded.
- endif
xor dx,dx ! DX=0 => floppy drive
if harddisk
@@ -387,13 +385,8 @@ bad_magic:
fatsect:
.word 0
-! if fatbits =16
error_msg:
.asciz "\r\nError during initial boot\r\nPress a key:"
-! else
-! error_msg:
-! .asciz "\r\nBoot error:"
-! endif
export boot_name
boot_name:
diff --git a/bootblocks/relocate.c b/bootblocks/relocate.c
index f409a4e..a2cced0 100644
--- a/bootblocks/relocate.c
+++ b/bootblocks/relocate.c
@@ -29,13 +29,17 @@ unsigned newseg;
/* Where do we start */
if(memseg == 0)
{
+ extern int _heap_top;
memseg = __get_cs();
codelen = __get_ds()-memseg;
__set_es(memseg-2);
- if (__deek_es(0) == 0x0301 ) {
- memlen = __deek_es( 24 );
- memlen >>=4;
- }
+
+ memlen = (((int)&_heap_top) >> 4);
+
+ /*
+ if (__deek_es(0) == 0x0301 ) memlen = (__deek_es(24) >> 4);
+ */
+
if( memlen == 0 ) memlen = 0x1000;
memlen += codelen;
__set_es(es);
diff --git a/bootblocks/unix.c b/bootblocks/unix.c
index e7f07a0..d8d6e91 100644
--- a/bootblocks/unix.c
+++ b/bootblocks/unix.c
@@ -8,22 +8,22 @@ kbhit() {
}
getch() {
- return 0;
+ return 3;
}
static int phy_fd = -1;
static open_fd()
{
- phy_fd = open("/dev/fd0", 0);
+ phy_fd = open("/tmp/ramdisk", 0);
if( phy_fd < 0 )
{
- fprintf(stderr, "Cannot open /dev/fd0\n");
+ fprintf(stderr, "Cannot open /dev/ramdisk\n");
phy_fd= -2;
}
}
-phy_read(drive, cyl, head, sect, len, buffer)
+_bios_disk_read(drive, cyl, head, sect, len, buffer)
int drive, cyl, head, sect, len;
char *buffer;
{
@@ -61,7 +61,7 @@ extern int disk_spt;
return 0;
}
-phy_reset()
+_bios_disk_reset()
{
}
@@ -70,6 +70,7 @@ motor_running()
return 1;
}
+#if 0
putsect(buffer, address)
char * buffer;
int address;
@@ -79,6 +80,7 @@ int address;
return 0;
}
#endif
+#endif
/* crctab calculated by Mark G. Mendel, Network Systems Corporation */
static unsigned short crctab[256] = {
diff --git a/ld/writex86.c b/ld/writex86.c
index c4cd3f5..eaf4881 100644
--- a/ld/writex86.c
+++ b/ld/writex86.c
@@ -153,10 +153,10 @@ bool_pt argxsym;
curseg = 3;
symres("__edata");
symres("__end");
+ symres("__heap_top");
curseg = 0; /* text seg, s.b. variable */
symres("__etext");
symres("__segoff");
- symres("__heap_top");
/* calculate segment and common sizes (sum over loaded modules) */
/* use zero init of segsz[] */
diff --git a/libc/bios/Makefile b/libc/bios/Makefile
index ffa5027..b491e98 100644
--- a/libc/bios/Makefile
+++ b/libc/bios/Makefile
@@ -4,7 +4,7 @@
ifeq ($(LIB_OS),BIOS)
ASRC=bios.c
-AOBJ=bios_start.o bios_isatty.o bios_nofiles.o \
+AOBJ=bios_start.o bios_isatty.o bios_abort.o bios_nofiles.o \
bios_read.o bios_write.o bios_lseek.o bios_close.o
BSRC=bios_vid.c
@@ -12,7 +12,7 @@ BOBJ=bios_putch.o bios_getch.o bios_getche.o bios_cputs.o bios_kbhit.o \
bios_rdline.o
CSRC=bios_min.c
-COBJ=bios_putc.o bios_getc.o
+COBJ=bios_putc.o bios_getc.o bios_khit.o
DSRC=bios_disk.c
DOBJ=bios_disk_rd.o bios_disk_wr.o bios_disk_rs.o bios_get_dpt.o
diff --git a/libc/bios/bios.c b/libc/bios/bios.c
index 3e10686..41b02c2 100644
--- a/libc/bios/bios.c
+++ b/libc/bios/bios.c
@@ -257,6 +257,19 @@ int fd;
/****************************************************************************/
+#ifdef L_bios_abort
+abort()
+{
+ static const char msg[] = "Program aborted, press return:";
+ write(2, msg, sizeof(msg)-1);
+ getch();
+ _exit(255);
+}
+
+#endif
+
+/****************************************************************************/
+
#endif
#endif
#endif
diff --git a/libc/error/Makefile b/libc/error/Makefile
index 8ec26dc..f14e956 100644
--- a/libc/error/Makefile
+++ b/libc/error/Makefile
@@ -6,13 +6,12 @@ CFLAGS=$(ARCH) $(CCFLAGS) $(DEFS)
ifeq ($(LIB_OS),ELKS)
OBJ=error.o sys_errlist.o perror.o sys_siglist.o __assert.o
+else
+OBJ=__assert.o
+endif
all: $(LIBC)($(OBJ))
@$(RM) $(OBJ)
-else
-all:
- @:
-endif
clean:
rm -f *.o libc.a
diff --git a/libc/include/assert.h b/libc/include/assert.h
index c58c57f..aef6cdf 100644
--- a/libc/include/assert.h
+++ b/libc/include/assert.h
@@ -1,4 +1,4 @@
-#ifdef __ASSERT_H
+#ifndef __ASSERT_H
#define __ASSERT_H
#include <features.h>