1164323Simp/******************************************************************************* 2164323Simp * 3164323Simp * Filename: arm_init.s 4164323Simp * 5164323Simp * Initialization for C-environment and basic operation. Adapted from 6164323Simp * ATMEL cstartup.s. 7164323Simp * 8164323Simp * Revision information: 9164323Simp * 10164323Simp * 20AUG2004 kb_admin initial creation 11164323Simp * 12JAN2005 kb_admin updated for 16KB eeprom 12164323Simp * Atmel stack prevents loading full size at once 13164323Simp * 14164323Simp * BEGIN_KBDD_BLOCK 15164323Simp * No warranty, expressed or implied, is included with this software. It is 16164323Simp * provided "AS IS" and no warranty of any kind including statutory or aspects 17164323Simp * relating to merchantability or fitness for any purpose is provided. All 18164323Simp * intellectual property rights of others is maintained with the respective 19164323Simp * owners. This software is not copyrighted and is intended for reference 20164323Simp * only. 21164323Simp * END_BLOCK 22164323Simp * 23164323Simp * $FreeBSD$ 24164323Simp ******************************************************************************/ 25164323Simp 26164323Simp .equ TWI_EEPROM_SIZE, 0x3000 27164323Simp .equ ARM_MODE_USER, 0x10 28164323Simp .equ ARM_MODE_FIQ, 0x11 29164323Simp .equ ARM_MODE_IRQ, 0x12 30164323Simp .equ ARM_MODE_SVC, 0x13 31164323Simp .equ ARM_MODE_ABORT, 0x17 32164323Simp .equ ARM_MODE_UNDEF, 0x1B 33164323Simp .equ ARM_MODE_SYS, 0x1F 34164323Simp .equ I_BIT, 0x80 35164323Simp .equ F_BIT, 0x40 36164323Simp .equ T_BIT, 0x20 37164323Simp 38164323Simp/* 39164323Simp * Stack definitions 40164323Simp * 41164323Simp * Start near top of internal RAM. 42164323Simp */ 43164323Simp .equ END_INT_SRAM, 0x4000 44164323Simp .equ SVC_STACK_START, (END_INT_SRAM - 0x4) 45164323Simp .equ SVC_STACK_USE, 0x21800000 46164323Simp 47164323Simpstart: 48164323Simp 49164323Simp/* vectors - must reside at address 0 */ 50164323Simp/* the format of this table is defined in the datasheet */ 51164323Simp B InitReset @; reset 52164323Simpundefvec: 53164323Simp B undefvec @; Undefined Instruction 54164323Simpswivec: 55164323Simp B swivec @; Software Interrupt 56164323Simppabtvec: 57164323Simp B pabtvec @; Prefetch Abort 58164323Simpdabtvec: 59164323Simp B dabtvec @; Data Abort 60164323Simprsvdvec: 61164323Simp#ifdef BOOT_IIC 62164323Simp .long (TWI_EEPROM_SIZE >> 9) 63164323Simp#else 64165397Simp#ifdef BOOT_BWCT 65165397Simp .long ((528 << 17) | (13 << 13) | (12 * 2)) 66165397Simp#else 67164323Simp .long ((1056 << 17) | (13 << 13) | (12 * 2)) 68164323Simp#endif 69165397Simp#endif 70164323Simpirqvec: 71164323Simp ldr pc, [pc,#-0xF20] @; IRQ : read the AIC 72164323Simpfiqvec: 73164323Simp B fiqvec @; FIQ 74164323Simp 75164323SimpInitReset: 76164323Simp 77164323Simp/* Set stack and init for SVC */ 78164323Simp ldr r1, = SVC_STACK_START 79164323Simp mov sp, r1 @; Init stack SYS 80164323Simp 81164323Simp msr cpsr_c, #(ARM_MODE_SVC | I_BIT | F_BIT) 82164323Simp mov sp, r1 @ ; Init stack SYS 83164323Simp 84164323Simp/* Perform system initialization */ 85164323Simp 86164323Simp .extern _init 87164323Simp bl _init 88164323Simp#ifndef BOOT_BOOT0 89164323Simp ldr r1, = SVC_STACK_USE 90164323Simp mov sp, r1 @ ; Move the stack to SDRAM 91164323Simp#endif 92164323Simp 93164323Simp/* Start execution at main */ 94164323Simp .extern main 95164323Simp_main: 96164323Simp__main: 97164323Simp bl main 98164323Simp/* main should not return. If it does, spin forever */ 99164323SimpinfiniteLoop: 100164323Simp b infiniteLoop 101164323Simp 102164323Simp#ifdef BOOT_COMMANDS 103164323Simp/* the following section is used to store boot commands in */ 104164323Simp/* non-volatile memory. */ 105164323Simp 106164323Simp .global BootCommandSection 107164323SimpBootCommandSection: 108164323Simp#ifdef SUPPORT_LINUX 109164323Simp .string "Bootloader for KB9202 Evaluation Board." 110164323Simp .string "c 0x20210000 0x10100000 0x80000 " 111164323Simp .string "m 0 0 0 0 0 0 " 112164323Simp .string "t 0x20000100 console=ttyS0,115200 root=/dev/ram rw initrd=0x20210000,654933" 113164323Simp .string "e 0x10000000 " 114164323Simp .string " " 115164323Simp#else 116164323Simp#if 1 117164323Simp .string "m 42 53 44 0 0 1" 118164323Simp .string "ip 206 168 13 194" 119164323Simp .string "server_ip 206 168 13 207" 120164323Simp .string "tftp 0x20000000 kernel.bin" 121164323Simp .string "e 0x20000000" 122164323Simp#else 123164323Simp .string "m 42 53 44 0 0 1" 124164323Simp .string "k 0x20000000" 125164323Simp .string "e 0x20000000" 126164323Simp#endif 127164323Simp .word 0 128164323Simp#endif 129164323Simp#endif 130