| 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 <abi/asmtool.h>
|
|---|
| 30 | #include <arch/arch.h>
|
|---|
| 31 |
|
|---|
| 32 | .section BOOTSTRAP
|
|---|
| 33 |
|
|---|
| 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 |
|
|---|
| 39 | SYMBOL(start)
|
|---|
| 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 |
|
|---|
| 53 | ldr sp, =boot_stack
|
|---|
| 54 | b bootstrap
|
|---|
| 55 |
|
|---|
| 56 | .section BOOTPT
|
|---|
| 57 | SYMBOL(boot_pt)
|
|---|
| 58 | .space PTL0_ENTRIES * PTL0_ENTRY_SIZE
|
|---|
| 59 |
|
|---|
| 60 | .section BOOTSTACK
|
|---|
| 61 | .space 4096
|
|---|
| 62 | SYMBOL(boot_stack)
|
|---|
| 63 |
|
|---|
| 64 | .text
|
|---|
| 65 |
|
|---|
| 66 | FUNCTION_BEGIN(halt)
|
|---|
| 67 | b halt
|
|---|
| 68 | FUNCTION_END(halt)
|
|---|
| 69 |
|
|---|
| 70 | FUNCTION_BEGIN(jump_to_kernel)
|
|---|
| 71 | #
|
|---|
| 72 | # Make sure that the I-cache, D-cache and memory are mutually coherent
|
|---|
| 73 | # before passing control to the copied code.
|
|---|
| 74 | #
|
|---|
| 75 |
|
|---|
| 76 | #
|
|---|
| 77 | # r0 is kernel entry point
|
|---|
| 78 | # r1 is pointer to the bootinfo structure
|
|---|
| 79 |
|
|---|
| 80 | #ifndef PROCESSOR_ARCH_armv7_a
|
|---|
| 81 | mrc p15, 0, r4, c1, c0, 0
|
|---|
| 82 |
|
|---|
| 83 | # Disable D-cache before the kernel is started.
|
|---|
| 84 | bic r4, r4, #(1 << CP15_C1_DC)
|
|---|
| 85 |
|
|---|
| 86 | # Disable I-cache and Branch predictors.
|
|---|
| 87 | bic r4, r4, #(1 << CP15_C1_IC)
|
|---|
| 88 | #ifdef PROCESSOR_ARCH_armv6
|
|---|
| 89 | bic r4, r4, #(1 << CP15_C1_BP)
|
|---|
| 90 | #endif
|
|---|
| 91 |
|
|---|
| 92 | mcr p15, 0, r4, c1, c0, 0
|
|---|
| 93 | #endif
|
|---|
| 94 |
|
|---|
| 95 | # Wait for the operations to complete
|
|---|
| 96 | #ifdef PROCESSOR_ARCH_armv7_a
|
|---|
| 97 | dsb
|
|---|
| 98 | #else
|
|---|
| 99 | # cp15 dsb, r4 is ignored (should be zero)
|
|---|
| 100 | mov r4, #0
|
|---|
| 101 | mcr p15, 0, r4, c7, c10, 4
|
|---|
| 102 | #endif
|
|---|
| 103 |
|
|---|
| 104 | # Clean ICache and BPredictors, r4 ignored (SBZ)
|
|---|
| 105 | mov r4, #0
|
|---|
| 106 | mcr p15, 0, r4, c7, c5, 0
|
|---|
| 107 | nop
|
|---|
| 108 |
|
|---|
| 109 | # Wait for the operations to complete
|
|---|
| 110 | #ifdef PROCESSOR_ARCH_armv7_a
|
|---|
| 111 | isb
|
|---|
| 112 | nop
|
|---|
| 113 | #elif defined(PROCESSOR_ARCH_armv6)
|
|---|
| 114 | # cp15 isb
|
|---|
| 115 | mcr p15, 0, r4, c7, c5, 4
|
|---|
| 116 | nop
|
|---|
| 117 | #endif
|
|---|
| 118 | mov pc, r0
|
|---|
| 119 | FUNCTION_END(jump_to_kernel)
|
|---|
| 120 |
|
|---|