Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Oct 11th, 2011  |  syntax: None  |  size: 1.93 KB  |  views: 42  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #include "config.h"
  2. #include "cpu.h"
  3. #include "crt0-common.S"
  4.  
  5. /* implement vectors, specify section and reset address */
  6. RBIMPL_VECTORS .vectors, start
  7.  
  8. /* When starting, we will be running at 0x40000000 most probably
  9.  * but the code is expected to be loaded at 0x4xxxxxxx (uncached) and to be
  10.  * running at virtual address 0xyyyyyyyy (cached). So we first
  11.  * need to move everything to the right locationn then we setup the mmu and
  12.  * jump to the final virtual address. */
  13. .text
  14. .global start
  15.     /** The code below must be able to run at any address **/
  16. start:
  17.     /* Copy running address */
  18.     sub     r7, pc, #8
  19.     /* Save r0 */
  20.     mov     r6, r0
  21.  
  22.     RBIMPL_START_BEGIN
  23.     /* Disable MMU, disable caching and buffering;
  24.      * use low exception range address (the core uses high range by default) */
  25.     mrc     p15, 0, r0, c1, c0, 0
  26.     ldr     r1, =0x3005
  27.     bic     r0, r1
  28.     mcr     p15, 0, r0, c1, c0, 0
  29.  
  30.     /* To call the C code we need a stack, since the stack is in virtual memory
  31.      * use the stack's physical address */
  32.     ldr     sp, =stackend_phys
  33.  
  34.     /* Enable MMU */
  35.     bl      memory_init
  36.  
  37.     /* Copy the DRAM
  38.      * Assume the dram binary blob is located at the loading address (r5) */
  39.     mov    r2, r7
  40.     ldr    r3, =_dramcopystart
  41.     ldr    r4, =_dramcopyend
  42. 1:
  43.     cmp     r4, r3
  44.     ldrhi   r5, [r2], #4
  45.     strhi   r5, [r3], #4
  46.     bhi     1b
  47.  
  48.     mov     r2, #0
  49.     mcr     p15, 0, r2, c7, c5, 0   @ Invalidate ICache
  50.    
  51.     /* Jump to real location */
  52.     ldr     pc, =remap
  53. remap:
  54.     RBIMPL_DO_STD_COPY _iedata, _iend, _iramcopy, _iramstart, _iramend, _initcopy, _initstart, _initend, _edata, _end
  55.  
  56.     RBIMPL_INIT_STACKS stackend, stackbegin, iriq_stack, fiq_stack
  57.     RBIMPL_START_END
  58.  
  59.     /* Jump to main */
  60.     mov     r0, r6
  61.     mov     r1, r7
  62.     bl      main
  63. 1:
  64.     b       1b
  65.  
  66. RBIMPL_STD_HANDLERS
  67.  
  68. RBIMPL_IRQ_FIQ_STACKS irq_stack, fiq_stack
  69.  
  70. end:
  71.  
  72.  
clone this paste RAW Paste Data