00001 /*This file is 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 00048 #include <avr32/io.h> 00049 00050 00053 00054 00055 // This must be linked @ 0x80000000 if it is to be run upon reset. 00056 .section .reset, "ax", @progbits 00057 00058 00059 .global _start 00060 .type _start, @function 00061 _start: 00062 // Jump to the C runtime startup routine. 00063 lda.w pc, _stext 00064 00065 00066 // _stext is placed outside the .reset section so that the program entry point 00067 // can be changed without affecting the C runtime startup. 00068 .section .text._stext, "ax", @progbits 00069 00070 00071 .global _stext 00072 .type _stext, @function 00073 _stext: 00074 // Set initial stack pointer. 00075 lda.w sp, _estack 00076 00077 // Set up EVBA so interrupts can be enabled. 00078 lda.w r0, _evba 00079 mtsr AVR32_EVBA, r0 00080 00081 // Enable the exception processing. 00082 csrf AVR32_SR_EM_OFFSET 00083 00084 // Call the startup customization function. 00085 call _init_startup 00086 00087 // Load initialized external SDRAM data having a global lifetime from the 00088 // data_sdram LMA. 00089 lda.w r0, _data_sdram 00090 lda.w r1, _edata_sdram 00091 cp r0, r1 00092 brhs idata_sdram_load_loop_end 00093 lda.w r2, _data_sdram_lma 00094 idata_sdram_load_loop: 00095 ld.d r4, r2++ 00096 st.d r0++, r4 00097 cp r0, r1 00098 brlo idata_sdram_load_loop 00099 idata_sdram_load_loop_end: 00100 00101 // Clear uninitialized external SDRAM data having a global lifetime in the 00102 // blank static storage section. 00103 lda.w r0, __bss_sdram_start 00104 lda.w r1, _bss_sdram_end 00105 cp r0, r1 00106 brhs udata_sdram_clear_loop_end 00107 mov r2, 0 00108 mov r3, 0 00109 udata_sdram_clear_loop: 00110 st.d r0++, r2 00111 cp r0, r1 00112 brlo udata_sdram_clear_loop 00113 udata_sdram_clear_loop_end: 00114 00115 // Load initialized data having a global lifetime from the data LMA. 00116 lda.w r0, _data 00117 lda.w r1, _edata 00118 cp r0, r1 00119 brhs idata_load_loop_end 00120 lda.w r2, _data_lma 00121 idata_load_loop: 00122 ld.d r4, r2++ 00123 st.d r0++, r4 00124 cp r0, r1 00125 brlo idata_load_loop 00126 idata_load_loop_end: 00127 00128 // Clear uninitialized data having a global lifetime in the blank static storage section. 00129 lda.w r0, __bss_start 00130 lda.w r1, _end 00131 cp r0, r1 00132 brhs udata_clear_loop_end 00133 mov r2, 0 00134 mov r3, 0 00135 udata_clear_loop: 00136 st.d r0++, r2 00137 cp r0, r1 00138 brlo udata_clear_loop 00139 udata_clear_loop_end: 00140 00141 #ifdef CONFIG_FRAME_POINTER 00142 // Safety: Set the default "return" @ to the exit routine address. 00143 lda.w lr, exit 00144 #endif 00145 00146 // Start the show. 00147 lda.w pc, main 00148 00149