diff options
author | Robert de Bath <rdebath@poboxes.com> | 1996-12-01 16:58:31 +0100 |
---|---|---|
committer | Lubomir Rintel <lkundrak@v3.sk> | 2013-10-23 23:34:16 +0200 |
commit | f8de35da65c5d93bb733073cf40da154bc1c0748 (patch) | |
tree | d28c7644739a24402376d24cb0020ea410a9ccff /bootblocks | |
parent | c218c617b5be443b7968308506969ad2b726d73c (diff) | |
download | dev86-f8de35da65c5d93bb733073cf40da154bc1c0748.tar.gz |
Import Dev86src-0.0.9.tar.gzv0.0.9
Diffstat (limited to 'bootblocks')
-rw-r--r-- | bootblocks/Makefile | 11 | ||||
-rw-r--r-- | bootblocks/bootlist.s | 4 | ||||
-rw-r--r-- | bootblocks/com_bcc.s | 2 | ||||
-rw-r--r-- | bootblocks/dosboot.c | 72 | ||||
-rw-r--r-- | bootblocks/mbr.s | 153 | ||||
-rw-r--r-- | bootblocks/msdos.s | 253 | ||||
-rw-r--r-- | bootblocks/relocate.c | 1 | ||||
-rw-r--r-- | bootblocks/skip.s | 83 | ||||
-rw-r--r-- | bootblocks/standalone.c | 309 | ||||
-rw-r--r-- | bootblocks/sysboot.s | 43 | ||||
-rw-r--r-- | bootblocks/tarboot.s | 2 | ||||
-rw-r--r-- | bootblocks/tiny.s | 55 |
12 files changed, 598 insertions, 390 deletions
diff --git a/bootblocks/Makefile b/bootblocks/Makefile index 0ed6e1d..9a4ccd9 100644 --- a/bootblocks/Makefile +++ b/bootblocks/Makefile @@ -14,7 +14,7 @@ nothing: all: makeboot monitor.out bin CSRC=minix.c -SSRC=tarboot.s tiny.s com_bcc.s tich.s sysboot.s bootlist.s +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) @@ -39,13 +39,16 @@ minix.s: minix.c makeboot: tarboot.v sysboot.v makeboot.c $(HOSTCC) $(HOSTCCFLAGS) -o makeboot makeboot.c +dosboot: dosboot.c sysboot.v skip.v msdos.v + $(HOSTCC) $(HOSTCCFLAGS) -o dosboot dosboot.c + clean: - rm -f monitor makeboot minix.s *.o *.bin *.out *.lst *.sym *.v + rm -f monitor makeboot dosboot minix.s *.o *.bin *.out *.lst *.sym *.v tgz: minix.bin monitor.out makeboot tar cfV bootblocks.tar ENIAC monitor.out \ README Makefile \ - $(MSRC) standalone.c makeboot.c \ + $(MSRC) dosboot.c makeboot.c \ $(CSRC) $(SSRC) \ makeboot minix.bin makeboot bootblocks.tar @@ -53,7 +56,7 @@ tgz: minix.bin monitor.out makeboot distribution: tar czf /tmp/bootblocks.tar.gz README Makefile \ - $(MSRC) standalone.c makeboot.c \ + $(MSRC) dosboot.c makeboot.c \ $(CSRC) $(SSRC) .SUFFIXES: .bin .v diff --git a/bootblocks/bootlist.s b/bootblocks/bootlist.s index 889842a..9230796 100644 --- a/bootblocks/bootlist.s +++ b/bootblocks/bootlist.s @@ -11,6 +11,8 @@ ! 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. @@ -24,7 +26,7 @@ reloc = 1 *linear ! Auto configure of bootpart. macro locn if *-start>?1 - fail + fail! ?1 endif .blkb ?1 + start-* mend diff --git a/bootblocks/com_bcc.s b/bootblocks/com_bcc.s index 26daff3..061575f 100644 --- a/bootblocks/com_bcc.s +++ b/bootblocks/com_bcc.s @@ -46,7 +46,7 @@ impure: ! ax is now offset 'tween CS&DS ! Check for overlap end_of_code: if end_of_code>hitme - fail + fail! At end_of_code endif .org ((ENDOFF)<<4)-1 diff --git a/bootblocks/dosboot.c b/bootblocks/dosboot.c new file mode 100644 index 0000000..72b8d25 --- /dev/null +++ b/bootblocks/dosboot.c @@ -0,0 +1,72 @@ + +#include <stdio.h> + +#include "sysboot.v" +#include "msdos.v" +#include "skip.v" + +char buffer[512]; + +struct bblist { + char * name; + char * data; + char * desc; +} bblocks[] = { + { "bare", sysboot_data, "Bare bootblock, lockup if booted" }, + { "dosfs", msdos_data, "Boots file BOOTFILE.SYS from dosfs" }, + { "skip", skip_data, "Bypasses floppy boot with message" }, + 0 +}; + +char * progname = ""; + +main(argc, argv) +int argc; +char ** argv; +{ + FILE * fd; + struct bblist *ptr = bblocks; + int i; + + progname = argv[0]; + + if( argc != 3 ) Usage(); + + for(;ptr->name; ptr++) if( strcmp(argv[1], ptr->name) == 0 ) break; + if( ptr->name == 0 ) Usage(); + + fd = fopen(argv[2], "r+"); + if( fd == 0 ) + { + fprintf(stderr, "Cannot open %s\n", argv[2]); + exit(1); + } + if( fread(buffer, 512, 1, fd) != 1 ) + { + fprintf(stderr, "Cannot read boot block\n"); + exit(1); + } + for(i=0; i<sysboot_dosfs_stat; i++) + buffer[i] = ptr->data[i]; + for(i=sysboot_codestart; i<512; i++) + buffer[i] = ptr->data[i]; + + rewind(fd); + if( fwrite(buffer, 512, 1, fd) != 1 ) + { + fprintf(stderr, "Cannot write boot block\n"); + exit(1); + } + fclose(fd); +} + +Usage() +{ + struct bblist *ptr = bblocks; + + fprintf(stderr, "Usage: %s bootname /dev/fd0\n", progname); + fprintf(stderr, "Blocks\n"); + for(;ptr->name; ptr++) + fprintf(stderr, "\t%s\t%s\n", ptr->name, ptr->desc); + exit(1); +} diff --git a/bootblocks/mbr.s b/bootblocks/mbr.s new file mode 100644 index 0000000..e190be2 --- /dev/null +++ b/bootblocks/mbr.s @@ -0,0 +1,153 @@ +! +! 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 +! (of 8 extents) before the boot blocks are checked. +! + +! Lowest available is $0500, MSDOS appears to use $0600 ... I wonder why? +ORGADDR=$0500 +preboot=1 ! Include the pre-boot loader ? + +! Include standard layout +org ORGADDR +include sysboot.s + +org ORGADDR+$7 +.ascii "ELKS MBR Copyright 1996, Robert de Bath" + +! Start after dos fsstat data, not strictly required. +org codestart + cli ! Assume _nothing_! + cld + mov bx,#$7C00 ! Pointer to start of BB. + xor ax,ax ! Segs all to zero + mov ds,ax + mov es,ax + mov ss,ax + mov sp,bx ! SP Just below BB + mov cx,#$100 ! Move 256 words + mov si,bx ! From default BB + mov di,#ORGADDR ! To the correct address. + rep + movsw + jmpi cont,#0 ! Set CS:IP correct. +cont: + sti ! Let the interrupts back in. + +! +! Next check for a pre-boot load. + + if preboot + push bx + mov si,#pre_boot_table + lodsw + mov di,ax ! First word is execute address +more_boot: + lodsw + test ax,ax + jz load_done + mov bx,ax ! word 1 address + lodsw + mov cx,ax ! word 2 CX, head/sector + lodsw + mov dx,ax ! word 3 DX, drive, cylinder + lodsw ! word 4 AX, $02, sector count + int $13 + jnc more_boot ! This doesn't retry, with a HD it shouldn't be bad. + jc disk_error +load_done: + call [di] +exec_done: + pop bx + endif + +! Now check the partition table, must use SI as pointer cause that's what the +! partition boot blocks expect. + + mov si,#partition_1 +check_active: + cmp byte [si],#$80 ! Flag for activated partition + jz found_active + add si,#partition_2-partition_1 + cmp si,#bootblock_magic + jnz check_active + + mov si,#no_bootpart ! Message & boot + jmp no_boot + +found_active: + 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 +retry: + mov ax,#$0201 ! Read 1 sector + int $13 ! Disk read. + jnc sector_loaded + +! Error, reset and retry + xor ax,ax + int $13 ! Disk reset + + dec di + jnz retry ! Try again + +disk_error: + mov si,#disk_read_error + jmp no_boot ! Sorry it ain't gonna work. + +sector_loaded: + mov di,#$7DFE ! End of sector loaded + cmp [di],#$AA55 ! Check for magic + jnz check_active ! No? Try next partition. + + mov bp,si ! LILO says some BBs use bp rather than si + jmpi #$7C00,#0 ! Go! + +! Fatal errors ........... +no_boot: ! SI now has pointer to error message + lodsb + cmp al,#0 + jz EOS + mov bx,#7 + mov ah,#$E ! Can't use $13 cause that's AT+ only! + int $10 + jmp no_boot +EOS: + cmp si,#press_end ! After msg output 'press key' message + jz keyboot + mov si,#press_key + jmp no_boot + +keyboot: ! 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! + +no_bootpart: + .asciz "No bootable partition" +disk_read_error: + .asciz "Error loading system" +press_key: + .asciz "\r\nPress a key to reboot" +press_end: + + if preboot +return: + ret + +export pre_boot_table +pre_boot_table: + .word return + .word 0 + endif + +! Now make sure this isn't to big! + if *>partition_1 + fail! Partition overlap + endif + +!THE END diff --git a/bootblocks/msdos.s b/bootblocks/msdos.s new file mode 100644 index 0000000..1e71f31 --- /dev/null +++ b/bootblocks/msdos.s @@ -0,0 +1,253 @@ +! +! This is a bootblock to load an execute a standalone program from an +! MSDOS filesystem on a floppy disk. +! +! The program is divided into two parts, the first 512 bytes contains a +! loader to fetch one block from a file called 'BOOTFILE.SYS' from the +! root directory of the disk. The second 512, which is stored in this file, +! loads the executable using functions supplied by the first. +! +! The 2nd part is loaded as if it's a floppy boot block and can be used to +! store, for instance, a LILO boot block to let LILO boot from an MSDOS +! floppy. +! +! The second part is NOT yet complete! +! +ORGADDR=$0500 + +use16 + +! Absolute position macro, fails if code before it is too big. +macro locn + if *-start>?1 + fail! *-start>?1 + endif + .blkb ?1 + start-* +mend + +org ORGADDR +start: +include sysboot.s + +! Data into the temp area, 30 clear bytes +org floppy_temp +root_count: .blkw 1 +old_bpb: .blkw 2 +bios_disk: .blkb 12 + + locn(codestart-start) + + cld ! Assume _nothing_! + mov bx,#$7C00 ! Pointer to start of BB. + xor ax,ax ! Segs all to zero + mov ds,ax + mov es,ax + mov ss,ax + mov sp,bx ! SP Just below BB + mov cx,#$100 ! Move 256 words + mov si,bx ! From default BB + mov di,#ORGADDR ! To the correct address. + rep + movsw + jmpi cont,#0 ! Set CS:IP correct. +cont: + sti ! Let the interrupts back in. + +! Need to fix BPB for fd0 to correct sectors (Like linux bootblock does) + mov di,#bios_disk + mov bp,#0x78 +! 0:bx is parameter table address + push ds + lds si,[bp] + +! ds:si is source + + mov cx,#6 +! copy 12 bytes + push di + rep + movsw + pop di + pop ds + +! New BPB is 0:di + mov [bp],di + mov 2[bp],ax + + mov al,[dos_spt] + mov 4[di],al + +! For each sector in root dir +! For each dir entry +! If entry name is == boot_name +! then load and call sector + + ! First dir = dos_fatlen*dos_nfat+dos_resv + mov ax,[dos_fatlen] + mov dl,[dos_nfat] + xor dh,dh + mul dx + add ax,[dos_resv] + mov di,ax + ! DI is sector number of first root dir sector. + + mov ax,[dos_nroot] + mov [root_count],ax + add ax,#15 + mov cl,#4 + shr ax,cl + add ax,di + mov bp,ax ! bp is first data sector. + +nextsect: + call linsect + mov ax,#$0201 + int $13 + jc floppy_error + +! ... foreach dir entry + mov si,bx +nextentry: + +! test entry name + push si + push di + mov di,#boot_name + mov cx,#11 + rep + cmpsb + pop di + pop si + je got_entry + + add si,#32 + cmp si,#512 + jnz nextentry + + inc di + sub [root_count],#16 + jp nextsect + jmp no_system + +got_entry: + mov ax,[si+26] ! Cluster number of start of file + test ax,ax + jz no_system ! Make sure we have a block. + + mov di,ax ! Save the cluster number we are loading. + call linclust + + mov ax,#$0201 + int $13 + jc floppy_error + + mov bx,#7 + mov ax,#$0E3E + int $10 + + jmpi $7C00,0 ! No magics, just go. + +! Convert a cluster number into a CHS in CX:DX +linclust: + sub ax,#2 + mov dl,[dos_clust] + xor dh,dh + mul dx + add ax,bp + mov di,ax + ! JMP linsect ... + +! +! This function converts a linear sector number in DI +! into a CHS representation in CX:DX +! +linsect: + xor dx,dx + mov ax,di + div [dos_spt] + inc dx + mov cl,dl ! Sector num + xor dx,dx ! Drive 0 + shr ax,#1 ! Assume dos_heads == 2 + adc dh,#0 ! Head num + mov ch,al ! Cylinder + ret + +no_system: +floppy_error: + + mov si,#error_msg +no_boot: ! SI now has pointer to error message + lodsb + cmp al,#0 + jz EOS + mov bx,#7 + mov ah,#$E ! Can't use $13 cause that's AT+ only! + int $10 + jmp no_boot +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! + +error_msg: + .asciz "\r\nError during initial boot\r\nPress a key:" + +export boot_name +boot_name: + .ascii "BOOTFILESYS" +name_end: +! NNNNNNNNEEE +! +!-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- +! +! Part 2, loaded like a boot block by part 1 +! ... Here we will allow some assumptions (cause we've set them) +fat_table = ORGADDR+$400 ! Where to load the fat + +locn(512) +part2_addr: + push di + mov cx,#$100 ! Move 256 words + mov si,#$7C00 ! From default BB + mov di,#part2_addr ! To the correct address. + rep + movsw + jmpi cont2,#0 ! Set CS:IP correct. +cont2: + +! 1) Load FAT + ! This assumes all of FAT1 is on the first track, this is normal + mov ax,[dos_fatlen] + mov ah,#2 + mov bx,#fat_table + mov cx,[dos_resv] ! Fat starts past bootblock + inc cx + xor dx,dx ! Head zero + int $13 + !jc floppy_error + + mov bx,#$7C00 + pop di ! Cluster to start load. + + ! load whole cluster +next_cluster: + + + call next_fat + cmp di,#0 + jnz next_cluster + br maincode + +next_fat: + !mov ax,di + !mov bx,ax + !shr ax,#1 + !add bx,ax + + +! The end ... place a marker. +locn(1023) + .byte $FF +maincode: diff --git a/bootblocks/relocate.c b/bootblocks/relocate.c index 121699e..37396a1 100644 --- a/bootblocks/relocate.c +++ b/bootblocks/relocate.c @@ -58,6 +58,7 @@ unsigned newseg; /* The actual jump ... */ memseg = newseg; + #asm mov ax,ds mov bx,cs diff --git a/bootblocks/skip.s b/bootblocks/skip.s new file mode 100644 index 0000000..8de5ada --- /dev/null +++ b/bootblocks/skip.s @@ -0,0 +1,83 @@ +! +! This floppy bootblock bypasses the floppy boot ... +! + +BOOTDISK = 0x80 +ORGADDR = $0600 + +use16 +org ORGADDR +start: +include sysboot.s + +org codestart + cli ! Assume _nothing_! + cld + mov bx,#$7C00 ! Pointer to start of BB. + xor ax,ax ! Segs all to zero + mov ds,ax + mov es,ax + mov ss,ax + mov sp,bx ! SP Just below BB + mov cx,#$100 ! Move 256 words + mov si,bx ! From default BB + mov di,#ORGADDR ! To the correct address. + rep + movsw + jmpi cont,#0 ! Set CS:IP correct. +cont: + sti ! Let the interrupts back in. + + mov si,#mesg + call prtmsg + + mov di,#5 +hcode: + mov ax,#$0201 ! Read 1 sector + mov cx,#$0001 ! From sector 1 + mov dx,#BOOTDISK ! Of the hard drive head zero + int $13 + jc error + jmpi $7c00,0 + +error: + mov si,#mesg2 + call prtmsg + + dec di + jz reboot + + mov si,#mesg3 + call prtmsg + jmp hcode + + if BOOTDISK = 0x80 +mesg: .asciz "Bypassing floppy boot\r\n" + else +mesg: .asciz "Booting drive two\r\n" + endif + +mesg2: .asciz "Disk error\r\n" +mesg3: .asciz "Retrying\r\n" +mesg4: .asciz "Press a key:" + +prtmsg: + lodsb + cmp al,#0 + jz EOS + mov bx,#7 + mov ah,#$E ! Can't use $13 cause that's AT+ only! + int $10 + jmp prtmsg +EOS: + ret + +reboot: + mov si,#mesg4 + call prtmsg + + xor ax,ax + int $16 + int $19 ! This should be OK as we haven't touched anything. + jmpi $0,$FFFF ! Wam! Try or die! + diff --git a/bootblocks/standalone.c b/bootblocks/standalone.c deleted file mode 100644 index 57634d4..0000000 --- a/bootblocks/standalone.c +++ /dev/null @@ -1,309 +0,0 @@ - -#include <errno.h> -#asm -entry _int_80 ! Tell ld86 we really do need this file. - ! then call the init stuff before main. - - loc 1 ! Make sure the pointer is in the correct segment -auto_func: ! Label for bcc -M to work. - .word _pre_main ! Pointer to the autorun function - .word no_op ! Space filler cause segs are padded to 4 bytes. - .text ! So the function after is also in the correct seg. -#endasm - -void int_80(); - -static void pre_main() -{ - /* Set the int 0x80 pointer to here */ - __set_es(0); - __doke_es(0x80*4+0, int_80); - __doke_es(0x80*4+2, __get_cs()); - bios_coninit(); -} - -void int_80() -{ -#asm -SYS_EXIT=1 -SYS_FORK=2 -SYS_READ=3 -SYS_WRITE=4 -SYS_OPEN=5 -SYS_CLOSE=6 -SYS_CHDIR=12 -SYS_LSEEK=19 -ENOSYS=38 - - push es - push si - push di - push dx - push cx - push bx - cmp ax,#SYS_READ - jne L1 - call _func_read - jmp L0 -L1: - cmp ax,#SYS_WRITE - jne L2 - call _func_write - jmp L0 -L2: - cmp ax,#SYS_LSEEK - jne L3 - call _func_lseek - jmp L0 -L3: - cmp ax,#SYS_EXIT - jne L4 - call _func_exit - jmp L0 -L4: - mov ax,#-ENOSYS -L0: - pop bx - pop cx - pop dx - pop di - pop si - pop es - iret -#endasm -} - -func_lseek() { return -38; } - -func_write(bx,cx,dx,di,si,es) -int bx,dx; -char * cx; -{ - register int v, c; - if(bx == 1 || bx == 2) - { - for(v=dx; v>0; v--) - { - c= *cx++; - if( c == '\n') bios_putc('\r'); - bios_putc(c); - } - return dx; - } - return -EBADF; -} - -func_read(bx,cx,dx,di,si,es) -int bx,dx; -char * cx; -{ - if(bx == 0) return read_line(cx, dx); - return -EBADF; -} - -read_line(buf, len) -char * buf; -int len; -{ - int ch; - int pos=0; - - if( len == 1 ) - { - buf[0]=((ch=bios_getc())&0xFF?ch&0xFF:((ch>>8)&0xFF|0x80)); - return 1; - } - - for(ch=0;;) - { - if(ch != '\003') - { - ch = bios_getc(); - if( pos == 0 && (ch&0xFF) == 0 ) - { - buf[0] = ((ch>>8)|0x80); - return 1; - } - ch &= 0x7F; - } - if( ch == '\r' ) - { - bios_putc('\r'); bios_putc('\n'); - buf[pos++] = '\n'; - return pos; - } - if( ch >= ' ' && ch != 0x7F && pos < len-1) - bios_putc(buf[pos++] = ch); - else if( (ch == '\003' || ch == '\b') && pos > 0 ) - { - bios_putc('\b'); bios_putc(' '); bios_putc('\b'); - pos--; - } - else if( ch == '\003' ) - return 0; - else - bios_putc('\007'); - } -} - -#define CTRL(x) ((x)&0x1F) -static int last_attr = 0x07; -static int con_mode; -static int con_size = 0x184F; -static int con_colour = 0; - -bios_coninit() -{ -#asm - mov ax,#$0F00 - int $10 - mov _con_mode,ax -#endasm - if( (con_mode &0xFF) > 39 ) con_size = (con_size&0xFF00) + (con_mode&0xFF); - if( (con_mode&0xFF00) != 0x700) - con_colour = 1; -} - -bios_putc(c) -int c; -{ -static char tbuf[3]; -static int tcnt=0; - if(tcnt) - { - tbuf[tcnt++] = c; - if( tcnt < 3 && (tbuf[0] != CTRL(']') || tbuf[1] < '`' || tbuf[1] > 'p')) - return; - if( tbuf[0] == CTRL('P') ) - { - if( tbuf[1] >= 32 && tbuf[1] <= 56 - && tbuf[2] >= 32 && tbuf[2] <= 111 ) - asm_cpos((tbuf[1]-32), (tbuf[2]-32)); - } - else - { - if( tbuf[1] >= '`' ) - last_attr = ( (tbuf[1]&0xF) | (last_attr&0xF0)); - else - last_attr = ( (tbuf[2]&0xF) | ((tbuf[1]&0xF)<<4)); - - if( !con_colour ) - last_attr = (last_attr&0x88) + ((last_attr&7)?0x07:0x70); - } - tcnt=0; - return; - } - if( c & 0xE0 ) { asm_colour(last_attr) ; asm_putc(c); } - else switch(c) - { - case CTRL('L'): - asm_cpos(0,0); - asm_cls(); - break; - case CTRL('P'): - case CTRL(']'): - tbuf[tcnt++] = c; - break; - default: - asm_putc(c); - break; - } - return; -} - -static asm_putc(c) -{ -#asm -#if !__FIRST_ARG_IN_AX__ - mov bx,sp - mov ax,[bx+2] -#endif - mov ah,#$0E - mov bx,#7 - int $10 -#endasm -} - -static asm_colour(c) -{ -#asm -#if __FIRST_ARG_IN_AX__ - mov bx,ax -#else - mov bx,sp - mov bx,[bx+2] -#endif - mov ah,#$08 - int $10 - mov ah,#$09 - mov cx,#1 - int $10 -#endasm -} - -static asm_cls() -{ -#asm - push bp ! Bug in some old BIOS's - !mov ax,#$0500 - !int $10 - mov ax,#$0600 - mov bh,_last_attr - mov cx,#$0000 - mov dx,_con_size - int $10 - pop bp -#endasm -} - -static asm_cpos(r,c) -{ -#asm -#if __FIRST_ARG_IN_AX__ - mov bx,sp - mov dh,al - mov ax,[bx+2] - mov dl,al -#else - mov bx,sp - mov ax,[bx+2] - mov dh,al - mov ax,[bx+4] - mov dl,al -#endif - mov ah,#$02 - mov bx,#7 - int $10 -#endasm -} - -bios_getc() -{ -#asm - xor ax,ax - int $16 -#endasm -} - -static void be_safe() -{ -#asm - iret -#endasm -} - -func_exit(bx,cx,dx,di,si,es) /* AKA reboot! */ -{ - __set_es(0); - __doke_es(0xE6*4+2,__get_cs()); - __doke_es(0xE6*4+0,be_safe); -#asm - mov ax,#$FFFF - int $E6 ! Try to exit DOSEMU - mov ax,#$0040 ! If we get here we're not in dosemu. - mov es,ax - seg es - mov [$72],#$1234 ! Warm reboot. - jmpi $0000,$FFFF -#endasm -} diff --git a/bootblocks/sysboot.s b/bootblocks/sysboot.s index 496b7a5..622488f 100644 --- a/bootblocks/sysboot.s +++ b/bootblocks/sysboot.s @@ -19,37 +19,41 @@ j codestart .blkb sysboot_start+3-* public dosfs_stat dosfs_stat: -.blkb 8 ! System ID -.word 0 ! Sector size -.byte 0 ! Cluster size -.word 0 ! Res-sector -.byte 0 ! FAT count -.word 0 ! Root dir entries -.word 0 ! Sector count (=0 if large FS) -.byte 0 ! Media code -.word 0 ! FAT length -.word 0 ! Sect/Track -.word 0 ! Heads -.long 0 ! Hidden sectors -! Here down is DOS 4+ -.long 0 ! Large FS sector count -.byte 0 ! Phys drive +dos_sysid: .blkb 8 ! System ID +dos_sect: .word 0 ! Sector size +dos_clust: .byte 0 ! Cluster size +dos_resv: .word 0 ! Res-sector +dos_nfat: .byte 0 ! FAT count +dos_nroot: .word 0 ! Root dir entries +dos_maxsect: .word 0 ! Sector count (=0 if large FS) +dos_media: .byte 0 ! Media code +dos_fatlen: .word 0 ! FAT length +dos_spt: .word 0 ! Sect/Track +dos_heads: .word 0 ! Heads +dos_hidden: .long 0 ! Hidden sectors + +! Here down is DOS 4+ and probably not needed for floppy boots. +floppy_temp: + +dos4_maxsect: .long 0 ! Large FS sector count +dos4_phy_drive: .byte 0 ! Phys drive .byte 0 ! Reserved .byte 0 ! DOS 4 -.long 0 ! Serial number -.blkb 11 ! Disk Label (DOS 4+) -.blkb 8 ! FAT type +dos4_serial: .long 0 ! Serial number +dos4_label: .blkb 11 ! Disk Label (DOS 4+) +dos4_fattype: .blkb 8 ! FAT type .blkb sysboot_start+0x3E-* public codestart codestart: - hlt + jmp codestart ! Partition table public partition_1 public partition_2 public partition_3 public partition_4 +public bootblock_magic .blkb sysboot_start+0x1BE-* partition_1: @@ -72,6 +76,7 @@ partition_4: .long 0 ! Linear position (0 based) .long 0 ! Linear length +bootblock_magic: .blkb sysboot_start+0x1FE-* .word 0xAA55 diff --git a/bootblocks/tarboot.s b/bootblocks/tarboot.s index ffa8db6..0fb85d3 100644 --- a/bootblocks/tarboot.s +++ b/bootblocks/tarboot.s @@ -25,7 +25,7 @@ DEBUG=1 ! Print dots ... macro locn if *-start>?1 - fail + fail! ?1 endif .blkb ?1 + start-* mend diff --git a/bootblocks/tiny.s b/bootblocks/tiny.s deleted file mode 100644 index 6090cd3..0000000 --- a/bootblocks/tiny.s +++ /dev/null @@ -1,55 +0,0 @@ -! -! This floppy bootblock bypasses the floppy boot ... -! - -BOOTSEG = 0x07c0 -BOOTDISK = 0x80 - -! Apparently on startup the only things we can assume are that we start at -! `start` (ABS addr $07C00) and we`ll have a few bytes of stack storage... - -! So first set DS=ES= 0x07c0 - include sysboot.s - .blkb codestart-* - -start: - mov ax,#BOOTSEG - mov ds,ax - mov es,ax - -! Print 'mesg' - mov ah,#0x03 ! read cursor pos - xor bh,bh - int 0x10 - - mov cx,#(emesg-mesg) - mov bp,#mesg - mov bx,#$7 ! page 0, attribute 7 (normal) - mov ax,#$1301 ! write string, move cursor - int $10 - -nogood: - xor si,si - mov di,#$0200 - mov cx,#$0100 - rep - movw - jmpi hcode,#BOOTSEG+$20 - -hcode: - mov ax,#$0201 ! Read 1 sector - xor bx,bx ! In the boot area - mov cx,#$0001 ! From sector 1 - mov dx,#BOOTDISK ! Of the hard drive head zero - int $13 - jc hcode ! Keep trying forever! - jmpi $7c00,0 - - -mesg: - if BOOTDISK = 0x80 -.ascii "Bypassing floppy boot\r\n" - else -.ascii "Booting drive two\r\n" - endif -emesg: |