Use pascal calling conventions for floppy asm functions.

git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@850 6ac86273-5f31-0410-b378-82cca8765d1b
This commit is contained in:
Bart Oldeman 2004-04-09 13:11:25 +00:00
parent 950078ad08
commit 7012672d7d
2 changed files with 57 additions and 75 deletions

View File

@ -28,12 +28,8 @@
; $Id$ ; $Id$
; ;
%ifndef SYS
%include "../kernel/segs.inc" %include "../kernel/segs.inc"
segment HMA_TEXT segment HMA_TEXT
%else
segment _TEXT class=CODE
%endif
; ;
; ;
; Reset both the diskette and hard disk system ; Reset both the diskette and hard disk system
@ -43,12 +39,11 @@
; returns TRUE if successful ; 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
push dx ; restore stack push ax ; restore address
push ax ;
mov ah,0 ; BIOS reset diskette & fixed disk mov ah,0 ; BIOS reset diskette & fixed disk
int 13h int 13h
@ -66,14 +61,15 @@ _fl_reset:
; returns 1 if disk has changed, 0 if not, 0xFFFF if error ; 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 ; get the drive number
push dx ; restore stack push ax ; restore stack
push ax ; push si ; restore stack
mov ah,16h ; read change status type mov ah,16h ; read change status type
xor si,si ; RBIL: avoid crash on AT&T 6300
int 13h int 13h
mov al,1 mov al,1
@ -85,6 +81,7 @@ _fl_diskchanged:
fl_dc_ret1: dec ax fl_dc_ret1: dec ax
fl_dc_ret: cbw fl_dc_ret: cbw
pop si
ret ret
; ;
@ -95,8 +92,8 @@ fl_dc_ret: cbw
; Formats one or more tracks, sector should be 0. ; Formats one or more tracks, sector should be 0.
; ;
; 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
jmp short fl_common jmp short fl_common
; ;
@ -117,25 +114,25 @@ _fl_format:
; ;
; Returns 0 if successful, error code otherwise. ; 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 ; cmd READ
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 ; cmd verify
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 ; cmd WRITE
fl_common: fl_common:
push bp ; C entry push bp ; C entry
mov bp,sp mov bp,sp
mov cx,[bp+8] ; 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 3ff=1023
@ -146,12 +143,12 @@ fl_common:
ror cl,1 ror cl,1
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+0Ch] ; count to read/write mov al,[bp+08h] ; count to read/write
les bx,[bp+0Eh] ; Load 32 bit buffer ptr les bx,[bp+04h] ; Load 32 bit buffer ptr
mov dl,[bp+4] ; get the drive (if or'ed 80h its mov dl,[bp+10h] ; get the drive (if or'ed 80h its
; hard drive. ; hard drive.
mov dh,[bp+6] ; get the head number mov dh,[bp+0Eh] ; get the head number
int 13h ; write sectors from mem es:bx int 13h ; write sectors from mem es:bx
@ -161,24 +158,24 @@ fl_common:
fl_error: fl_error:
mov ah,0 ; force into < 255 count mov ah,0 ; force into < 255 count
pop bp pop bp
ret ret 14
; COUNT fl_lba_ReadWrite(BYTE drive, UWORD mode, VOID FAR *dap_p) ; COUNT fl_lba_ReadWrite(BYTE drive, UWORD 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 ; C entry
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+4] ; get the drive (if ored 80h harddrive) mov dl,[bp+10] ; get the drive (if ored 80h harddrive)
mov ax,[bp+6] ; get the command mov ax,[bp+8] ; get the command
lds si,[bp+8] ; 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
pop si pop si
@ -188,25 +185,23 @@ _fl_lba_ReadWrite:
ret_AH: 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 ret 8
; ;
; void fl_readkey (void); ; void 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 global FL_SETDISKTYPE
_fl_setdisktype: FL_SETDISKTYPE:
pop bx ; return address pop bx ; return address
pop dx ; drive number (dl)
pop ax ; disk type (al) pop ax ; disk type (al)
push ax ; restore stack pop dx ; drive number (dl)
push dx push bx ; restore stack
push bx
mov ah,17h mov ah,17h
int 13h int 13h
jmp short ret_AH jmp short ret_AH
@ -214,16 +209,13 @@ _fl_setdisktype:
; ;
; COUNT fl_setmediatype (WORD drive, WORD tracks, WORD sectors); ; COUNT 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 dx ; drive number
pop cx ; number of tracks
pop bx ; sectors/track pop bx ; sectors/track
push bx ; restore stack pop cx ; number of tracks
push cx pop dx ; drive number
push dx push ax ; restore stack
push ax
push di push di
dec cx ; should be highest track dec cx ; should be highest track

View File

@ -41,39 +41,29 @@ static BYTE *dskRcsId =
/* #define STATIC */ /* #define STATIC */
#ifdef PROTO BOOL ASMPASCAL fl_reset(WORD);
BOOL ASMCFUNC fl_reset(WORD); COUNT ASMPASCAL fl_diskchanged(WORD);
COUNT ASMCFUNC fl_readdasd(WORD);
COUNT ASMCFUNC fl_diskchanged(WORD);
COUNT ASMCFUNC fl_rd_status(WORD);
COUNT ASMCFUNC fl_format(WORD, WORD, WORD, WORD, WORD, UBYTE FAR *); COUNT ASMPASCAL fl_format(WORD, WORD, WORD, WORD, WORD, UBYTE FAR *);
COUNT ASMCFUNC fl_read(WORD, WORD, WORD, WORD, WORD, UBYTE FAR *); COUNT ASMPASCAL fl_read(WORD, WORD, WORD, WORD, WORD, UBYTE FAR *);
COUNT ASMCFUNC fl_write(WORD, WORD, WORD, WORD, WORD, UBYTE FAR *); COUNT ASMPASCAL fl_write(WORD, WORD, WORD, WORD, WORD, UBYTE FAR *);
COUNT ASMCFUNC fl_verify(WORD, WORD, WORD, WORD, WORD, UBYTE FAR *); COUNT ASMPASCAL fl_verify(WORD, WORD, WORD, WORD, WORD, UBYTE FAR *);
COUNT ASMCFUNC fl_setdisktype(WORD, WORD); COUNT ASMPASCAL fl_setdisktype(WORD, WORD);
COUNT ASMCFUNC fl_setmediatype(WORD, WORD, WORD); COUNT ASMPASCAL fl_setmediatype(WORD, WORD, WORD);
VOID ASMCFUNC fl_readkey(VOID); VOID ASMPASCAL fl_readkey(VOID);
extern COUNT ASMPASCAL fl_lba_ReadWrite(BYTE drive, WORD mode,
extern COUNT ASMCFUNC fl_lba_ReadWrite(BYTE drive, WORD mode,
struct _bios_LBA_address_packet FAR struct _bios_LBA_address_packet FAR
* dap_p); * dap_p);
#ifdef __WATCOMC__
#pragma aux (pascal) fl_reset modify exact [ax dx]
#pragma aux (pascal) fl_diskchanged modify exact [ax dx]
#pragma aux (pascal) fl_setdisktype modify exact [ax bx dx]
#pragma aux (pascal) fl_readkey modify exact [ax]
#pragma aux (pascal) fl_lba_ReadWrite modify exact [ax dx]
#endif
STATIC int LBA_Transfer(ddt * pddt, UWORD mode, VOID FAR * buffer, STATIC int LBA_Transfer(ddt * pddt, UWORD mode, VOID FAR * buffer,
ULONG LBA_address, unsigned total, UWORD * transferred); ULONG LBA_address, unsigned total, UWORD * transferred);
#else
BOOL ASMCFUNC fl_reset();
COUNT ASMCFUNC fl_readdasd();
COUNT ASMCFUNC fl_diskchanged();
COUNT ASMCFUNC fl_rd_status();
COUNT ASMCFUNC fl_format();
COUNT ASMCFUNC fl_read();
COUNT ASMCFUNC fl_write();
COUNT ASMCFUNC fl_verify();
VOID ASMCFUNC fl_readkey();
COUNT ASMCFUNC fl_setmediatype();
COUNT ASMCFUNC fl_setdisktype();
#endif
#define NENTRY 26 /* total size of dispatch table */ #define NENTRY 26 /* total size of dispatch table */