1/* $NetBSD: smdk2800_start.S,v 1.1 2002/11/20 18:06:26 bsh Exp $ */ 2 3/* 4 * Copyright (c) 2002 Fujitsu Component Limited 5 * Copyright (c) 2002 Genetec Corporation 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: 11 * 1. Redistributions of source code must retain the above copyright 12 * notice, this list of conditions and the following disclaimer. 13 * 2. Redistributions in binary form must reproduce the above copyright 14 * notice, this list of conditions and the following disclaimer in the 15 * documentation and/or other materials provided with the distribution. 16 * 3. Neither the name of The Fujitsu Component Limited nor the name of 17 * Genetec corporation may not be used to endorse or promote products 18 * derived from this software without specific prior written permission. 19 * 20 * THIS SOFTWARE IS PROVIDED BY FUJITSU COMPONENT LIMITED AND GENETEC 21 * CORPORATION ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, 22 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 23 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 * DISCLAIMED. IN NO EVENT SHALL FUJITSU COMPONENT LIMITED OR GENETEC 25 * CORPORATION BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 28 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 29 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 30 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 31 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32 * SUCH DAMAGE. 33 */ 34 35#include <machine/asm.h> 36#include <arm/armreg.h> 37#include <arm/arm32/pte.h> 38 39/* 40 * Kernel start routine for Samsung SMDK2800. 41 * This code is excuted at the very first after the kernel is loaded 42 * by boot program on ROM or gzboot. 43 */ 44 .text 45 46 .global _C_LABEL(smdk2800_start) 47_C_LABEL(smdk2800_start): 48 /* Are we running on ROM ? */ 49 cmp pc, #0x08200000 50 bhs smdk2800_start_ram 51 52 /* move me to RAM 53 * XXX: we can use memcpy if it is PIC 54 */ 55 ldr r1, Lcopy_size 56 adr r0, _C_LABEL(smdk2800_start) 57 add r1, r1, #3 58 mov r1, r1, LSR #2 59 mov r2, #0x08200000 60 mov r4, r2 61 62 cmp r0, r2 63 bhs 5f 64 65 /* src < dest. copy from top */ 66 add r0,r0,r1,LSL #2 67 add r2,r2,r1,LSL #2 68 693: ldr r3,[r0,#-4]! 70 str r3,[r2,#-4]! 71 subs r1,r1,#1 72 bhi 3b 73 b 7f 74 75 /* src >= dest. copy from bottom */ 765: ldr r3,[r0],#4 77 str r3,[r2],#4 78 subs r1,r1,#1 79 bhi 5b 80 817: 82 /* Jump to RAM */ 83 ldr r0, Lstart_off 84 add pc, r4, r0 85 86Lcopy_size: .word _edata-_C_LABEL(smdk2800_start) 87Lstart_off: .word smdk2800_start_ram-_C_LABEL(smdk2800_start) 88 89smdk2800_start_ram: 90 /* 91 * Kernel is loaded in SDRAM (0x08200000..), and is expected to run 92 * in VA 0xc0200000.. 93 */ 94 95 /* get ttb prepared by boot program */ 96 mrc p15, 0, r0, c2, c0, 0 97 /* Disable MMU for a while */ 98 mrc p15, 0, r2, c1, c0, 0 99 bic r2, r2, #CPU_CONTROL_MMU_ENABLE 100 mcr p15, 0, r2, c1, c0, 0 101 102 nop 103 nop 104 nop 105 106 /* 107 * Map VA 0xc0000000..0xc3ffffff to PA 0x08000000..0x09ffffff 108 */ 109 mov r1, #(L1_S_AP(AP_KRW)) 110 orr r1, r1, #(L1_TYPE_S) 111 orr r1, r1, #0x08000000 112 mov r2, #(0xc00 * 4) 1131: 114 str r1, [r0, r2] 115 add r2, r2, #4 116 add r1, r1, #L1_S_SIZE 117 cmp r2, #(0xc20 * 4) 118 blo 1b 119 120 121 mcr p15, 0, r0, c2, c0, 0 /* Set TTB */ 122 mcr p15, 0, r0, c8, c7, 0 /* Flush TLB */ 123 124 /* Set the Domain Access register. Very important! */ 125 mov r0, #1 126 mcr p15, 0, r0, c3, c0, 0 127 128 /* Enable MMU */ 129 mrc p15, 0, r0, c1, c0, 0 130 orr r0, r0, #CPU_CONTROL_MMU_ENABLE 131 mcr p15, 0, r0, c1, c0, 0 132 133 nop 134 nop 135 nop 136 137 /* Jump to kernel code in TRUE VA */ 138 adr r0, Lstart 139 ldr pc, [r0] 140 141Lstart: 142 .word start 143