mirror of
https://github.com/FDOS/kernel.git
synced 2025-07-23 13:54:30 +02:00
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:
parent
fe30b5a698
commit
b4ec361ab6
@ -28,129 +28,108 @@
|
|||||||
; $Id$
|
; $Id$
|
||||||
;
|
;
|
||||||
|
|
||||||
%include "../kernel/segs.inc"
|
%include "../kernel/segs.inc"
|
||||||
segment HMA_TEXT
|
segment HMA_TEXT
|
||||||
|
|
||||||
;
|
;
|
||||||
|
; BOOL ASMPASCAL fl_reset(WORD drive);
|
||||||
;
|
;
|
||||||
; Reset both the diskette and hard disk system
|
; Reset both the diskette and hard disk system.
|
||||||
;
|
; returns TRUE if successful.
|
||||||
; BOOL fl_reset(WORD drive)
|
|
||||||
;
|
|
||||||
; returns TRUE if successful
|
|
||||||
;
|
;
|
||||||
|
|
||||||
global FL_RESET
|
global FL_RESET
|
||||||
FL_RESET:
|
FL_RESET:
|
||||||
pop ax ; return address
|
pop ax ; return address
|
||||||
pop dx ; drive
|
pop dx ; drive, (DL only, bit 7 set resets both floppy & hd)
|
||||||
push ax ; restore address
|
push ax ; restore address
|
||||||
mov ah,0 ; BIOS reset diskette & fixed disk
|
mov ah,0 ; BIOS reset diskette & fixed disk
|
||||||
int 13h
|
int 13h
|
||||||
|
|
||||||
sbb ax,ax ; cy==1 is error
|
sbb ax,ax ; carry set indicates error, AX=-CF={-1,0}
|
||||||
inc ax ; TRUE on success, FALSE on failure
|
inc ax ; ...return TRUE (1) on success,
|
||||||
ret
|
ret ; else FALSE (0) on failure
|
||||||
|
|
||||||
|
|
||||||
;
|
;
|
||||||
|
; COUNT ASMPASCAL fl_diskchanged(WORD drive);
|
||||||
;
|
;
|
||||||
; Read disk change line status
|
; Read disk change line status.
|
||||||
;
|
; returns 1 if disk has changed, 0 if not, 0xFFFF if error.
|
||||||
; COUNT fl_diskchanged(WORD drive)
|
|
||||||
;
|
|
||||||
; returns 1 if disk has changed, 0 if not, 0xFFFF if error
|
|
||||||
;
|
;
|
||||||
|
|
||||||
global FL_DISKCHANGED
|
global FL_DISKCHANGED
|
||||||
FL_DISKCHANGED:
|
FL_DISKCHANGED:
|
||||||
pop ax ; return address
|
pop ax ; return address
|
||||||
pop dx ; get the drive number
|
pop dx ; drive (DL only, 00h-7Fh)
|
||||||
push ax ; restore stack
|
push ax ; restore stack
|
||||||
push si ; restore stack
|
|
||||||
|
|
||||||
|
push si ; preserve value
|
||||||
mov ah,16h ; read change status type
|
mov ah,16h ; read change status type
|
||||||
xor si,si ; RBIL: avoid crash on AT&T 6300
|
xor si,si ; RBIL: avoid crash on AT&T 6300
|
||||||
int 13h
|
int 13h
|
||||||
|
pop si ; restore
|
||||||
|
|
||||||
mov al,1
|
sbb al,al ; AL=-CF={-1,0} where 0==no change
|
||||||
jnc fl_dc_ret1 ; cy==1 is error or disk has changed
|
jnc fl_dc ; carry set on error or disk change
|
||||||
|
cmp ah,6 ; if AH==6 then disk change, else error
|
||||||
cmp ah,6 ; ah=6: disk has changed
|
jne fl_dc ; if error, return -1
|
||||||
je fl_dc_ret
|
mov al, 1 ; set change occurred
|
||||||
dec ax ; 0xFF on error
|
fl_dc: cbw ; extend AL into AX, AX={1,-1}
|
||||||
|
ret ; note: AH=0 on no change, AL set above
|
||||||
fl_dc_ret1: dec ax
|
|
||||||
fl_dc_ret: cbw
|
|
||||||
pop si
|
|
||||||
ret
|
|
||||||
|
|
||||||
;
|
;
|
||||||
; Format Sectors
|
; Format tracks (sector should be 0).
|
||||||
;
|
; COUNT ASMPASCAL fl_format(WORD drive, WORD head, WORD track, WORD sector, WORD count, UBYTE FAR *buffer);
|
||||||
; COUNT fl_format(WORD drive, WORD head, WORD track, WORD sector, WORD count, BYTE FAR *buffer);
|
; Reads one or more sectors.
|
||||||
;
|
; COUNT ASMPASCAL fl_read (WORD drive, WORD head, WORD track, WORD sector, WORD count, UBYTE FAR *buffer);
|
||||||
; Formats one or more tracks, sector should be 0.
|
; 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.
|
; Returns 0 if successful, error code otherwise.
|
||||||
|
;
|
||||||
|
|
||||||
global FL_FORMAT
|
global FL_FORMAT
|
||||||
FL_FORMAT:
|
FL_FORMAT:
|
||||||
mov ah, 5
|
mov ah,5 ; format track
|
||||||
jmp short fl_common
|
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
|
global FL_READ
|
||||||
FL_READ:
|
FL_READ:
|
||||||
mov ah,2 ; cmd READ
|
mov ah,2 ; read sector(s)
|
||||||
jmp short fl_common
|
jmp short fl_common
|
||||||
|
|
||||||
global FL_VERIFY
|
global FL_VERIFY
|
||||||
FL_VERIFY:
|
FL_VERIFY:
|
||||||
mov ah,4 ; cmd verify
|
mov ah,4 ; verify sector(s)
|
||||||
jmp short fl_common
|
jmp short fl_common
|
||||||
|
|
||||||
global FL_WRITE
|
global FL_WRITE
|
||||||
FL_WRITE:
|
FL_WRITE:
|
||||||
mov ah,3 ; cmd WRITE
|
mov ah,3 ; write sector(s)
|
||||||
|
|
||||||
fl_common:
|
fl_common:
|
||||||
push bp ; C entry
|
push bp ; setup stack frame
|
||||||
mov bp,sp
|
mov bp,sp
|
||||||
|
|
||||||
mov cx,[bp+0Ch] ; cylinder number (lo only if hard)
|
mov cx,[bp+0Ch] ; cylinder number (lo only if hard)
|
||||||
|
|
||||||
mov al,1 ; this should be an error code
|
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
|
ja fl_error
|
||||||
|
|
||||||
xchg ch,cl ; ch=low 8 bits of cyl number
|
xchg ch,cl ; ch=low 8 bits of cyl number
|
||||||
ror cl,1 ; extract bits 8+9 to cl
|
ror cl,1 ; bits 8-9 of cylinder number...
|
||||||
ror cl,1
|
ror cl,1 ; ...to bits 6-7 in CL
|
||||||
or cl,[bp+0Ah] ; or in the sector number (bits 0-5)
|
or cl,[bp+0Ah] ; or in the sector number (bits 0-5)
|
||||||
|
|
||||||
mov al,[bp+08h] ; count to read/write
|
mov al,[bp+08h] ; count to read/write (# of sectors)
|
||||||
les bx,[bp+04h] ; Load 32 bit buffer ptr
|
les bx,[bp+04h] ; Load 32 bit buffer ptr into ES:BX
|
||||||
|
|
||||||
mov dl,[bp+10h] ; get the drive (if or'ed 80h its
|
mov dl,[bp+10h] ; drive (if or'ed 80h its a hard drive)
|
||||||
; hard drive.
|
|
||||||
mov dh,[bp+0Eh] ; get the head number
|
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
|
sbb al,al ; carry: al=ff, else al=0
|
||||||
and al,ah ; carry: error code, else 0
|
and al,ah ; carry: error code, else 0
|
||||||
@ -160,20 +139,21 @@ fl_error:
|
|||||||
pop bp
|
pop bp
|
||||||
ret 14
|
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.
|
; Returns 0 if successful, error code otherwise.
|
||||||
;
|
;
|
||||||
|
|
||||||
global FL_LBA_READWRITE
|
global FL_LBA_READWRITE
|
||||||
FL_LBA_READWRITE:
|
FL_LBA_READWRITE:
|
||||||
push bp ; C entry
|
push bp ; setup stack frame
|
||||||
mov bp,sp
|
mov bp,sp
|
||||||
|
|
||||||
push ds
|
push ds
|
||||||
push si ; wasn't in kernel < KE2024Bo6!!
|
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
|
mov ax,[bp+8] ; get the command
|
||||||
lds si,[bp+4] ; get far dap pointer
|
lds si,[bp+4] ; get far dap pointer
|
||||||
int 13h ; read from/write to drive
|
int 13h ; read from/write to drive
|
||||||
@ -182,34 +162,41 @@ FL_LBA_READWRITE:
|
|||||||
pop ds
|
pop ds
|
||||||
|
|
||||||
pop bp
|
pop bp
|
||||||
ret_AH:
|
|
||||||
mov al,ah ; place any error code into al
|
mov al,ah ; place any error code into al
|
||||||
mov ah,0 ; zero out ah
|
mov ah,0 ; zero out ah
|
||||||
ret 8
|
ret 8
|
||||||
|
|
||||||
;
|
;
|
||||||
; void fl_readkey (void);
|
; void ASMPASCAL fl_readkey (void);
|
||||||
;
|
;
|
||||||
|
|
||||||
global FL_READKEY
|
global FL_READKEY
|
||||||
FL_READKEY: xor ah, ah
|
FL_READKEY: xor ah, ah
|
||||||
int 16h
|
int 16h
|
||||||
ret
|
ret
|
||||||
|
|
||||||
global FL_SETDISKTYPE
|
;
|
||||||
|
; COUNT ASMPASCAL fl_setdisktype (WORD drive, WORD type);
|
||||||
|
;
|
||||||
|
|
||||||
|
global FL_SETDISKTYPE
|
||||||
FL_SETDISKTYPE:
|
FL_SETDISKTYPE:
|
||||||
pop bx ; return address
|
pop bx ; return address
|
||||||
pop ax ; disk type (al)
|
pop ax ; disk format type (al)
|
||||||
pop dx ; drive number (dl)
|
pop dx ; drive number (dl)
|
||||||
push bx ; restore stack
|
push bx ; restore stack
|
||||||
mov ah,17h
|
mov ah,17h ; floppy set disk type for format
|
||||||
int 13h
|
int 13h
|
||||||
jmp short ret_AH
|
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:
|
FL_SETMEDIATYPE:
|
||||||
pop ax ; return address
|
pop ax ; return address
|
||||||
pop bx ; sectors/track
|
pop bx ; sectors/track
|
||||||
@ -218,17 +205,18 @@ FL_SETMEDIATYPE:
|
|||||||
push ax ; restore stack
|
push ax ; restore stack
|
||||||
push di
|
push di
|
||||||
|
|
||||||
dec cx ; should be highest track
|
dec cx ; number of cylinders - 1 (last cyl number)
|
||||||
xchg ch,cl ; low 8 bits of cyl number
|
xchg ch,cl ; CH=low 8 bits of last cyl number
|
||||||
|
|
||||||
ror cl,1 ; extract bits 8+9 to cl bit 6+7
|
ror cl,1 ; extract bits 8-9 of cylinder number...
|
||||||
ror cl,1
|
ror cl,1 ; ...into cl bit 6-7
|
||||||
|
|
||||||
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
|
mov ah,18h ; disk set media type for format
|
||||||
int 13h
|
int 13h
|
||||||
jc skipint1e
|
jc skipint1e
|
||||||
|
|
||||||
push es
|
push es
|
||||||
xor dx,dx
|
xor dx,dx
|
||||||
mov es,dx
|
mov es,dx
|
||||||
|
@ -49,6 +49,6 @@ static BYTE *date_hRcsId =
|
|||||||
#define REVISION_MINOR 1
|
#define REVISION_MINOR 1
|
||||||
#define REVISION_SEQ 35
|
#define REVISION_SEQ 35
|
||||||
#define BUILD "2035"
|
#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_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 */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user