based on floppy.asm patchset from Arkady, use ret instead of ret 8 appropriately;

improve comments, including sync with prototypes in dsk.c; small code clean up


git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@979 6ac86273-5f31-0410-b378-82cca8765d1b
This commit is contained in:
Kenneth J Davis 2004-06-18 06:57:33 +00:00
parent fe30b5a698
commit b4ec361ab6
2 changed files with 85 additions and 97 deletions

View File

@ -28,129 +28,108 @@
; $Id$
;
%include "../kernel/segs.inc"
segment HMA_TEXT
%include "../kernel/segs.inc"
segment HMA_TEXT
;
; BOOL ASMPASCAL fl_reset(WORD drive);
;
; Reset both the diskette and hard disk system
;
; BOOL fl_reset(WORD drive)
;
; returns TRUE if successful
; Reset both the diskette and hard disk system.
; returns TRUE if successful.
;
global FL_RESET
FL_RESET:
pop ax ; return address
pop dx ; drive
pop dx ; drive, (DL only, bit 7 set resets both floppy & hd)
push ax ; restore address
mov ah,0 ; BIOS reset diskette & fixed disk
int 13h
sbb ax,ax ; cy==1 is error
inc ax ; TRUE on success, FALSE on failure
ret
mov ah,0 ; BIOS reset diskette & fixed disk
int 13h
sbb ax,ax ; carry set indicates error, AX=-CF={-1,0}
inc ax ; ...return TRUE (1) on success,
ret ; else FALSE (0) on failure
;
; COUNT ASMPASCAL fl_diskchanged(WORD drive);
;
; Read disk change line status
;
; 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, 0xFFFF if error.
;
global FL_DISKCHANGED
FL_DISKCHANGED:
pop ax ; return address
pop dx ; get the drive number
pop dx ; drive (DL only, 00h-7Fh)
push ax ; restore stack
push si ; restore stack
mov ah,16h ; read change status type
push si ; preserve value
mov ah,16h ; read change status type
xor si,si ; RBIL: avoid crash on AT&T 6300
int 13h
int 13h
pop si ; restore
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 ; AL=-CF={-1,0} where 0==no change
jnc fl_dc ; carry set on error or disk change
cmp ah,6 ; if AH==6 then disk change, else error
jne fl_dc ; if error, return -1
mov al, 1 ; set change occurred
fl_dc: cbw ; extend AL into AX, AX={1,-1}
ret ; note: AH=0 on no change, AL set above
;
; 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.
; Format tracks (sector should be 0).
; COUNT ASMPASCAL fl_format(WORD drive, WORD head, WORD track, WORD sector, WORD count, UBYTE FAR *buffer);
; Reads one or more sectors.
; COUNT ASMPASCAL fl_read (WORD drive, WORD head, WORD track, WORD sector, WORD count, UBYTE FAR *buffer);
; Writes one or more sectors.
; COUNT ASMPASCAL fl_write (WORD drive, WORD head, WORD track, WORD sector, WORD count, UBYTE FAR *buffer);
; COUNT ASMPASCAL fl_verify(WORD drive, WORD head, WORD track, WORD sector, WORD count, UBYTE FAR *buffer);
;
; Returns 0 if successful, error code otherwise.
;
global FL_FORMAT
FL_FORMAT:
mov ah, 5
mov ah,5 ; format track
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
mov ah,2 ; read sector(s)
jmp short fl_common
global FL_VERIFY
FL_VERIFY:
mov ah,4 ; cmd verify
mov ah,4 ; verify 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
push bp ; setup stack frame
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
cmp ch,3 ; this code can't write above 3FFh=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
ror cl,1 ; bits 8-9 of cylinder number...
ror cl,1 ; ...to bits 6-7 in CL
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 al,[bp+08h] ; count to read/write (# of sectors)
les bx,[bp+04h] ; Load 32 bit buffer ptr into ES:BX
mov dl,[bp+10h] ; get the drive (if or'ed 80h its
; hard drive.
mov dl,[bp+10h] ; drive (if or'ed 80h its a hard drive)
mov dh,[bp+0Eh] ; get the head number
int 13h ; write sectors from mem es:bx
int 13h ; process sectors
sbb al,al ; carry: al=ff, else al=0
and al,ah ; carry: error code, else 0
@ -160,75 +139,84 @@ fl_error:
pop bp
ret 14
; COUNT fl_lba_ReadWrite(BYTE drive, UWORD mode, VOID FAR *dap_p)
;
; COUNT ASMPASCAL fl_lba_ReadWrite(BYTE drive, WORD mode, void FAR * dap_p);
;
; Returns 0 if successful, error code otherwise.
;
global FL_LBA_READWRITE
FL_LBA_READWRITE:
push bp ; C entry
push bp ; setup stack frame
mov bp,sp
push ds
push si ; wasn't in kernel < KE2024Bo6!!
mov dl,[bp+10] ; get the drive (if ored 80h harddrive)
mov dl,[bp+10] ; drive (if or'ed with 80h a hard drive)
mov ax,[bp+8] ; get the command
lds si,[bp+4] ; get far dap pointer
int 13h ; read from/write to drive
pop si
pop si
pop ds
pop bp
ret_AH:
mov al,ah ; place any error code into al
mov ah,0 ; zero out ah
ret 8
;
; void fl_readkey (void);
; void ASMPASCAL fl_readkey (void);
;
global FL_READKEY
global FL_READKEY
FL_READKEY: xor ah, ah
int 16h
ret
global FL_SETDISKTYPE
;
; COUNT ASMPASCAL fl_setdisktype (WORD drive, WORD type);
;
global FL_SETDISKTYPE
FL_SETDISKTYPE:
pop bx ; return address
pop ax ; disk type (al)
pop ax ; disk format type (al)
pop dx ; drive number (dl)
push bx ; restore stack
mov ah,17h
int 13h
jmp short ret_AH
mov ah,17h ; floppy set disk type for format
int 13h
ret_AH:
mov al,ah ; place any error code into al
mov ah,0 ; zero out ah
ret
;
; COUNT fl_setmediatype (WORD drive, WORD tracks, WORD sectors);
; COUNT 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 bx ; sectors/track
pop cx ; number of tracks
pop dx ; drive number
push ax ; restore stack
push di
push di
dec cx ; should be highest track
xchg ch,cl ; low 8 bits of cyl number
dec cx ; number of cylinders - 1 (last cyl number)
xchg ch,cl ; CH=low 8 bits of last cyl number
ror cl,1 ; extract bits 8-9 of cylinder number...
ror cl,1 ; ...into cl bit 6-7
ror cl,1 ; extract bits 8+9 to cl bit 6+7
ror cl,1
or cl,bl ; or in bits 7-6
or cl,bl ; sectors/track (bits 0-5) or'd with high cyl bits 7-6
mov ah,18h
int 13h
mov ah,18h ; disk set media type for format
int 13h
jc skipint1e
push es
xor dx,dx
mov es,dx

View File

@ -49,6 +49,6 @@ static BYTE *date_hRcsId =
#define REVISION_MINOR 1
#define REVISION_SEQ 35
#define BUILD "2035"
#define SUB_BUILD ""
#define SUB_BUILD "a"
#define KERNEL_VERSION_STRING "1.1.35" /*#REVISION_MAJOR "." #REVISION_MINOR "." #REVISION_SEQ */
#define KERNEL_BUILD_STRING "2035" /*#BUILD SUB_BUILD */
#define KERNEL_BUILD_STRING "2035a" /*#BUILD SUB_BUILD */