source: rtems/c/src/lib/libbsp/powerpc/score603e/start/start.S @ c3b76087

4.104.114.84.95
Last change on this file since c3b76087 was c3b76087, checked in by Joel Sherrill <joel.sherrill@…>, on 07/12/00 at 13:44:27

Added comment.

  • Property mode set to 100644
File size: 4.5 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/score/targopts.h> /* for SCORE603E_GENERATION */
21#include "ppc-asm.h"
22
23        .file   "start.s"
24        .section ".got2","aw"
25        .align  2
26
27.LCTOC1 = .+32768
28
29        .extern FUNC_NAME(atexit)
30        .globl  FUNC_NAME(__atexit)
31        .section ".sdata","aw"
32        .align  2
33FUNC_NAME(__atexit):                    /* tell C's eabi-ctor's we have an atexit function */
34        .long   FUNC_NAME(atexit)@fixup /* and that it is to register __do_global_dtors */
35
36        .section ".fixup","aw"
37        .align  2
38        .long   FUNC_NAME(__atexit)
39
40        .section ".got2","aw"
41.Ltable = .-.LCTOC1
42        .long   .LCTOC1                 /* address we think .LCTOC1 is loaded at */
43
44.Lbss_start = .-.LCTOC1
45        .long   _edata                 /* includes sbss and bss */
46
47.Lend = .-.LCTOC1
48        .long   _end
49
50.Lstack = .-.LCTOC1                     /* stack address if set by user */
51        .long   __stack
52
53        .text
54.Lptr:
55        .long .LCTOC1-.Laddr
56
57        .globl  _start
58        .type   _start,@function
59_start:
60        b       past_constants
61                                        /* Set MSR */
62        .long   _etext                  /* end of code space */
63        .long   _edata                  /* end of code and data space */
64
65past_constants:
66        lis     r5,0
67        mr      r4,r5
68        ori     r4,r4,0x0000            /* 0x2030  */
69        mtmsr   r4
70       
71#if (SCORE603E_GENERATION == 1)
72        lis     r4,0
73        mtspr   530,r4                  /* Set IBAT1U */
74        mtspr   531,r4                  /* Set IBAT1L */
75        mtspr   534,r4                  /* Set IBAT3U */
76        mtspr   535,r4                  /* Set IBAT3L */
77        mtspr   538,r4                  /* Set DBAT1U */
78        mtspr   539,r4                  /* Set DBAT1L */
79        lis     r4,0
80        ori     r4,r4,0x1fff
81        mtspr   528,r4                  /* Set IBAT0U */
82        mtspr   536,r4                  /* Set DBAT0U */
83        lis     r4,0
84        ori     r4,r4,0x0002   
85        mtspr   529,r4                  /* Set IBAT0L */
86        mtspr   537,r4                  /* Set DBAT0L */
87        lis     r4,-4096                /*  0xf000    */
88        ori     r4,r4,8191              /*  0x1fff    */
89        mtspr   532,r4                  /* Set IBAT2U */
90        mtspr   540,r4                  /* Set DBAT2U */
91        lis     r4,-4096                /*  0xf000    */
92        ori     r4,r4,1
93        mtspr   533,r4                  /* Set IBAT2L */
94        mtspr   541,r4                  /* Set DBAT2L */
95        lis     r4,-32768               /*  0x8000    */
96        ori     r4,r4,8191              /*  0x1fff    */
97        mtspr   542,r4                  /* Set DBAT3U */
98        lis     r4,-32768               /*  0x8000    */
99        ori     r4,r4,0x003a
100        mtspr   543,r4                  /* Set DBAT3L */
101
102#elif (SCORE603E_GENERATION == 2)
103/* XXX FILL THIS IN WHEN I GET HELLO TO COME UP. */
104       
105#else
106#error "Unknown Generation of  Score603e"
107#endif
108
109        bl      .Laddr                  /* get current address */
110.Laddr:
111        mflr    r4                      /* real address of .Laddr */
112        lwz     r5,(.Lptr-.Laddr)(r4)   /* linker generated address of .LCTOC1 */
113        add     r5,r5,r4                /* correct to real pointer */
114        lwz     r4,.Ltable(r5)          /* get linker's idea of where .Laddr is */
115        subf    r4,r4,r5                /* calculate difference between where linked and current */
116
117        /* clear bss */
118        lwz     r6,.Lbss_start(r5)      /* calculate beginning of the BSS */
119        lwz     r7,.Lend(r5)            /* calculate end of the BSS */
120        add     r6,r6,r4                /* adjust pointers */
121        add     r7,r7,r4
122
123        cmplw   1,r6,r7
124        bc      4,4,.Ldone
125
126        subf    r8,r6,r7                /* number of bytes to zero */
127        srwi    r9,r8,2                 /* number of words to zero */
128        mtctr   r9
129        li      r0,0                    /* zero to clear memory */
130        addi    r6,r6,-4                /* adjust so we can use stwu */
131.Lloop:
132        stwu    r0,4(r6)                /* zero bss */
133        bdnz    .Lloop
134
135.Ldone:
136
137        lwz     r0,.Lstack(r5)          /* stack address or 0 */
138        cmplwi  1,r0,0                  /* equal to 0? */
139        bc      12,6,.Lnostack          /* use default stack if == 0 */
140        mr      sp,r0                   /* use user defined stack */
141
142.Lnostack:
143        /* set up initial stack frame */
144        addi    sp,sp,-4                /* make sure we don't overwrite debug mem */
145        lis     r0,0
146        stw     r0,0(sp)                /* clear back chain */
147        stwu    sp,-56(sp)              /* push another stack frame */
148
149        /* Let her rip */
150        bl      FUNC_NAME(boot_card)
151
152        /* return value from boot_card is argument to exit */
153        bl      FUNC_NAME(exit)
154        trap
155.Lstart:
156        .size   _start,.Lstart-_start
Note: See TracBrowser for help on using the repository browser.