~ubuntu-branches/ubuntu/raring/codeblocks/raring-proposed

« back to all changes in this revision

Viewing changes to src/plugins/scriptedwizard/resources/arm/files/phyCORE-PXA255/src/vectors.S

  • Committer: Bazaar Package Importer
  • Author(s): Cosme Domínguez Díaz
  • Date: 2010-08-09 04:38:38 UTC
  • mfrom: (1.1.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 4.
  • Revision ID: james.westby@ubuntu.com-20100809043838-a59ygguym4eg0jgw
Tags: 10.05-0ubuntu1
* New upstream release. Closes (LP: #322350)
 - Switch to dpkg-source 3.0 (quilt) format
 - Remove unneeded README.source
 - Add debian/get-source-orig script that removes all
   Windows prebuilt binaries
* Bump Standards-Version to 3.9.1
 - Stop shipping *.la files
* debian/control
 - Add cdbs package as Build-Depend
 - Add libbz2-dev and zlib1g-dev packages as
   Build-Depends (needed by libhelp_plugin.so)
 - Remove dpatch package of Build-Depends
 - Add codeblocks-contrib-debug package
 - Split architecture-independent files of codeblocks
   package in codeblocks-common package
* debian/rules
 - Switch to CDBS rules system
 - Add parallel build support
 - Add a call to debian/get-source-orig script
 - Use lzma compression (saves 23,5 MB of free space)
* debian/patches
 - Refresh 01_codeblocks_plugin_path
 - Add 02_no_Makefiles_in_debian_dir to remove any link
   in codeblocks build system to deleted Makefiles of debian directory
 - Drop 02_ftbfs_gcc44 and 03_ftbfs_glib221 (merged in upstream)
* debian/watch
 - Update to use the new host (berlios.de)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// #========================================================================
 
2
// #
 
3
// # vectors.S
 
4
// #
 
5
// # ARM exception vectors (phyCORE_PXA255)
 
6
// #
 
7
// #
 
8
// # Copyright HighTec EDV-Systeme GmbH 1982-2006
 
9
// #
 
10
// #========================================================================
 
11
 
 
12
 
 
13
#define CPSR_IRQ_DISABLE        0x80    /* IRQ disabled when = 1 */
 
14
#define CPSR_FIQ_DISABLE        0x40    /* FIQ disabled when = 1 */
 
15
#define CPSR_THUMB_ENABLE       0x20    /* Thumb mode   when = 1 */
 
16
#define CPSR_MODE32_ENABLE      0x10    /* 32 bit mode  when = 1 */
 
17
 
 
18
#define CPSR_MODE_BITS          0x1F
 
19
#define CPSR_USER_MODE          0x10
 
20
#define CPSR_FIQ_MODE           0x11
 
21
#define CPSR_IRQ_MODE           0x12
 
22
#define CPSR_SVC_MODE           0x13
 
23
#define CPSR_DBG_MODE           0x15    /* XScale extension */
 
24
#define CPSR_ABORT_MODE         0x17
 
25
#define CPSR_UNDEF_MODE         0x1B
 
26
#define CPSR_SYSTEM_MODE        0x1F
 
27
 
 
28
#define SWI_Location            0x28    /* HiMo: address of SWI handler */
 
29
#define IRQ_Location            0x38    /* HiMo: address of IRQ handler */
 
30
 
 
31
//;
 
32
//; # Platform specific definition for phyCORE-PXA255 board
 
33
//;
 
34
 
 
35
/* Reset Controller Registers */
 
36
#define RST_BASE                0x40F00030
 
37
#define RCSR_OFFS               0
 
38
#define RCSR                    (RST_BASE + 0x00)
 
39
 
 
40
/* Operating System Timer */
 
41
#define OSTIMER_BASE    0x40A00000
 
42
#define OSMR3_OFFS      0x0C
 
43
#define OSCR_OFFS       0x10
 
44
#define OWER_OFFS       0x18
 
45
#define OIER_OFFS       0x1C
 
46
 
 
47
/* Clock Manager Register */
 
48
#define CC_BASE         0x41300000
 
49
#define CCCR_OFFS       0x00
 
50
#define CKEN_OFFS       0x04
 
51
 
 
52
/* Interrupt Controller Registers */
 
53
#define IC_BASE         0x40D00000
 
54
/* Interrupt Mask Register */
 
55
#define ICMR            (IC_BASE + 0x04)
 
56
#define ICMR_OFFS       0x04
 
57
 
 
58
/* MMU bit definitions */
 
59
 
 
60
#define MMU_Control_M   (1 << 0)        /* Enable MMU */
 
61
#define MMU_Control_A   (1 << 1)        /* Enable address alignment faults */
 
62
#define MMU_Control_C   (1 << 2)        /* Enable cache */
 
63
#define MMU_Control_B   (1 << 7)        /* Enable Big-Endian */
 
64
#define MMU_Control_S   (1 << 8)        /* Enable system protection */
 
65
#define MMU_Control_R   (1 << 9)        /* Enable ROM protection */
 
66
#define MMU_Control_Z   (1 << 11)       /* Branch Target Buffer Enable */
 
67
#define MMU_Control_I   (1 << 11)       /* Enable Instruction cache */
 
68
#define MMU_Control_V   (1 << 12)       /* Interrupt vectors at 0xFFFF0000 */
 
69
 
 
70
#define PHYS_RAM_BASE   0xa0000000
 
71
 
 
72
/* Intel proposed macro for writing CP15 */
 
73
        .macro CPWAIT
 
74
        mrc     p15,0,r0,c2,c0,0
 
75
        mov     r0,r0
 
76
        sub     pc,pc,#4
 
77
        .endm
 
78
 
 
79
 
 
80
//; #==========================================================================
 
81
//; #  Hardware exception vectors.
 
82
//; #  The vector table will be copied to location 0x0000 at startup time.
 
83
//;
 
84
        .code   32
 
85
        .section ".vectors","ax"
 
86
        .global __exception_handlers
 
87
 
 
88
        b       start
 
89
__exception_handlers:
 
90
__vector_table_start:
 
91
        ldr     pc,.reset_vector
 
92
        ldr     pc,.undefined_instruction
 
93
        ldr     pc,.software_interrupt
 
94
        ldr     pc,.abort_prefetch
 
95
        ldr     pc,.abort_data
 
96
        .word   0
 
97
        ldr     pc,.IRQ
 
98
        ldr     pc,.FIQ
 
99
 
 
100
//; # The layout of these pointers should match the vector table above since
 
101
//; # they are copied in pairs.
 
102
        .global vectors
 
103
vectors:
 
104
.reset_vector:
 
105
        .word   reset_vector
 
106
.undefined_instruction:
 
107
        .word   undefined_instruction
 
108
.software_interrupt:
 
109
        .word   software_interrupt
 
110
.abort_prefetch:
 
111
        .word   abort_prefetch
 
112
.abort_data:
 
113
        .word   abort_data
 
114
        .word   0
 
115
.IRQ:
 
116
        .word   IRQ
 
117
.FIQ:
 
118
        .word   FIQ
 
119
 
 
120
__vector_table_end:
 
121
 
 
122
        .text
 
123
//; begin of startup code
 
124
start:
 
125
 
 
126
        .global reset_vector
 
127
        .type   reset_vector,function
 
128
reset_vector:
 
129
 
 
130
//; #   PLATFORM_SETUP1         //; # Early stage platform initialization
 
131
 
 
132
//; # Init MMU
 
133
//; # MMU disabled, Alignment fault disabled, DCache disabled
 
134
//; # exceptions vectors at 0
 
135
        mrc     p15,0,r1,c1,c0
 
136
        bic     r1,r1,#(MMU_Control_M+MMU_Control_A+MMU_Control_C)
 
137
        bic     r1,r1,#MMU_Control_V
 
138
        mcr     p15,0,r1,c1,c0
 
139
 
 
140
        mov     r0,#0
 
141
        mcr     p15,0,r0,c8,c7,0        //; # invalidate all TLBs
 
142
        mcr     p15,0,r0,c7,c7,0        //; # invalidate caches
 
143
 
 
144
        /* mask all IRQs */
 
145
        ldr     r0,=IC_BASE
 
146
        mov     r1,#0
 
147
        str     r1,[r0,#ICMR_OFFS]
 
148
 
 
149
//; # initialize clock
 
150
        ldr     r0,=CC_BASE
 
151
        mov     r1,#0                   //; disable all peripheral clocks
 
152
        str     r1,[r0,#CKEN_OFFS]      //; CKEN Clock Enable Register
 
153
#ifdef FAST_CLOCK
 
154
        ldr     r1,=0x161               //; 4 x fMemory
 
155
#else
 
156
        ldr     r1,=0x141               //; 2 x fMemory
 
157
#endif /* FAST_CLOCK */
 
158
        str     r1,[r0,#CCCR_OFFS]      //; CCCR Core Clock Configuration Register
 
159
        mov     r0,#2
 
160
        mcr     p14,0,r0,c6,c0          //; activate clock change
 
161
 
 
162
        /* ToDo: initialize RAM/ROM/SDRAM */
 
163
 
 
164
#ifndef DONT_USE_MMU
 
165
        /* initialize MMU tables */
 
166
        ldr     r0,=PHYS_RAM_BASE
 
167
        ldr     sp,=__startup_stack
 
168
        add     sp,sp,r0
 
169
        bl      pxa_mmu_init
 
170
 
 
171
        /* MMU on */
 
172
        ldr     r2,=1f
 
173
        mrc     p15,0,r0,c1,c0,0
 
174
        orr     r0,r0,#MMU_Control_M    /* enable MMU */
 
175
        mcr     p15,0,r0,c1,c0,0
 
176
        mov     pc,r2
 
177
1:
 
178
        nop
 
179
        nop
 
180
        nop
 
181
#endif /* DONT_USE_MMU */
 
182
 
 
183
 
 
184
//;
 
185
//; # copy the vector table (__vector_table_start .. __vector_table_end) to address 0
 
186
//;
 
187
#ifndef USE_HIMO
 
188
//; #  HiMo needs its own exception handlers --> don't overwrite these!!
 
189
        mov     r8,#0
 
190
        ldr     r9,=__exception_handlers
 
191
        ldmia   r9!,{r0-r7}
 
192
        stmia   r8!,{r0-r7}
 
193
        ldmia   r9!,{r0-r7}
 
194
        stmia   r8!,{r0-r7}
 
195
#endif /* !USE_HIMO */
 
196
 
 
197
//      ; Relocate [copy] data from ROM to RAM
 
198
        ldr     r0,=__rom_data_start
 
199
        ldr     r1,=__ram_data_start
 
200
        ldr     r2,=__ram_data_end
 
201
1:
 
202
        cmp     r1,r2           //; #  while (r1 < r2)
 
203
        ldrcc   r3,[r0],#4      //; #  {
 
204
        strcc   r3,[r1],#4      //; #    *r1++ = *r0++;
 
205
        bcc     1b              //; #  }
 
206
 
 
207
//      ; clear BSS
 
208
        ldr     r1,=__bss_start
 
209
        ldr     r2,=__bss_end
 
210
        mov     r0,#0
 
211
1:
 
212
        cmp     r1,r2           //; # while (r1 < r2)
 
213
        strcc   r0,[r1],#4      //; #   *r1++ = 0;
 
214
        bcc     1b
 
215
 
 
216
#if defined(USE_IRQ) && defined(USE_HIMO)
 
217
//; replace IRQ handler by our own handler
 
218
        ldr     r1,=IRQ_Location
 
219
        ldr     r0,=HIMO_IRQ_Address
 
220
        ldr     r2,[r1]
 
221
        str     r2,[r0]
 
222
        ldr     r2,=IRQ
 
223
        str     r2,[r1]
 
224
#endif /* USE_IRQ && USE_HIMO */
 
225
 
 
226
//      ; # initialize interrupt/exception environments
 
227
        ldr     sp,=__startup_stack
 
228
        mov     r0,#(CPSR_IRQ_DISABLE|CPSR_FIQ_DISABLE|CPSR_IRQ_MODE)
 
229
        msr     cpsr,r0
 
230
        ldr     sp,=__interrupt_stack
 
231
        mov     r0,#(CPSR_IRQ_DISABLE|CPSR_FIQ_DISABLE|CPSR_FIQ_MODE)
 
232
        msr     cpsr,r0
 
233
        ldr     sp,=__FIQ_exception_stack
 
234
        mov     r0,#(CPSR_IRQ_DISABLE|CPSR_FIQ_DISABLE|CPSR_UNDEF_MODE)
 
235
        msr     cpsr,r0
 
236
        ldr     sp,=__exception_stack
 
237
        mov     r0,#(CPSR_IRQ_DISABLE|CPSR_FIQ_DISABLE|CPSR_ABORT_MODE)
 
238
        msr     cpsr,r0
 
239
        ldr     sp,=__exception_stack
 
240
 
 
241
//      ; # initialize CPSR (machine state register)
 
242
        mov     r0,#(CPSR_IRQ_DISABLE|CPSR_FIQ_DISABLE|CPSR_SVC_MODE)
 
243
        msr     cpsr,r0
 
244
 
 
245
//      ; # Note: some functions in LIBGCC1 will cause a "restore from SPSR"!!
 
246
        msr     spsr,r0
 
247
 
 
248
#ifdef USE_IRQ
 
249
//; # initialize interrupt tables
 
250
        bl      IrqInit
 
251
#endif /* USE_IRQ */
 
252
 
 
253
 
 
254
#if 1
 
255
//; # do low level PXROS initialization if we are in a PXROS environment
 
256
        ldr     r0,=PxPrepareInit
 
257
        cmp     r0,#0
 
258
        movne   lr,pc
 
259
        movne   pc,r0
 
260
#endif
 
261
 
 
262
#ifndef DONT_USE_MMU
 
263
#ifdef ENABLE_ICACHE
 
264
        mrc     p15,0,r0,c1,c0,0
 
265
        orr     r0,r0,#MMU_Control_I    /* enable instruction cache */
 
266
#ifdef ENABLE_DCACHE
 
267
        orr     r0,r0,#(MMU_Control_C)  /* enable data cache */
 
268
#endif /* ENABLE_DCACHE */
 
269
        mcr     p15,0,r0,c1,c0,0
 
270
        CPWAIT
 
271
#endif /* ENABLE_ICACHE */
 
272
#endif /* DONT_USE_MMU */
 
273
 
 
274
//      ; # switch to user mode, evtl. IRQs enabled
 
275
#ifdef USE_IRQ
 
276
#ifdef USE_SYSTEM_MODE
 
277
        mov     r0,#(CPSR_FIQ_DISABLE | CPSR_SYSTEM_MODE)
 
278
#else
 
279
        mov     r0,#(CPSR_FIQ_DISABLE | CPSR_USER_MODE)
 
280
#endif /* USE_SYSTEM_MODE */
 
281
#else
 
282
#ifdef USE_SYSTEM_MODE
 
283
        mov     r0,#(CPSR_IRQ_DISABLE | CPSR_FIQ_DISABLE | CPSR_SYSTEM_MODE)
 
284
#else
 
285
        mov     r0,#(CPSR_IRQ_DISABLE | CPSR_FIQ_DISABLE | CPSR_USER_MODE)
 
286
#endif /* USE_SYSTEM_MODE */
 
287
#endif /* USE_IRQ */
 
288
        msr     cpsr,r0
 
289
        ldr     sp,=__user_stack
 
290
 
 
291
#ifndef __NO_CTOR_DTOR_SUPPORT__
 
292
#ifdef __USES_INITFINI__
 
293
        /* Some arm/elf targets use the .init and .fini sections
 
294
           to create constructors and destructors, and for these
 
295
           targets we need to call the _init function and arrange
 
296
           for _fini to be called at program exit.  */
 
297
        ldr     r0,=_fini
 
298
        bl      atexit
 
299
        bl      _init
 
300
#endif /* __USES_INITFINI__ */
 
301
#endif /* !__NO_CTOR_DTOR_SUPPORT__ */
 
302
 
 
303
        mov     a1,#0           //; # set argc to 0
 
304
        mov     a2,#0           //; # and argv to NUL
 
305
        bl      main
 
306
#ifdef USE_HIMO
 
307
#ifdef USE_IRQ
 
308
        bl      IrqInit         //; # stop interrupts
 
309
        bl      RestoreHIMO     //; # restore HIMO environment
 
310
#endif /* USE_IRQ */
 
311
#endif /* USE_HIMO */
 
312
 
 
313
#ifdef __NO_CTOR_DTOR_SUPPORT__
 
314
        bl      _exit
 
315
#else
 
316
        mov     a1,#0
 
317
        bl      exit            //; # exit(0)
 
318
#endif /* __NO_CTOR_DTOR_SUPPORT__ */
 
319
 
 
320
 
 
321
 
 
322
//;
 
323
//; # Exception handlers
 
324
//; # Assumption: get here from a Supervisor context [mode]
 
325
//;
 
326
        .code   32
 
327
undefined_instruction:
 
328
        b       undefined_instruction
 
329
 
 
330
        .code   32
 
331
software_interrupt:
 
332
        b       software_interrupt
 
333
 
 
334
        .code   32
 
335
abort_prefetch:
 
336
        b       abort_prefetch
 
337
 
 
338
        .code   32
 
339
abort_data:
 
340
        b       abort_data
 
341
 
 
342
 
 
343
        .code   32
 
344
FIQ:
 
345
        b       FIQ
 
346
 
 
347
 
 
348
 
 
349
IRQ:
 
350
#ifdef USE_IRQ
 
351
        sub     lr,lr,#4                //; adjust return address before saving it
 
352
        str     lr,[sp,#-4]!
 
353
        mrs     lr,spsr                 //; and status bits
 
354
        stmfd   sp!,{r0-r3,r12,lr}      //; save APCS working register and SPSR
 
355
 
 
356
//      ; switch to another mode (to avoid  problem with C language handler code)
 
357
//      ; SVC mode if interrupted service else SYSTEM mode (interrupted task)
 
358
        mrs     r0,cpsr                 //; read the current status register
 
359
        bic     r0,r0,#CPSR_MODE_BITS   //; clear the mode bits
 
360
        and     lr,lr,#CPSR_MODE_BITS   //; extract the mode bits of interrupted state
 
361
        cmp     lr,#CPSR_SVC_MODE
 
362
        orreq   r0,r0,#CPSR_SVC_MODE    //; switch to SVC mode
 
363
        orrne   r0,r0,#CPSR_SYSTEM_MODE //; switch to SYSTEM mode
 
364
        msr     cpsr_cf,r0
 
365
        nop
 
366
 
 
367
        stmfd   sp!,{lr}                //; save original lr (lr_svc|lr)
 
368
 
 
369
        bl      IrqHandler
 
370
 
 
371
        ldmfd   sp!,{lr}                //; restore original lr (lr_svc|lr)
 
372
//      ; and switch back to IRQ mode
 
373
        mrs     r12,cpsr                //; read the status register
 
374
        bic     r12,r12,#CPSR_MODE_BITS //; clear the mode bits
 
375
        orr     r12,r12,#CPSR_IRQ_MODE  //; switch to IRQ mode
 
376
        msr     cpsr_cf,r12             //; write it back
 
377
        nop
 
378
 
 
379
        ldmfd   sp!,{r0-r3,r12,lr}      //; restore APCS working register and SPSR
 
380
        msr     spsr_cf,lr
 
381
        ldmfd   sp!,{pc}^               //; and return from interrupt and restore CPSR
 
382
#else
 
383
        b       IRQ
 
384
#endif /* USE_IRQ */
 
385
 
 
386
 
 
387
 
 
388
#if defined(USE_IRQ) && defined(USE_HIMO)
 
389
//; restore HIMO's original exception handler environment
 
390
 
 
391
        .global RestoreHIMO
 
392
RestoreHIMO:
 
393
        ldr     r0,=HIMO_IRQ_Address
 
394
        ldr     r0,[r0]
 
395
        ldr     r1,=IRQ_Location
 
396
        str     r0,[r1]
 
397
 
 
398
//; restore HIMO's SWI handler if it's a PXROS application
 
399
        ldr     r0,=PxPrepareInit
 
400
        cmp     r0,#0
 
401
        moveq   pc,lr
 
402
 
 
403
        ldr     r0,=oldSWIHandler
 
404
        ldr     r0,[r0]
 
405
        ldr     r1,=SWI_Location
 
406
        str     r0,[r1]
 
407
 
 
408
        mov     pc,lr
 
409
#endif /* USE_IRQ && USE_HIMO */
 
410
 
 
411
 
 
412
 
 
413
 
 
414
//; # -------------------------------------------------------------------------
 
415
//; # data section used by startup code
 
416
 
 
417
        .data
 
418
 
 
419
//; # -------------------------------------------------------------------------
 
420
//; # Temporary interrupt stack
 
421
 
 
422
        .section ".bss"
 
423
 
 
424
#if defined(USE_IRQ) && defined(USE_HIMO)
 
425
HIMO_IRQ_Address:
 
426
        .long   0
 
427
#endif /* USE_IRQ && USE_HIMO */
 
428
 
 
429
        .global __interrupt_stack
 
430
        .global __startup_stack
 
431
        .global _PxSysstackend
 
432
 
 
433
//; # Small stacks, only used for saving information between CPU modes
 
434
__exception_stack_base:
 
435
        .rept   32
 
436
        .long   0
 
437
        .endr
 
438
__FIQ_exception_stack:
 
439
        .rept   32
 
440
        .long   0
 
441
        .endr
 
442
__exception_stack:
 
443
 
 
444
//; # Runtime stack used during all IRQ interrupt processing
 
445
#ifndef IRQ_STACK_SIZE
 
446
#ifdef USE_IRQ
 
447
#define IRQ_STACK_SIZE          2048
 
448
#else
 
449
#define IRQ_STACK_SIZE          16*4
 
450
#endif /* USE_IRQ */
 
451
#endif /* IRQ_STACK_SIZE */
 
452
 
 
453
        .balign 16
 
454
__interrupt_stack_base:
 
455
        .rept   IRQ_STACK_SIZE
 
456
        .byte   0
 
457
        .endr
 
458
        .balign 16
 
459
__interrupt_stack:
 
460
//; # the following 2 words are used for PXROS taskret storage
 
461
        .long   0
 
462
        .long   0
 
463
 
 
464
#ifndef STARTUP_STACK_SIZE
 
465
#define STARTUP_STACK_SIZE      2048
 
466
#endif /* STARTUP_STACK_SIZE */
 
467
 
 
468
        .balign 16
 
469
_PxSysstackend:
 
470
__startup_stack_base:
 
471
        .rept   STARTUP_STACK_SIZE
 
472
        .byte   0
 
473
        .endr
 
474
        .balign 16
 
475
__startup_stack:
 
476
 
 
477
#ifndef USER_STACK_SIZE
 
478
#define USER_STACK_SIZE         2048
 
479
#endif /* USER_STACK_SIZE */
 
480
 
 
481
        .balign 16
 
482
__user_stack_base:
 
483
        .rept   USER_STACK_SIZE
 
484
        .byte   0
 
485
        .endr
 
486
        .balign 16
 
487
__user_stack:
 
488
 
 
489
 
 
490
//; # --------------------------------------------------------------------------
 
491
//; #  end of vectors.S