hm60x/hm801: Buttons rework.
[maemo-rb.git] / firmware / target / arm / crt0.S
blobb9cc27f5c5f2e70d6255aee14b4d9870cdc50728
1 /***************************************************************************
2  *             __________               __   ___.
3  *   Open      \______   \ ____   ____ |  | _\_ |__   _______  ___
4  *   Source     |       _//  _ \_/ ___\|  |/ /| __ \ /  _ \  \/  /
5  *   Jukebox    |    |   (  <_> )  \___|    < | \_\ (  <_> > <  <
6  *   Firmware   |____|_  /\____/ \___  >__|_ \|___  /\____/__/\_ \
7  *                     \/            \/     \/    \/            \/
8  * $Id$
9  *
10  * Copyright (C) 2008 by Marcoen Hirschberg
11  *
12  * This program is free software; you can redistribute it and/or
13  * modify it under the terms of the GNU General Public License
14  * as published by the Free Software Foundation; either version 2
15  * of the License, or (at your option) any later version.
16  *
17  * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18  * KIND, either express or implied.
19  *
20  ****************************************************************************/
21 #include "config.h"
22 #include "cpu.h"
24     .section .init.text,"ax",%progbits
26     .global    start
27 start:
28     /* Exception vectors */
30     /*
31      * reset vector *MUST* use relative-addressing only
32      * the MMU might not be enabled yet, and the PC might point to
33      * a memory region not present in the linked binary
34      */
36     b   newstart
37     b   undef_instr_handler
38     b   software_int_handler
39     b   prefetch_abort_handler
40     b   data_abort_handler
41     b   reserved_handler
42     b   irq_handler
43     b   fiq_handler
45 _vectorsend:
47     .text
49 newstart:
50     msr     cpsr_c, #0xd3 /* enter supervisor mode, disable IRQ/FIQ */
52 #if CONFIG_CPU == AS3525 || CONFIG_CPU == AS3525v2
53     bl      memory_init
54 #endif
56 #ifdef USE_IRAM
57     /* Zero out IBSS */
58     ldr     r2, =_iedata
59     ldr     r3, =_iend
60     mov     r4, #0
62     cmp     r3, r2
63     strhi   r4, [r2], #4
64     bhi     1b
66     /* Copy the IRAM */
67     /* must be done before bss is zeroed */
68     ldr     r2, =_iramcopy
69     ldr     r3, =_iramstart
70     ldr     r4, =_iramend
72     cmp     r4, r3
73     ldrhi   r5, [r2], #4
74     strhi   r5, [r3], #4
75     bhi     1b
76 #endif
78 #ifdef HAVE_INIT_ATTR
79     /* copy init data to codec buffer */
80     /* must be done before bss is zeroed */
81     ldr    r2, =_initcopy
82     ldr    r3, =_initstart
83     ldr    r4, =_initend
85     cmp     r4, r3
86     ldrhi   r5, [r2], #4
87     strhi   r5, [r3], #4
88     bhi     1b
90     mov     r2, #0
91     mcr     p15, 0, r2, c7, c5, 0   @ Invalidate ICache
92 #endif
94     /* Initialise bss section to zero */
95     ldr     r2, =_edata
96     ldr     r3, =_end
97     mov     r4, #0
99     cmp     r3, r2
100     strhi   r4, [r2], #4
101     bhi     1b
103     /* Set up stack for IRQ mode */
104     msr     cpsr_c, #0xd2
105     ldr     sp, =irq_stack
107     msr     cpsr_c, #0xd3
108 #if CONFIG_CPU == AS3525 || CONFIG_CPU == AS3525v2
109     /* Let abort and undefined modes use irq stack */
110     /* svc stack is for interrupt processing */
111     ldr     sp, =svc_stack
112 #else
113     /* Let svc, abort and undefined modes use irq stack */
114     ldr     sp, =irq_stack
116     /* Set up stack for FIQ mode */
117     msr     cpsr_c, #0xd1
118     ldr     sp, =fiq_stack
119 #endif
120     msr     cpsr_c, #0xd7
121     ldr     sp, =irq_stack
122     msr     cpsr_c, #0xdb
123     ldr     sp, =irq_stack
125     /* Switch to sys mode */
126     msr     cpsr_c, #0xdf
128     /* Set up some stack and munge it with 0xdeadbeef */
129     ldr     sp, =stackend
130     ldr     r2, =stackbegin
131     ldr     r3, =0xdeadbeef
133     cmp     sp, r2
134     strhi   r3, [r2], #4
135     bhi     1b
137     ldr     ip, =main       @ make sure we are using the virtual address
138     bx      ip
140 /* Cache-align interrupt stacks */
141 .balign    32
143 /* 256 words of IRQ stack */
144     .space 256*4
145 irq_stack:
147 /* 256 words of FIQ/SVC stack */
148     .space 256*4
149 fiq_stack:
150 svc_stack:
152 end: