Advertisement
Guest User

Untitled

a guest
Mar 2nd, 2010
254
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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"
  23.  
  24.     .section .init.text,"ax",%progbits
  25.  
  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]
  37.  
  38. #if CONFIG_CPU==S5L8700
  39.     .word 0x43554644 /* DFUC */
  40. #else
  41.     .word 0xdeadbeef /* to keep the same PC offsets */
  42. #endif
  43.  
  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
  52.  
  53. _vectorsend:
  54.  
  55.     .text
  56.  
  57. newstart:
  58.     msr     cpsr_c, #0xd3 /* enter supervisor mode, disable IRQ/FIQ */
  59.  
  60. #if (CONFIG_CPU==AS3525 || CONFIG_CPU==AS3525v2) && !defined(BOOTLOADER)
  61.     /* Setup MMU : has to be done before accessing IRAM ! */
  62.     bl      memory_init
  63.  
  64.     /* Zero out IBSS */
  65.     ldr     r2, =_iedata
  66.     ldr     r3, =_iend
  67.     mov     r4, #0
  68. 1:
  69.     cmp     r3, r2
  70.     strhi   r4, [r2], #4
  71.     bhi     1b
  72.  
  73.     /* Copy the IRAM */
  74.     /* must be done before bss is zeroed */
  75.     ldr     r2, =_iramcopy
  76.     ldr     r3, =_iramstart
  77.     ldr     r4, =_iramend
  78. 1:
  79.     cmp     r4, r3
  80.     ldrhi   r5, [r2], #4
  81.     strhi   r5, [r3], #4
  82.     bhi     1b
  83.  
  84. #endif
  85.  
  86. #ifdef INIT_DATA
  87.     /* copy init data to codec buffer */
  88.     /* must be done before bss is zeroed */
  89.     ldr    r2, =_initcopy
  90.     ldr    r3, =_initstart
  91.     ldr    r4, =_initend
  92. 1:
  93.     cmp     r4, r3
  94.     ldrhi   r5, [r2], #4
  95.     strhi   r5, [r3], #4
  96.     bhi     1b
  97.  
  98.     mov     r2, #0
  99.     mcr     p15, 0, r2, c7, c5, 0   @ Invalidate ICache
  100. #endif
  101.  
  102.     /* Initialise bss section to zero */
  103.     ldr     r2, =_edata
  104.     ldr     r3, =_end
  105.     mov     r4, #0
  106. 1:
  107.     cmp     r3, r2
  108.     strhi   r4, [r2], #4
  109.     bhi     1b
  110.    
  111.     /* Set up some stack and munge it with 0xdeadbeef */
  112.     ldr     sp, =stackend
  113.     ldr     r2, =stackbegin
  114.     ldr     r3, =0xdeadbeef
  115. 1:
  116.     cmp     sp, r2
  117.     strhi   r3, [r2], #4
  118.     bhi     1b
  119.    
  120.     /* Set up stack for IRQ mode */
  121.     msr     cpsr_c, #0xd2
  122.     ldr     sp, =irq_stack
  123.  
  124.     /* Set up stack for FIQ mode */
  125.     msr     cpsr_c, #0xd1
  126.     ldr     sp, =fiq_stack
  127.  
  128.     /* Let abort and undefined modes use IRQ stack */
  129.     msr     cpsr_c, #0xd7
  130.     ldr     sp, =irq_stack
  131.     msr     cpsr_c, #0xdb
  132.     ldr     sp, =irq_stack
  133.  
  134.     /* Switch back to supervisor mode */
  135.     msr     cpsr_c, #0xd3
  136.  
  137.     bl      main
  138.  
  139.  
  140. /* All illegal exceptions call into UIE with exception address as first
  141.  * parameter. This is calculated differently depending on which exception
  142.  * we're in. Second parameter is exception number, used for a string lookup
  143. * in UIE. */
  144. undef_instr_handler:
  145.    sub    r0, lr, #4
  146.    mov    r1, #0
  147.    b      UIE
  148.  
  149. /* We run supervisor mode most of the time, and should never see a software
  150. * exception being thrown. Perhaps make it illegal and call UIE? */
  151. software_int_handler:
  152. reserved_handler:
  153.    movs   pc, lr
  154.  
  155. prefetch_abort_handler:
  156.    sub    r0, lr, #4
  157.    mov    r1, #1
  158.    b      UIE
  159.  
  160. data_abort_handler:
  161.    sub    r0, lr, #8
  162.    mov    r1, #2
  163.    b      UIE
  164.  
  165. /* 256 words of IRQ stack */
  166.    .space 256*4
  167. irq_stack:
  168.  
  169. /* 256 words of FIQ stack */
  170.    .space 256*4
  171. fiq_stack:
  172.  
  173. end:
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement