Subject: Re: May 14 scsi changes: driver support needed?
To: None <thorpej@zembu.com>
From: Juergen Hannken-Illjes <hannken@eis.cs.tu-bs.de>
List: current-users
Date: 05/21/2001 17:31:52
> On Mon, May 21, 2001 at 03:40:58PM +0200, Manuel Bouyer wrote:
> 
>  > Hum, this means we need to add __attribute__((packed)) to all structs defining
>  > SCSI commands or results ? Looks strange to me, as this worked before without
>  > this ... Or maybe we need them only for scsipi_mode_sense and
>  > scsipi_mode_select, as they're the only ones with union in the struct ?
> 
> In fact, a union of 2 structs.  Structres have minimum alignments on
> some architectures, regardless of what they have inside them.
> 
> We should add __packed__ to all of SCSI "wire protocol" structures,
> definitely.
> 
> -- 
>         -- Jason R. Thorpe <thorpej@zembu.com>

The addition of those attributes doesn't cure the MODE SELECT problem.
The scsi command still has 7 instead of 6 bytes.

The following diff works at least for scsi:

 #define	MODE_SELECT		0x15
 struct scsipi_mode_select {
 	u_int8_t opcode;
 	u_int8_t byte2;
 #define	SMS_SP	0x01		/* save page */
 #define	SMS_PF	0x10
-	u_int8_t unused[2];
+	u_int8_t unused;
 	union {
 		struct {
 			u_int8_t unused;
 			u_int8_t length;
 		} scsi __attribute__((packed));
 		struct {
 			u_int8_t length[2];
 		} atapi __attribute__((packed));
 	} u_len;
 	u_int8_t control;
 } __attribute__((packed));

This gives:

	scsi	atapi

0:	opcode	opcode
1:	byte2	byte2
2:	unused	unused
3:	unused	length
4:	length	length
5:	control	control
 
If the atapi command has 7 bytes we need either two structs or must adjust
the command length passed during command execution.
-- 
Juergen Hannken-Illjes - hannken@eis.cs.tu-bs.de - TU Braunschweig (Germany)