Source-Changes-D archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: CVS commit: src/sys/sys
On Mon, Sep 15, 2014 at 11:58:35AM +0900, NONAKA Kimihiro wrote:
> Hi,
>
> 2014-09-15 3:07 GMT+09:00 Christos Zoulas <christos%astron.com@localhost>:
>
> > Perhaps it is better to memcpy the data to some aligned struct rather
> > than referencing it directly and making it packed (which is not portable).
>
> I wrote the following patch. ok?
>
> Index: ./sys/sys/bootblock.h
> ===================================================================
> RCS file: /cvsroot/src/sys/sys/bootblock.h,v
> retrieving revision 1.57
> diff -u -r1.57 bootblock.h
> --- ./sys/sys/bootblock.h 14 Sep 2014 17:39:06 -0000 1.57
> +++ ./sys/sys/bootblock.h 15 Sep 2014 02:50:00 -0000
> @@ -815,7 +815,7 @@
> uint32_t descBlock; /* first block of driver */
> uint16_t descSize; /* driver size in blocks */
> uint16_t descType; /* system type */
> -} __packed;
> +};
>
> /*
> * system types; Apple reserves 0-15
> @@ -834,6 +834,10 @@
> uint32_t sbData; /* (used internally by ROM) */
> uint16_t sbDrvrCount; /* number of driver descriptors */
> struct apple_drvr_descriptor sb_dd[APPLE_DRVR_MAP_MAX_DESCRIPTORS];
> + /* XXX: Don't access directly.
> + * Data abort occurs by an access to
> + * unaligned address on arm.
> + */
> uint16_t pad[3];
> } __packed;
If the only problem is that some of the uint32_t are 16bit aligned
then use a 32bit type that has __attribute__((aligned(2)) applied to it.
Then the compiler can directlt access the uint16_t fields and need only
use two 16bit accesses for the 32bit ones.
That is already done for the mbr (which has a misaligned 32bit sector
number) and could be in the same file.
Also to get a 4-byte aligned 64bit quantity for amd64's i386 compat.
As mentioned later the memcpy() version won't work.
David
--
David Laight: david%l8s.co.uk@localhost
Home |
Main Index |
Thread Index |
Old Index