Changeset View
Changeset View
Standalone View
Standalone View
sys/boot/mips/uboot/start.S
- This file was added.
/*- | |||||
* Copyright (c) 2016 Stanislav Galabov | |||||
* All rights reserved. | |||||
* | |||||
* Redistribution and use in source and binary forms, with or without | |||||
* modification, are permitted provided that the following conditions | |||||
* are met: | |||||
* 1. Redistributions of source code must retain the above copyright | |||||
* notice, this list of conditions and the following disclaimer. | |||||
* 2. Redistributions in binary form must reproduce the above copyright | |||||
* notice, this list of conditions and the following disclaimer in the | |||||
* documentation and/or other materials provided with the distribution. | |||||
* | |||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND | |||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | |||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||||
* SUCH DAMAGE. | |||||
* | |||||
* $FreeBSD$ | |||||
*/ | |||||
#include <machine/asm.h> | |||||
.text | |||||
#ifdef SUPPORT_SELF_RELOC | |||||
.extern _C_LABEL(self_reloc) | |||||
#endif | |||||
.extern _C_LABEL(main) | |||||
.weak _DYNAMIC | |||||
/* | |||||
* Entry point to the loader that U-Boot passes control to. | |||||
*/ | |||||
ENTRY(_start) | |||||
#ifdef SUPPORT_SELF_RELOC | |||||
/* XXX: Does anyone need this part at all? It currently doesn't work. */ | |||||
.set mips32r2 | |||||
/* | |||||
* Do self-relocation when the weak external symbol _DYNAMIC is non-NULL | |||||
* When linked as a dynamic relocatable file, the linker automatically | |||||
* defines _DYNAMIC with a value that is the offset of the dynamic | |||||
* relocation info section. | |||||
* Note that we're still on u-boot's stack here, but the self_reloc | |||||
* code uses only a couple dozen bytes of stack space. | |||||
*/ | |||||
lw t0, .here_off /* .here_off is a symbol whose value */ | |||||
/* is its own offset in the text seg. */ | |||||
/* Get its pc-relative address and */ | |||||
lw t1, .dynamic_off /* subtract its value and we get */ | |||||
nop | |||||
add t2, t0, t1 | |||||
movn t1, t2, t1 | |||||
beqz t1, 1f | |||||
nop | |||||
b _C_LABEL(self_reloc) /* Do reloc if _DYNAMIC is non-NULL. */ | |||||
nop | |||||
1: | |||||
#endif | |||||
sw sp, uboot_address | |||||
b main | |||||
END(_start) | |||||
#ifdef SUPPORT_SELF_RELOC | |||||
/* | |||||
* Data for self-relocation, in the text segment for pc-rel access. | |||||
*/ | |||||
.here_off: | |||||
.word . - _start | |||||
.dynamic_off: | |||||
.word _DYNAMIC | |||||
#endif | |||||
/* | |||||
* syscall() | |||||
*/ | |||||
ENTRY(syscall) | |||||
sw ra, ret_address | |||||
lw t9, syscall_ptr | |||||
jalr t9 | |||||
nop | |||||
lw ra, ret_address | |||||
jr ra | |||||
nop | |||||
END(syscall) | |||||
/* | |||||
* Data section | |||||
*/ | |||||
.data | |||||
.align 4 | |||||
.globl syscall_ptr | |||||
syscall_ptr: | |||||
.long 0 | |||||
.globl uboot_address | |||||
uboot_address: | |||||
.long 0 | |||||
ret_address: | |||||
.long 0 |