--- Begin Message ---
diff -ruNp old/drivers/floppy.asm new/drivers/floppy.asm
--- old/drivers/floppy.asm 2004-04-09 06:11:44.000000000 +0000
+++ new/drivers/floppy.asm 2004-06-07 20:31:24.000000000 +0000
@@ -28,15 +28,14 @@
; $Id: floppy.asm,v 1.18 2004/04/09 13:11:22 bartoldeman Exp $
;
- %include "../kernel/segs.inc"
- segment HMA_TEXT
-;
-;
-; Reset both the diskette and hard disk system
+%include "../kernel/segs.inc"
+segment HMA_TEXT
+
;
-; BOOL fl_reset(WORD drive)
+; int ASMPASCAL fl_reset(WORD drive);
;
-; returns TRUE if successful
+; Reset both the diskette and hard disk system.
+; returns TRUE if successful.
;
global FL_RESET
@@ -44,199 +43,174 @@ FL_RESET:
pop ax ; return address
pop dx ; drive
push ax ; restore address
- mov ah,0 ; BIOS reset diskette & fixed disk
+ mov ah,0 ; reset disk
int 13h
+ sbb ax,ax ; CF=1: error
+ inc ax ; return TRUE (1) on success,
+ ret ; FALSE (0) on error
- sbb ax,ax ; cy==1 is error
- inc ax ; TRUE on success, FALSE on failure
- ret
-
-
-;
;
-; Read disk change line status
+; int ASMPASCAL fl_diskchanged(WORD drive);
;
-; COUNT fl_diskchanged(WORD drive)
-;
-; returns 1 if disk has changed, 0 if not, 0xFFFF if error
+; Read disk change line status.
+; returns 1 if disk has changed, 0 if not, 0xFF if error.
;
global FL_DISKCHANGED
FL_DISKCHANGED:
pop ax ; return address
- pop dx ; get the drive number
+ pop dx ; drive
push ax ; restore stack
- push si ; restore stack
- mov ah,16h ; read change status type
+ push si
+ mov ah,16h ; read change status type
xor si,si ; RBIL: avoid crash on AT&T 6300
int 13h
-
- mov al,1
- jnc fl_dc_ret1 ; cy==1 is error or disk has changed
-
- cmp ah,6 ; ah=6: disk has changed
- je fl_dc_ret
- dec ax ; 0xFF on error
-
-fl_dc_ret1: dec ax
-fl_dc_ret: cbw
pop si
- ret
+ sbb al,al
+ jnc fl_dc_ret ; CF=0: disk has not changed
+ cmp ah,6
+ jne fl_dc_ret ; 0xFF on error
+ mov al,1 ; ah=6: disk has changed
+fl_dc_ret:
+ jmp short ret_AH_0
+
+;
+; int ASMPASCAL fl_read (WORD drive, WORD head, WORD track, WORD sector, WORD count,
void FAR *buffer);
+; int ASMPASCAL fl_write (WORD drive, WORD head, WORD track, WORD sector, WORD count,
void FAR *buffer);
+; int ASMPASCAL fl_verify(WORD drive, WORD head, WORD track, WORD sector, WORD count,
void FAR *buffer);
+; int ASMPASCAL fl_format(WORD drive, WORD head, WORD track, WORD sector, WORD count,
void FAR *buffer);
;
-; Format Sectors
-;
-; COUNT fl_format(WORD drive, WORD head, WORD track, WORD sector, WORD count, BYTE
FAR *buffer);
-;
-; Formats one or more tracks, sector should be 0.
-;
-; Returns 0 if successful, error code otherwise.
+
+; Format tracks (sector should be 0).
+
global FL_FORMAT
FL_FORMAT:
- mov ah, 5
- jmp short fl_common
-;
-; Read Sectors
-;
-; COUNT fl_read(WORD drive, WORD head, WORD track, WORD sector, WORD count, BYTE FAR
*buffer);
-;
-; Reads one or more sectors.
-;
-; Returns 0 if successful, error code otherwise.
-;
-;
-; Write Sectors
-;
-; COUNT fl_write(WORD drive, WORD head, WORD track, WORD sector, WORD count, BYTE FAR
*buffer);
-;
-; Writes one or more sectors.
-;
-; Returns 0 if successful, error code otherwise.
-;
- global FL_READ
-FL_READ:
- mov ah,2 ; cmd READ
- jmp short fl_common
-
+ mov ah,5 ; format track
+ jmp short fl_common
+
global FL_VERIFY
FL_VERIFY:
- mov ah,4 ; cmd verify
- jmp short fl_common
-
+ mov ah,4 ; verify sector(s)
+ jmp short fl_common
+
+ global FL_READ
+FL_READ:
+ mov ah,2 ; read sector(s)
+ jmp short fl_common
+
global FL_WRITE
FL_WRITE:
- mov ah,3 ; cmd WRITE
+ mov ah,3 ; write sector(s)
-fl_common:
- push bp ; C entry
+fl_common:
+ push bp
mov bp,sp
- mov cx,[bp+0Ch] ; cylinder number (lo only if hard)
-
- mov al,1 ; this should be an error code
- cmp ch,3 ; this code can't write above 3ff=1023
- ja fl_error
-
- xchg ch,cl ; ch=low 8 bits of cyl number
- ror cl,1 ; extract bits 8+9 to cl
- ror cl,1
- or cl,[bp+0Ah] ; or in the sector number (bits 0-5)
-
- mov al,[bp+08h] ; count to read/write
- les bx,[bp+04h] ; Load 32 bit buffer ptr
-
- mov dl,[bp+10h] ; get the drive (if or'ed 80h its
- ; hard drive.
- mov dh,[bp+0Eh] ; get the head number
-
- int 13h ; write sectors from mem es:bx
+ mov cx,[bp+12] ; cylinder number
+ mov al,1 ; error code
+ cmp ch,3
+ ja fl_error ; can't write above 3FFh=1023
+
+ xchg ch,cl ; ch=low 8 bits of cylinder number
+ mov dh,[bp+14] ; head number
+ ror cl,1 ; bits 8-9 of cylinder number...
+ ror cl,1 ; ...to bits 6-7 in CL
+ or cl,[bp+10] ; sector number (bits 0-5)
+
+ mov al,[bp+8] ; number of sectors
+ les bx,[bp+4] ; 32-bit buffer ptr
+ mov dl,[bp+16] ; drive (if or'ed 80h its hard drive)
+ int 13h ; process sectors
sbb al,al ; carry: al=ff, else al=0
and al,ah ; carry: error code, else 0
- ; (Zero transfer count)
fl_error:
- mov ah,0 ; force into < 255 count
+ mov ah,0
pop bp
ret 14
-
-; COUNT fl_lba_ReadWrite(BYTE drive, UWORD mode, VOID FAR *dap_p)
+;
+; int ASMPASCAL fl_lba_ReadWrite(WORD drive, WORD mode, void FAR * dap);
;
; Returns 0 if successful, error code otherwise.
;
+
global FL_LBA_READWRITE
FL_LBA_READWRITE:
- push bp ; C entry
+ push bp
mov bp,sp
-
+ push si
push ds
- push si ; wasn't in kernel < KE2024Bo6!!
-
- mov dl,[bp+10] ; get the drive (if ored 80h harddrive)
- mov ax,[bp+8] ; get the command
- lds si,[bp+4] ; get far dap pointer
+ mov dl,[bp+10] ; drive (if or'ed 80h its hard drive)
+ mov ax,[bp+8] ; command
+ lds si,[bp+4] ; far dap pointer
int 13h ; read from/write to drive
-
- pop si
pop ds
-
+ pop si
pop bp
-ret_AH:
- mov al,ah ; place any error code into al
- mov ah,0 ; zero out ah
+ mov al,ah ; place error code into al
+ mov ah,0
ret 8
;
-; void fl_readkey (void);
+; void ASMPASCAL fl_readkey (void);
;
-global FL_READKEY
-FL_READKEY: xor ah, ah
+ global FL_READKEY
+FL_READKEY:
+ mov ah,0
int 16h
ret
-global FL_SETDISKTYPE
+;
+; int ASMPASCAL fl_setdisktype (WORD drive, WORD type);
+;
+
+ global FL_SETDISKTYPE
FL_SETDISKTYPE:
pop bx ; return address
- pop ax ; disk type (al)
- pop dx ; drive number (dl)
+ pop ax ; disk type
+ pop dx ; drive
push bx ; restore stack
- mov ah,17h
+ mov ah,17h ; set disk type for format
int 13h
- jmp short ret_AH
-
+ret_AH:
+ mov al,ah ; place any error code into al
+ret_AH_0:
+ mov ah,0 ; zero out ah
+ ret
+
;
-; COUNT fl_setmediatype (WORD drive, WORD tracks, WORD sectors);
+; int ASMPASCAL fl_setmediatype (WORD drive, WORD tracks, WORD sectors);
;
-global FL_SETMEDIATYPE
+
+ global FL_SETMEDIATYPE
FL_SETMEDIATYPE:
pop ax ; return address
pop bx ; sectors/track
pop cx ; number of tracks
- pop dx ; drive number
+ pop dx ; drive
push ax ; restore stack
push di
- dec cx ; should be highest track
- xchg ch,cl ; low 8 bits of cyl number
-
- ror cl,1 ; extract bits 8+9 to cl bit 6+7
- ror cl,1
-
- or cl,bl ; or in bits 7-6
-
- mov ah,18h
+ dec cx ; last cylinder number
+ xchg ch,cl ; CH=low 8 bits of last cyl number
+ ror cl,1 ; bits 8-9 of cylinder number...
+ ror cl,1 ; ...to bits 6-7 in CL
+ or cl,bl ; sectors/track (bits 0-5)
+ mov ah,18h ; set media type for format
int 13h
jc skipint1e
+
push es
xor dx,dx
mov es,dx
cli
+ mov [es:0x1e*4],di
pop word [es:0x1e*4+2] ; set int 0x1e table to es:di
- mov [es:0x1e*4 ], di
sti
-skipint1e:
+skipint1e:
pop di
jmp short ret_AH
-
--- End Message ---