From: Wolfgang Denk Date: Sun, 14 Nov 2010 16:01:02 +0100 Subject: [U-Boot] RFC: Aligning arch initialisation sequences In-Reply-To: <4CDFD1AE.1070409@free.fr> References: <4CD67A22.9040802@gmail.com> <201011091835.38581.vapier@gentoo.org> <4CDE1107.80108@gmail.com> <4CDE4A53.4070106@free.fr> <4CDE741C.1020507@gmail.com> <4CDF6F2E.9040900@gmail.com> <4CDF7821.4080300@gmail.com> <4CDFA8E9.3050803@free.fr> <20101114103001.7EE2014EA7E@gemini.denx.de> <4CDFD1AE.1070409@free.fr> Message-ID: <20101114150102.DAAF914EA7E@gemini.denx.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Dear Albert ARIBAUD, In message <4CDFD1AE.1070409@free.fr> you wrote: > > >> There is no way to set aside a register in ARM code for applicative > >> purposes. > > > What exactly do you mean by that? > > Use of the 16 ARM registers r0 to r15 in C code is governed by ABIs; we > use the one known as (GNU) EABI. The compiler will both respect this ABI > when generating code and assume it is respected by any other code in the > application. Well, that just means that your above statement should be completed by the phrase "as long as we strictly adhere to some specific ABI". > The GNU EABI is based on the AAPCS which defines the use of registers. > r0 to r3 are used for call parameters; r4 to r8, r10 and r11 are used > as local variables; r12 is a scratch register; r13, r14 and 15 are the > stack pointer, return address holder and program counter respectively. > None of these registers can be used as a global constant except r9, > which is indicated as 'plaform-specific' and potentially useable by > variants of the AAPCS. > > One could argue that using r9 to locage GD would constitue such a > variant, platform-specific use of AAPCS. However, some -gcc) compiler > switches actually cause the generated code to follow such variants of > AAPCS and use r9 for specific purposes (some even r10 if r9 is used, > even though this is not strictly AAPCS compliant) -- and I don't know > about potential uses by other compilers. > > I would thus not favor using r9 for gd access if there is another way. Traditionally, U-Boot has been using r9 as GOT pointer. And we use r8 as pointer to the global data (which is what the ``register volatile gd_t *gd asm ("r8")'' means. We make sure that the compiler respects this use by adding a "-ffixed-r8" compiler option. This is perfectly OK, as we don't have to interface in any way with any strictly EABI conforming code - we are working in a completely controlled environment and can adjust rules as needed. Best regards, Wolfgang Denk -- DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de Knowledge, sir, should be free to all! -- Harry Mudd, "I, Mudd", stardate 4513.3