ASPI issue

ASPI issue

Post by Nick » Mon, 07 Jul 2003 20:48:48



Hello all,

I'm attempting to write a programs to read SCSI drives, hence I need
to use ASPI. Unfortunately the ASPI drivers are in real mode and DJGPP
is in protected mode. That's where my problems begin.

My code is

void ( *Aspi )( unsigned char * ) = ( void  * )0;

static __dpmi_regs              callback_regs;
static _go32_dpmi_seginfo       callback_info;

typedef struct {
        unsigned char commandCode;
        unsigned char commandStatus;
        unsigned char hostAdapterNo;
        unsigned char scsiRequestFlag;
        unsigned char reserved1[ 4 ];
        unsigned char targetId;
        unsigned char targetLun;
        unsigned char dataAllocLength[4];
        unsigned char senseAllocLength;
        unsigned char dataBufferOffset[4];
        unsigned char dataBufferSegment[4];
        unsigned char srbLinkOffest[4];
        unsigned char srbLinkSegment[4];
        unsigned char scsiCdbLength;
        unsigned char hostAdapterStatus;
        unsigned char targetStatus;
        unsigned char postRoutineOffset[4];
        unsigned char postRoutineSegment[4];
        unsigned char reserved2[ 34 ];
        unsigned char cdb[ 6 ];
        unsigned char sense[ SENSE_LENGTH ];

Quote:} srbCdb6;

srbCdb6 srb;

int AspiInit()
{
        int handle;
        __dpmi_regs rg;

        if( ( handle = open( "SCSIMGR$", O_RDONLY ) ) == -1 ){
                printf( "Error : ASPI SCSI manager not found.\n" );
                printf( " Please add ASPI SCSI manager to your
config.sys.\n" );
                return( -1 );
        }

        callback_info.pm_offset = (long)Aspi;
        _go32_dpmi_allocate_real_mode_callback_retf(&callback_info,
&callback_regs);

        rg.x.ax = 0x4402;               /* IOCTL in */
        rg.x.bx = handle;
        rg.x.cx = 4;
        rg.x.es = callback_info.rm_segment;
        rg.x.dx = callback_info.rm_offset;
        __dpmi_int(0x21, &rg);

        close( handle );

        return( 0 );

Quote:}

And when I try to use Aspi(srb) I have a seg fault. I assume it's
because either srb should be in Dos memory, but i've copied it in __tb
and it crashed as well, or Aspi is not well defined, or there is
something else I didn't catch.

Thanks for your help
Nick

 
 
 

ASPI issue

Post by Andre » Tue, 08 Jul 2003 19:16:17


This should help a bit, but is not all of the info you need.
Quote:>typedef struct {
>    unsigned char commandCode;
>    unsigned char commandStatus;
... SNIP..
>    unsigned char reserved2[ 34 ];
>    unsigned char cdb[ 6 ];
>    unsigned char sense[ SENSE_LENGTH ];
>} srbCdb6;

This structure may need to be packed. See the FAQ for how to pack a
structure.

Quote:>    callback_info.pm_offset = (long)Aspi;
>    _go32_dpmi_allocate_real_mode_callback_retf(&callback_info,
>&callback_regs);

>    rg.x.ax = 0x4402;               /* IOCTL in */
>    rg.x.bx = handle;
>    rg.x.cx = 4;
>    rg.x.es = callback_info.rm_segment;
>    rg.x.dx = callback_info.rm_offset;
>    __dpmi_int(0x21, &rg);

>    close( handle );

>    return( 0 );
>}

>And when I try to use Aspi(srb) I have a seg fault. I assume it's
>because either srb should be in Dos memory, but i've copied it in __tb
>and it crashed as well, or Aspi is not well defined, or there is
>something else I didn't catch.

Did you look at Ralph Brown's Interrupt list for what the 0x4402 call
needs and what is returned. Make sure you get it from Raph's home page
links as there are allot of very old versions out there. I can't
rember the URL.

It may be usefull to download the DJLS203.zip or DJLS204.ZIP and see
if there are any similar int 21calls so you can see how the LIBC does
it. This is a long shot, but may help.

Andrew

 
 
 

ASPI issue

Post by Nick » Wed, 09 Jul 2003 03:19:45




Quote:>This should help a bit, but is not all of the info you need.

Thank you very much, I'll have a look at it.

Nick

 
 
 

ASPI issue

Post by Eli Zaretski » Tue, 15 Jul 2003 04:18:55



> Newsgroups: comp.os.msdos.djgpp
> Date: Sun, 06 Jul 2003 13:48:48 +0200

> My code is

> void ( *Aspi )( unsigned char * ) = ( void  * )0;

Where's the pointer to Aspi set to something non-zero?  I don't see
anything in your code that does that.  Did I miss something?

Quote:>    callback_info.pm_offset = (long)Aspi;

This is only valid if Aspi is a real function, not a NULL pointer.
That is, you need to write a _real_ handler function called Aspi.

Quote:> And when I try to use Aspi(srb) I have a seg fault.

Please post the full text of the crash message, complete with
registers' dump and SYMIFY'ed call traceback.  That info is very
important to find the reason(s) for the crash.

Quote:> I assume it's
> because either srb should be in Dos memory, but i've copied it in __tb
> and it crashed as well, or Aspi is not well defined, or there is
> something else I didn't catch.

I think it's because Aspi is a NULL pointer.  You cannot call a NULL
pointer without crashing.
 
 
 

ASPI issue

Post by Eli Zaretski » Tue, 15 Jul 2003 04:20:22



> Newsgroups: comp.os.msdos.djgpp
> Date: Mon, 07 Jul 2003 20:16:17 +1000
> >typedef struct {
> >       unsigned char commandCode;
> >       unsigned char commandStatus;
> ... SNIP..
> >       unsigned char reserved2[ 34 ];
> >       unsigned char cdb[ 6 ];
> >       unsigned char sense[ SENSE_LENGTH ];
> >} srbCdb6;
> This structure may need to be packed.

No, it doesn't: all the struct members are declared `char', so they
are already packed (since a char member doesn't require any alignment.