[comp.sys.amiga.tech] Bug in DoIO / SendIO ??

BEYSSAC@FRESE51.BITNET (03/16/90)

   There seems to be a bug in the KickStart 1.2 DoIO/SendIO routines.
On entry they clear the IO_FLAGS fields of the IoRequest structure.

   The DoIO routine begins with :

   DoIO move.l  A1,-(A7)
        move.b  #1,IO_FLAGS(A1)         ;should be or.b #1 !!!

   SendIO begins with :

   SendIO clr.b IO_FLAGS(A1)            ;should be and.b #$FE !!!


   I discovered this using the trackdisk.device in raw mode with the
IOTDF_INDEXSYNC flag. It didn't work ! I wrote a little patch for DoIO
and SendIO, and now it works as it should. There is no problem with the
other parts of the system.

   I'm not quite sure it must be corrected this way, but as I say
above, it now works.

   Maybe this has already been corrected in the 1.3 roms, I didn't
check...

jjszucs@cbmvax.commodore.com (John J. Szucs) (03/17/90)

In article <9003160832.AA23378@jade.berkeley.edu> BEYSSAC@FRESE51.BITNET writes:
>
>   There seems to be a bug in the KickStart 1.2 DoIO/SendIO routines.
>On entry they clear the IO_FLAGS fields of the IoRequest structure.
>
>   The DoIO routine begins with :
>
>   DoIO move.l  A1,-(A7)
>        move.b  #1,IO_FLAGS(A1)         ;should be or.b #1 !!!
>
>   SendIO begins with :
>
>   SendIO clr.b IO_FLAGS(A1)            ;should be and.b #$FE !!!
>
>
>   I discovered this using the trackdisk.device in raw mode with the
>IOTDF_INDEXSYNC flag. It didn't work ! I wrote a little patch for DoIO
>and SendIO, and now it works as it should. There is no problem with the
>other parts of the system.
>
>   I'm not quite sure it must be corrected this way, but as I say
>above, it now works.
>
>   Maybe this has already been corrected in the 1.3 roms, I didn't
>check...

In the AutoDocs for DoIO is the following paragraph (under the IMPLEMENTATION
section):

	"This function first tries to complete the IO via the "Quick I/O"
	 mechanism. The io_Flags field is always set to IOF_QUICK (0x01)
	 before the internal device call."

In the AutoDocs for SendIO is the following paragraph (under the FUNCTION
section) is the following sentence:

	"The io_Flags field of the IORequest will be set to zero before the
	 request is sent. See BegionIO() for more details."

Based on the above, DoIO and SendIO are functioning in accordance with the
documentation.

If you wish to send an I/O request (such as the trackdisk.device I/O
request you described) without the io_Flags field unchanged, use the BeginIO
function of amiga.lib, which is described (under the FUNCTION section of
the AutoDocs entry for BeginIO function) as:

	"This function takes an IORequest, and passes it directly to the
	 BEGINIO vector of the proper device. This works exactly like
	 SendIO, but does not clear the io_Flags field first."

Note that you must call WaitIO to wait for the completion of the I/O request.

To perform the equivalent of DoIO without io_Flags being modified:

	BeginIO(IORequest); /* send I/O request to device */
	Error=WaitIO(IORequest);  /* wait for I/O request to complete */
	SetSignal(0L,1<<ReplyPort->mp_SigBit);   /* clear reply port signal
						    bit */

where IORequest is an IORequest and ReplyPort is the reply port for the
IORequest.

================================================================================
|| John J. Szucs                    || The opinions expressed are my own and  ||
|| Systems Evaluation Group         || in no way represent the opinions or    ||
|| Product Assurance Department     || policies of Commodore Technology, Inc. ||
|| Commodore Technology, Inc.       || or any associated entity.              ||
================================================================================
UseNet: {rutgers|uunet}!cbmvax!jjszucs | "F u cn rd ths, u cn bcm a cmptr prgmr"
InterNet: jjszucs@cbmvax.commodore.com |

valentin@cbmvax.commodore.com (Valentin Pepelea) (03/21/90)

In article <9003160832.AA23378@jade.berkeley.edu> BEYSSAC@FRESE51.BITNET writes:
>
>   There seems to be a bug in the KickStart 1.2 DoIO/SendIO routines.
>On entry they clear the IO_FLAGS fields of the IoRequest structure.

The io_Flags field is reserved. The four lower bits are reserved to Exec's
own use, and the fours upper bits are reserved for the individual device
driver's use.

>   I discovered this using the trackdisk.device in raw mode with the
>IOTDF_INDEXSYNC flag. It didn't work ! I wrote a little patch for DoIO
>and SendIO, and now it works as it should. There is no problem with the
>other parts of the system.

Indeed, this appears to be a bug, but not where you think it is! In this
case, you are supposed to be calling BeginIO() directly rather than
going indirectly thorugh SendIO() or DoIO(). To use BeginIO() you must
link with amiga.lib.

So this is a documentation bug for the trackdisk.device. The documentation
of the audio.device mentions explicitly that BeginIO() must be used. Thank
you for pointing this bug out.

Valentin
-- 
The Goddess of democracy? "The tyrants     Name:    Valentin Pepelea
may distroy a statue,  but they cannot     Phone:   (215) 431-9327
kill a god."                               UseNet:  cbmvax!valentin@uunet.uu.net
             - Ancient Chinese Proverb     Claimer: I not Commodore spokesman be

bader+@andrew.cmu.edu (Miles Bader) (03/22/90)

valentin@cbmvax.commodore.com (Valentin Pepelea) writes:
> In article <9003160832.AA23378@jade.berkeley.edu> BEYSSAC@FRESE51.BITNET writes:
> >   There seems to be a bug in the KickStart 1.2 DoIO/SendIO routines.
> >On entry they clear the IO_FLAGS fields of the IoRequest structure.
...
> >   I discovered this using the trackdisk.device in raw mode with the
> >IOTDF_INDEXSYNC flag. It didn't work ! I wrote a little patch for DoIO
> >and SendIO, and now it works as it should. There is no problem with the
> >other parts of the system.
> 
> Indeed, this appears to be a bug, but not where you think it is! In this
> case, you are supposed to be calling BeginIO() directly rather than
> going indirectly thorugh SendIO() or DoIO(). To use BeginIO() you must
> link with amiga.lib.
> 
> So this is a documentation bug for the trackdisk.device. The documentation
> of the audio.device mentions explicitly that BeginIO() must be used. Thank
> you for pointing this bug out.

I recall someone asking this a long time ago, and the replies gave the
impression that: 1) it is a bug, 2) it will stay broken for compatibility's
sake (and thus the workaround "BeginIO").

No?  [This is important, of course, since we have the right to feel irritated
about it if really is a bug; I know I've never seen a good reason for it
being a "feature"]

-Miles