[Freedos-kernel] patch: floppy.asm (2/5)

2004-06-08 Thread Arkady V.Belousov
Hi!

Part 2:

- prototypes fixed and syncronized with dsk.c.

Note: I plan in the future join fl_read, fl_write, fl_verify and fl_format
into one function (similar to fl_lba_ReadWrite), consequently, I place those
prototypes near.

--- Begin Message ---
diff -ruNp old/drivers/floppy.asm new/drivers/floppy.asm
--- old/drivers/floppy.asm  2004-06-08 20:00:48.0 +
+++ new/drivers/floppy.asm  2004-06-08 20:10:34.0 +
@@ -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(UBYTE drive);
 ;
-;   returns TRUE if successful
+; Reset both the diskette and hard disk system.
+; returns TRUE if successful.
 ;
 
global  FL_RESET
@@ -51,14 +50,11 @@ FL_RESET:
inc ax  ; TRUE on success, FALSE on failure
 ret
 
-
 ;
+; int ASMPASCAL fl_diskchanged(UBYTE drive);
 ;
-; Read disk change line status
-;
-; COUNT fl_diskchanged(WORD drive)
-;
-;   returns 1 if disk has changed, 0 if not, 0x if error
+; Read disk change line status.
+; returns 1 if disk has changed, 0 if not, 0x if error.
 ;
 
global  FL_DISKCHANGED
@@ -85,35 +81,19 @@ fl_dc_ret:  cbw
 ret
 
 ;
-; 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.
+; int ASMPASCAL fl_read  (UBYTE drive, WORD head, WORD track, WORD sector, WORD 
count, void FAR *buffer);
+; int ASMPASCAL fl_write (UBYTE drive, WORD head, WORD track, WORD sector, WORD 
count, void FAR *buffer);
+; int ASMPASCAL fl_verify(UBYTE drive, WORD head, WORD track, WORD sector, WORD 
count, void FAR *buffer);
+; int ASMPASCAL fl_format(UBYTE drive, WORD head, WORD track, WORD sector, WORD 
count, void FAR *buffer);
 ;
-; 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
@@ -160,11 +140,12 @@ fl_error:
 pop bp
 ret 14
 
-
-; COUNT fl_lba_ReadWrite(BYTE drive, UWORD mode, VOID FAR *dap_p)
+;
+; int ASMPASCAL fl_lba_ReadWrite(UBYTE drive, WORD mode, void FAR * dap);
 ;
 ; Returns 0 if successful, error code otherwise.
 ;
+
global  FL_LBA_READWRITE
 FL_LBA_READWRITE:
pushbp  ; C entry
@@ -187,15 +168,19 @@ FL_LBA_READWRITE:
ret 8
 
 ;
-; void fl_readkey (void);
+; void ASMPASCAL fl_readkey (void);
 ;
 
-global FL_READKEY
+   global  FL_READKEY
 FL_READKEY: xorah, ah
int 16h
ret
 
-global FL_SETDISKTYPE
+;
+; int ASMPASCAL fl_setdisktype (UBYTE drive, WORD type);
+;
+
+   global  FL_SETDISKTYPE
 FL_SETDISKTYPE:
pop bx  ; return address
pop ax  ; disk type (al)
@@ -207,11 +192,12 @@ ret_AH:
mov al,ah   ; place error code into al
mov ah,0
ret
-
+
 ;
-; COUNT fl_setmediatype (WORD drive, WORD tracks, WORD sectors);
+; int ASMPASCAL fl_setmediatype (UBYTE drive, WORD tracks, WORD sectors);
 ;
-global FL_SETMEDIATYPE
+
+   global  FL_SETMEDIATYPE
 FL_SETMEDIATYPE:
pop ax  ; return address
 pop bx ; sectors/track
--- End Message ---


[Freedos-kernel] patch: floppy.asm (3/5)

2004-06-08 Thread Arkady V.Belousov
Hi!

Part three:

- small code clean and tune.

--- Begin Message ---
diff -ruNp old/drivers/floppy.asm new/drivers/floppy.asm
--- old/drivers/floppy.asm  2004-06-08 20:10:34.0 +
+++ new/drivers/floppy.asm  2004-06-08 20:35:36.0 +
@@ -54,7 +54,7 @@ FL_RESET:
 ; int ASMPASCAL fl_diskchanged(UBYTE drive);
 ;
 ; Read disk change line status.
-; returns 1 if disk has changed, 0 if not, 0x if error.
+; returns 1 if disk has changed, 0 if not, 0xFF if error.
 ;
 
global  FL_DISKCHANGED
@@ -67,18 +67,14 @@ FL_DISKCHANGED:
 mov ah,16h  ;  read change status type
xor si,si   ; RBIL: avoid crash on AT&T 6300
 int 13h
+   pop si
 
-   mov al,1
-jncfl_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
-popsi
-ret
+   sbb al,al   ; CF=0 (disk has not changed)
+   jnc ret_AH_0; ...return 0
+   cmp ah,6; ah!=6 (error)
+   jne ret_AH_0; ...return 0xFF
+   mov al,1; ah=6 (disk has changed)
+   jmp short ret_AH_0  ; ...return 1
 
 ;
 ; int ASMPASCAL fl_read  (UBYTE drive, WORD head, WORD track, WORD sector, WORD 
count, void FAR *buffer);
@@ -172,7 +168,8 @@ FL_LBA_READWRITE:
 ;
 
global  FL_READKEY
-FL_READKEY: xorah, ah
+FL_READKEY:
+   mov ah,0
int 16h
ret
 
@@ -190,6 +187,7 @@ FL_SETDISKTYPE:
 int 13h
 ret_AH:
mov al,ah   ; place error code into al
+ret_AH_0:
mov ah,0
ret
 
--- End Message ---


[Freedos-kernel] patch: floppy.asm (1/5)

2004-06-08 Thread Arkady V.Belousov
Hi!

 Because some peoples complain that my patches too big, I split patch
for floppy.asm by some consequtive part. Part one:

- bugfix: when fl_lba_ReadWrite() converted to ASMPASCAL (and `ret' replaced
  by `ret 8'), "ret_AH" was remained as label for this tail (whereas other
  functions use plain `ret'); now ret_AH moved into another function.

--- Begin Message ---
diff -ruNp old/drivers/floppy.asm new/drivers/floppy.asm
--- old/drivers/floppy.asm  2004-04-09 06:11:44.0 +
+++ new/drivers/floppy.asm  2004-06-08 20:00:48.0 +
@@ -182,7 +182,6 @@ FL_LBA_READWRITE:
pop ds
 
pop bp
-ret_AH:
mov al,ah   ; place any error code into al
mov ah,0; zero out ah   
ret 8
@@ -204,7 +203,10 @@ FL_SETDISKTYPE:
pushbx  ; restore stack
 mov ah,17h
 int 13h
-   jmp short ret_AH
+ret_AH:
+   mov al,ah   ; place error code into al
+   mov ah,0
+   ret
 
 ;
 ; COUNT fl_setmediatype (WORD drive, WORD tracks, WORD sectors);
--- End Message ---


[Freedos-kernel] patch: floppy.asm (4/5)

2004-06-08 Thread Arkady V.Belousov
Hi!

Part four, changed only comments, code unchanged.

- fixed wrong comments, more and better comments.

--- Begin Message ---
diff -ruNp old/drivers/floppy.asm new/drivers/floppy.asm
--- old/drivers/floppy.asm  2004-06-08 20:35:36.0 +
+++ new/drivers/floppy.asm  2004-06-08 21:12:22.0 +
@@ -43,12 +43,11 @@ FL_RESET:
pop ax  ; return address
pop dx  ; drive
pushax  ; restore address
-mov ah,0; BIOS reset diskette & fixed disk
+   mov ah,0; reset disk
 int 13h
-
-sbbax,ax   ; cy==1 is error
-   inc ax  ; TRUE on success, FALSE on failure
-ret
+   sbb ax,ax   ; CF=1: error
+   inc ax  ; ...return TRUE (1) on success,
+   ret ;  FALSE (0) on error
 
 ;
 ; int ASMPASCAL fl_diskchanged(UBYTE drive);
@@ -60,11 +59,11 @@ FL_RESET:
global  FL_DISKCHANGED
 FL_DISKCHANGED:
pop ax  ; return address
-   pop dx  ; get the drive number
+   pop dx  ; drive
pushax  ; restore stack
-   pushsi  ; restore stack
 
-mov ah,16h  ;  read change status type
+   pushsi
+   mov ah,16h  ; read change status type
xor si,si   ; RBIL: avoid crash on AT&T 6300
 int 13h
pop si
@@ -87,52 +86,47 @@ FL_DISKCHANGED:
 
global  FL_FORMAT
 FL_FORMAT:
-mov ah, 5
+   mov ah,5; format track
 jmp short fl_common
 
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:
-pushbp  ; C entry
+   pushbp
 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
-
-xchgch,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
+
+   xchgch,cl   ; ch=low 8 bits of cylinder number
+   ror cl,1; bits 8-9 of cylinder number...
+rorcl,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)
+   mov dh,[bp+14]  ; head number
+   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
 
@@ -144,23 +138,19 @@ fl_error:
 
global  FL_LBA_READWRITE
 FL_LBA_READWRITE:
-   pushbp  ; C entry
+   pushbp
mov bp,sp
-   
pushd

[Freedos-kernel] Another LBACACHE test

2004-06-08 Thread The Somertons
Hi all

I did the LBACACHE test again on that 386, (same as Test 2 in the previous
e-mail; copy the same approx 1.2 MB file 10 times).

CONFIG.SYS
DEVICE=C:\DOS\FDXXMS.SYS
DOS=HIGH
FILES=20
BUFFERS=20
STACKS=0,0

AUTOEXEC.BAT
@ECHO OFF
PATH=C:\DOS
LBACACHE BUF 12

Result:

LBACACHE, 3 MB: 1 minute 10 seconds

SMARTDRV results (also the LBACACHE info data) should be coming soon.

Justin



---
This SF.Net email is sponsored by: GNOME Foundation
Hackers Unite!  GUADEC: The world's #1 Open Source Desktop Event.
GNOME Users and Developers European Conference, 28-30th June in Norway
http://2004/guadec.org
___
Freedos-kernel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/freedos-kernel


[Freedos-kernel] More LBACACHE test results

2004-06-08 Thread The Somertons
Hi again,

Here's more LBACACHE test results along with SMARTDRV comparisons. Maybe
more tests will be done later.

CONFIG.SYS contents:
DEVICE=C:\DOS\FDXXMS.SYS
DOS=HIGH
FILES=20
BUFFERS=20
STACKS=0,0
LASTDRIVE=E

AUTOEXEC.BAT contents:
@ECHO OFF
PATH=C:\DOS
(disk cache command)

Test 1, a 1.2 MB file copied 10 times (same as last time):

No disk cache: 1:10

LBACACHE 3 MB, 1:10
SMARTDRV 3 MB, 0:48
SMARTDRV WC 3 MB, 0:50

LBACACHE 8 MB, 1:11

LBACACHE 11 MB, 1:07
SMARTDRV 11 MB, 0:52
SMARTDRV WC 11 MB, 0:16

LBACACHE 256 KB, 1:13

LBACACHE 512 KB, 1:14
SMARTDRV 512 KB, 1:11

Info samples (edited for easy reading):

LBACACHE 3 MB
XMS handle has size (in kB) 3072
read  hits:   00010802  read  misses: 00010867
write hits:   0087  write misses: 00021664
sectors per bin in table: 0016  bytes per bin in table: 0008
*** kilo-reads:   0021  --> percentage of hits:  0049
*** kilo-writes:  0021  --> percentage of hits:  

SMARTDRV 3 MB
Room for384 elements of   8,192 bytes each
There have been   1,493 cache hits
and   1,690 cache misses

SMARTDRV WC 3 MB
Room for384 elements of   8,192 bytes each
There have been   1,762 cache hits
and   1,508 cache misses

Hope it all makes sense,

Justin



---
This SF.Net email is sponsored by: GNOME Foundation
Hackers Unite!  GUADEC: The world's #1 Open Source Desktop Event.
GNOME Users and Developers European Conference, 28-30th June in Norway
http://2004/guadec.org
___
Freedos-kernel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/freedos-kernel


Re: [Freedos-kernel] Re: Kernel bug parade / moving on

2004-06-08 Thread Arkady V.Belousov
Hi!

7-Июн-2004 04:48 [EMAIL PROTECTED] (Eric Auer) wrote to
[EMAIL PROTECTED]:

>> EA> * 698 floppy change / floppy DMA boundary check should be moved from
>> EA>   "int" 25/26 to the int 13 handler.
>>  Hm. Probably I not very understand this request, but FreeDOS does all
>> DMA checks in dsk.c:LBA_Transfer().
EA> Moving the check to int 13 means that DOS programs which use int 13 directly
EA> never have to worry about DMA boundaries. MS DOS provides this service. It
EA> also
EA> hooks int 13 to have more secure detection of disk changes (i.e. even if the

 Hm. I myself don't ready to introduce such (complex) feature.

>> EA> * 1176 second floppy controller not detected.
>>  FreeDOS detects second floppy drive presence through analyzing
>> "equipment list" (INT 11) ...
EA> Yes, sure, but I wrote about second floppy CONTROLLER. This is the thing
EA> to which you connect the third and possibly fourth floppy drive and which
EA> - I believe - can only be found in 808x PCs, not in newer models. Not sure
EA> if the BIOS has or needs special support for that as well.

 As I understand, for BIOS this is easy: "floppy drives" numbered from 0
to 7F, hard disks numbered 80..FF. Thus, BIOS allows to have 128 floppy
drives. :) Of course, eqipment list enumerates only up to four drives (two
bits). Inefficient logic: with bit 0 eq.list there was possible to enumerate
up to 7 drives.

 How DOS should deal with third and fourth drives - I don't know, but I
suggest, this is possible only through driver.sys (there you point physical
drive number 0..127, and it traps next logical drive letter).

 In any case, this is not issue for kernel itslef (unless you builtin
driver.sys functionality, say, over drivparm= statement)

>> EA> * 1630 int 21.4bxx should clear the high parts of the general 32 bit
>>  ? _Why_ DOS "should" clear hight parts of 32-bit registers?!
EA> Because some programs would conceivably assume that the high parts are 0
EA> instead of setting them to 0 manually. Check www.256b.com to see that DOS
EA> programs sometimes assume quite a lot of stuff about initial register
EA> values.

 FD _already_ imitates most MS-DOS (undocumented garbage) - see
task.c:load_transfer(), where Lucho adds some initializations. I don't think
that we should add there also dealing with 32-bit registers, especially I
doubt that (16-bit) MS-DOS deals with high parts of 32-bit registers.

>>  To make UMBs, DOS uses XMS services.
EA> Good point. Then UMBs on pre-286 PCs would need really special drivers.

 Of course.

EA> Anyway, you can tell the user that UMBs are almost impossible if you detect
EA> an 808x at boot time then (i.e. if the user tries to use UMBs then the error
EA> message can be more helpful: If 286+, suggest loading an XMS plus if needed
EA> an extra UMB or if 386+ EMM386 driver. If 808x, suggest giving up X-)). Same

 Ie. you offer to integrate help, tutor and training subsystem into
kernel? Currently DOS ignores DOS=UMB statement, if there are no UMBs
available. I think, extra messages like "NO UPPER MEMORY AVAILABLE FOR YOUR
DOS=UMB STATEMENT" makes only uncomfortable noise. I think, such messages is
an issue for system information programs - for example, Manifest from QEMM
package offers `Hints' menu, where it offer tips how to optimize the system
(like "Reduce the number of DOS FILES allocated").

>> EA> * 1789 the builtin disk format (!) function causes weird kernel error
>> EA>   message LBA-Transfer error...
EA> Sorry, there is a word missing in the above!!
EA> The builtin disk format function OF PKZIP causes weird kernel error message
EA> ...

 Hm. May you give details?




---
This SF.Net email is sponsored by: GNOME Foundation
Hackers Unite!  GUADEC: The world's #1 Open Source Desktop Event.
GNOME Users and Developers European Conference, 28-30th June in Norway
http://2004/guadec.org
___
Freedos-kernel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/freedos-kernel


[Freedos-kernel] Re: Re: Re: Kernel bug parade / moving on

2004-06-08 Thread Eric Auer

Hi Arkady!

The bug submitter for "clear high parts of 32 bit registers on exec"
claims to have experienced actual problems because of one program leaving
values in registers and another program assuming those parts to be 0.
However, he does not tell anything about which program is affected.

If it would be DOS4GW then we would be really motivated :-).

>  How DOS should deal with third and fourth drives - I don't know, but I
> suggest, this is possible only through driver.sys (there you point physical
> drive number 0..127, and it traps next logical drive letter).

You just said that BIOS would handle it and that equipment list can handle
up to four drives as well. So why would we need a driver sys for it? And I
do indeed suggest to make driver sys a kernel builtin if we need it at all.

>  Ie. you offer to integrate help, tutor and training subsystem into
> kernel? Currently DOS ignores DOS=UMB statement, if there are no UMBs
> available. I think, extra messages like "NO UPPER MEMORY AVAILABLE FOR YOUR
> DOS=UMB STATEMENT" makes only uncomfortable noise.

This is partially true. Better error messages are sometimes good but a whole
tutor system would mean noise. By the way, does the kernel suppress showing
more than one UMB-warning if you have more than one DEVICEHIGH/INSTALLHIGH now?
Bernd filed a bug report / feature request to suppress the extra noise.

> Manifest from QEMM
> package offers `Hints' menu, where it offer tips how to optimize the system

This reminds me that some QEMM versions spoil APMDOS / ADV:... mode of
FDAPM (i.e. it saves no energy if QEMM loaded). If you have QEMM yourself,
feel free to test whether your version is affected in combination with your
CPU and BIOS. Manifest was a cool piece of software at the time.

About bug 1789, kernel confused by PKZIP-builtin format command: I think
the LBA-... error message happened at the beginning and the end of the
process. But please do read the whole bugzilla entry and contact the bug
reporter to learn more, I do not use PKZIP (I use Info-ZIP ZIP / UNZIP).

Eric



---
This SF.Net email is sponsored by: GNOME Foundation
Hackers Unite!  GUADEC: The world's #1 Open Source Desktop Event.
GNOME Users and Developers European Conference, 28-30th June in Norway
http://2004/guadec.org
___
Freedos-kernel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/freedos-kernel