[comp.sys.amiga.programmer] Default packet for handlers inconsistent!

david@walking.pub.uu.oz.au (David Le Blanc) (06/17/91)

I am writing my first device handler, and have the following program 
segment:

   WaitPort(MyPort) ;
   MyMessage = GetMsg(MyPort) ;
   DebugPrint(&dmsg,"Messagetype = %lx\n",MyMessage->mn_Node.ln_Type) ;
   pkt = (struct DosPacket *) MyMessage->mn_Node.ln_Name ;
   DebugPrint(&dmsg,"pkt = %lx\n",pkt) ;
   DebugPrint(&dmsg,"type = %lx\n",pkt->dp_Type) ;
   DebugPrint(&dmsg,"arg1 = %lx\n",pkt->dp_Arg1) ;
   DebugPrint(&dmsg,"arg2 = %lx\n",pkt->dp_Arg2) ;
   DebugPrint(&dmsg,"arg3 = %lx\n",pkt->dp_Arg3) ;
   bstr = (char *) (((long) pkt->dp_Arg1) << 2);
   DebugPrint(&dmsg,"bstr = %lx\n",bstr) ;
   len = *bstr ;
   DebugPrint(&dmsg,"len = %lx\n",len) ;

As you can see, I am 'DebugPrint'ing info from the *initial* startup packet,
(and returning FALSE, and an error message).

The problem is that the line 'DebugPrint(&dmsg,"arg1 = %lx\n",pkt->dp_Arg1)'
prints FFFFFF7F when the handler is loaded first time! Every other time
I get 'C3D5A0' or something meaning that it is correct, and the device
name prints correctly. (Not shown in the code fragment)
(The reason I get the initial packet at each access is that I return 'FAIL'
no matter what.)

Why is the FIRST startup packet different than all the rest?

Note that this only happens If I use the 'Mount = 1' entry in the mountlist,
otherwise it behaves as I would have expected.

It seems that if mount=1, the code is loaded and initialised differently than
it would be with mount=0.

Any Ideas? I really want dp_Arg1 to be valid when it starts up!
I assume I can always get the device name from (dp_Arg3<<2)->dvi_Name or some
such. 

Do I assume that dp_Arg1 is nolonger supported properly or what?? Anyone??

Also, when should I set the 'task' field of DevInfo? When I want my handler
to hang around I assume. If I return fail, is the code unloaded? Is it valid
for me to reset the SegList pointer, and unload myself???

Questions questions questions...

PS DebugPrint is a function that sends the text to a msgport called 'debug.port'
   and another program monitoring that port actually outputs the text.

Thanks.
   David.



--
 -----------------------------------------------------------------------------
   David Le Blanc    UUCP (home)   : david@walking.pub.uu.oz.au
   david@walking     ACSNET (work) : david@dogmelb.mlb.geomechanics.csiro.au
 - CSIRO Division of Geomechanics - Fragment analysis and 3D Fractal imaging -
          "What do you mean officer? This bike can't GO 140 km/h"
 -----------------------------------------------------------------------------