diff options
author | Robert de Bath <rdebath@poboxes.com> | 1997-05-09 19:36:29 +0200 |
---|---|---|
committer | Lubomir Rintel <lkundrak@v3.sk> | 2013-10-23 23:39:48 +0200 |
commit | e63c244cb22bf48ca1d2695784a072269d19ea96 (patch) | |
tree | 45b9018259f43db629b27395783cf48e55a85eee /bootblocks | |
parent | 4c36e9a0c125ccfff37aa440dab2cf58c4152fff (diff) | |
download | dev86-e63c244cb22bf48ca1d2695784a072269d19ea96.tar.gz |
Import Dev86src-0.12.0.tar.gzv0.12.0
Diffstat (limited to 'bootblocks')
-rw-r--r-- | bootblocks/Makefile | 11 | ||||
-rw-r--r-- | bootblocks/README | 12 | ||||
-rw-r--r-- | bootblocks/dosfs.c | 1 | ||||
-rw-r--r-- | bootblocks/makeboot.c | 2 | ||||
-rw-r--r-- | bootblocks/mbr.s | 10 | ||||
-rw-r--r-- | bootblocks/minix.c | 299 | ||||
-rw-r--r-- | bootblocks/monitor.c | 27 | ||||
-rw-r--r-- | bootblocks/sysboot.s | 29 |
8 files changed, 349 insertions, 42 deletions
diff --git a/bootblocks/Makefile b/bootblocks/Makefile index 85393a7..707179f 100644 --- a/bootblocks/Makefile +++ b/bootblocks/Makefile @@ -15,8 +15,8 @@ all: default tgz bin CSRC=minix.c SSRC=tarboot.s skip.s com_bcc.s tich.s sysboot.s bootlist.s mbr.s msdos.s -encap: $(SSRC:s=v) $(CSRC:c=v) -bin: $(SSRC:s=bin) $(CSRC:c=bin) +encap: $(SSRC:s=v) $(CSRC:c=v) minixhd.v +bin: $(SSRC:s=bin) $(CSRC:c=bin) minixhd.bin MOBJ=monitor.o i86_funcs.o relocate.o help.o bzimage.o dosfs.o nofs.o MSRC=monitor.c i86_funcs.c relocate.c help.c bzimage.c dosfs.c nofs.c @@ -35,6 +35,9 @@ monitor: $(MSRC) minix.s: minix.c $(BCC) -Mc -S minix.c +minixhd.s: minix.c + $(BCC) -Mc -DHARDDISK -S minix.c -o minixhd.s + makeboot: makeboot.c sysboot.v skip.v msdos.v tarboot.v $(HOSTCC) $(HOSTCCFLAGS) -o makeboot makeboot.c @@ -62,7 +65,9 @@ distribution: .SUFFIXES: .bin .v .s.bin: - $(BCC) -c $*.s -A-b -A$*.bin -A-s -A$*.sym -A-l -A$*.lst + $(BCC) -c $*.s -A-u- -A-b -A/tmp/$*.bin -A-s -A$*.sym -A-l -A$*.lst + -@mv /tmp/$*.bin $*.bin + -@rm $*.o .s.v: as86_encap $*.s $*.v $*_ $(ASFLAGS) $(LST) diff --git a/bootblocks/README b/bootblocks/README index 5d2344b..e78097d 100644 --- a/bootblocks/README +++ b/bootblocks/README @@ -30,9 +30,7 @@ C:\> makeboot dos a: Place a Linux-8086 executable in the root directory of the floppy. $ make monitor.out -$ mount -t msdos /dev/fd0 /mnt -$ cp monitor.out /mnt/bootfile.sys -$ umount /dev/fd0 +$ mcopy monitor.out a:BOOTFILE.SYS or C:\> copy monitor.out a:\bootfile.sys @@ -80,10 +78,10 @@ Take 1 msdos floppy. $ makeboot dos /dev/fd0 $ mount -t msdos /dev/fd0 /mnt $ cp monitor.out /mnt/bootfile.sys -$ umount /dev/fd0 -$ cp /usr/src/linux/arch/i386/boot/bzImage /mnt/fd0/vmlinuz -$ echo 'root=/dev/ram ramdisk_file=ramdisk.gz mem=80M' > /mnt/fd0/vmlinuz.cmd -$ cp /archive/ramdisk.gz /mnt/fd0/ramdisk.gz + +$ cp /usr/src/linux/arch/i386/boot/bzImage /mnt/vmlinuz +$ echo 'root=/dev/ram ramdisk_file=ramdisk.gz mem=80M' > /mnt/vmlinuz.cmd +$ cp /archive/ramdisk.gz /mnt/ramdisk.gz $ umount /dev/fd0 The stuff about ramdisk is only if you want an init ramdisk. You can also use: diff --git a/bootblocks/dosfs.c b/bootblocks/dosfs.c index a545b28..9dba0af 100644 --- a/bootblocks/dosfs.c +++ b/bootblocks/dosfs.c @@ -54,6 +54,7 @@ struct filestatus { open_file(fname) char * fname; { + extern union REGS __argr; char conv_name[12]; char *s, *d; int i; diff --git a/bootblocks/makeboot.c b/bootblocks/makeboot.c index 28d7ded..0f07735 100644 --- a/bootblocks/makeboot.c +++ b/bootblocks/makeboot.c @@ -24,7 +24,7 @@ struct bblist { } bblocks[] = { { "tar", tarboot_data, FS_TAR, "Bootable GNU tar volume lable" }, { "dosfs", msdos_data, FS_ADOS, "Boots file BOOTFILE.SYS from dosfs" }, - { "bare", sysboot_data, FS_DOS, "Bare bootblock, lockup if booted" }, + { "none", sysboot_data, FS_DOS, "No OS bookblock, just message" }, { "skip", skip_data, FS_DOS, "Bypasses floppy boot with message" }, { "stat", 0, FS_STAT, "Display dosfs superblock" }, { "copy", 0, FS_STAT, "Copy boot block to makeboot.sav" }, diff --git a/bootblocks/mbr.s b/bootblocks/mbr.s index dd4cb27..f6a8048 100644 --- a/bootblocks/mbr.s +++ b/bootblocks/mbr.s @@ -8,7 +8,7 @@ ! Lowest available is $0500, MSDOS appears to use $0600 ... I wonder why? ORGADDR=$0500 -preboot=1 ! Include the pre-boot loader ? +preboot=0 ! Include the pre-boot loader ? ! Include standard layout org ORGADDR @@ -58,7 +58,7 @@ more_boot: jnc more_boot ! This doesn't retry, with a HD it shouldn't be bad. jc disk_error load_done: - call [di] + call di exec_done: pop bx endif @@ -70,6 +70,7 @@ exec_done: check_active: cmp byte [si],#$80 ! Flag for activated partition jz found_active +bad_boot: add si,#partition_2-partition_1 cmp si,#bootblock_magic jnz check_active @@ -83,6 +84,7 @@ found_active: mov cx,[si+2] ! cx = Sector & head encoded for int $13 ! bx is correct retry: + movb [$7DFE],#0 ! Clear magic for dosemu mov ax,#$0201 ! Read 1 sector int $13 ! Disk read. jnc sector_loaded @@ -101,7 +103,7 @@ disk_error: sector_loaded: mov di,#$7DFE ! End of sector loaded cmp [di],#$AA55 ! Check for magic - jnz check_active ! No? Try next partition. + jnz bad_boot ! No? Try next partition. mov bp,si ! LILO says some BBs use bp rather than si jmpi #$7C00,#0 ! Go! @@ -141,6 +143,8 @@ return: export pre_boot_table pre_boot_table: + ! Example: Load rest of H0,C0 into mem at $7C00 (8k). + ! .word $7C00, $7C00,$0002,$0000,$0210, $0000 .word return .word 0 endif diff --git a/bootblocks/minix.c b/bootblocks/minix.c index f6ba7b4..8242707 100644 --- a/bootblocks/minix.c +++ b/bootblocks/minix.c @@ -2,7 +2,7 @@ * This bootblock loads the linux-8086 executable in the file 'linux' * from the root directory of a minix filesystem. * - * Copyright (C) 1990-1996 Robert de Bath, distributed under the GPL Version 2 + * Copyright (C) 1990-1997 Robert de Bath, distributed under the GPL Version 2 * Based on minix filesystem definitions. */ @@ -16,36 +16,72 @@ #define BOOTSEG (0x07c0) #define LOADSEG (0x1000) +#ifdef HARDDISK +#define get_now() +#endif + #asm -BOOTSEG = 0x07c0 +! BOOTSEG = 0x07c0 +! LOADSEG = 0x1000 ! This must be sector aligned + BOOTADDR = 0x7c00 -LOADSEG = 0x1000 ! This must be sector aligned +ORGADDR = $0500 .text ! Apparently on startup the only things we can assume are that we start at -! `start` (ABS addr $07C00) ... +! `start` (ABS addr $07C00) and the boot sector is in the segment. ! So first set CS=DS=ES=SS=0 ! The we move this to $0500 and put the stack at the top of the first 64k. ! The directory 'file' is loaded $1500 and scanned there. ! The final executable will be loaded in the 2nd 64k chunk. ! -org $0500 ! The lowest available address. +org ORGADDR ! The lowest available address. start: include sysboot.s + +org dos_sysid + .ascii "MINIXFS BOOT (C) 1990-1997, Robert de Bath" + org codestart +#ifdef HARDDISK + mov bx,[si+8] ! Fetch the linear address of part from DS:SI + mov dh,[si+10] ! DL is drive number +#endif + xor ax,ax mov ds,ax mov es,ax mov ss,ax mov sp,ax +#ifndef HARDDISK mov ax,#$0204 ! Read 4 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 int $13 +#else + + mov cx,#$100 ! Move 256 words + mov si,#BOOTADDR ! From default BB + mov di,#ORGADDR ! To the correct address. + rep + movsw + + xchg dl,dh + mov [bootpart],bx ! Save the partition sector offset (and drive) + mov [bootpart+2],dx + + ! Read first 3 sectors of hd. + xor dx,dx + mov cx,#1 + mov bx,#ORGADDR+$200 + mov al,#3 + + call load_sect +#endif jmpi code,#0 @@ -214,15 +250,213 @@ _bootfile: ! 'boot' is good too. .ascii "linux" .byte 0,0,0,0,0,0,0,0,0 +#ifdef HARDDISK +bootpart: .long 0 +#else _loadcount: .word 0 _firstsect: .word 0 _loadaddr: .word 0 _lastsect: .word 0 +#endif code: call _loadprog call _runprog br _nogood + +#endasm + +#ifdef HARDDISK + +#asm +_load_block: + push bp + mov bp,sp + + ! Fetch load location + mov ax,[bp+4] + mov es,ax + + ! Test for block zero + mov ax,6[bp] + test ax,ax + jne real_block + + ! Iff block zero, zap memory + push di + mov cx,#512 + xor ax,ax + mov di,ax + rep + stosw + pop di + +func_exit: + mov sp,bp + pop bp + ret + +real_block: +#ifdef DOTS + mov ax,#$2E + push ax + call _bios_putc + inc sp + inc sp +#endif + +! Load a real block. + mov cx,ax + xor dx,dx + shl cx,#1 + rcl dx,#1 + + xor bx,bx + mov al,#2 + call load_sect + + j func_exit + +! +! Load AL sectors from linear sector DX:CX into location ES:BX +! Linear sector zero is a [bootpart] +! This loads one sector at a time, but that's OK cause even in the _very_ +! worst case it'll take no more that 5 seconds to load a 16 bit executable. +! +load_sect: + add cx,[bootpart] + adc dx,[bootpart+2] +moresect: + cmp al,#0 + jnz onesect + clc + ret + +! Load one sector... +onesect: + push ax ! Save lots + push di + push si + push cx ! Drive and sector. + push dx + + push es ! Load location + push bx + + push cx ! Drive and sector. + push dx + + ! Fetch drive 'shape' + mov ah,#8 + mov dl,dh + int $13 ! DX:CX = drive specification + jc _nogood + + and cx,#$3F ! Get sector count => DI + mov di,cx + + xor dl,dl ! Get head count => SI + xchg dl,dh + inc dx + mov si,dx + + pop dx ! Get back drive and sector + pop ax + + mov bl,dh ! Save drive + xor dh,dh + + div di ! DX=sector, AX=track number + mov cx,dx + inc cl ! CL=sector number + + xor dx,dx + div si ! DX=head, AX=cylinder + + mov dh,dl + mov dl,bl ! DX for int 1302 + + xchg al,ah + ror al,#1 + ror al,#1 + or cx,ax ! CX for int 1302 + + pop bx ! ES:BX for int 1302 + pop es + + mov ax,#$0201 + int $13 + jc _nogood + + pop dx + pop cx + pop si + pop di + pop ax + + dec al + add cx,#1 + adc dh,#0 + add bh,#2 + jmp moresect +#endasm + +#else +#asm +_set_bpb: +bios_tabl=dosfs_stat ! Temp space. +bios_disk=dosfs_stat+4 ! + +#ifndef __CALLER_SAVES__ + push si + push di +#endif + + mov di,#bios_disk + mov bx,#0x78 +! 0:bx is parameter table address + + push ds + push di + + mov si,[bx] + mov ax,[bx+2] + mov [bios_tabl],si + mov [bios_tabl+2],ax + push ax + + pop ds +! ds:si is source + +! copy 12 bytes + mov cl,#6 + cld + rep + movsw + + pop di + pop ds + mov ax,[_n_sectors] + movb 4[di],al ! patch sector count + + mov [bx],di + mov 2[bx],es + +#ifndef __CALLER_SAVES__ + pop si + pop di +#endif + ret + +_unset_bpb: +! 0:0x78 is parameter table address + + mov ax,[bios_tabl] + mov [0x78],ax + mov ax,[bios_tabl+2] + mov [0x78+2],ax + ret + #endasm static @@ -314,11 +548,7 @@ zero_block(address) #endasm } -#ifndef load_zone -NOT_DEFINED_load_zone(address, zoneno) -{ -} -#endif +#endif /* !HARDDISK */ #ifdef DOTS static @@ -339,6 +569,27 @@ bios_putc(c) static nogood() { +#ifdef HARDDISK +#asm + mov si,#fail_fs +min_nextc: + lodsb + cmp al,#0 + jz min_eos + mov bx,#7 + mov ah,#$E ! Can't use $13 cause that's AT+ only! + int $10 + jmp 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! + +fail_fs: + .asciz "Inital boot failed, press return to reboot\r\n" +#endasm +#else /* This didn't work, chain the boot sector of the HD */ #asm push cs @@ -352,16 +603,20 @@ hcode: jc hcode ! Keep trying forever! jmpi BOOTADDR,0 #endasm +#endif } +/****************************************************************************/ #asm end_of_part1: if *>start+0x200 - fail + fail! Part 1 too large! endif .blkb 0x200+start-* #endasm +/****************************************************************************/ + static loadprog() { @@ -372,6 +627,10 @@ loadprog() n_sectors = b_super.s_nzones / 80; if( n_sectors < 5 ) n_sectors = b_super.s_nzones / 40; +#ifndef HARDDISK + set_bpb(); +#endif + try_again:; #ifdef zone_shift if( zone_shift != b_super.s_log_zone_size) nogood(); @@ -459,6 +718,9 @@ register char * p = dirptr->d_name; } nogood(); } +#ifndef HARDDISK + unset_bpb(); +#endif } static @@ -466,8 +728,14 @@ runprog() { /* This did work, run the loaded executable */ #asm +#ifdef HARDDISK + mov dx,[bootpart+2] + xchg dh,dl ! DX => hard drive + push [bootpart] ! CX => partition offset +#else xor dx,dx ! DX=0 => floppy drive push dx ! CX=0 => partition offset = 0 +#endif mov si,[_n_sectors] ! Save for monitor.out mov bx,#LOADSEG @@ -477,7 +745,7 @@ runprog() xor di,di ! Zero mov ax,[di] cmp ax,#0x0301 ! Right magic ? - bne nogood ! Yuk ... + bne _nogood ! Yuk ... mov ax,[di+2] and ax,#$20 ! Is it split I/D ? jz impure ! No ... @@ -509,6 +777,13 @@ idiv_u: xor dx,dx div bx ret +#ifndef zone_shift +isl: +islu: + mov cl,bl + shl ax,cl + ret +#endif libend: vars: diff --git a/bootblocks/monitor.c b/bootblocks/monitor.c index b9cc751..dbf2d64 100644 --- a/bootblocks/monitor.c +++ b/bootblocks/monitor.c @@ -9,7 +9,7 @@ #include "readfs.h" #ifdef __STANDALONE__ -#define VT52COLOUR +#define NOT_VT52COLOUR #define NOT_ANSICOLOUR #endif @@ -27,6 +27,9 @@ extern struct t_cmd_list { static unsigned int current_address; static int number_base = 16; +#ifdef __STANDALONE__ + extern union REGS __argr; +#endif #ifdef __STANDALONE__ main() @@ -48,22 +51,17 @@ static char minibuf[2] = " "; #endif init_prog(); - -#if 0 #ifdef __STANDALONE__ - reg_line(); -#endif -#ifdef VT52COLOUR - colour_line(); -#endif + if( (__argr.x.dx & 0xFF) == 0 ) #endif + { + display_help(0); - display_help(0); - - if(1) /* ( x86 > 2 && !x86_emu ) /* Check some basics */ - cmd_bzimage((void*)0); - else - printf("System appears incompatible use '=' <return> to try anyway\n"); + if( x86 > 2 && !x86_emu ) /* Check some basics */ + cmd_bzimage((void*)0); + else + printf("System is not a 386+ in real mode, load aborted.\nUse 'bzimage' command toattempt load.\n"); + } for (;;) { @@ -175,7 +173,6 @@ void init_prog() #ifdef __STANDALONE__ reg_line() { - extern union REGS __argr; printf("REGS: AX=%04x BX=%04x CX=%04x DX=%04x SI=%04x DI=%04x\n", __argr.x.ax, __argr.x.bx, __argr.x.cx, __argr.x.dx, __argr.x.si, __argr.x.di); diff --git a/bootblocks/sysboot.s b/bootblocks/sysboot.s index 54b0fb2..3bc7c57 100644 --- a/bootblocks/sysboot.s +++ b/bootblocks/sysboot.s @@ -45,10 +45,37 @@ dos4_serial: .blkw 2 ! Serial number dos4_label: .blkb 11 ! Disk Label (DOS 4+) dos4_fattype: .blkb 8 ! FAT type +! +! This is where the code will be overlaid, the default is an 'oops' .blkb sysboot_start+0x3E-* public codestart codestart: - jmp codestart + xor ax,ax + mov ds,ax + mov es,ax + mov ss,ax + mov sp,ax + jmpi sys_code+$7C00-sysboot_start,#0 + +sys_code: ! SI now has pointer to error message + mov si,#sys_no_os+$7C00-sysboot_start +sys_nextc: + lodsb + cmp al,#0 + jz sys_eos + mov bx,#7 + mov ah,#$E ! Can't use $13 cause that's AT+ only! + int $10 + jmp sys_nextc +sys_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! + +sys_no_os: + .asciz "PANIC! NO OS Found!\r\n" + ! Partition table public partition_1 |