1 /* $NetBSD: g42xxeb_start.S,v 1.1.2.1 2005/03/04 16:38:25 skrll Exp $ */
4 * Copyright (c) 2002, 2003 Genetec Corporation. All rights reserved.
5 * Written by Hiroyuki Bessho for Genetec Corporation.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. The name of Genetec Corporation may not be used to endorse or
16 * promote products derived from this software without specific prior
19 * THIS SOFTWARE IS PROVIDED BY GENETEC CORPORATION ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GENETEC CORPORATION
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
32 #include <machine/asm.h>
33 #include <arm/armreg.h>
34 #include <arm/arm32/pte.h>
35 #include <arm/arm32/pmap.h> /* for PMAP_DOMAIN_KERNEL */
38 #define SDRAM_START 0xa0000000
42 * CPWAIT -- Canonical method to wait for CP15 update.
43 * NOTE: Clobbers the specified temp reg.
44 * copied from arm/arm/cpufunc_asm_xscale.S
45 * XXX: better be in a common header file.
47 #define CPWAIT_BRANCH \
51 mrc p15, 0, tmp, c2, c0, 0 /* arbitrary read of CP15 */ ;\
52 mov tmp, tmp /* wait for it to complete */ ;\
53 CPWAIT_BRANCH /* branch to next insn */
56 * Kernel start routine for G4255EB (TWINTAIL)
57 * this code is excuted at the very first after the kernel is loaded
62 .global _C_LABEL(g42xxeb_start)
63 _C_LABEL(g42xxeb_start):
64 /* Are we running on ROM ? */
69 * XXX: we can use memcpy if it is PIC
72 adr r0, _C_LABEL(g42xxeb_start)
76 add r2, r2, #0x00200000
88 Lcopy_size: .word _edata-_C_LABEL(g42xxeb_start)
89 Lstart_off: .word g42xxeb_start_ram-_C_LABEL(g42xxeb_start)
93 * Kernel is loaded in SDRAM (0xa0200000..), and is expected to run
97 mrc p15, 0, r0, c2, c0, 0 /* get ttb prepared by redboot */
98 adr r4, mmu_init_table2
100 #ifdef BUILD_STARTUP_PAGETABLE
101 mrc p15, 0, r2, c1, c0, 0
102 tst r2, #CPU_CONTROL_MMU_ENABLE /* we already have a page table? */
105 /* build page table from scratch */
106 ldr r0, Lstartup_pagetable
107 adr r4, mmu_init_table
114 add r3, r3, #(L1_S_SIZE)
118 ldmia r4!, {r1,r2,r3} /* # of sections, PA|attr, VA */
122 mcr p15, 0, r0, c2, c0, 0 /* Set TTB */
123 mcr p15, 0, r0, c8, c7, 0 /* Flush TLB */
125 /* Set the Domain Access register. Very important! */
126 mov r0, #((DOMAIN_CLIENT << (PMAP_DOMAIN_KERNEL*2)) | DOMAIN_CLIENT)
127 mcr p15, 0, r0, c3, c0, 0
130 mrc p15, 0, r0, c1, c0, 0
131 orr r0, r0, #CPU_CONTROL_MMU_ENABLE
132 mcr p15, 0, r0, c1, c0, 0
135 /* Jump to kernel code in TRUE VA */
142 #define MMU_INIT(va,pa,n_sec,attr) \
144 .word 4*((va)>>L1_S_SHIFT) ; \
147 #ifdef BUILD_STARTUP_PAGETABLE
148 #ifndef STARTUP_PAGETABLE_ADDR
149 #define STARTUP_PAGETABLE_ADDR 0xa0004000
151 Lstartup_pagetable .word STARTUP_PAGETABLE_ADDR
153 /* fill all table VA==PA */
154 MMU_INIT(0x00000000, 0x00000000, 1<<(32-L1_S_SHIFT), L1_TYPE_S|L1_S_AP(AP_KRW))
155 /* map SDRAM VA==PA, WT cacheable */
156 MMU_INIT(SDRAM_START, SDRAM_START, 64, L1_TYPE_S|L1_S_C|L1_S_AP(AP_KRW))
159 /* map VA 0xc0000000..0xc3ffffff to PA 0xa0000000..0xa3ffffff */
160 MMU_INIT(0xc0000000, SDRAM_START, 64, L1_TYPE_S|L1_S_C|L1_S_AP(AP_KRW))
162 .word 0 /* end of table */