One of my computers running FreeDOS is a quite new notebook with 2TB hard 
disk of NVMe type.

(Samsung SSD 970 EVO Plus 2TB)

FreeDOS boots to own cca 32GB FAT32 partition.

It works but sometimes I have problems with writes. (Reading is always OK)

When I want to write something (usualy when I copy file) I often get a error
message like "General failure" or "Write fault"

This problems are only with internal harddisk. When I boot with USB drive 
attached BIOS founds it as BIOS disk 81h, DOS assignes a drive letter (D:)
and no problems are on this drive.




It is not directly a bug of FreeDOS because same behaviour I have also with
MS-DOS 7.1

Today I did more investigations on this problem.




It occurs in DOS function INT21h/AH=40h. (which is called from high-level
languages)

This function has parameter buffer size which is given via CX register.

If I put into CX value 4607 or less, the write is OK. But if I put there 
4608 or more the function falls with error.

BTW: 4608 is 9*512 (just coincidence or clue?)




 Function INT21h/AH=40h also emits en error code in AX register in case of
fault. And it is very strange here because it emits A2h.

However if I call then the function INT21h/AH=59h it shows error 1Fh in AX.
I do not understand why it differs from AX value from 40h function...




I wrote a short pascal program which ilustrates this ( http://www.laaca.
borec.cz/testwrt.zip )


I also tried to debug it with debugger but I can work only in Turbo Debugger
and it cannot go deeper through INT 21h call.

I suppose than INT21h/40h calls INT26h and then is called INT13h. But I am
not able to go this level with Turbo Debugger.

To be short, it seems that in my computer is some bug in BIOS function INT13
h which is not able to serve writes bigger than 4607 bytes. However it seems
to be doable to create some TSR patch for it...




Here is the source of the TESTWRT.PAS

=============================================================

program testwrt;
const HexDigits:array[0..15] of char = '0123456789ABCDEF';

Function HexStr(l:longint):string;
var a:longint;
    s:string;
begin
s:='';
a:=0;
repeat
s:=HexDigits[l and 15]+s;
l:=l div 16;
inc(a);
until l=0;
case Length(s) of
  1:s:='0'+s;
  3:s:='0'+s;
  5:s:='000'+s;
  6:s:='00'+s;
  7:s:='0'+s;
end; {case}
HexStr:=s;
end;



Function SaveToFile(handle:word;p:pointer;len:word):word;assembler;
asm
push ds
lds dx,p
mov cx,len
mov bx,handle
mov ah,40h
int 21h
pop ds
jc @error
mov ax,0
@error:
end;

Procedure ErrorDetails(var _ax:word; var _bh,_bl,_cl:byte);assembler;
asm
mov ah,59h
mov bx,0
int 21h
push es
push di
les di,_ax
mov es:[di],ax

les di,_ax
mov es:[di],ax

les di,_bh
mov es:[di],bh

les di,_bl
mov es:[di],bl

les di,_cl
mov es:[di],cl

pop di
pop es
end;


{const vel = 4607;} {4607 is OK, but 4608 throws error 162}

{4608 = 9*512}
var f:file;
    p:pchar;
    i,j:integer;
    vel:word;
    h:^word;
    w:word;
    _ax:word;
    _bh,_bl,_cl:byte;

begin
writeln('Test program for writting file using blocks of various sizes.');
writeln('Creates file C:\TEST.DAT');
writeln('Usage: TESTWRT <blocksize>');
writeln('<blockfize> is specified in bytes. On my computer it works OK up 
to');
writeln('4607 but 4608 and up throws error.');
writeln;
if ParamCount<>1 then Halt(0);
Val(ParamStr(1),vel,j);
if j<>0 then Halt(0);
if (vel<0) or (vel>32000) then Halt(0);
GetMem(p,vel);
assign(f,'c:\test.dat');
rewrite(f,1);
h:=@f;    {offset 0 = DOS handle}
for j:=0 to vel-1 do p[j]:=char(j); {Lets fill buffer with something 
defined}

for j:=1 to 4 do
    begin
    writeln('Saving portion No.: ',j);
    w:=SaveToFile(h^,p,vel);
    if w<>0 then
       begin
       ErrorDetails(_ax,_bh,_bl,_cl);
       writeln('DOS status: ',w, ' (',hexstr(w),'h)');
       writeln('AX: ',_ax, ' (',hexstr(_ax),'h)');
       writeln('BH: ',_bh, ' (',hexstr(_bh),'h)');
       writeln('BL: ',_bl, ' (',hexstr(_bl),'h)');
       writeln('CL: ',_cl, ' (',hexstr(_cl),'h)');
       end
       else writeln('DOS status: ',w);
    end;

close(f);
FreeMem(p,vel);
end.






_______________________________________________
Freedos-devel mailing list
Freedos-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/freedos-devel

Reply via email to