[oi-dev] Broadcom wireless drivers for OpenIndiana

Jean-Pierre jean-pierre.andre at wanadoo.fr
Fri Apr 26 16:01:11 UTC 2013


Jim Klimov wrote:

[...]

>
> OR...
>
> + parent struct:
> * 4 single-bytes (they do remain single, right?..)
> * 4-byte padding (...or the single-bytes should be 4*2-byte words)
> ++ Sub-structure in the union (8-aligned itself):
> ** 4-byte isl_len (starts at offset 8 from parent struct)
> ** 4-byte padding
> ** 8-byte pointer (8-aligned in both structures)
> ** 8-byte offset (starts at offset 24 from parent struct)
>
> Does this layout fit the actual drivers? :)

Yes, that is correct. The alignment in inner struct
recursively forces both paddings.

Looking at it again, I see that I also had to #if
the attribute "__attribute__((packed))" at the end
of the structure. I did it for my compiler, but I
now think this is plain wrong and had to be deleted
for all 64-bit compilers (it must probably be kept
for 32-bit ones).

> If so, some more #ifdef padding fields are needed, but I guess I can
> craft them based on your offset numbers...
>
> Does the first 4-byte padding belong in the child struct or in the
> parent, prefixing all variations of the union sub-structures?

You need two paddings, the way you showed above. I suggest
the patch below (possibly damaged by the mailer), which
might be overkill :

--- include/ntoskrnl_var.h.ref	2013-04-26 17:20:58.881730000 +0200
+++ include/ntoskrnl_var.h	2013-04-26 17:59:49.473614000 +0200
@@ -848,10 +848,16 @@
  	 * io_stack_location structure is opaque to drivers
  	 * anyway, I'm not going to bother with the extra crap.
  	 */
+#ifdef __amd64__
+	uint32_t	padding1; /* required for alignement */
+#endif

  	union {
  		struct {
  			uint32_t		isl_len;
+#ifdef __amd64__
+			uint32_t		padding1; /* for alignement */
+#endif
  			/* "POINTER_ALIGNMENT" according to msdn */
  			uint32_t		*isl_key;
  			uint64_t		isl_byteoff;
@@ -880,7 +886,7 @@
  			void			*isl_arg3;
  			void			*isl_arg4;
  		} isl_others;
-#if defined(SOZOBON)
+#ifdef __amd64__
  	} isl_parameters;
  #else
  	} isl_parameters __attribute__((packed));





More information about the oi-dev mailing list