WLAN from SDIO to SPI: battle plan
Andy Green
andy at openmoko.com
Wed Aug 27 05:01:54 CEST 2008
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Somebody in the thread at some point said:
| By the way, it's really the "packed" that throws gcc into wild
| confusion. It can get even funnier:
|
| struct {
| volatile int foo;
| } __attribute__((__packed__)) *p;
|
| void bar(void)
| {
| p->foo = 0x42;
| }
|
| # arm-angstrom-linux-gnueabi-gcc -Wall -O -c -o foo.o foo.c
| # arm-angstrom-linux-gnueabi-objdump -d foo.o
|
| [...]
| c: e3a01000 mov r1, #0 ; 0x0
| 10: e3812042 orr r2, r1, #66 ; 0x42
| 14: e5c32000 strb r2, [r3]
| 18: e5d32001 ldrb r2, [r3, #1]
| 1c: e5c31001 strb r1, [r3, #1]
| 20: e5d32002 ldrb r2, [r3, #2]
| 24: e5c31002 strb r1, [r3, #2]
| 28: e5d32003 ldrb r2, [r3, #3]
| 2c: e5c31003 strb r1, [r3, #3]
| [...]
|
| Doesn't quite have the peculiar "byte order" of your example,
| though.
Ah there is a much bigger story there, __packed__ allows the struct
pointer to be at an unaligned address by forcing compiler to operate on
it bytewise. Scroll down about halfway through this:
http://warmcat.com/_wp/2007/05/25/the-alignment-monster/
- -Andy
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org
iEYEARECAAYFAki0w6IACgkQOjLpvpq7dMoB7QCfQ8VE3nnUjyC62w64V+NWmFZK
GcEAnjYytRwZKVbhvhtgYgBA2Pr1u87v
=fQl7
-----END PGP SIGNATURE-----
More information about the openmoko-kernel
mailing list