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

4.104.114.84.95
Last change on this file since 9c448e1 was 9c448e1, checked in by Joel Sherrill <joel.sherrill@…>, on 02/19/99 at 00:22:33

BSP for Vista Score603e added.

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