00001 /*This file has been prepared for Doxygen automatic documentation generation.*/ 00016 /* Copyright (c) 2009 Atmel Corporation. All rights reserved. 00017 * 00018 * Redistribution and use in source and binary forms, with or without 00019 * modification, are permitted provided that the following conditions are met: 00020 * 00021 * 1. Redistributions of source code must retain the above copyright notice, this 00022 * list of conditions and the following disclaimer. 00023 * 00024 * 2. Redistributions in binary form must reproduce the above copyright notice, 00025 * this list of conditions and the following disclaimer in the documentation 00026 * and/or other materials provided with the distribution. 00027 * 00028 * 3. The name of Atmel may not be used to endorse or promote products derived 00029 * from this software without specific prior written permission. 00030 * 00031 * 4. This software may only be redistributed and used in connection with an Atmel 00032 * AVR product. 00033 * 00034 * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED 00035 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 00036 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE 00037 * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR 00038 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 00039 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00040 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 00041 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00042 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00043 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE 00044 * 00045 */ 00046 00047 #include <avr32/io.h> 00048 #include "flashvault.h" 00049 00052 00053 00054 // This is the beginning of the 3rd-party application (i.e. outside the FlashVault). 00055 .section .text._stext, "ax", @progbits 00056 00057 00058 .global thirdparty_start 00059 .type thirdparty_start, @function 00060 // Note: no need for a .org directive, because the placement of thirdparty_start 00061 // at the very start of the 3rd-party area is taken care of in the linker script. 00062 thirdparty_start: 00063 // Set initial stack pointer. 00064 lda.w sp, _estack 00065 00066 // Set up EVBA so interrupts can be enabled. 00067 lda.w r0, _evba 00068 mtsr AVR32_EVBA, r0 00069 00070 // Enable the exception processing. 00071 csrf AVR32_SR_EM_OFFSET 00072 00073 // Load initialized data having a global lifetime from the data LMA. 00074 lda.w r0, thirdparty_data 00075 lda.w r1, thirdparty_edata 00076 cp r0, r1 00077 brhs idata_load_loop_end 00078 lda.w r2, thirdparty_data_lma 00079 idata_load_loop: 00080 ld.d r4, r2++ 00081 st.d r0++, r4 00082 cp r0, r1 00083 brlo idata_load_loop 00084 idata_load_loop_end: 00085 00086 // Clear uninitialized data having a global lifetime in the blank static storage section. 00087 lda.w r0, thirdparty_bss_start 00088 lda.w r1, thirdparty_bss_end 00089 cp r0, r1 00090 brhs udata_clear_loop_end 00091 mov r2, 0 00092 mov r3, 0 00093 udata_clear_loop: 00094 st.d r0++, r2 00095 cp r0, r1 00096 brlo udata_clear_loop 00097 udata_clear_loop_end: 00098 00099 #ifdef CONFIG_FRAME_POINTER 00100 // Safety: Set the default "return" @ to the exit routine address. 00101 lda.w lr, exit 00102 #endif 00103 00104 // Start the show. 00105 lda.w pc, main 00106 00107