/*1* Copyright (c) 2018 naehrwert2*3* This program is free software; you can redistribute it and/or modify it4* under the terms and conditions of the GNU General Public License,5* version 2, as published by the Free Software Foundation.6*7* This program is distributed in the hope it will be useful, but WITHOUT8* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or9* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for10* more details.11*12* You should have received a copy of the GNU General Public License13* along with this program. If not, see <http://www.gnu.org/licenses/>.14*/1516.section .text._start17.arm1819.extern _reloc_ipl20.type _reloc_ipl, %function2122.extern memset23.type memset, %function2425.extern _irq_setup26.type _irq_setup, %function2728.globl _start29.type _start, %function30_start:31ADR R0, _start32LDR R1, =__ipl_start33CMP R0, R134BEQ _real_start3536/* If we are not in the right location already, copy a relocator to upper IRAM. */37ADR R2, _reloc_ipl38LDR R3, =0x4003FF0039MOV R4, #(_real_start - _reloc_ipl)40_copy_loop:41LDMIA R2!, {R5}42STMIA R3!, {R5}43SUBS R4, #444BNE _copy_loop4546/* Use the relocator to copy ourselves into the right place. */47LDR R2, =__ipl_end48SUB R2, R2, R149LDR R3, =_real_start50LDR R4, =0x4003FF0051BX R45253_reloc_ipl:54LDMIA R0!, {R4-R7}55STMIA R1!, {R4-R7}56SUBS R2, #0x1057BNE _reloc_ipl58/* Jump to the relocated entry. */59BX R36061_real_start:62/* Initially, we place our stack under relocator but will move it to under the payload. */63/* This depends on application scope. */64LDR SP, =0x4003FF0065LDR R0, =__bss_start66EOR R1, R1, R167LDR R2, =__bss_end68SUB R2, R2, R069BL memset70BL _irq_setup71B .7273.globl pivot_stack74.type pivot_stack, %function75pivot_stack:76MOV SP, R077BX LR787980