summaryrefslogtreecommitdiff
path: root/bootblocks
diff options
context:
space:
mode:
authorRobert de Bath <rdebath@poboxes.com>2002-02-17 23:02:29 +0100
committerLubomir Rintel <lkundrak@v3.sk>2013-10-23 23:48:46 +0200
commitdf538463687d768b6ee8247ff4412b78850e7404 (patch)
tree52f42c02ef8139e5d73a8504e1bb3e896f3c0bc9 /bootblocks
parentd91fa39567f5659e3931cf61517d62fddcd87570 (diff)
downloaddev86-df538463687d768b6ee8247ff4412b78850e7404.tar.gz
Import Dev86src-0.16.2.tar.gzv0.16.2
Diffstat (limited to 'bootblocks')
-rw-r--r--bootblocks/Makefile5
-rw-r--r--bootblocks/README7
-rw-r--r--bootblocks/boot_fpy.s203
-rw-r--r--bootblocks/bzimage.c63
-rw-r--r--bootblocks/commands.c1
-rw-r--r--bootblocks/fs.c3
-rw-r--r--bootblocks/fs_tar.c2
-rw-r--r--bootblocks/i86_funcs.c2
-rw-r--r--bootblocks/mbr.s19
-rw-r--r--bootblocks/monitor.c34
-rw-r--r--bootblocks/msdos.s12
-rw-r--r--bootblocks/relocate.c3
-rw-r--r--bootblocks/tarboot.s14
-rw-r--r--bootblocks/tich.s3
-rw-r--r--bootblocks/trk_buf.c50
-rw-r--r--bootblocks/unix.c13
16 files changed, 355 insertions, 79 deletions
diff --git a/bootblocks/Makefile b/bootblocks/Makefile
index 66a87c4..6efa75b 100644
--- a/bootblocks/Makefile
+++ b/bootblocks/Makefile
@@ -19,7 +19,8 @@ all: bootbin bootsys default tgz
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
+SSRC=sysboot.s tarboot.s skip.s com_bcc.s tich.s mbr.s msdos.s noboot.s \
+ boot_fpy.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
@@ -46,7 +47,7 @@ fs_min.o: minix.h
bootfile.sys: $(MSRC) $(MINC)
@rm -f $(MOBJ)
- make 'CFLAGS=$(CFLAGS) -DDOSFLOPPY -i' monitor.out
+ make 'CFLAGS=$(CFLAGS) -DDOSFLOPPY -i -d' monitor.out
mv monitor.out bootfile.sys
@rm -f $(MOBJ)
diff --git a/bootblocks/README b/bootblocks/README
index 80a447e..81fc634 100644
--- a/bootblocks/README
+++ b/bootblocks/README
@@ -54,8 +54,8 @@ 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 beware some older versions of superformat defeat this because
- they do not correctly calculate intersector gaps.
+ But some older versions of superformat defeat this because they do
+ not correctly calculate intersector gaps.
1.3 ) Minixfs boot block
@@ -146,8 +146,7 @@ Contents
at the prompt '>' where 'linux' is the name of the bzImage file.
Escape or ^C will interrupt the boot and drop you to the '>' prompt.
- Esacpe or ^C at the '>' prompt will reboot
- (This may be a little too sensitive :-)
+ ^C at the '>' prompt will reboot
A file called 'help.txt' will be displayed upto the first line that starts
with a '%', chunks after that (seperated by '%'s) will be displayed when
diff --git a/bootblocks/boot_fpy.s b/bootblocks/boot_fpy.s
new file mode 100644
index 0000000..ef1f21a
--- /dev/null
+++ b/bootblocks/boot_fpy.s
@@ -0,0 +1,203 @@
+! This binary is for loading a dev86 a.out file from a floppy without
+! a filesystem; to make a bootable disk just do:
+!
+! 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
+LOADSEG=0x0080 ! Must be 512b aligned for DMA
+
+.org EXEADDR-1
+.byte 0xFF ! Marker
+
+.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 di,#ORGADDR
+ cld
+ rep
+ movsw
+ jmpi go,#0
+go:
+ mov ds,ax ! Setup SP & S-regs
+ mov ss,ax
+ mov sp,#ORGADDR
+ mov ax,[a_text] ! How many sectors to load
+ mov cl,#4
+ shr ax,cl
+ mov bx,ax
+ mov ax,[a_data]
+ mov cl,#4
+ shr ax,cl
+ add ax,bx
+ add ax,#$1F
+ mov cl,#5
+ shr ax,cl ! ax = sectors to read
+
+ ! This routine starts by loading one sector at a time, with most
+ ! modern PCs the processor is fast enough to keep up with single
+ ! sector reads, in reality an 8Mhz 286 can keep up!
+ ! 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
+ ! 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.
+ !
+ ! Overall this usually gives good performance, and with a BIOS that
+ ! isn't completely broken and correctly formatted floppies will run
+ ! at about 2.5 rotations per cylinder (1.25 per track). If you find
+ ! 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.
+
+ ! AX = count of sectors
+ mov cx,#2 ! CX = First sector
+ mov bx,#LOADSEG ! ES:BX = Where to load
+ mov es,bx
+ xor bx,bx ! Initial offset
+
+ xor dx,dx ! DX = Drive 0
+
+ ! ax=cnt, dl=drv, ch=*, dh=*, cl=sec, es:bx=buffer.
+
+read_data:
+ mov si,ax ! Save big count.
+ xor ch,ch
+ xor dh,dh
+
+ mov maxsect,cl ! Save first sector.
+
+load_loop:
+ mov di,#5 ! Error retry.
+
+sect_retry:
+ mov ax,#$0201
+ ! ah=2, al=1, dl=drv, ch=cyl, dh=head, cl=sec, es:bx=buffer.
+ int $13
+ jnc next_sect
+
+ dec di ! Retry counter
+ jz sect_error
+
+ cmp cl,maxsect ! If this is first sector or previously ok sector
+ jle sect_retry ! number then retry.
+
+ mov maxsect,cl
+ j inc_trk
+
+next_sect:
+ mov ax,es ! Inc load address.
+ add ax,#32
+ mov es,ax
+
+ dec si ! Had enough ?
+ jz all_loaded
+
+inc_sect:
+ inc cl
+ cmp cl,maxsect
+ jnz load_loop
+inc_trk: ! Reached end of track, seek to next.
+ mov cl,#1
+ xor dh,cl
+ jnz load_track
+ inc ch
+load_track:
+ cmp si,maxsect ! Is the whole track needed ?
+ jb load_loop ! no, goto load_loop for 1 by 1
+
+ ! Try to load the track _once_ only, if it fails go 1 by 1 again.
+
+ mov ax,maxsect
+ dec ax
+ mov ah,#$02
+ ! ah=2, al=*, dl=drv, ch=cyl, dh=head, cl=sec, es:bx=buffer.
+ int $13
+ jc load_loop
+
+ mov ax,maxsect ! Ok that worked, update the pointers
+ dec ax
+ mov cl,#5
+ shl ax,cl
+ mov di,es
+ add ax,di
+ mov es,ax
+
+ inc si
+ sub si,maxsect
+ jnz inc_trk
+
+all_loaded:
+
+ xor dx,dx ! DX=0 => floppy drive
+ push dx ! CX=0 => partition offset = 0
+ mov si,dx ! Sect/track = 0
+
+ mov bx,#EXEADDR>>4
+ mov ds,bx ! DS = loadaddress
+ xor di,di ! Zero
+ mov ax,[di+2]
+ and ax,#$20 ! Is it split I/D ?
+ jz impure ! No ...
+ mov cl,#4
+ mov ax,[di+8]
+ shr ax,cl
+impure:
+ pop cx ! Partition offset.
+ inc bx
+ inc bx ! bx = initial CS
+ add ax,bx
+ mov ss,ax
+ mov sp,[di+24] ! Chmem value
+ mov ds,ax
+
+ ! AX=ds, BX=cs, CX=X, DX=X, SI=X, DI=0, BP=X, ES=X, DS=*, SS=*, CS=*
+
+bad_magic:
+ push bx ! jmpi 0,#LOADSEG+2
+ push di
+ retf
+
+sect_error:
+ ! TODO Error.
+ j sect_error
+
+maxsect:
+ .word 0
+
+! Check for overlap
+end_of_code:
+ if end_of_code>hitme
+ fail! Overlap at end_of_code
+ endif
+
+.org EXEADDR
+hitme:
+
+magic: .space 2 ! A.out header
+btype: .space 2
+headerlen: .space 4
+a_text: .space 4
+a_data: .space 4
+a_bss: .space 4
+a_entry: .space 4
+a_total: .space 4
+a_syms: .space 4
+
diff --git a/bootblocks/bzimage.c b/bootblocks/bzimage.c
index fac9017..8540cd6 100644
--- a/bootblocks/bzimage.c
+++ b/bootblocks/bzimage.c
@@ -113,6 +113,7 @@ char * command_line;
#endif
low_sects = buffer[497] + 1; /* setup sects + boot sector */
+ if (low_sects == 1) low_sects = 5;
image_length = (file_length()+511)/512 - low_sects;
address = 0x900;
@@ -154,11 +155,11 @@ char * command_line;
printf("%dk to go \r", (int)(len/1024)); fflush(stdout);
#ifndef NOCOMMAND
- v = (bios_khit()&0x7F);
+ v = (kbhit()&0x7F);
if( v == 3 || v == 27 )
{
printf("User interrupt!\n");
- bios_getc();
+ getch();
return -1;
}
#endif
@@ -332,36 +333,42 @@ register char * image_buf;
{
is_zimage = 0;
- /* Boot sector magic number */
+ /* Boot sector magic numbers */
if( *(unsigned short*)(image_buf+510) != 0xAA55 ||
-
- /* Setup start */
- memcmp(image_buf+0x202, "HdrS", 4) != 0 ||
-
- /* Setup version */
- *(unsigned short*)(image_buf+0x206) < 0x200 )
+ memcmp(image_buf, "\270\300\007\216") != 0 )
{
printf("File %s is not a linux Image file\n", fname);
return -1;
}
- /* Code 32 start address for zImage */
- if( *(unsigned long*)(image_buf+0x214) == 0x1000 )
- {
- printf("File %s is a zImage file\n", fname);
- is_zimage = 1;
- return 0;
- }
- else
- /* Code 32 start address bzImage */
- if( *(unsigned long*)(image_buf+0x214) != 0x100000 )
+ /* Setup start */
+ if ( memcmp(image_buf+0x202, "HdrS", 4) == 0 &&
+ /* Setup version */
+ *(unsigned short*)(image_buf+0x206) >= 0x200 )
{
- printf("File %s is a strange Image file\n", fname);
- return -1;
+ /* Code 32 start address for zImage */
+ if( *(unsigned long*)(image_buf+0x214) == 0x1000 )
+ {
+ printf("File %s is a zImage file\n", fname);
+ is_zimage = 1;
+ return 0;
+ }
+ else
+ /* Code 32 start address bzImage */
+ if( *(unsigned long*)(image_buf+0x214) == 0x100000 )
+ {
+ printf("File %s is a bzImage file\n", fname);
+ return 0;
+ }
}
- printf("File %s is a bzImage file\n", fname);
+ is_zimage = 1;
+ printf("File %s is an old Image file\n", fname);
+#if ZIMAGE_LOAD_SEG == 0x10000
return 0;
+#else
+ return -1;
+#endif
}
#ifndef __ELKS__
@@ -516,7 +523,14 @@ static char * image_str = "BOOT_IMAGE=";
free(ptr);
}
else if( inp == 0 )
+ {
inp = free_inp = input_cmd(image);
+ if( inp == 0 )
+ {
+ printf("\nAborted\n");
+ return -1;
+ }
+ }
if( auto_flag ) len += strlen(auto_str) + 1;
if( image ) len += strlen(image_str) + strlen(image) + 1;
@@ -685,11 +699,11 @@ unsigned int k_top;
for( ; rd_len>0 ; rd_len--)
{
#ifndef NOCOMMAND
- int v = (bios_khit()&0x7F);
+ int v = (kbhit()&0x7F);
if( v == 3 || v == 27 )
{
printf("User interrupt!\n");
- bios_getc();
+ getch();
return -1;
}
#endif
@@ -727,6 +741,7 @@ check_crc()
__movedata(address*16, 0, __get_ds(), buffer, 512);
low_sects = buffer[497] + 1; /* setup sects + boot sector */
+ if (low_sects == 1) low_sects = 5;
for(len=image_size; len>0; len-=512)
{
diff --git a/bootblocks/commands.c b/bootblocks/commands.c
index 9720cfe..d39aa60 100644
--- a/bootblocks/commands.c
+++ b/bootblocks/commands.c
@@ -155,6 +155,7 @@ cmd_regs()
printf(": AX=%04x BX=%04x CX=%04x DX=%04x SI=%04x DI=%04x",
__argr.x.ax, __argr.x.bx, __argr.x.cx, __argr.x.dx,
__argr.x.si, __argr.x.di);
+ printf(" CF=%x", __argr.x.cflag);
printf(" CS=%04x DS=%04x ES=%04x\n", __get_cs(), __get_ds(), __get_es());
#else
printf("Only in standalone\n");
diff --git a/bootblocks/fs.c b/bootblocks/fs.c
index 47faffc..ec3e0a6 100644
--- a/bootblocks/fs.c
+++ b/bootblocks/fs.c
@@ -13,6 +13,9 @@ char * fname;
#endif
if( fs_type ) close_file();
+ /* If we can't read the boot sector there is a _real_ problem */
+ if (read_sector(0) == 0) return -1;
+
if( tar_open_file(fname) >= 0 ) { fs_type = 1; return 0; }
if( min_open_file(fname) >= 0 ) { fs_type = 2; return 0; }
if( dos_open_file(fname) >= 0 ) { fs_type = 3; return 0; }
diff --git a/bootblocks/fs_tar.c b/bootblocks/fs_tar.c
index ccab3b5..6a5c6ca 100644
--- a/bootblocks/fs_tar.c
+++ b/bootblocks/fs_tar.c
@@ -168,7 +168,7 @@ char * buffer;
{
printf("Please insert next disk and press return:");
fflush(stdout);
- while( (k=(bios_getc() & 0x7F)) != '\r' && k != '\n')
+ while( (k=(getch() & 0x7F)) != '\r' && k != '\n')
if( k == 27 || k == 3 )
{
printf("... Aborting\n");
diff --git a/bootblocks/i86_funcs.c b/bootblocks/i86_funcs.c
index 7b88da2..dd9ec33 100644
--- a/bootblocks/i86_funcs.c
+++ b/bootblocks/i86_funcs.c
@@ -109,6 +109,8 @@ void cpu_check()
#ifdef __STANDALONE__
x86_test = x86_emu;
+ if (__argr.x.cflag)
+ x86_test = 1;
#else
x86_test = 1;
#endif
diff --git a/bootblocks/mbr.s b/bootblocks/mbr.s
index d071a8b..e633c87 100644
--- a/bootblocks/mbr.s
+++ b/bootblocks/mbr.s
@@ -327,9 +327,9 @@ more_boot:
jz load_done
mov bx,ax ! word 1 address
lodsw
- mov cx,ax ! word 2 CX, head/sector
+ mov cx,ax ! word 2 CX, cylinder/sector
lodsw
- mov dx,ax ! word 3 DX, drive, cylinder
+ mov dx,ax ! word 3 DX, drive, head
lodsw ! word 4 AX, $02, sector count
int $13
jnc more_boot ! This doesn't retry, with a HD it shouldn't be bad.
@@ -353,19 +353,16 @@ pre_boot_table:
! .word <execute address>
! Then repeat ..
! .word <BX>, <CX>, <DX>, <AX>
+ ! Or.
+ ! .word <Load Address>
+ ! .byte <sector> + (<cyl> & $300)>>2), <cyl> & $FF, <Drive>, <Head>, <cnt>, 2
! Finally
! .word 0
! Example: Load rest of H0,C0 into mem at $7C00 (8k).
- ! .word $7C00, $7C00,$0002,$8000,$0210, $0000
-
- ! Example: Use single LBA call
- ! .word <execute address>
- ! .word 0,0,$8000,$4200, $0010
- ! .word <number of blocks>
- ! .long <transfer buffer>
- ! .long <start block number>
- ! .long <start block number high 4 bytes>
+ ! .word $7C00
+ ! .word $7C00,$0002,$8000,$0210
+ ! .word $0000
endif
!-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
diff --git a/bootblocks/monitor.c b/bootblocks/monitor.c
index 2e47da8..27f25ea 100644
--- a/bootblocks/monitor.c
+++ b/bootblocks/monitor.c
@@ -32,29 +32,33 @@ static char minibuf[2] = " ";
#endif
init_prog();
+
+ if (!x86_test)
+ {
#ifdef __STANDALONE__
#ifndef NOCOMMAND
- if( __get_ds() != 0x1000 )
- {
- /* First to top of RAM */
- relocator(-1);
- /* 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());
- }
+ if( __get_ds() != 0x1000 )
+ {
+ /* First to top of RAM */
+ relocator(-1);
+ /* 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
- disk_drive = __argr.h.dl;
+ 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 b9f02a9..4e9eb1a 100644
--- a/bootblocks/msdos.s
+++ b/bootblocks/msdos.s
@@ -356,8 +356,6 @@ maincode:
mov bx,#LOADSEG
mov ds,bx ! DS = loadaddress
- inc bx
- inc bx ! bx = initial CS
xor di,di ! Zero
mov ax,[di]
cmp ax,#0x0301 ! Right magic ?
@@ -370,19 +368,19 @@ maincode:
shr ax,cl
impure:
pop cx ! Partition offset.
+ inc bx
+ inc bx ! bx = initial CS
add ax,bx
mov ss,ax
mov sp,[di+24] ! Chmem value
mov ds,ax
+ ! AX=ds, BX=cs, CX=X, DX=X, SI=X, DI=0, BP=X, ES=X, DS=*, SS=*, CS=*
+
+bad_magic:
push bx ! jmpi 0,#LOADSEG+2
push di
-
- ! AX=ds, BX=cs, CX=X, DX=X, SI=X, DI=0, BP=X, ES=X, DS=*, SS=*, CS=*
retf
-bad_magic:
- pop cx
- jmpi LOADSEG<<4,0 ! No magics, just go.
!---------------------------------------------------------------------------
! initilised data
diff --git a/bootblocks/relocate.c b/bootblocks/relocate.c
index 5e14d0e..2e31ea8 100644
--- a/bootblocks/relocate.c
+++ b/bootblocks/relocate.c
@@ -23,6 +23,9 @@ unsigned newseg;
unsigned moved, codelen;
unsigned es = __get_es();
+ /* If running under DOS don't relocate */
+ if (__argr.x.cflag) return;
+
/* Where do we start */
if(memseg == 0)
{
diff --git a/bootblocks/tarboot.s b/bootblocks/tarboot.s
index a8e56fa..a21d9eb 100644
--- a/bootblocks/tarboot.s
+++ b/bootblocks/tarboot.s
@@ -97,7 +97,7 @@ endif
jz nogood ! If it`s zero .. Hmm
if STACK = 0
- mov sp,#bad_magic ! Real bad magic :-)
+ mov sp,#overstack ! Real bad magic :-)
endif
call load_sectors
@@ -262,9 +262,10 @@ div_loop:
loop div_loop
mov di,bx
-bad_magic:
ret
+overstack:
+
!-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
!
! This is good so far, is it an 8086 a.out file ?
@@ -277,8 +278,6 @@ go_go_go:
mov bx,#LOADSEG
mov ds,bx ! DS = loadaddress
- inc bx
- inc bx ! bx = initial CS
xor di,di ! Zero
mov ax,[di]
cmp ax,#0x0301 ! Right magic ?
@@ -291,15 +290,18 @@ go_go_go:
shr ax,cl
impure:
pop cx ! Partition offset.
+ inc bx
+ inc bx ! bx = initial CS
add ax,bx
mov ss,ax
mov sp,[di+24] ! Chmem value
mov ds,ax
+ ! AX=ds, BX=cs, CX=X, DX=X, SI=X, DI=0, BP=X, ES=X, DS=*, SS=*, CS=*
+
+bad_magic:
push bx ! jmpi 0,#LOADSEG+2
push di
-
- ! AX=ds, BX=cs, CX=X, DX=X, SI=X, DI=0, BP=X, ES=X, DS=*, SS=*, CS=*
retf
!-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
diff --git a/bootblocks/tich.s b/bootblocks/tich.s
index 15bc238..ce21e4a 100644
--- a/bootblocks/tich.s
+++ b/bootblocks/tich.s
@@ -34,5 +34,6 @@ mesg:
.ascii "Hello world"
emesg:
+! Floppies aren't supposed to need this, oh well.
org 510
- .word 0
+ .word $AA55
diff --git a/bootblocks/trk_buf.c b/bootblocks/trk_buf.c
index 86a6721..cfa1e93 100644
--- a/bootblocks/trk_buf.c
+++ b/bootblocks/trk_buf.c
@@ -92,7 +92,6 @@ void reset_disk()
char * read_lsector(sectno)
long sectno;
{
- int tries = 6;
int rv;
int phy_s = 1;
@@ -147,12 +146,26 @@ long sectno;
do
{
- rv = phy_read(disk_drive, phy_c, phy_h, phy_s+1, 1, data_buf1);
- tries--;
+ int v,tries = 6;
+ do
+ {
+ rv = phy_read(disk_drive, phy_c, phy_h, phy_s+1, 1, data_buf1);
+ tries--;
+ }
+ while(rv && tries > 0);
+ if( rv )
+ {
+ printf("Disk error 0x%02x %d:%d:%d:%d[%2d] -> 0x%04x[]\nRetry:",
+ rv, disk_drive, phy_c, phy_h, phy_s+1, 1, data_buf1);
+ fflush(stdout);
+
+ v = phy_reset(disk_drive);
+ v = (getch()&0x7F);
+ printf("\n");
+ if( v == 3 || v == 27 ) break;
+ }
}
- while(rv && tries > 0);
- if( rv ) printf("Disk error 0x%02x %d:%d:%d:%d[%2d] -> 0x%04x[]\n",
- rv, disk_drive, phy_c, phy_h, phy_s+1, 1, data_buf1);
+ while(rv);
check_motor = motor_running();
@@ -334,6 +347,31 @@ func_ok:
#endasm
}
+phy_reset(drive)
+{
+#asm
+ push bp
+ mov bp,sp
+
+ push di
+ push es
+
+ mov dl,[bp+2+_phy_reset.drive]
+
+ mov ah,#$08
+ int $13
+ jnc reset_ok
+ mov cx,ax
+ mov dx,#-1
+reset_ok:
+ mov ax,cx
+
+ pop es
+ pop di
+ pop bp
+#endasm
+}
+
motor_running()
{
#asm
diff --git a/bootblocks/unix.c b/bootblocks/unix.c
index 455d9b1..e7f07a0 100644
--- a/bootblocks/unix.c
+++ b/bootblocks/unix.c
@@ -3,11 +3,11 @@
#ifdef __ELKS__
-bios_khit() {
+kbhit() {
return 0;
}
-bios_getc() {
+getch() {
return 0;
}
@@ -61,6 +61,15 @@ extern int disk_spt;
return 0;
}
+phy_reset()
+{
+}
+
+motor_running()
+{
+ return 1;
+}
+
putsect(buffer, address)
char * buffer;
int address;