FS#8961 - Anti-Aliased Fonts.
[kugel-rb.git] / firmware / target / arm / crt0.S
blob4bd01e4952e55e82cb8e3ecddd99b94719435677
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 */
29     ldr     pc, [pc, #28]
30     ldr     pc, [pc, #28]
31     ldr     pc, [pc, #28]
32     ldr     pc, [pc, #28]
33     ldr     pc, [pc, #28]
34     ldr     pc, [pc, #28]
35     ldr     pc, [pc, #28]
36     ldr     pc, [pc, #28]
38 #if CONFIG_CPU==S5L8700
39     .word 0x43554644 /* DFUC */
40 #else
41     .word 0xdeadbeef /* to keep the same PC offsets */
42 #endif
44 .word newstart
45 .word undef_instr_handler
46 .word software_int_handler
47 .word prefetch_abort_handler
48 .word data_abort_handler
49 .word reserved_handler
50 .word irq_handler
51 .word fiq_handler
53 _vectorsend:
55     .text
57 newstart:
58     msr     cpsr_c, #0xd3 /* enter supervisor mode, disable IRQ/FIQ */
60 #if CONFIG_CPU==AS3525 && !defined(BOOTLOADER)
61     /* Setup MMU : has to be done before accessing IRAM ! */
62     bl      memory_init
64     /* Zero out IBSS */
65     ldr     r2, =_iedata
66     ldr     r3, =_iend
67     mov     r4, #0
69     cmp     r3, r2
70     strhi   r4, [r2], #4
71     bhi     1b
73     /* Copy the IRAM */
74     ldr     r2, =_iramcopy
75     ldr     r3, =_iramstart
76     ldr     r4, =_iramend
78     cmp     r4, r3
79     ldrhi   r5, [r2], #4
80     strhi   r5, [r3], #4
81     bhi     1b
82 #endif
84     /* Initialise bss section to zero */
85     ldr     r2, =_edata
86     ldr     r3, =_end
87     mov     r4, #0
89     cmp     r3, r2
90     strhi   r4, [r2], #4
91     bhi     1b
92     
93     /* Set up some stack and munge it with 0xdeadbeef */
94     ldr     sp, =stackend
95     ldr     r2, =stackbegin
96     ldr     r3, =0xdeadbeef
98     cmp     sp, r2
99     strhi   r3, [r2], #4
100     bhi     1b
101     
102     /* Set up stack for IRQ mode */ 
103     msr     cpsr_c, #0xd2
104     ldr     sp, =irq_stack
106     /* Set up stack for FIQ mode */ 
107     msr     cpsr_c, #0xd1
108     ldr     sp, =fiq_stack
110     /* Let abort and undefined modes use IRQ stack */
111     msr     cpsr_c, #0xd7
112     ldr     sp, =irq_stack
113     msr     cpsr_c, #0xdb
114     ldr     sp, =irq_stack
116     /* Switch back to supervisor mode */
117     msr     cpsr_c, #0xd3
119     bl      main
122 /* All illegal exceptions call into UIE with exception address as first
123  * parameter. This is calculated differently depending on which exception
124  * we're in. Second parameter is exception number, used for a string lookup
125  * in UIE. */
126 undef_instr_handler:
127     mov    r0, lr
128     mov    r1, #0
129     b      UIE
131 /* We run supervisor mode most of the time, and should never see a software
132  * exception being thrown. Perhaps make it illegal and call UIE? */
133 software_int_handler:
134 reserved_handler:
135     movs   pc, lr
137 prefetch_abort_handler:
138     sub    r0, lr, #4
139     mov    r1, #1
140     b      UIE
142 data_abort_handler:
143     sub    r0, lr, #8 
144     mov    r1, #2
145     b      UIE
147 /* 256 words of IRQ stack */
148     .space 256*4
149 irq_stack:
151 /* 256 words of FIQ stack */
152     .space 256*4
153 fiq_stack:
155 end: