Search
lxdream.org :: lxdream/test/lib-arm/crt0.s
lxdream 0.9.1
released Jun 29
Download Now
filename test/lib-arm/crt0.s
changeset 821:4398dafeb77d
prev812:8cc61d5ea1f8
author nkeynes
date Wed Aug 20 11:25:46 2008 +0000 (15 years ago)
permissions -rw-r--r--
last change Setup the interrupt/exception vectors properly in the arm crt0
Use fully guarded memcpy_to_aica for program transfer
view annotate diff log raw
     1 .section .text
     2 .code 32
     3 .align 	0
     4 .global	start
     5 .global ___exit
     6 .global _atexit
     7 start:
     8 	b real_entry
     9 	b exception_entry
    10 	b exception_entry /* SWI - not used so jump to general exception */
    11 	b exception_entry
    12 	b exception_entry
    13 	b exception_entry /* Not a vector, but if we ever get here... */
    14 	b irq_entry
    15 	b fiq_entry
    17 /* Start by setting up a stack */
    18 real_entry:
    19 	/*  Set up the stack pointer to a fixed value */
    20 	ldr	r3, .LC0
    21 	mov 	sp, r3
    22 	/* Setup a default stack-limit in-case the code has been
    23 	   compiled with "-mapcs-stack-check".  Hard-wiring this value
    24 	   is not ideal, since there is currently no support for
    25 	   checking that the heap and stack have not collided, or that
    26 	   this default 64k is enough for the program being executed.
    27 	   However, it ensures that this simple crt0 world will not
    28 	   immediately cause an overflow event:  */
    29 	sub	sl, sp, #64 << 10	/* Still assumes 256bytes below sl */
    30 	b .LB0
    32 .syscall:
    33 	.word   -1              /* Syscall # */
    34 	.word   0               /* Arguments */
    35 	.word   0
    36 	.word   0
    38 irq_counter:
    39 	.word 0
    40 fiq_counter:
    41 	.word 0
    43 .LB0:
    44 	/* Zero-out the BSS segment */
    45 	mov 	a2, #0			/* Second arg: fill value */
    46 	mov	fp, a2			/* Null frame pointer */
    47 	mov	r7, a2			/* Null frame pointer for Thumb */
    49 	ldr	a1, .LC1		/* First arg: start of memory block */
    50 	ldr	a3, .LC2	
    51 	sub	a3, a3, a1		/* Third arg: length of block */
    52 	bl	memset
    54 	/* Enter main with no arguments for now */
    55 	mov	r0, #0		/*  no arguments  */
    56 	mov	r1, #0		/*  no argv either */
    57 	bl	main
    59 	bl	exit		/* Should not return */
    61 	/* For Thumb, constants must be after the code since only 
    62 	positive offsets are supported for PC relative addresses. */
    64 exception_entry:
    65 	mov r13, #-2
    66 	str r13, .syscall
    67 .die:
    68 	b .die
    70 irq_entry:
    71 	/* Increment IRQ counter and return */
    72 	ldr r13, irq_counter
    73 	add r13, r13, #1
    74 	str r13, irq_counter
    75 	subs r15, r14, #4
    76 fiq_entry:
    77 	/* Increment FIQ counter and return */
    78 	ldr r13, fiq_counter
    79 	add r13, r13, #1
    80 	str r13, fiq_counter
    81 	subs r15, r14, #4
    83 	.align 0
    84 .LC0:
    85 	.word   _stack
    86 .LC1:
    87 	.word	__bss_start
    88 .LC2:
    89 	.word	__bss_end
.