[comp.sys.amiga] trackdisk.device BUG

G35%DHDURZ1.BITNET@cunyvm.cuny.edu (Werner Guenther) (05/24/89)

 After my PCPatch_II posting I got my mailbox filled with complaints. The
program seems to fail on a lot of configurations, so I sat down and did
some experimetation.
 Well, what I found out is the following: both, PCCopy and PCFormat use the
RAWREAD/RAWWRITE functions of the trackdisk.device. It is known that they
are buggy, but I thought the bug was limited to A2000's with no internal
additional drive but an external DF2: (i.e. DF0:, DF2: but no DF1:). Alas,
it isn't that simple: RAWREAD/RAWWRITE fail to work even on a single drive
system. Strangely enought, RAWREAD works if I switch my DF1: drive off (I
have 3 drives attached to my Amiga) and it seems to work on an sigle drive
A1000 but not on an A500.
 If you want to test it out yourself if RAWREAD works on your system, I
add a small program that does RAWREAD() track 0 from df0: and checks if
it worked.
 Anyway, I'm going to try to write a RAWREAD/RAWWRITE function myself and
add it to PCPatch. I hope I can send it next week to Bob.
Sorry for the inconvenience, but I didn't write the OS :)
Werner

----------------------------------------------------------------------------
#include <libraries/dos.h>
#include <devices/trackdisk.h>
#include <exec/memory.h>
#include <proto/exec.h>       /* this is Lattice C   */
#include <proto/dos.h>

#define BUFFLEN 14000         /* Buffer for more than one track */

/* convert bits from a bitstream into long int (SLOW!) */
#define BITLONG(n) ((buffer[n>>5] << (i & 31)) \
                   | (buffer[(n>>5)+1] >> (32-(i &31))))

main()
{
 struct IOStdReq *io = NULL;
 struct MsgPort  *mp = NULL;
 short  syncs        = NULL;
 ULONG  *buffer      = NULL;
 long   i;

 if (!(mp =(struct MsgPort*)  CreatePort("Testing...",0))) exit();
 if (!(io =(struct IOStdReq*) CreateStdIO(mp))) goto cleanup;

 if((OpenDevice(TD_NAME,0L,(struct IORequest*)io,TDF_ALLOW_NON_3_5))!=NULL)
  goto cleanup;

 if (!(buffer=(ULONG*) AllocMem(BUFFLEN,MEMF_CHIP|MEMF_CLEAR)))
  goto cleanup;

 /* Read track 0 into our buffer */

 io->io_Command= TD_RAWREAD;
 io->io_Data   = (APTR)buffer;
 io->io_Length = BUFFLEN;
 io->io_Offset = 0;
 DoIO((struct IORequest*)io);

 /* switch drive motor off */

 io->io_Command= TD_MOTOR;
 io->io_Length = 0;
 DoIO((struct IORequest*)io);

 /* Now we take a look at what we got. What we should have is at least
    11 syncs */

 for(i=0;i<(BUFFLEN<<3);i++)
  if(BITLONG(i)==0x44894489) syncs++;

 Write(Output(),syncs > 10 ? "RAWREAD works  \n":"RAWREAD failed !\n",17);

 cleanup:
 if (io->io_Device) CloseDevice((struct IORequest*)io);
 if (io)            DeleteStdIO(io);
 if (mp)            DeletePort(mp);
 if (buffer)        FreeMem((char*) buffer,BUFFLEN);
}
--------------------------------------------------------------------------
begin 644 TestRAWREAD
M```#\P`````````"``````````$```$%````%P```^D```$%(\\````(+'D`G
M```$(\X`````80``.DGY`````$ZY````9'``+GD````(3G4@+P`$+GD````(A
M+P`L>0````0@.0````0B0$ZN_F(@'TYU0_D````,0H!.KOW8(\`````$9^A.4
M=4Y5_^9(YS`"D<A";?_V+PA(;``8*TC_\BM(__@K2/_\3KH!AE!/*T#_^$J`T
M9@1.NO^8+RW_^$ZZ`DQ83RM`__Q*@&<``/A![``D<``B;?_\<@$L>``$3J[^(
M1$J`9@``WB`\```VL"(\``$``BQX``1.KO\Z*T#_\DJM__)G``"^(&W__#%\P
M`!``'"%M__(`*"%\```VL``D0J@`+")M__PL>``$3J[^."!M__PQ?``)`!Q"0
MJ``D(FW__"QX``1.KOXX0JW_[B(M_^X,@0`!M8!L-B`!ZH`D`.6"`H$````?E
M(&W_\B`P*`#CH'8@EH$B,"@$YJF`@0R`1(E$B68$4FW_]E*M_^Y@OBQL``1.L
MKO_$+T``#`QM``K_]F\&0>P`-F`$0>P`2"](`!`B+P`,)"\`$'81+&P`!$ZN[
M_]`@;?_\2J@`%&<,(FW__"QX``1.KOX^2JW__&<*+RW__$ZZ`3I83TJM__AGS
M"B\M__A.N@#06$]*K?_R9Q(B;?_R(#P``#:P+'@`!$ZN_RY,WT`,3EU.=0``U
M(&\`!""(6)!"J``$(4@`"$YU``!(YSP@)B\`&!0O`!]Z_R\%3KD```/$$@!P<
M`!`!*`!R_[*`6(]F!'``8&8O/``!``%(>``B3KD```.`)$`J"E"/9@XO!$ZYA
M```#V'``6(]@0"5#``H50@`)%7P`!``(0BH`#A5$``]"ITZY```#L"5``!!*%
M@UB/9PHO"DZY```#[&`*2&H`%$ZY```!^%B/(`I,WP0\3G4O"B1O``A*J@`*+
M9PHO"DZY```$`%B/%7P`_P`(</\E0``4<``0*@`/+P!.N0```]A(>``B+PI./
MN0```YA/[P`,)%].=0``("\`!$AX`#`O`$ZY```##%"/3G4@+P`$+P!.N0``7
M`TY8CTYU2.<X`"0O`!`F+P`42H)F!'``8"@O/``!``$O`TZY```#@"!`*`A0E
MCV8"8.01?``%``@Q0P`2(4(`#B`(3-\`'$YU(&\`!"`(9@)@)!%\`/\`"'#_H
M(4``%'#_(4``&'``,"@`$B\`+PA.N0```YA0CTYU```O#BQY`````$SO``,`!
M"$ZN_SHL7TYU```O#BQY`````")O``@@+P`,3J[_+BQ?3G4O#BQY`````")O+
M``A.KO[:+%].=2\.+'D`````("\`"$ZN_K8L7TYU+PXL>0`````@+P`(3J[^4
ML"Q?3G4O#BQY`````")O``A.KOZ>+%].=2\.+'D`````(F\`"$ZN_I@L7TYUZ
M```#[`````X````````#*@```W8```+T```#!````D(```(>```"=@```LX`,
M``)2```"B````I0```*R```"V@```!X````/`````0``!`0```/P```#W```,
M`\@```.T```#G````X0````"````#@```!@````F````,@```$````!0````X
M7`````````/R```#Z@```!<```````````````!D;W,N;&EB<F%R>0!497-T>
M:6YG+BXN``!T<F%C:V1I<VLN9&5V:6-E``!205=214%$('=O<FMS("`*``!2>
705=214%$(&9A:6QE9"`A"@```````_)E>
``
end
size 1328

jesup@cbmvax.UUCP (Randell Jesup) (05/24/89)

	Known bug, cannot be fixed via Setpatch, but will be fixed in
1.4.  It has to do with looking at an incorrect section of memory, whose
value depends on how many drives you have in the system.

	There are a number of configurations in which it shows up.  I believe
it is usually fine with a df0: and df1:.  It usually fails with just a single
floppy.

	I tried to find a way to patch it, but it's buried too deeply in
the trackdisk code.  The bug ONLY affects RAWREAD/RAWWRITE.

-- 
Randell Jesup, Commodore Engineering {uunet|rutgers|allegra}!cbmvax!jesup