source: rtems/c/src/lib/libbsp/powerpc/psim/start/start.S @ 561f53b

Last change on this file since 561f53b was 561f53b, checked in by Jennifer Averett <Jennifer.Averett@…>, on 11/22/04 at 22:30:59

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

PR 581/bsps

  • Makefile.am, bsp_specs, configure.ac, clock/Makefile.am, include/bsp.h, start/Makefile.am, start/start.S, startup/Makefile.am, startup/bspstart.c, startup/linkcmds, vectors/Makefile.am, vectors/vectors.S, wrapup/Makefile.am: Convert PSIM to new exception model.
  • irq/Makefile.am, irq/irq.c, irq/irq.h, irq/irq_asm.S, irq/irq_init.c: New files.
  • clock/clock.c: Removed.
  • Property mode set to 100644
File size: 3.2 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 <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        bl      __eabi  /* setup EABI and SYSV environment */
76        /* clear bss */
77        lwz     r6,.Lbss_start(r5)      /* calculate beginning of the BSS */
78        lwz     r7,.Lend(r5)            /* calculate end of the BSS */
79        add     r6,r6,r4                /* adjust pointers */
80        add     r7,r7,r4
81
82        cmplw   1,r6,r7
83        bc      4,4,.Ldone
84
85        subf    r8,r6,r7                /* number of bytes to zero */
86        srwi    r9,r8,2                 /* number of words to zero */
87        mtctr   r9
88        li      r0,0                    /* zero to clear memory */
89        addi    r6,r6,-4                /* adjust so we can use stwu */
90.Lloop:
91        stwu    r0,4(r6)                /* zero bss */
92        bdnz    .Lloop
93
94.Ldone:
95
96        lwz     r0,.Lstack(r5)          /* stack address or 0 */
97        cmplwi  1,r0,0                  /* equal to 0? */
98        bc      12,6,.Lnostack          /* use default stack if == 0 */
99        mr      sp,r0                   /* use user defined stack */
100
101.Lnostack:
102        /* set up initial stack frame */
103        addi    sp,sp,-4                /* make sure we don't overwrite debug mem */
104        lis     r0,0
105        stw     r0,0(sp)                /* clear back chain */
106        stwu    sp,-56(sp)              /* push another stack frame */
107
108        lis     r5,environ@ha
109        la      r5,environ@l(r5)        /* environp */
110        li      r4, 0                   /* argv */
111        li      r3, 0                   /* argc */
112
113        /* Let her rip */
114        bl      FUNC_NAME(boot_card)
115
116        /* return value from boot_card is argument to exit */
117        bl      FUNC_NAME(exit)
118        trap
119.Lstart:
120        .size   _start,.Lstart-_start
121
122        .comm   environ,4,4
123
Note: See TracBrowser for help on using the repository browser.