From mboxrd@z Thu Jan 1 00:00:00 1970 From: Vipin Kumar Date: Mon, 4 Oct 2010 16:00:02 +0530 Subject: [U-Boot] packed attribute problem In-Reply-To: <20101004101714.A19931539A0@gemini.denx.de> References: <4CA9A095.9000900@st.com> <20101004101714.A19931539A0@gemini.denx.de> Message-ID: <4CA9ACAA.2020001@st.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On 10/4/2010 3:47 PM, Wolfgang Denk wrote: > Dear Vipin Kumar, > Dear Wolfgang > In message <4CA9A095.9000900@st.com> you wrote: >> >> I encountered a problem something like >> >> struct xyz { >> int x; >> int y; >> int z[CONST]; >> } __attribute__ ((packed)); >> >> struct xyz *abc; >> u32 * status_reg = (u32 *)&abc->z[0]; >> >> writel(status, status_reg); >> >> This writel results in writing byte by byte on the address pointed to by status_reg. >> This problem is visible with both gcc version 4.4.1 as well as 4.5.0 > > I bet this is on some ARM system? > Yes, it is on an ARM system (CortexA9). But I still feel that since I am creating a new u32 * status_reg, the code should not use any intelligence and use the pointer only to produce an str instruction in the form str r0, [r1] But it retains the packed property of the structure even with a new u32 ponter typecasted to u32 * u32 * status_reg = (u32 *)xyz->x; A writel to status_reg results in byte by byte writing >> Incidently, the same code works well with 4.2.4 > > ...which surprises me. I thought this has always been an ARM > "feature". > >> The problem is visible in the usb host driver which uses the packed structures for >> accessing device registers. > > Hm... Why do these structs have any "__attribute__ ((packed))" at all? > Even I could not understand that very well Regards Vipin > Best regards, > > Wolfgang Denk >