199767f8919635c4928607450d9e0abb932109ceToomas Soome/*******************************************************************************
199767f8919635c4928607450d9e0abb932109ceToomas Soome *
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Filename: arm_init.s
199767f8919635c4928607450d9e0abb932109ceToomas Soome *
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Initialization for C-environment and basic operation. Adapted from
199767f8919635c4928607450d9e0abb932109ceToomas Soome * ATMEL cstartup.s.
199767f8919635c4928607450d9e0abb932109ceToomas Soome *
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Revision information:
199767f8919635c4928607450d9e0abb932109ceToomas Soome *
199767f8919635c4928607450d9e0abb932109ceToomas Soome * 20AUG2004 kb_admin initial creation
199767f8919635c4928607450d9e0abb932109ceToomas Soome * 12JAN2005 kb_admin updated for 16KB eeprom
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Atmel stack prevents loading full size at once
199767f8919635c4928607450d9e0abb932109ceToomas Soome *
199767f8919635c4928607450d9e0abb932109ceToomas Soome * BEGIN_KBDD_BLOCK
199767f8919635c4928607450d9e0abb932109ceToomas Soome * No warranty, expressed or implied, is included with this software. It is
199767f8919635c4928607450d9e0abb932109ceToomas Soome * provided "AS IS" and no warranty of any kind including statutory or aspects
199767f8919635c4928607450d9e0abb932109ceToomas Soome * relating to merchantability or fitness for any purpose is provided. All
199767f8919635c4928607450d9e0abb932109ceToomas Soome * intellectual property rights of others is maintained with the respective
199767f8919635c4928607450d9e0abb932109ceToomas Soome * owners. This software is not copyrighted and is intended for reference
199767f8919635c4928607450d9e0abb932109ceToomas Soome * only.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * END_BLOCK
199767f8919635c4928607450d9e0abb932109ceToomas Soome *
199767f8919635c4928607450d9e0abb932109ceToomas Soome * $FreeBSD$
199767f8919635c4928607450d9e0abb932109ceToomas Soome ******************************************************************************/
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome .equ TWI_EEPROM_SIZE, 0x3000
199767f8919635c4928607450d9e0abb932109ceToomas Soome .equ ARM_MODE_USER, 0x10
199767f8919635c4928607450d9e0abb932109ceToomas Soome .equ ARM_MODE_FIQ, 0x11
199767f8919635c4928607450d9e0abb932109ceToomas Soome .equ ARM_MODE_IRQ, 0x12
199767f8919635c4928607450d9e0abb932109ceToomas Soome .equ ARM_MODE_SVC, 0x13
199767f8919635c4928607450d9e0abb932109ceToomas Soome .equ ARM_MODE_ABORT, 0x17
199767f8919635c4928607450d9e0abb932109ceToomas Soome .equ ARM_MODE_UNDEF, 0x1B
199767f8919635c4928607450d9e0abb932109ceToomas Soome .equ ARM_MODE_SYS, 0x1F
199767f8919635c4928607450d9e0abb932109ceToomas Soome .equ I_BIT, 0x80
199767f8919635c4928607450d9e0abb932109ceToomas Soome .equ F_BIT, 0x40
199767f8919635c4928607450d9e0abb932109ceToomas Soome .equ T_BIT, 0x20
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome/*
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Stack definitions
199767f8919635c4928607450d9e0abb932109ceToomas Soome *
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Start near top of internal RAM.
199767f8919635c4928607450d9e0abb932109ceToomas Soome */
199767f8919635c4928607450d9e0abb932109ceToomas Soome .equ END_INT_SRAM, 0x4000
199767f8919635c4928607450d9e0abb932109ceToomas Soome .equ SVC_STACK_START, (END_INT_SRAM - 0x4)
199767f8919635c4928607450d9e0abb932109ceToomas Soome .equ SVC_STACK_USE, 0x21800000
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soomestart:
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome/* vectors - must reside at address 0 */
199767f8919635c4928607450d9e0abb932109ceToomas Soome/* the format of this table is defined in the datasheet */
199767f8919635c4928607450d9e0abb932109ceToomas Soome B InitReset @; reset
199767f8919635c4928607450d9e0abb932109ceToomas Soomeundefvec:
199767f8919635c4928607450d9e0abb932109ceToomas Soome B undefvec @; Undefined Instruction
199767f8919635c4928607450d9e0abb932109ceToomas Soomeswivec:
199767f8919635c4928607450d9e0abb932109ceToomas Soome B swivec @; Software Interrupt
199767f8919635c4928607450d9e0abb932109ceToomas Soomepabtvec:
199767f8919635c4928607450d9e0abb932109ceToomas Soome B pabtvec @; Prefetch Abort
199767f8919635c4928607450d9e0abb932109ceToomas Soomedabtvec:
199767f8919635c4928607450d9e0abb932109ceToomas Soome B dabtvec @; Data Abort
199767f8919635c4928607450d9e0abb932109ceToomas Soomersvdvec:
199767f8919635c4928607450d9e0abb932109ceToomas Soome#ifdef BOOT_IIC
199767f8919635c4928607450d9e0abb932109ceToomas Soome .long (TWI_EEPROM_SIZE >> 9)
199767f8919635c4928607450d9e0abb932109ceToomas Soome#else
199767f8919635c4928607450d9e0abb932109ceToomas Soome#ifdef BOOT_BWCT
199767f8919635c4928607450d9e0abb932109ceToomas Soome .long ((528 << 17) | (13 << 13) | (12 * 2))
199767f8919635c4928607450d9e0abb932109ceToomas Soome#else
199767f8919635c4928607450d9e0abb932109ceToomas Soome .long ((1056 << 17) | (13 << 13) | (12 * 2))
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif
199767f8919635c4928607450d9e0abb932109ceToomas Soomeirqvec:
199767f8919635c4928607450d9e0abb932109ceToomas Soome ldr pc, [pc,#-0xF20] @; IRQ : read the AIC
199767f8919635c4928607450d9e0abb932109ceToomas Soomefiqvec:
199767f8919635c4928607450d9e0abb932109ceToomas Soome B fiqvec @; FIQ
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas SoomeInitReset:
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome/* Set stack and init for SVC */
199767f8919635c4928607450d9e0abb932109ceToomas Soome ldr r1, = SVC_STACK_START
199767f8919635c4928607450d9e0abb932109ceToomas Soome mov sp, r1 @; Init stack SYS
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome msr cpsr_c, #(ARM_MODE_SVC | I_BIT | F_BIT)
199767f8919635c4928607450d9e0abb932109ceToomas Soome mov sp, r1 @ ; Init stack SYS
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome/* Perform system initialization */
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome .extern _init
199767f8919635c4928607450d9e0abb932109ceToomas Soome bl _init
199767f8919635c4928607450d9e0abb932109ceToomas Soome#ifndef BOOT_BOOT0
199767f8919635c4928607450d9e0abb932109ceToomas Soome ldr r1, = SVC_STACK_USE
199767f8919635c4928607450d9e0abb932109ceToomas Soome mov sp, r1 @ ; Move the stack to SDRAM
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome/* Start execution at main */
199767f8919635c4928607450d9e0abb932109ceToomas Soome .extern main
199767f8919635c4928607450d9e0abb932109ceToomas Soome_main:
199767f8919635c4928607450d9e0abb932109ceToomas Soome__main:
199767f8919635c4928607450d9e0abb932109ceToomas Soome bl main
199767f8919635c4928607450d9e0abb932109ceToomas Soome/* main should not return. If it does, spin forever */
199767f8919635c4928607450d9e0abb932109ceToomas SoomeinfiniteLoop:
199767f8919635c4928607450d9e0abb932109ceToomas Soome b infiniteLoop
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#ifdef BOOT_COMMANDS
199767f8919635c4928607450d9e0abb932109ceToomas Soome/* the following section is used to store boot commands in */
199767f8919635c4928607450d9e0abb932109ceToomas Soome/* non-volatile memory. */
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome .global BootCommandSection
199767f8919635c4928607450d9e0abb932109ceToomas SoomeBootCommandSection:
199767f8919635c4928607450d9e0abb932109ceToomas Soome#ifdef SUPPORT_LINUX
199767f8919635c4928607450d9e0abb932109ceToomas Soome .string "Bootloader for KB9202 Evaluation Board."
199767f8919635c4928607450d9e0abb932109ceToomas Soome .string "c 0x20210000 0x10100000 0x80000 "
199767f8919635c4928607450d9e0abb932109ceToomas Soome .string "m 0 0 0 0 0 0 "
199767f8919635c4928607450d9e0abb932109ceToomas Soome .string "t 0x20000100 console=ttyS0,115200 root=/dev/ram rw initrd=0x20210000,654933"
199767f8919635c4928607450d9e0abb932109ceToomas Soome .string "e 0x10000000 "
199767f8919635c4928607450d9e0abb932109ceToomas Soome .string " "
199767f8919635c4928607450d9e0abb932109ceToomas Soome#else
199767f8919635c4928607450d9e0abb932109ceToomas Soome#if 1
199767f8919635c4928607450d9e0abb932109ceToomas Soome .string "m 42 53 44 0 0 1"
199767f8919635c4928607450d9e0abb932109ceToomas Soome .string "ip 206 168 13 194"
199767f8919635c4928607450d9e0abb932109ceToomas Soome .string "server_ip 206 168 13 207"
199767f8919635c4928607450d9e0abb932109ceToomas Soome .string "tftp 0x20000000 kernel.bin"
199767f8919635c4928607450d9e0abb932109ceToomas Soome .string "e 0x20000000"
199767f8919635c4928607450d9e0abb932109ceToomas Soome#else
199767f8919635c4928607450d9e0abb932109ceToomas Soome .string "m 42 53 44 0 0 1"
199767f8919635c4928607450d9e0abb932109ceToomas Soome .string "k 0x20000000"
199767f8919635c4928607450d9e0abb932109ceToomas Soome .string "e 0x20000000"
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif
199767f8919635c4928607450d9e0abb932109ceToomas Soome .word 0
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif