diff options
author | Robert de Bath <rdebath@poboxes.com> | 2002-04-17 22:05:01 +0200 |
---|---|---|
committer | Lubomir Rintel <lkundrak@v3.sk> | 2013-10-23 23:48:46 +0200 |
commit | 352e3b3230dfc6746be6d53325ffe1e33efc5289 (patch) | |
tree | 4c169beb4657a1ed3a046817db01cbe49b17017c /bootblocks | |
parent | df538463687d768b6ee8247ff4412b78850e7404 (diff) | |
download | dev86-352e3b3230dfc6746be6d53325ffe1e33efc5289.tar.gz |
Import Dev86src-0.16.3.tar.gzv0.16.3
Diffstat (limited to 'bootblocks')
-rw-r--r-- | bootblocks/Makefile | 33 | ||||
-rw-r--r-- | bootblocks/README | 18 | ||||
-rw-r--r-- | bootblocks/boot_fpy.s | 91 | ||||
-rw-r--r-- | bootblocks/i86_funcs.c | 65 | ||||
-rw-r--r-- | bootblocks/killhd.s | 42 | ||||
-rw-r--r-- | bootblocks/mbr.s | 40 | ||||
-rw-r--r-- | bootblocks/minix.c | 3 | ||||
-rw-r--r-- | bootblocks/monitor.c | 20 | ||||
-rw-r--r-- | bootblocks/msdos.s | 3 | ||||
-rw-r--r-- | bootblocks/skip.s | 3 |
10 files changed, 236 insertions, 82 deletions
diff --git a/bootblocks/Makefile b/bootblocks/Makefile index 6efa75b..40e7817 100644 --- a/bootblocks/Makefile +++ b/bootblocks/Makefile @@ -2,15 +2,15 @@ HOSTCC=cc HOSTCCFLAGS=-O BCC=bcc +AS86=as86 +DEFS= CC=$(BCC) -CFLAGS=-ansi -Ms -Oi -O -s +CFLAGS=-ansi -Ms -Oi -O -s $(DEFS) # CFLAGS=-ansi -Ms ASFLAGS=-0 -w MINIXDEFS=-DDOTS -MONDEFS= # LST=-l $*.lst -# CLST=-A-l -A$*.lst default: makeboot makeboot.com monitor.out minix_elks.bin lsys.com @@ -20,7 +20,7 @@ bootsys: bootfile.sys boottar.sys bootminix.sys CSRC=minix.c SSRC=sysboot.s tarboot.s skip.s com_bcc.s tich.s mbr.s msdos.s noboot.s \ - boot_fpy.s + boot_fpy.s killhd.s encap: $(SSRC:s=v) $(CSRC:c=v) minixhd.v msdos16.v bootbin: $(SSRC:s=bin) $(CSRC:c=bin) minixhd.bin msdos16.bin minix_elks.bin @@ -39,10 +39,13 @@ EXTRAS=minix.h elf_info.c elf_info.h standalone.c li86.s \ install: +monitor.com: $(MOBJ) + $(CC) $(CFLAGS) $(MONDEFS) -H0x10000 -d $(MOBJ) -o monitor.com -M > monitor.sym + monitor.out: $(MOBJ) $(CC) $(CFLAGS) $(MONDEFS) -H0x10000 $(MOBJ) -o monitor.out -M > monitor.sym -$(MOBJ): $(MINC) version.h +$(MOBJ): $(MINC) fs_min.o: minix.h bootfile.sys: $(MSRC) $(MINC) @@ -72,13 +75,13 @@ monitor: $(MSRC) $(MINC) bzimage.o: bzimage.c zimage.v minix.s: minix.c Makefile - $(BCC) -Mf -O -DTRY_FLOPPY $(MINIXDEFS) -S minix.c + $(CC) -Mf -O -DTRY_FLOPPY $(MINIXDEFS) -S minix.c minix_elks.s: minix_elks.c Makefile minix.v - $(BCC) -Mf -O $(MINIXDEFS) -S minix_elks.c + $(CC) -Mf -O $(MINIXDEFS) -S minix_elks.c minixhd.s: minix.c Makefile - $(BCC) -Mf -O -DHARDDISK $(MINIXDEFS) -S minix.c -o minixhd.s + $(CC) -Mf -O -DHARDDISK $(MINIXDEFS) -S minix.c -o minixhd.s msdos16.s: msdos.s sed 's/^fatbits=12/fatbits=16/' < msdos.s > msdos16.s @@ -87,19 +90,15 @@ makeboot: makeboot.c $(BOOTBLOCKS) $(HOSTCC) $(HOSTCCFLAGS) -o makeboot makeboot.c makeboot.com: makeboot.c $(BOOTBLOCKS) - $(BCC) -Md -O -o makeboot.com makeboot.c + $(CC) -Md -O -o makeboot.com makeboot.c lsys.com: lsys.c msdos.v msdos16.v - $(BCC) -Md -O -o lsys.com lsys.c - -version.h: - head -1 ../Libc_version | \ - sed 's/\(.*\)/#define VERSION "\1"/' > version.h + $(CC) -Md -O -o lsys.com lsys.c clean realclean: rm -f bootfile.sys boottar.sys bootminix.sys rm -f monitor makeboot bootblocks.tar.gz - rm -f minix.s minixhd.s minix_elks.s version.h msdos16.s + rm -f minix.s minixhd.s minix_elks.s msdos16.s rm -f *.com *.o *.bin *.out *.lst *.sym *.v *.tmp tgz: minix.bin monitor.out makeboot.com makeboot @@ -121,9 +120,7 @@ distribution: .SUFFIXES: .bin .v .s.bin: - $(BCC) -W -c $*.s -A-u- -A-b -A$*.tmp -A-s -A$*.sym $(CLST) - mv $*.tmp $*.bin - -@rm $*.o + $(AS86) -w- -0 -b $*.bin -s $*.sym $*.s $(LST) .s.v: as86_encap $*.s $*.v $*_ $(ASFLAGS) $(LST) diff --git a/bootblocks/README b/bootblocks/README index 81fc634..26abd97 100644 --- a/bootblocks/README +++ b/bootblocks/README @@ -31,9 +31,16 @@ Contents 1.1 ) Master boot sector - This MBR is a very simple one with no frills, being less that 254 bytes - long is can be used as an MBR for a disk with old style 'Disk manager' - partitions. All 16 partitions are bootable. + This MBR is a very simple one with no frills by default. + + The actual code is less that 254 bytes long so it can be used as + an MBR for a disk with old style 'Disk manager' partitions. All 16 + partitions are bootable. + + Option 2 is a boot message that displayed as soon as the MBR loads. + + Option 3 is code to accept a keypress from the user to select which + partition to boot (or the floppy). 1.2 ) Dosfs boot sector @@ -54,8 +61,9 @@ 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. - But some older versions of superformat defeat this because they do - not correctly calculate intersector gaps. + But some versions of superformat can defeat this because they do + not correctly calculate intersector gaps. I suggest using fdformat + as this uses a 'safe' layout for standard 1440k disks. 1.3 ) Minixfs boot block diff --git a/bootblocks/boot_fpy.s b/bootblocks/boot_fpy.s index ef1f21a..a40d0fa 100644 --- a/bootblocks/boot_fpy.s +++ b/bootblocks/boot_fpy.s @@ -3,36 +3,59 @@ ! ! cat boot_fpy.bin monitor.out > /dev/fd0 ! -! Warning: Disk errors currently cause a hang. -! The boot sector does not end with $AA55 this is not a problem -! with the BIOS but many boot managers will not boot it. ORGADDR=0x0600 -EXEADDR=0x06E0 +EXEADDR=0x0800 ! This must be up to 0x7E0 or 0x0800 LOADSEG=0x0080 ! Must be 512b aligned for DMA +! Padding so you can join with 'cat'. .org EXEADDR-1 -.byte 0xFF ! Marker +.byte 0 + +! This marker is needed by many boot managers (and bochs) but the BIOS does +! NOT require it on a floppy. +if EXEADDR=0x0800 +.org ORGADDR+0x1FE +.word 0xAA55 +endif .org ORGADDR entry start public start start: - mov ax,#$07C0 ! Relocate to ORGADDR - mov ds,ax xor ax,ax - mov es,ax - mov cx,#256 - mov si,ax + mov si,#$7C00 mov di,#ORGADDR + + mov ss,ax + mov sp,di ! Or si or ax + + push ax + pop ds + push ax + pop es + + mov cx,#256 cld rep - movsw + movsw jmpi go,#0 go: - mov ds,ax ! Setup SP & S-regs - mov ss,ax - mov sp,#ORGADDR + +! Grrr, have to load sector 1 in by hand. +if EXEADDR=0x0800 +Loopi: + mov ax,#$0201 ! Read 1 sector + mov bx,#EXEADDR ! Into EXEADDR + mov cx,#$0002 ! From sector 2 + xor dx,dx ! Of the floppy drive head zero + int $13 + jc Loopi +endif + + mov si,#Boot_message + call puts + mov ax,[a_text] ! How many sectors to load mov cl,#4 shr ax,cl @@ -51,7 +74,7 @@ go: ! But occasionally some older machines have really poor BIOSes ! (Some modern ones too) so once we know how many sectors to read ! we switch to reading a track at a time. But we only try it once - ! for each track, normally, as long as the load address is sector + ! for each track. Normally, as long as the load address is sector ! aligned, this will work every time but with some BIOSes we can't ! read a track without messing with the BPB so if the track read ! fails it's one try we fall back to sector reads. @@ -62,10 +85,11 @@ go: ! your BIOS is one of the bad ones you'll have to format your disks ! to a 2:1 interleave. ! - ! BTW: There are some versions of superformat that incorrectly - ! calculate the inter-sector gaps and end up squeezing the sectors - ! to the start of the track. This means that only a full track read - ! is fast enough. + ! BTW: It's very easy to make superformat incorrectly calculate the + ! inter-sector gaps so it ends up squeezing the sectors to the start + ! of the track. This means that only a full track read is fast enough. + ! I suggest you use fdformat as it always uses 'safe' parameters for + ! a 1440k floppy. ! AX = count of sectors mov cx,#2 ! CX = First sector @@ -176,12 +200,37 @@ bad_magic: retf sect_error: - ! TODO Error. - j sect_error + ! Disk error, wait then reboot. + + mov si,#reboot_msg + call puts + + xor ax,ax ! Wait for the user. + int $16 + jmpi $0,$FFFF + +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 maxsect: .word 0 +reboot_msg: + .asciz "Disk error, press a key to reboot:" + +Boot_message: + .asciz "Boot sector loaded.\r\n" + ! Check for overlap end_of_code: if end_of_code>hitme diff --git a/bootblocks/i86_funcs.c b/bootblocks/i86_funcs.c index dd9ec33..2112141 100644 --- a/bootblocks/i86_funcs.c +++ b/bootblocks/i86_funcs.c @@ -122,7 +122,6 @@ void mem_check() main_mem_top = 16384; return; /* If not standalone don't try */ #else - { #asm int 0x12 ! Amount of boot memory mov cl,#6 @@ -144,12 +143,66 @@ got_ext: mov [_main_mem_top],ax #endasm - } - if( main_mem_top == 0xFFFFL ) - { - /* It say 64Mb-1k - Hmmmm I think it might be 128! */ - } + /* Rest are big memory for 80386+ */ + if( x86 < 3 ) return; + + /* Try int $15 EAX=$E820 */ + { + struct e820_dat { + unsigned long base_lo, base_hi; + unsigned long len_lo, len_hi; + long addr_type; + } e820_item; + long epoll = 0; + + do + { + e820_item.addr_type = 0; +#asm + mov eax,#$E820 + mov ebx,.mem_check.epoll[bp] + mov ecx,#20 + mov edx,#$534D4150 + push ds + pop es + lea di,.mem_check.e820_item[bp] + int $15 + jnc got_e820 + xor ebx,ebx +got_e820: + mov .mem_check.epoll[bp],ebx +#endasm + if (e820_item.addr_type == 1 + && e820_item.base_hi == 0 + && e820_item.base_lo == 0x100000L) + { + /* XXX Later ... */ + if (e820_item.len_hi) main_mem_top = 0x40000; + else + main_mem_top = (e820_item.len_lo >> 10); + return; + } + } + while(epoll); + } + + /* Try int $15 EAX=$E801 */ + { + unsigned int mem_64, mem_16; /* For int $15,AX=$E801 */ +#asm + mov ax,#$E801 + int $15 + jc no_e801 + mov .mem_check.mem_16[bp],ax + mov .mem_check.mem_64[bp],bx +#endasm + main_mem_top = ((unsigned long)mem_64<<6) + mem_16; +#asm +no_e801: +#endasm + } + #endif } diff --git a/bootblocks/killhd.s b/bootblocks/killhd.s new file mode 100644 index 0000000..b4cd3b5 --- /dev/null +++ b/bootblocks/killhd.s @@ -0,0 +1,42 @@ +! +! This program destroys the MBR and the start of the first partition of +! the hard disk. IT DOES NOT HAVE AN 'ARE YOU SURE?' +! + +org $7c00 + +include sysboot.s + +org dos_sysid + .ascii "DEATH" ! System ID + + org codestart + + cld + xor ax,ax + mov es,ax + mov ds,ax + mov ss,ax + mov sp,ax + + mov di,#$8000 + mov cx,#$0400 + rep + stosw ! Zap a space. + + mov dx,#$0080 + mov cx,#$0001 + mov bx,#$8000 + mov ax,#$0301 + int $13 ! Zap the MBR + + mov dx,#$0180 + mov cx,#$0001 + mov bx,#$8000 + mov ax,#$0304 + int $13 ! Zap the first partition boot and super. + + xor ax,ax ! Wait for key + int $16 + jmpi $0,$FFFF ! Reboot + diff --git a/bootblocks/mbr.s b/bootblocks/mbr.s index e633c87..a5e4585 100644 --- a/bootblocks/mbr.s +++ b/bootblocks/mbr.s @@ -10,13 +10,15 @@ ! Space for 12 extra partitions in the 'DiskManager' form that Linux ! _does_ understand. ! -! NB: This needs Dev86 0.15.2 or later +! NB: This needs as86 0.15.2 or later ! Lowest available is $0500, MSDOS appears to use $0600 ... I wonder why? ORGADDR=$0500 preboot=0 ! Include the pre-boot loader. mbrkey=0 ! Option to choose the boot record base on keystroke message=1 ! Display boot message +use512=0 ! Put the end marker at byte 510..512 + diskman=0 ! Disk manager partitions, allows 16 partitions but ! don't overwrite this with a LILO BB. @@ -137,7 +139,7 @@ no_boot: ! SI now has pointer to error message mov si,#crlf call puts tick: - call key_wait + call key_pause j tick else @@ -159,8 +161,7 @@ EOS: keyboot: ! Wait for a key then reboot xor ax,ax int $16 -! int $19 ! This rarely does anything useful... - jmpi $0,$FFFF ! Wam! Try or die! + jmpi $0,$FFFF ! Reboot. press_key: .asciz "\r\nPress return:" @@ -190,9 +191,16 @@ linearise: ! Choose the partition based on a pressed key ... if mbrkey +key_pause: + mov si,#Pause + call puts + j wait_key + key_wait: mov si,#Prompt call puts + +wait_key: mov di,#19 ! Wait for 18-19 ticks next_loop: @@ -214,18 +222,16 @@ bad_key: ret Got_key: + mov ah,#0 ! Clean the kbd buffer. + int $16 + cmp al,#$20 - jnz not_space - mov si,#Pause - j showit -not_space: + jz key_pause ! Recursion !? + mov Showkey,al mov si,#Showkey -showit: call puts - - mov ah,#0 ! Clean the kbd buffer. - int $16 + mov al,Showkey ! ... Now we use our key ... ! 0 => Floppy @@ -270,11 +276,11 @@ EOS: ret Prompt: - .asciz "MBR: " + .asciz "\rMBR 0-4: " Unprompt: - .asciz "\b\b\b\b\b \b\b\b\b\b" + .asciz "\r \r" Pause: - .asciz "\b\b> " + .asciz "\rMBR 0-4> " Showkey: .ascii " " crlf: @@ -393,5 +399,9 @@ diskman_magic: .byte 0xFF endif + if use512 + org ORGADDR+0x1FE + .word 0xAA55 + endif !THE END diff --git a/bootblocks/minix.c b/bootblocks/minix.c index 62b3031..69daa1a 100644 --- a/bootblocks/minix.c +++ b/bootblocks/minix.c @@ -230,8 +230,7 @@ min_nextc: min_eos: ! Wait for a key then reboot xor ax,ax int $16 - !int $19 ! This should be OK as we haven't touched anything. - jmpi $0,$FFFF ! Wam! Try or die! + jmpi $0,$FFFF ! Reboot. fail_fs: .byte 13,10 diff --git a/bootblocks/monitor.c b/bootblocks/monitor.c index 27f25ea..ed823a6 100644 --- a/bootblocks/monitor.c +++ b/bootblocks/monitor.c @@ -1,6 +1,5 @@ #include "monitor.h" -#include "version.h" char command_buf[256]; @@ -39,13 +38,11 @@ static char minibuf[2] = " "; #ifndef NOCOMMAND if( __get_ds() != 0x1000 ) { - /* First to top of RAM */ - relocator(-1); + /* First out of the way. */ + relocator(3); /* 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 @@ -127,7 +124,9 @@ static char minibuf[2] = " "; void init_prog() { + int offt; #ifdef COLOUR + vt52_putch(0); printf("\033E\033Rg\033Sa\033J"); #endif printf("Linux x86"); @@ -170,16 +169,15 @@ void init_prog() } printf("\n"); - printf("There is %dk of boot memory", boot_mem_top/64); + printf("There is %u bytes available", offt-sbrk(0)); + printf(", %dk of boot memory", boot_mem_top/64); if( main_mem_top ) { - printf(" %d.%dM %sof main memory", + printf(", %d.%dM of main memory", (int)(main_mem_top/1024), - (int)((10*main_mem_top)/1024%10), - main_mem_top >= 0xFC00L ?"(perhaps more) ":"" - ); + (int)((10*main_mem_top)/1024%10)); } - printf("\n"); + printf(".\n"); } /****************************************************************************/ diff --git a/bootblocks/msdos.s b/bootblocks/msdos.s index 4e9eb1a..7f8156e 100644 --- a/bootblocks/msdos.s +++ b/bootblocks/msdos.s @@ -213,8 +213,7 @@ no_boot: ! SI now has pointer to error message EOS: xor ax,ax int $16 - int $19 ! This should be OK as we haven't touched anything. - jmpi $0,$FFFF ! Wam! Try or die! + jmpi $0,$FFFF ! Reboot. !--------------------------------------------------------------------------- ! This loads the boot program 1 sector at a time, funny thing is it actually diff --git a/bootblocks/skip.s b/bootblocks/skip.s index aed4e40..c33e432 100644 --- a/bootblocks/skip.s +++ b/bootblocks/skip.s @@ -72,8 +72,7 @@ reboot: xor ax,ax int $16 - int $19 ! This should be OK as we haven't touched anything. - jmpi $0,$FFFF ! Wam! Try or die! + jmpi $0,$FFFF ! Reboot. mesg2: .asciz "Disk error\r\n" mesg3: .asciz "Retrying\r\n" |