source: rtems/c/src/lib/libbsp/powerpc/psim/start/start.S @ 270ce1ff

4.104.114.84.95
Last change on this file since 270ce1ff was 270ce1ff, checked in by Jennifer Averett <Jennifer.Averett@…>, on 11/22/04 at 22:13:35

2004-11-22 Jennifer Averett <jennifer@…>

PR 581/bsps

  • Makefile.am, bsp_specs, configure.ac, include/bsp.h, include/tm27.h, start/start.S, startup/bspstart.c, startup/linkcmds, tools/Makefile.am, tools/psim, vectors/vectors.S, wrapup/Makefile.am: Convert PSIM to new exception model.
  • irq/irq.c, irq/irq.h, irq/irq_asm.S, irq/irq_init.c: New files.
  • startup/setvec.c, timer/timer.c: Removed.
  • Property mode set to 100644
File size: 3.1 KB
Line 
1/*
2 * This is based on the mvme-crt0.S file from libgloss/rs6000.
3 * crt0.S -- startup file for PowerPC systems.
4 *
5 * Copyright (c) 1995 Cygnus Support
6 *
7 * The authors hereby grant permission to use, copy, modify, distribute,
8 * and license this software and its documentation for any purpose, provided
9 * that existing copyright notices are retained in all copies and that this
10 * notice is included verbatim in any distributions. No written agreement,
11 * license, or royalty fee is required for any of the authorized uses.
12 * Modifications to this software may be copyrighted by their authors
13 * and need not follow the licensing terms described here, provided that
14 * the new terms are clearly indicated on the first page of each file where
15 * they apply.
16 *
17 *  $Id$
18 */
19
20#include <rtems/asm.h>
21#include <rtems/score/cpu.h>
22#include <libcpu/io.h>
23#include "ppc-asm.h"
24
25        .file   "startsim.s"
26        .section ".got2","aw"
27        .align  2
28
29.LCTOC1 = .+32768
30
31        .extern FUNC_NAME(atexit)
32        .globl  FUNC_NAME(__atexit)
33        .section ".sdata","aw"
34        .align  2
35FUNC_NAME(__atexit):                    /* tell C's eabi-ctor's we have an atexit function */
36        .long   FUNC_NAME(atexit)@fixup /* and that it is to register __do_global_dtors */
37
38        .section ".fixup","aw"
39        .align  2
40        .long   FUNC_NAME(__atexit)
41
42        .section ".got2","aw"
43.Ltable = .-.LCTOC1
44        .long   .LCTOC1                 /* address we think .LCTOC1 is loaded at */
45
46.Lbss_start = .-.LCTOC1
47        .long   __bss_start
48
49.Lend = .-.LCTOC1
50        .long   _end
51
52.Lstack = .-.LCTOC1                     /* stack address if set by user */
53        .long   __stack
54
55        .text
56.Lptr:
57        .long .LCTOC1-.Laddr
58
59        .globl  __rtems_entry_point
60        .type   __rtems_entry_point,@function
61__rtems_entry_point:
62#if 1
63        .globl  _start
64        .type   _start,@function
65_start:
66#endif
67        bl      .Laddr                  /* get current address */
68.Laddr:
69        mflr    r4                      /* real address of .Laddr */
70        lwz     r5,(.Lptr-.Laddr)(r4)   /* linker generated address of .LCTOC1 */
71        add     r5,r5,r4                /* correct to real pointer */
72        lwz     r4,.Ltable(r5)          /* get linker's idea of where .Laddr is */
73        subf    r4,r4,r5                /* calculate difference between where linked and current */
74
75        /* clear bss */
76        lwz     r6,.Lbss_start(r5)      /* calculate beginning of the BSS */
77        lwz     r7,.Lend(r5)            /* calculate end of the BSS */
78        add     r6,r6,r4                /* adjust pointers */
79        add     r7,r7,r4
80
81        cmplw   1,r6,r7
82        bc      4,4,.Ldone
83
84        subf    r8,r6,r7                /* number of bytes to zero */
85        srwi    r9,r8,2                 /* number of words to zero */
86        mtctr   r9
87        li      r0,0                    /* zero to clear memory */
88        addi    r6,r6,-4                /* adjust so we can use stwu */
89.Lloop:
90        stwu    r0,4(r6)                /* zero bss */
91        bdnz    .Lloop
92
93.Ldone:
94
95        lwz     r0,.Lstack(r5)          /* stack address or 0 */
96        cmplwi  1,r0,0                  /* equal to 0? */
97        bc      12,6,.Lnostack          /* use default stack if == 0 */
98        mr      sp,r0                   /* use user defined stack */
99
100.Lnostack:
101        /* set up initial stack frame */
102        addi    sp,sp,-4                /* make sure we don't overwrite debug mem */
103        lis     r0,0
104        stw     r0,0(sp)                /* clear back chain */
105        stwu    sp,-56(sp)              /* push another stack frame */
106
107        lis     r5,environ@ha
108        la      r5,environ@l(r5)        /* environp */
109        li      r4, 0                   /* argv */
110        li      r3, 0                   /* argc */
111
112        /* Let her rip */
113        bl      FUNC_NAME(boot_card)
114
115        /* return value from boot_card is argument to exit */
116        bl      FUNC_NAME(exit)
117        trap
118.Lstart:
119        .size   _start,.Lstart-_start
Note: See TracBrowser for help on using the repository browser.