blob: bc9f0023bc041f50c9b086f5a925bb7bd8ce72ff [file]
/*
* Copyright 2014, NICTA
*
* This software may be distributed and modified according to the terms of
* the BSD 2-Clause license. Note that NO WARRANTY is provided.
* See "LICENSE_BSD2.txt" for details.
*
* @TAG(NICTA_BSD)
*/
/*
* A default crt0 for ia32. It does the bare minimum required to get into
* main() with a sensible C environment.
*
* This file will only be linked in if:
* - no other file already provides a _start symbol, and
* - _start is an undefined external symbol (force this by passing
* "-u _start" to ld).
*/
#define __ASM__
#include <autoconf.h>
#ifdef CONFIG_LIB_SEL4_PLAT_SUPPORT_START
#include <sel4/arch/constants.h>
.global _start
.text
#ifdef X86_64
.align 0x1000
_start:
leaq _stack_top, %rsp
/* Setup segment selector for IPC buffer access. */
movw $IPCBUF_GDT_SELECTOR, %ax
movw %ax, %gs
# setup the bootinfo
movq %rbx, %rdi
call seL4_InitBootInfo
/* Call constructors and other initialisation functions. */
call _init
call main
# the return value is in rax
movq %rax, %rdi
call exit
1: jmp 1b
#else
_start:
leal _stack_top, %esp
/* Setup segment selector for IPC buffer access. */
movw $IPCBUF_GDT_SELECTOR, %ax
movw %ax, %gs
/* Setup the global "bootinfo" structure. */
pushl %ebx
call seL4_InitBootInfo
addl $4, %esp
/* Call constructors and other initialisation functions. */
call _init
/* Start main. */
call main
/* Call exit with the return value from main. */
pushl %eax
call exit
1: jmp 1b
#endif
.bss
.align 8
_stack_bottom:
.space 16384
_stack_top:
#endif /* CONFIG_LIB_SEL4_PLAT_SUPPORT_START */