Received: from list by lists.gnu.org with archive (Exim 4.71) id 1UPAUw-00021Y-QT for mharc-grub-devel@gnu.org; Mon, 08 Apr 2013 07:44:30 -0400 Received: from eggs.gnu.org ([208.118.235.92]:50072) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UPAUq-0001tZ-Or for grub-devel@gnu.org; Mon, 08 Apr 2013 07:44:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UPAUj-0003R0-Dh for grub-devel@gnu.org; Mon, 08 Apr 2013 07:44:24 -0400 Received: from mail-wi0-x231.google.com ([2a00:1450:400c:c05::231]:54860) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UPAUi-0003Qo-Vo for grub-devel@gnu.org; Mon, 08 Apr 2013 07:44:17 -0400 Received: by mail-wi0-f177.google.com with SMTP id hm14so2437203wib.16 for ; Mon, 08 Apr 2013 04:44:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:date:from:to:cc:subject:message-id:references :mime-version:content-type:content-disposition:in-reply-to :user-agent:x-gm-message-state; bh=6FtskhJfNrDo2Jywc3/nLv05FIfnSA+BM+xYPqFeodc=; b=mBOPuaFMBDJZdIJx50//x3ge7xpAzA2MId8Ls7XJE6waAJ8r0D/oaoV3qjccqAgMmJ PwVQesTHMSizLBUijzl2Vs2zb5JY4pir3ROOShImXURzOczzPtQTK/wUhJlYpemORVKo rxBt2b9hj78nTHtq9RZxzQOfzpMQTBeifgvk1xNQAPrEavavchfFuqvMuuxKoY60NbfK xKokC+aQWBdqWIuiwDl5i71BjFl9rOTtctG31Rrun9P4Ny/8+mXnZxz8yvyeeGLJD8cg 19Sv9RsbnsR1KsEwlZFP0wfPJ1cSLWhzvcQk/yWusHPeo8ANe8sb8VtYaFbpg2gfvSmE GlLw== X-Received: by 10.194.89.234 with SMTP id br10mr30880102wjb.43.1365421455743; Mon, 08 Apr 2013 04:44:15 -0700 (PDT) Received: from rocoto.smurfnet.nu ([2001:4b98:dc0:41:216:3eff:fea7:75f3]) by mx.google.com with ESMTPS id t7sm19190338wij.2.2013.04.08.04.44.13 (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 08 Apr 2013 04:44:14 -0700 (PDT) Date: Mon, 8 Apr 2013 11:44:45 +0000 From: Leif Lindholm To: The development of GNU GRUB Subject: Re: Raspberry pi support Message-ID: <20130408114445.GS23069@rocoto.smurfnet.nu> References: <5161AAE3.6050403@gmail.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="8t9RHnE3ZwKMSgU+" Content-Disposition: inline In-Reply-To: <5161AAE3.6050403@gmail.com> User-Agent: Mutt/1.5.20 (2009-06-14) X-Gm-Message-State: ALoCoQkv+itSJaewSuU0Yc0E6QIhsBr+XmJjK1uFGpS5yijo9XT2EoGZn5YdVyCQyCXcdg5tGqtd X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:400c:c05::231 Cc: phcoder@gmail.com X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 08 Apr 2013 11:44:28 -0000 --8t9RHnE3ZwKMSgU+ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Sun, Apr 07, 2013 at 07:20:35PM +0200, Vladimir '??-coder/phcoder' Serbinenko wrote: > Based on Leif Lindholm's patches I could go to GRUB console on raspberry pi. > The biggest problem is that cache flushing is simply skipped. Another > problem is that due to different linux image format linux loader doesn't > work. Is this because you're feeding it a uImage? It is entirely possible to runtime detect the U-Boot signature, and simply skip the header. > I didn't test grub-install but fed GRUB to uboot using kermit. > Is there any advantage in building armv6 binary by default unless user > overrides through TARGET_CFLAGS? I think it would get messy: the barrier operations supported by ARMv6 are deprecated in ARMv7. I would suggest an alternative approach, which is to build all of the assembly in "arm" state, and to keep the generic functionality to an ARMv6 subset. This would then have to be done in multiple files, but as an example, I have implemented this for specifically the cache synchronization, attached to this email. > Some of the fixes are to make tools work on amd64 > > > === modified file 'conf/Makefile.common' > --- conf/Makefile.common 2013-04-07 00:41:07 +0000 > +++ conf/Makefile.common 2013-04-07 16:08:07 +0000 > @@ -40,8 +40,7 @@ > if COND_arm > # Image entry point always in ARM (A32) state - ensure proper functionality if > # the rest is built for the Thumb (T32) state. > - CFLAGS_PLATFORM += -mthumb-interwork -mno-unaligned-access -mlong-calls > - CCASFLAGS_PLATFORM = -Wa,-mimplicit-it=thumb > + CFLAGS_PLATFORM += -mthumb-interwork -march=armv6 -mlong-calls > LDFLAGS_PLATFORM = -Wl,--wrap=__clear_cache > endif -mno-unaligned-access is required to function on platforms that do not have caches/MMU enabled at this point. They do exist, so please leave it in. And for reasons stated above, -march= should be set to whatever your target architecture is. Extracted by configure, I suppose? / Leif --8t9RHnE3ZwKMSgU+ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="armv6cache.patch" === modified file 'conf/Makefile.common' --- conf/Makefile.common 2013-04-04 19:40:53 +0000 +++ conf/Makefile.common 2013-04-08 10:42:47 +0000 @@ -41,6 +41,7 @@ # Image entry point always in ARM (A32) state - ensure proper functionality if # the rest is built for the Thumb (T32) state. CFLAGS_PLATFORM += -mthumb-interwork -mno-unaligned-access -mlong-calls + CCASFLAGS_PLATFORM = -marm LDFLAGS_PLATFORM = -Wl,--wrap=__clear_cache endif === modified file 'grub-core/kern/arm/cache.S' --- grub-core/kern/arm/cache.S 2013-04-04 19:40:53 +0000 +++ grub-core/kern/arm/cache.S 2013-04-08 11:21:16 +0000 @@ -21,14 +21,16 @@ .file "cache.S" .text .syntax unified -#if !defined (__thumb2__) - .arm -#define ARM(x...) x -#define THUMB(x...) +#if (__ARM_ARCH_6__ == 1) +# define DMB mcr p15, 0, r0, c7, c10, 5 +# define DSB mcr p15, 0, r0, c7, c10, 4 +# define ISB mcr p15, 0, r0, c7, c5, 4 +#elif (__ARM_ARCH_7A__ == 1) +# define DMB dmb +# define DSB dsb +# define ISB isb #else - .thumb -#define THUMB(x...) x -#define ARM(x...) +# error Unsupported architecture version! #endif .align 2 @@ -38,7 +40,7 @@ */ @ r0 - *beg (inclusive) -@ r1 - *end (exclusive) +@ r1 - *end (exclusive) clean_dcache_range: @ Clean data cache for range to point-of-unification ldr r2, dlinesz @@ -50,11 +52,11 @@ mcr p15, 0, r0, c7, c11, 1 @ DCCMVAU add r0, r0, r2 @ Next line b 1b -2: dsb +2: DSB bx lr @ r0 - *beg (inclusive) -@ r1 - *end (exclusive) +@ r1 - *end (exclusive) invalidate_icache_range: @ Invalidate instruction cache for range to point-of-unification ldr r2, ilinesz @@ -68,17 +70,16 @@ b 1b @ Branch predictor invalidate all 2: mcr p15, 0, r0, c7, c5, 6 @ BPIALL - dsb - isb + DSB + ISB bx lr -sync_caches: - dmb - dsb +sync_caches: + DMB + DSB push {r4-r6, lr} ldr r2, probed @ If first call, probe cache sizes cmp r2, #0 - THUMB( it eq ) bleq probe_caches @ This call corrupts r3 mov r4, r0 mov r5, r1 @@ -92,7 +93,8 @@ push {r4-r6, lr} mrc p15, 0, r4, c0, c0, 1 @ Read Cache Type Register mov r5, #1 - ubfx r6, r4, #16, #4 @ Extract min D-cache num word log2 + lsr r6, r4, #16 @ Extract min D-cache num word log2 + and r6, r6, #0xf add r6, r6, #2 @ words->bytes lsl r6, r5, r6 @ Convert to num bytes ldr r3, =dlinesz @@ -133,21 +135,26 @@ clean_invalidate_dcache: push {r4-r12, lr} mrc p15, 1, r0, c0, c0, 1 @ Read CLIDR - ubfx r1, r0, #24, #3 @ Extract LoC - + lsr r1, r0, #24 @ Extract LoC + and r1, r1, #0x7 + mov r2, #0 @ First level, L1 2: and r8, r0, #7 @ cache type at current level cmp r8, #2 blt 5f @ instruction only, or none, skip level - @ set current cache level/type (for CSSIDR read) + @ set current cache level/type (for CCSIDR read) lsl r8, r2, #1 mcr p15, 2, r8, c0, c0, 0 @ Write CSSELR (level, type: data/uni) @ read current cache information - mrc p15, 1, r8, c0, c0, 0 @ Read CSSIDR - ubfx r3, r8, #13, #14 @ Number of sets -1 - ubfx r4, r8, #3, #9 @ Number of ways -1 + mrc p15, 1, r8, c0, c0, 0 @ Read CCSIDR + lsr r3, r8, #13 @ Number of sets -1 + ldr r9, =0x3fff + and r3, r3, r9 + lsr r4, r8, #3 @ Number of ways -1 + ldr r9, =0x1ff + and r4, r4, r9 and r7, r8, #7 @ log2(line size in words) - 2 add r7, r7, #2 @ adjust mov r8, #1 @@ -170,11 +177,11 @@ clz r9, r10 @ r9 = way field offset add r9, r9, #1 4: lsl r10, r6, r9 - orr r11, r8, r10 @ insert way field - + orr r11, r8, r10 @ insert way field + @ clean and invalidate line by set/way mcr p15, 0, r11, c7, c14, 2 @ DCCISW - + @ next way add r6, r6, #1 cmp r6, r4 @@ -184,7 +191,7 @@ add r5, r5, #1 cmp r5, r3 ble 3b - + @ next level 5: lsr r0, r0, #3 @ align next level CLIDR 'type' field add r2, r2, #1 @ increment cache level counter @@ -192,8 +199,8 @@ blt 2b @ outer loop @ return -6: dsb - isb +6: DSB + ISB pop {r4-r12, pc} FUNCTION(grub_arm_disable_caches_mmu) @@ -203,8 +210,8 @@ mrc p15, 0, r0, c1, c0, 0 bic r0, r0, #(1 << 2) mcr p15, 0, r0, c1, c0, 0 - dsb - isb + DSB + ISB @ clean/invalidate D-cache bl clean_invalidate_dcache @@ -213,14 +220,14 @@ mrc p15, 0, r0, c1, c0, 0 bic r0, r0, #(1 << 12) mcr p15, 0, r0, c1, c0, 0 - dsb - isb + DSB + ISB @ invalidate I-cache (also invalidates branch predictors) mcr p15, 0, r0, c7, c5, 0 - dsb - isb - + DSB + ISB + @ clear SCTLR M bit mrc p15, 0, r0, c1, c0, 0 bic r0, r0, #(1 << 0) @@ -228,8 +235,8 @@ mcr p15, 0, r0, c8, c7, 0 @ invalidate TLB mcr p15, 0, r0, c7, c5, 6 @ invalidate branch predictor - dsb - isb + DSB + ISB pop {r4, pc} --8t9RHnE3ZwKMSgU+--