Part of Slepp's ProjectsPastebinTURLImagebinFilebin
Feedback -- English French German Japanese
Create Upload Newest Tools Donate
Sign In | Create Account

Anonymous
Tuesday, November 28th, 2006 at 10:07:41pm UTC 

  1. /***************************************************************************
  2.  *             __________               __   ___.
  3.  *   Open      \______   \ ____   ____ |  | _\_ |__   _______  ___
  4.  *   Source     |       _//  _ \_/ ___\|  |/ /| __ \ /  _ \  \/  /
  5.  *   Jukebox    |    |   (  <_> )  \___|    < | \_\ (  <_> > <  <
  6.  *   Firmware   |____|_  /\____/ \___  >__|_ \|___  /\____/__/\_ \
  7.  *                     \/            \/     \/    \/            \/
  8.  * $Id: crt0-pp.S,v 1.2 2006-11-22 00:49:16 dan_a Exp $
  9.  *
  10.  * Copyright (C) 2002 by Linus Nielsen Feltzing
  11.  *
  12.  * All files in this archive are subject to the GNU General Public License.
  13.  * See the file COPYING in the source tree root for full license agreement.
  14.  *
  15.  * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
  16.  * KIND, either express or implied.
  17.  *
  18.  ****************************************************************************/
  19. #include "config.h"
  20. #include "cpu.h"
  21.  
  22.     .section .init.text,"ax",%progbits
  23.  
  24.     .global    start
  25. start:
  26.  
  27. /* PortalPlayer bootloader and startup code based on startup.s from the iPodLinux
  28.  * loader
  29.  *
  30.  * Copyright (c) 2003, Daniel Palffy (dpalffy (at) rainstorm.org)
  31.  * Copyright (c) 2005, Bernard Leach <[email protected]>
  32.  *
  33.  */
  34. #if CONFIG_CPU == PP5002
  35.     .equ    PROC_ID,  0xc4000000
  36.     .equ    COP_CTRL, 0xcf004058
  37.     .equ    COP_STATUS, 0xcf004050
  38.     .equ    IIS_CONFIG, 0xc0002500
  39.     .equ    SLEEP,    0xca
  40.     .equ    WAKE,     0xce
  41.     .equ    SLEEPING, 0x4000
  42. #else
  43.     .equ    PROC_ID,  0x60000000
  44.     .equ    COP_CTRL, 0x60007004
  45.     .equ    COP_STATUS, 0x60007004
  46.     .equ    IIS_CONFIG, 0x70002800
  47.     .equ    SLEEP,    0x80000000
  48.     .equ    WAKE,     0x0
  49.     .equ    SLEEPING, 0x80000000
  50.     .equ    CACHE_CTRL, 0x6000c000
  51. #endif
  52.  
  53.     msr    cpsr_c, #0xd3 /* enter supervisor mode, disable IRQ */
  54.  
  55. /* 1 - Copy the bootloader to IRAM */
  56.     /* get the high part of our execute address */
  57.     ldr    r2, =0xffffff00
  58.     and    r4, pc, r2
  59.  
  60.     /* Copy bootloader to safe area - 0x40000000 */
  61.     mov    r5, #0x40000000
  62.     ldr    r6, = _dataend
  63.     sub    r0, r6, r5       /* length of loader */
  64.     add    r8, r4, r0       /* r8 points to start of loader */
  65. 1:
  66.     cmp    r5, r6
  67.     ldrcc  r2, [r4], #4
  68.     strcc  r2, [r5], #4
  69.     bcc    1b
  70.  
  71. /* 2 - Jump both CPU and COP there */
  72.     ldr    pc, =start_loc    /* jump to the relocated start_loc:  */
  73.    
  74. start_loc:
  75.  
  76.     /* Find out which processor we are */
  77.     mov    r0, #PROC_ID
  78.     ldr    r0, [r0]
  79.     and    r0, r0, #0xff
  80.     cmp    r0, #0x55
  81.     beq    cpu
  82.  
  83.     /* put us (co-processor) to sleep */
  84.     ldr    r4, =COP_CTRL
  85.     mov    r3, #SLEEP
  86.     str    r3, [r4]
  87.     ldr    pc, =cop_wake_start
  88.  
  89. cop_wake_start:
  90.     /* COP: Invalidate cache */
  91.     ldr    r0, =0xf000f044
  92.     ldr    r1, [r0]
  93.     orr    r1, r1, #0x6
  94.     str    r1, [r0]
  95.  
  96.  
  97.     ldr    r0, =0x6000c000
  98. 1:
  99.     ldr    r1, [r0]
  100.     tst    r1, #0x8000
  101.     bne    1b
  102.  
  103.     ldr    r0, =startup_loc
  104.     ldr    pc, [r0]
  105.  
  106. cpu:
  107.     /* Wait for COP to be sleeping */
  108.     ldr    r4, =COP_STATUS
  109. 1:
  110.     ldr    r3, [r4]
  111.     ands   r3, r3, #SLEEPING
  112.     beq    1b
  113.  
  114.     /* Initialise bss section to zero */
  115.     ldr    r2, =_edata
  116.     ldr    r3, =_end
  117.     mov    r4, #0
  118. 1:
  119.     cmp    r3, r2
  120.     strhi  r4, [r2], #4
  121.     bhi    1b
  122.    
  123.     /* Set up some stack and munge it with 0xdeadbeef */
  124.     ldr    sp, =stackend
  125.     mov    r3, sp
  126.     ldr    r2, =stackbegin
  127.     ldr    r4, =0xdeadbeef
  128. 1:
  129.     cmp    r3, r2
  130.     strhi  r4, [r2], #4
  131.     bhi    1b
  132.  
  133.     mov    r0, r8 /* r8 holds the start of the loader - copy this to r0 */
  134.  
  135.     /* execute the loader - this will load an image to 0x10000000 */
  136.     bl     main
  137.  
  138.     ldr    r1, =startup_loc
  139.     str    r0, [r1]
  140.    
  141.     /* Flush cache */
  142.     ldr    r3, =0xf000f044
  143.     ldr    r4, [r3]
  144.     orr    r4, r4, #0x2
  145.     str    r4, [r3]
  146.  
  147.     ldr    r3, =0x6000c000
  148. 1:
  149.     ldr    r4, [r3]
  150.     tst    r4, #0x8000
  151.     bne    1b
  152.  
  153.     /* Wake up the coprocessor before executing the firmware */
  154.     ldr    r4, =COP_CTRL
  155.     mov    r3, #WAKE
  156.     str    r3, [r4]
  157.  
  158.     mov    pc, r0
  159.  
  160. startup_loc:
  161.     .word    0x0
  162.  
  163. .align 8    /* starts at 0x100 */
  164. .global boot_table
  165. boot_table:
  166.     /* here comes the boot table, don't move its offset */
  167.     .space 400

Update the Post

Either update this post and resubmit it with changes, or make a new post.

You may also comment on this post.

update paste below
details of the post (optional)

Note: Only the paste content is required, though the following information can be useful to others.

Save name / title?

(space separated, optional)



Please note that information posted here will expire by default in one month. If you do not want it to expire, please set the expiry time above. If it is set to expire, web search engines will not be allowed to index it prior to it expiring. Items that are not marked to expire will be indexable by search engines. Be careful with your passwords. All illegal activities will be reported and any information will be handed over to the authorities, so be good.

comments powered by Disqus