Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 14 Sep 2001 15:17:04 -0700
From:      Mike Smith <msmith@freebsd.org>
To:        Warner Losh <imp@harmony.village.org>
Cc:        Mike Smith <msmith@FreeBSD.ORG>, Yar Tikhiy <yar@FreeBSD.ORG>, hackers@FreeBSD.ORG, msmith@mass.dis.org, msmith@mass.dis.org
Subject:   Re: Driver structures & alignment 
Message-ID:  <200109142217.f8EMH4504153@mass.dis.org>
In-Reply-To: Message from Warner Losh <imp@harmony.village.org>  of "Fri, 14 Sep 2001 15:02:45 MDT." <200109142102.f8EL2jt24452@harmony.village.org> 

next in thread | previous in thread | raw e-mail | index | archive | help
> In message <200109132309.f8DN9vX03967@mass.dis.org> Mike Smith writes:
> : Any form of packing is going to cause problems for items that are
> : located in illegal fashions. 
> 
> It is almost more appropriate to use bus_space_{read,write} than using
> memory mapped structures.  The bus macros will work for otherwise
> unaligned thigns, while direct access won't.  Also, the
> compiler/system may optimize things in strange ways that cause
> problems.  Do yourself a big favor and don't go down this path.

The most common use for alignment-sensitive data structures nowadays
is in control structures exchanged with devices via busmaster DMA.

Needless to say, the bus_space functions aren't very useful for this, and
controlled alignment is necessary.

Even then, I really want a mechanical way of generating a stub function to
correct endianness in a structure based on the structure definition; we have
a lot of drivers that are explicitly little-endian due to all this.

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200109142217.f8EMH4504153>