Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:23:57

0001 /*
0002  * This is based on the mvme-crt0.S file from libgloss/rs6000.
0003  * crt0.S -- startup file for PowerPC systems.
0004  *
0005  * Copyright (c) 1995 Cygnus Support
0006  *
0007  * The authors hereby grant permission to use, copy, modify, distribute,
0008  * and license this software and its documentation for any purpose, provided
0009  * that existing copyright notices are retained in all copies and that this
0010  * notice is included verbatim in any distributions. No written agreement,
0011  * license, or royalty fee is required for any of the authorized uses.
0012  * Modifications to this software may be copyrighted by their authors
0013  * and need not follow the licensing terms described here, provided that
0014  * the new terms are clearly indicated on the first page of each file where
0015  * they apply.
0016  */
0017 
0018 #include <rtems/asm.h>
0019 #include <rtems/score/cpu.h>
0020 #include <libcpu/io.h>
0021 #include "ppc-asm.h"
0022 
0023     .section ".got2","aw"
0024     .align  2
0025 
0026 .LCTOC1 = .+32768
0027 
0028     .section ".got2","aw"
0029 .Ltable = .-.LCTOC1
0030     .long   .LCTOC1         /* address we think .LCTOC1 is loaded at */
0031 
0032 .Lbss_start = .-.LCTOC1
0033     .long   bsp_section_sbss_begin
0034 
0035 .Lend = .-.LCTOC1
0036     .long   bsp_section_bss_end
0037 
0038 .Lstack = .-.LCTOC1         /* stack address if set by user */
0039     .long   _ISR_Stack_area_end
0040 
0041     .text
0042 .Lptr:
0043     .long .LCTOC1-.Laddr
0044 
0045     .globl  __rtems_entry_point
0046     .type   __rtems_entry_point,@function
0047 __rtems_entry_point:
0048 #if 1
0049     .globl  _start
0050     .type   _start,@function
0051 _start:
0052 #endif
0053     bl  .Laddr          /* get current address */
0054 .Laddr:
0055     mflr    r4          /* real address of .Laddr */
0056     lwz r5,(.Lptr-.Laddr)(r4)   /* linker generated address of .LCTOC1 */
0057     add r5,r5,r4        /* correct to real pointer */
0058     lwz r4,.Ltable(r5)      /* get linker's idea of where .Laddr is */
0059     subf    r4,r4,r5        /* calculate difference between where linked and current */
0060 
0061     /* clear bss */
0062     lwz r6,.Lbss_start(r5)  /* calculate beginning of the BSS */
0063     lwz r7,.Lend(r5)        /* calculate end of the BSS */
0064     add r6,r6,r4        /* adjust pointers */
0065     add r7,r7,r4
0066 
0067     cmplw   1,r6,r7
0068     bc  4,4,.Ldone
0069 
0070     subf    r8,r6,r7        /* number of bytes to zero */
0071     srwi    r9,r8,2         /* number of words to zero */
0072     mtctr   r9
0073     li  r0,0            /* zero to clear memory */
0074     addi    r6,r6,-4        /* adjust so we can use stwu */
0075 .Lloop:
0076     stwu    r0,4(r6)        /* zero bss */
0077     bdnz    .Lloop
0078 
0079 .Ldone:
0080 
0081     lwz r0,.Lstack(r5)  /* stack area or 0 */
0082     cmplwi  1,r0,0          /* equal to 0? */
0083     bc  12,6,.Lnostack      /* use default stack if == 0 */
0084     mr  sp,r0           /* use user defined stack */
0085 
0086 .Lnostack:
0087 #ifdef __ALTIVEC__
0088     /* enable altivec; this requires the ALTIVEC user
0089      * extension to be installed in the user extension
0090      * slot 0!
0091      */
0092     mfmsr r0
0093     oris  r0, r0, (1<<(31-16-6))
0094     mtmsr r0
0095     isync
0096     /*
0097      * set vscr and vrsave to known values
0098      */
0099     li    r0, 0
0100     mtvrsave r0
0101     vxor   0,0,0
0102     mtvscr 0
0103 #endif
0104     /* set up initial stack frame */
0105     addi    sp,sp,-4        /* make sure we don't overwrite debug mem */
0106     /* align */
0107     li  r3, CPU_STACK_ALIGNMENT-1
0108     andc    sp, sp, r3
0109     lis r0,0
0110     stw r0,0(sp)        /* clear back chain */
0111     stwu    sp,-CPU_STACK_ALIGNMENT(sp)     /* push another stack frame */
0112     bl  FUNC_NAME(__eabi)
0113 
0114     /* Let her rip */
0115     li  r3, 0           /* command line */
0116     bl  FUNC_NAME(boot_card)
0117 
0118        .globl  FUNC_NAME(bsp_reset)
0119 FUNC_NAME(bsp_reset):
0120     li  10,99           /* 0x63 */
0121     sc
0122 
0123 .Lstart:
0124     .size   _start,.Lstart-_start