source: mainline/boot/arch/arm32/src/asm.S@ 83742a4

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 83742a4 was 83742a4, checked in by Jan Vesely <jano.vesely@…>, 13 years ago

arm32: Add cache maintenance to jump_to_kernel, enable caches on bbxm boot.

BBXM boots significantly faster.
Should be generic enough for all ARMs.

  • Property mode set to 100644
File size: 3.7 KB
Line 
1#
2# Copyright (c) 2007 Michal Kebrt
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
29#include <arch/arch.h>
30
31.section BOOTSTRAP
32
33.global start
34.global boot_pt
35.global boot_stack
36.global halt
37.global jump_to_kernel
38
39start:
40 ldr sp, =boot_stack
41 b bootstrap
42
43.section BOOTPT
44boot_pt:
45 .space PTL0_ENTRIES * PTL0_ENTRY_SIZE
46
47.section BOOTSTACK
48 .space 4096
49boot_stack:
50
51.text
52
53halt:
54 b halt
55
56jump_to_kernel:
57 #
58 # TODO
59 # Make sure that the I-cache, D-cache and memory are mutually coherent
60 # before passing control to the copied code.
61 #
62
63 #
64 # r0 is kernel entry point
65 # r1 is pointer to the bootinfo structure
66 # r2 is a kernel text end
67
68 # make sure kernel is flushed and available in memory
69 # Disable I-cache and D-cache before the kernel is started.
70 # TODO disabling DCache should not be necessary...
71#define CP15_C1_IC 12
72#define CP15_C1_DC 2
73 mrc p15, 0, r4, c1, c0, 0
74 bic r4, r4, #(1 << CP15_C1_DC)
75 bic r4, r4, #(1 << CP15_C1_IC)
76 mcr p15, 0, r4, c1, c0, 0
77
78 # use r4 as a moving pointer
79 mov r4, r0
803:
81 # DCCMVAC (flush by virt address, to the point of coherence)
82 mcr p15, 0, r4, c7, c10, 1
83 # TODO: it would be better to use cacheline size
84 add r4, r4, #4
85 # are we there yet?
86 cmp r4, r2
87 blt 3b
88 nop
89 mov r4, #0
90
91 #Wait for the operations to complete
92#ifdef PROCESSOR_ARCH_armv7_a
93 dsb
94#else
95 #cp15 dsb, r4 is ignored (should be zero)
96 mcr p15, 0, r4, c7, c10, 4
97#endif
98
99 # Clean ICache and BPredictors, r4 ignored (SBZ)
100 mcr p15, 0, r4, c7, c5, 0
101
102 #Wait for the operations to complete
103#ifdef PROCESSOR_ARCH_armv7_a
104 isb
105#else
106 # cp15 isb
107 mcr p15, 0, r4, c7, c5, 4
108#endif
109
110
111#if defined(MACHINE_gta02)
112
113#define CP15_C1_IC 12
114#define CP15_C1_DC 2
115#define CP15_C7_SEG_SHIFT 5
116#define CP15_C7_SEG_SIZE 3
117#define CP15_C7_IDX_SHIFT 26
118
119 # Disable I-cache and D-cache before the kernel is started.
120 mrc p15, 0, r4, c1, c0, 0
121 bic r4, r4, #(1 << CP15_C1_DC)
122 bic r4, r4, #(1 << CP15_C1_IC)
123 mcr p15, 0, r4, c1, c0, 0
124
125 # Now clean D-cache to guarantee coherency between I-cache and D-cache.
126
127 # D-cache clean and invalidate procedure.
128 # See ARM920T TRM pages 2-17, 4-17.
129
130 # Initialize segment
131 mov r4, #0
132 # Initialize index
1331: mov r5, #0
1342: orr r6, r4, r5
135 # Clean and invalidate a single line
136 mcr p15, 0, r6, c7, c10, 2
137 # Increment index
138 add r5, r5, #(1 << CP15_C7_IDX_SHIFT)
139 cmp r5, #0
140 bne 2b
141 # Increment segment
142 add r4, #(1 << CP15_C7_SEG_SHIFT)
143 tst r4, #(1 << (CP15_C7_SEG_SHIFT + CP15_C7_SEG_SIZE))
144 beq 1b
145#endif
146
147 mov pc, r0
Note: See TracBrowser for help on using the repository browser.