From: Marcus Tangermann <Marcus.Tangermann@web.de>
To: linux-embedded@vger.kernel.org
Subject: Re: Alignment on XScale ARM
Date: Sat, 08 Nov 2008 19:37:17 +0100 [thread overview]
Message-ID: <1734891834@web.de> (raw)
Hello,
due to your hints I've found a solution. The problem was simple: The buffer was not word aligned as the Xscale requires.
With
char buffer[8192] __attribute__((aligned(4)));
things are working. Sometimes you don't see the wood for the trees.
So thanks to all for the good hints!
Marcus
> -----Ursprüngliche Nachricht-----
> Von: "Marcus Tangermann" <Marcus.Tangermann@web.de>
> Gesendet: 07.11.08 23:52:43
> An: linux-embedded@vger.kernel.org
> Betreff: Alignment on XScale ARM
> Hi,
>
> we use an XScale 422 (ARM) with a big endian Linux system based on the buildroot environment. It seems there is an alignment problem we have. I've tracked down the problem to the following.
> 1. The data received via a netlink communication from the kernel is stored into a buffer buf. The data is correct.
> 2. The address of the buffer is converted to a pointer to nlmsghdr:
> struct nlmsghdr *h;
> h = (struct nlmsghdr*) buf;
> printf("IPSECTOOLS: Length %04d\n", h->nlmsg_len);
> printf("IPSECTOOLS: Type %02d\n", h->nlmsg_type);
> The results of printf are nonsens. The first fields seem to have an offset of 2 bytes, at the end there also seem to be swapped bytes.
> 3. To test what might happen, I've created an own struct
> struct aligntest{
> __u32 first;
> __u32 int second;
> __u32 third;
> __u32 fourth;
> };
> When you now set a point to a buffer, again the values are wrong:
> s1 = (struct aligntest*) buf;
> printf("1: %08X\n", s1->first);
> printf("2: %08X\n", s1->second);
> printf("3: %08X\n", s1->third);
> printf("4: %08X\n", s1->fourth);
>
> It seems, that there is a problem with the unsigned int values. When you add the attribute "packed" to the definition of struct aligntest ( __attribute__(__packed__) ), all values are displayed correctly.
> So, any hints what the problem can be?
>
> Regards
> Marcus
> ____________________________________________________________________
> Psssst! Schon vom neuen WEB.DE MultiMessenger gehört?
> Der kann`s mit allen: http://www.produkte.web.de/messenger/?did=3123
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-embedded" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
__________________________________________________________________
"Run, Fatboy, Run" sowie "Rails & Ties" kostenlos anschauen!
Blockbuster-Gutscheine sichern unter http://www.blockbuster.web.de
next reply other threads:[~2008-11-08 18:37 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-11-08 18:37 Marcus Tangermann [this message]
-- strict thread matches above, loose matches on Subject: below --
2008-11-07 22:52 Alignment on XScale ARM Marcus Tangermann
2008-11-08 14:22 ` Will Newton
2008-11-08 15:37 ` Nicolas Pitre
2008-11-08 18:02 ` David Brownell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1734891834@web.de \
--to=marcus.tangermann@web.de \
--cc=linux-embedded@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.