summaryrefslogtreecommitdiff
path: root/bootblocks
diff options
context:
space:
mode:
authorRobert de Bath <rdebath@poboxes.com>1999-12-17 19:06:32 +0100
committerLubomir Rintel <lkundrak@v3.sk>2013-10-23 23:43:38 +0200
commit3401185106fb312c6a7bba3d9e90d44b6df0043b (patch)
tree63bace6fae9b547cc0c939c6803185cc3ad8aa0e /bootblocks
parent3d4957c86ff239b24b43933924ec72a3fd288518 (diff)
downloaddev86-3401185106fb312c6a7bba3d9e90d44b6df0043b.tar.gz
Import Dev86src-0.15.0.tar.gzv0.15.0
Diffstat (limited to 'bootblocks')
-rw-r--r--bootblocks/Makefile4
-rw-r--r--bootblocks/README3
-rw-r--r--bootblocks/bootlist.s257
-rw-r--r--bootblocks/bzimage.c21
-rw-r--r--bootblocks/monitor.c10
-rw-r--r--bootblocks/msdos.s18
6 files changed, 26 insertions, 287 deletions
diff --git a/bootblocks/Makefile b/bootblocks/Makefile
index bf081ba..96dfadf 100644
--- a/bootblocks/Makefile
+++ b/bootblocks/Makefile
@@ -17,9 +17,7 @@ default: makeboot makeboot.com monitor.out minix_elks.bin
all: default tgz bin minix_elks.bin
CSRC=minix.c
-SSRC=sysboot.s \
- tarboot.s skip.s com_bcc.s tich.s \
- bootlist.s mbr.s msdos.s noboot.s
+SSRC=sysboot.s tarboot.s skip.s com_bcc.s tich.s mbr.s msdos.s noboot.s
encap: $(SSRC:s=v) $(CSRC:c=v) minixhd.v msdos16.v
bin: $(SSRC:s=bin) $(CSRC:c=bin) minixhd.bin msdos16.bin
diff --git a/bootblocks/README b/bootblocks/README
index f51bcd3..80a447e 100644
--- a/bootblocks/README
+++ b/bootblocks/README
@@ -120,7 +120,8 @@ 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, Minix or Tar floppy.
+ 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.
diff --git a/bootblocks/bootlist.s b/bootblocks/bootlist.s
deleted file mode 100644
index a9c603c..0000000
--- a/bootblocks/bootlist.s
+++ /dev/null
@@ -1,257 +0,0 @@
-! This bootsector is modified by the installer to have a list of sectors at
-! offset 256.
-
-! Table format is a list of dwords. Each dword has a partition offest in
-! the low 24 bits and a count in the high.
-!
-! Prob better to make it: HH DD MM LL rather than DD HH MM LL
-! as this matches the BIOS better
-!
-! Note:
-! Stack top is at abs location 64k.
-!
-
-! PS: This hasn't been tested much ... make that at all!
-
-BOOTSEG = 0x07c0
-LOADSEG = 0x07e0 ! Just after boot sector.
-
-public linear
-linear = 1 ! Is linear processing done ? (0 doesn't work)
-public floppy
-floppy = 0 *linear ! Allow for floppy drive ? (don't work)
-public reloc
-reloc = 1 *linear ! Auto configure of bootpart.
-
-macro locn
- if *-start>?1
- fail! ?1
- endif
- .blkb ?1 + start-*
-mend
-
-use16
-entry start
-
-org $7b00
-
-! temporary space
-
-n_cyl: .blkw 1
-n_secs: .blkw 1
-t_drive: .blkb 1
-t_sector: .blkb 1
-t_secs: .blkw 1
-
-org $7c00
-start:
- j code
-
-runit:
- jmpi 0,0 ! This instruction is altered by the installer
-
-public execaddr ! Via this label.
-execaddr = *-4
-
-public bootpart
-bootpart:
- .data4 0x80000011
-code:
-
- if reloc
- mov cx,[si+8] ! Fetch the linear address of part from DS:SI
- mov dh,[si+10] ! DL is drive number
- xchg dl,dh ! Into normal form.
- endif
-
- xor ax,ax
- mov ds,ax
- mov ss,ax
- mov sp,ax
-
- if reloc
- mov [bootpart],cx
- mov [bootpart+2],dx
- endif
-
-! ASSUME ds=ss= 0 (cs should also be zero)
-
- mov ax,#LOADSEG
- mov es,ax
-
- mov si,#table
-load_addrs:
- cld
-
- if linear
- lodsw
- mov cx,ax
- add cx,[bootpart]
- lodsw
- mov dx,[bootpart+2]
- adc dl,al
- mov al,ah
- else
- lodsw ; XXX Broken, doesn't set AL correctly.
- mov cx,ax
- lodsw
- mov dx,ax
- lodsb
- endif
-
- test al,al
- jz runit
-
-loadem:
- xor bx,bx
- push ax
- call cread
- jc failed
- pop ax
- mov cl,#5
- sal ax,cl
- mov bx,es
- add ax,bx
- mov es,ax
- j load_addrs
-
-! Humm, something goes wrong, not much we can do ...
-! Let`s squeak then try again
-failed:
- mov ax,#$0E45
- mov bx,#7
- int $10
- pop ax
-
- j loadem
-
-cread:
- ! This function is like BIOS 1302 but it`s linear.
- ! It's taken, almost, intact from LILO.
-
- ! DH is drive, DL:CX is linear address, AL is count.
- ! ES:BX is load address, beware of DMA limitations
-
- ! All registers except AX and flags are preserved.
-
- mov t_secs,al ! save number of sectors
-lnread: push cx ! keep linear address
- push dx
- xchg dl,dh
-
- if linear
- if floppy
- test dl,#0x80 ! Floppy is physical only.
- jz lrd
- endif
-
- push bx ! BX is used as scratch
- push cx ! LSW
- push dx ! MSW with drive
- mov ah,#8 ! get drive geometry (do not clobber ES:DI)
- push es
- push di
- int 0x13
- pop di
- pop es
- mov bl,dh ! BL <- #heads
- pop dx ! get MSW
-
- jnc int_ok ! error -> quit
-
- pop cx ! discard stack contents
- pop bx
- pop dx
- pop cx
- ret ! (carry is already set)
-int_ok:
- mov t_drive,dl ! save drive
- mov dl,dh ! linear address into DX:AX
- xor dh,dh
- mov bh,dh ! (clear BH too)
- pop ax
- push cx ! compute #cyls-1
- xchg ch,cl
- rol ch,1
- rol ch,1
- and ch,#3
- mov n_cyl,cx ! save #cyls-1
- pop cx
- and cx,#0x3f ! CX <- #secs
- mov n_secs,cx
- div cx ! AX <- track, DX <- sector
- inc dl
- mov t_sector,dl
- xor dx,dx ! divide by #heads
- inc bx
- div bx ! AX <- cylinder, DX <- head
- mov dh,dl ! set up DX (head:drive)
- mov dl,t_drive
- cmp ax,n_cyl ! valid cylinder number ?
- ja linerr3 ! no -> error
- xchg ah,al ! build cylinder number
- ror al,1
- ror al,1
- or al,t_sector
- mov cx,ax
- pop bx ! restore BX
- and ax,#0x3f ! read beyond end of track ?
- add ax,t_secs
- cmp ax,n_secs
- jna intrk ! no -> go on
- mov al,n_secs ! read to end of track
- sub al,t_sector
- inc al
- jmp lrd ! read it
-intrk: mov al,t_secs ! read all sectors
-
- endif
-
-lrd: push ax ! save AX and BX
- push bx
-
- mov ah,#2 !
- int 0x13 ! read sectors
-
- pop bx ! restore AX and BX and the linear address
- pop ax
- pop dx
- pop cx
-
- if linear
-
- jc linerr ! error -> quit
- sub t_secs,al ! adjust sector count
- jz lindone ! zero -> done
- xor ah,ah ! increase linear address
- add cx,ax
- adc dh,#0
- xchg ah,al ! move BX
- add ah,ah
- add bx,ax
- jc interr ! crossing segment boundaries -> error
- br lnread ! process remaining sectors
-
-linerr3:pop bx ! pop BX and linear address
- pop dx
- pop cx
-interr: xor ax,ax ! zero indicates internal error
-
- else
- jnc lindone
- endif
-
-linerr: stc ! error
- ret
-lindone:clc ! no error
- ret ! done
-
-
-!-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
-
-public table
-table:
-! .long 0x80000012
-! .byte 1
-! .long 0x07e00000
-! .byte 0
diff --git a/bootblocks/bzimage.c b/bootblocks/bzimage.c
index 89d5ef1..7711f41 100644
--- a/bootblocks/bzimage.c
+++ b/bootblocks/bzimage.c
@@ -480,15 +480,15 @@ char * iname;
return strdup(buffer);
}
-build_linuxarg(image, cmd)
-char *image, *cmd;
+build_linuxarg(image, inp)
+char *image, *inp;
{
static char * auto_str = "auto";
static char * image_str = "BOOT_IMAGE=";
int len = 0;
char * ptr, *s, *d;
- char * free_cmd = 0;
- char * free_inp = 0, * inp = 0;
+ char * free_cmd = 0, * cmd = 0;
+ char * free_inp = 0;
image_name = strdup(image);
@@ -498,12 +498,7 @@ static char * image_str = "BOOT_IMAGE=";
if( cmd == 0 )
cmd = free_cmd = read_cmdfile(image);
- if( cmd == 0 )
- {
- if( auto_flag ) return 0;
- printf("No such command file\n");
- return -1;
- }
+ if( cmd == 0 && auto_flag ) return 0;
if( auto_flag )
{
@@ -515,6 +510,8 @@ static char * image_str = "BOOT_IMAGE=";
}
free(ptr);
}
+ else if( inp == 0 )
+ inp = free_inp = input_cmd(image);
if( auto_flag ) len += strlen(auto_str) + 1;
if( image ) len += strlen(image_str) + strlen(image) + 1;
@@ -645,8 +642,8 @@ unsigned int k_top;
char buf[2];
fname++;
close_file();
- printf("Insert root floppy and press return:"); fflush(stdout);
- read(0, buf, 2);
+ printf("Insert root disk and press return:"); fflush(stdout);
+ if( read(0, buf, 2) <=0 ) return -1;
}
if( open_file(fname) < 0 )
diff --git a/bootblocks/monitor.c b/bootblocks/monitor.c
index 1ba93ec..2e47da8 100644
--- a/bootblocks/monitor.c
+++ b/bootblocks/monitor.c
@@ -47,16 +47,14 @@ static char minibuf[2] = " ";
}
#endif
- if( (__argr.x.dx & 0xFF) == 0 )
+ disk_drive = __argr.h.dl;
#endif
- {
#ifdef NOCOMMAND
- cmd_type("help.txt");
+ cmd_type("help.txt");
#else
- display_help(0);
+ display_help(0);
#endif
- cmd_bzimage((void*)0);
- }
+ cmd_bzimage((void*)0);
#ifdef NOCOMMAND
printf("Unable to boot, sorry\nreboot:");
diff --git a/bootblocks/msdos.s b/bootblocks/msdos.s
index 7f691ff..f291b6b 100644
--- a/bootblocks/msdos.s
+++ b/bootblocks/msdos.s
@@ -18,6 +18,12 @@
! 3) The value of the hidden sectors field must be zero
!
! All these are true for mtools created floppies on normal PC drives.
+!
+! In addition this now has a compile time option for 16 bit FAT floppies
+! TODO: Hard partition (dos_hidden != 0)
+! Zip disks (floppy with dos_hidden != 0)
+! Auto detect disk type
+!
!---------------------------------------------------------------------------
ORGADDR=$0500
@@ -29,12 +35,7 @@ export fatbits
fatbits=12 ! Set to 12 or 16 (16 for LS-120 disks)
export heads
-
-if fatbits =12
-heads=2 ! This can be 0,1 or 2. 0 is dynamic.
-else
heads=0 ! This can be 0,1 or 2. 0 is dynamic.
-endif
!---------------------------------------------------------------------------
! Absolute position macro, fails if code before it is too big.
@@ -90,7 +91,6 @@ cont:
xor dh,dh
mul dx
add ax,[dos_resv]
- ! Assume: dos_hidden == 0
mov di,ax
! DI is sector number of first root dir sector.
@@ -160,10 +160,12 @@ linsect:
linsect1:
xor dx,dx
linsect2:
+ ! Add partition offset in.
if fatbits =16
- add ax,[dos_hidden]
- adc dx,[dos_hidden+2]
+ add ax,[dos_hidden]
+ adc dx,[dos_hidden+2]
endif
+
div [dos_spt]
inc dx
mov cl,dl ! Sector num