source: mainline/boot/arch/arm32/src/asm.S

Last change on this file was 98c4c16, checked in by Jakub Jermar <jakub@…>, 6 years ago

Enable word-aligned doubleword accesses on ARMv6

This fixes loading by U-boot on Raspberry Pi. U-boot turns on the
alignment enforcement bit in SCTLR and so, unlike when booting without
U-boot, any word-aligned STRD instruction in the loader causes a data
abort exception.

  • Property mode set to 100644
File size: 3.2 KB
RevLine 
[d630139]1#
[6b781c0]2# Copyright (c) 2007 Michal Kebrt
[d630139]3# All rights reserved.
4#
5# Redistribution and use in source and binary forms, with or without
6# modification, are permitted provided that the following conditions
7# are met:
8#
9# - Redistributions of source code must retain the above copyright
10# notice, this list of conditions and the following disclaimer.
11# - Redistributions in binary form must reproduce the above copyright
12# notice, this list of conditions and the following disclaimer in the
13# documentation and/or other materials provided with the distribution.
14# - The name of the author may not be used to endorse or promote products
15# derived from this software without specific prior written permission.
16#
17# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27#
28
[73b3ecd]29#include <abi/asmtool.h>
[4872160]30#include <arch/arch.h>
[6b781c0]31
32.section BOOTSTRAP
33
[98c4c16]34#define CP15_C1_U 22
35#define CP15_C1_IC 12
36#define CP15_C1_BP 11
37#define CP15_C1_DC 2
38
[73b3ecd]39SYMBOL(start)
[98c4c16]40
41#ifdef PROCESSOR_ARCH_armv6
42 /*
43 * Enable unaligned doubleword memory accesses (STRD/LDRD) if the
44 * processor supports it. Note that that boils down to ARMv6 processors
45 * only as the older architectures require doubleword alignment and
46 * ARMv7 always assumes the U bit is 1.
47 */
48 mrc p15, 0, r0, c1, c0, 0
49 orr r0, r0, #(1 << CP15_C1_U)
50 mcr p15, 0, r0, c1, c0, 0
51#endif
52
[6ac14a70]53 ldr sp, =boot_stack
[6b781c0]54 b bootstrap
55
[4872160]56.section BOOTPT
[73b3ecd]57SYMBOL(boot_pt)
[4872160]58 .space PTL0_ENTRIES * PTL0_ENTRY_SIZE
59
60.section BOOTSTACK
61 .space 4096
[73b3ecd]62SYMBOL(boot_stack)
[4872160]63
64.text
65
[73b3ecd]66FUNCTION_BEGIN(halt)
[4872160]67 b halt
[73b3ecd]68FUNCTION_END(halt)
[4872160]69
[73b3ecd]70FUNCTION_BEGIN(jump_to_kernel)
[3527a93]71 #
72 # Make sure that the I-cache, D-cache and memory are mutually coherent
73 # before passing control to the copied code.
74 #
[b5a3b50]75
[83742a4]76 #
77 # r0 is kernel entry point
78 # r1 is pointer to the bootinfo structure
79
[296a80e]80#ifndef PROCESSOR_ARCH_armv7_a
[b80d132]81 mrc p15, 0, r4, c1, c0, 0
[a35b458]82
[9658879]83 # Disable D-cache before the kernel is started.
[b80d132]84 bic r4, r4, #(1 << CP15_C1_DC)
[296a80e]85
[803f581]86 # Disable I-cache and Branch predictors.
[b80d132]87 bic r4, r4, #(1 << CP15_C1_IC)
[803f581]88#ifdef PROCESSOR_ARCH_armv6
[b80d132]89 bic r4, r4, #(1 << CP15_C1_BP)
[803f581]90#endif
[a35b458]91
[b80d132]92 mcr p15, 0, r4, c1, c0, 0
[296a80e]93#endif
[a35b458]94
[803f581]95 # Wait for the operations to complete
[83742a4]96#ifdef PROCESSOR_ARCH_armv7_a
97 dsb
98#else
[803f581]99 # cp15 dsb, r4 is ignored (should be zero)
[e93bb24]100 mov r4, #0
[83742a4]101 mcr p15, 0, r4, c7, c10, 4
102#endif
[a35b458]103
[83742a4]104 # Clean ICache and BPredictors, r4 ignored (SBZ)
[e93bb24]105 mov r4, #0
[83742a4]106 mcr p15, 0, r4, c7, c5, 0
[bfb6576]107 nop
[83742a4]108
[803f581]109 # Wait for the operations to complete
[83742a4]110#ifdef PROCESSOR_ARCH_armv7_a
111 isb
[bfb6576]112 nop
[1a2a6e7]113#elif defined(PROCESSOR_ARCH_armv6)
[83742a4]114 # cp15 isb
115 mcr p15, 0, r4, c7, c5, 4
[bfb6576]116 nop
[83742a4]117#endif
[ab63b04e]118 mov pc, r0
[73b3ecd]119FUNCTION_END(jump_to_kernel)
120
Note: See TracBrowser for help on using the repository browser.