source: rtems/c/src/lib/libbsp/powerpc/ppcn_60x/start/start.S @ d16ca93

4.104.114.84.95
Last change on this file since d16ca93 was 15c48f4c, checked in by Joel Sherrill <joel.sherrill@…>, on 08/02/00 at 16:30:57

Properly pass argc, argc, and environp to boot_card.

  • Property mode set to 100644
File size: 3.7 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 * (c) 1998, Radstone Technology plc.
6 *
7 *
8 * This is an unpublished work the copyright  in  which   vests
9 * in  Radstone Technology plc.  All rights reserved.
10 *
11 * The information contained herein is the property of Radstone
12 * Technology  plc.  and  is  supplied  without  liability  for
13 * errors or omissions and no part may be reproduced,  used  or
14 * disclosed except as authorized by contract or  other written
15 * permission.     The    copyright    and    the     foregoing
16 * restriction   on  reproduction, use and disclosure extend to
17 * all  the   media   in   which   this  information   may   be
18 * embodied.
19 *
20 * Copyright (c) 1995 Cygnus Support
21 *
22 * The authors hereby grant permission to use, copy, modify, distribute,
23 * and license this software and its documentation for any purpose, provided
24 * that existing copyright notices are retained in all copies and that this
25 * notice is included verbatim in any distributions. No written agreement,
26 * license, or royalty fee is required for any of the authorized uses.
27 * Modifications to this software may be copyrighted by their authors
28 * and need not follow the licensing terms described here, provided that
29 * the new terms are clearly indicated on the first page of each file where
30 * they apply.
31 *
32 *  $Id$
33 */
34
35#include <rtems/score/targopts.h> /* for PPC_USE_DATA_CACHE */
36#include "ppc-asm.h"
37#include "bsp.h"
38
39        .file   "start.s"
40
41        .extern FUNC_NAME(atexit)
42        .globl  FUNC_NAME(__atexit)
43        .section ".sdata","aw"
44        .align  2
45FUNC_NAME(__atexit):                    /* tell C's eabi-ctor's we have an atexit function */
46        .long   FUNC_NAME(atexit)@fixup /* and that it is to register __do_global_dtors */
47
48        .section ".fixup","aw"
49        .align  2
50        .long   FUNC_NAME(__atexit)
51
52        .text
53        .globl  _start
54        .type   _start,@function
55_start:
56        /* Set MSR */
57        /*
58         * Enable data and instruction address translation and floating point
59         */
60        li      r3,MSR_IR | MSR_DR | MSR_FP
61        mtmsr   r3
62
63        /*
64         * The caches are already flushed by the firmware so just enable
65         */
66        mfspr   r3,HID0
67#if PPC_USE_DATA_CACHE
68        /*
69         * Enable data and instruction cache
70         */
71        ori     r3,r3 ,H0_60X_ICE | H0_60X_DCE
72#else
73        /*
74         * Enable instruction cache only
75         */
76        ori     r3,r3 ,H0_60X_ICE
77#endif
78        mtspr   HID0,r3
79       
80        /* clear bss */
81        lis     r6,__bss_start@h
82        ori     r6,r6,__bss_start@l
83        lis     r7,__bss_end@h
84        ori     r7,r7,__bss_end@l
85
86        cmplw   1,r6,r7
87        bc      4,4,.Lbss_done
88
89        subf    r8,r6,r7                /* number of bytes to zero */
90        srwi    r9,r8,2                 /* number of words to zero */
91        mtctr   r9
92        li      r0,0                    /* zero to clear memory */
93        addi    r6,r6,-4                /* adjust so we can use stwu */
94.Lbss_loop:
95        stwu    r0,4(r6)                /* zero bss */
96        bdnz    .Lbss_loop
97
98.Lbss_done:
99
100        /* clear sbss */
101        lis     r6,__sbss_start@h
102        ori     r6,r6,__sbss_start@l
103        lis     r7,__sbss_end@h
104        ori     r7,r7,__sbss_end@l
105
106        cmplw   1,r6,r7
107        bc      4,4,.Lsbss_done
108
109        subf    r8,r6,r7                /* number of bytes to zero */
110        srwi    r9,r8,2                 /* number of words to zero */
111        mtctr   r9
112        li      r0,0                    /* zero to clear memory */
113        addi    r6,r6,-4                /* adjust so we can use stwu */
114.Lsbss_loop:
115        stwu    r0,4(r6)                /* zero sbss */
116        bdnz    .Lsbss_loop
117
118.Lsbss_done:
119
120        lis     sp,__stack@h
121        ori     sp,sp,__stack@l
122
123        /* set up initial stack frame */
124        addi    sp,sp,-4                /* make sure we don't overwrite debug mem */
125        lis     r0,0
126        stw     r0,0(sp)                /* clear back chain */
127        stwu    sp,-56(sp)              /* push another stack frame */
128
129        lis     r5,environ@ha
130        la      r5,environ@l(r5)        /* environp */
131        li      r4, 0                   /* argv */
132        li      r3, 0                   /* argc */
133        /* Let her rip */
134        bl      FUNC_NAME(boot_card)
135
136        /*
137         * This should never get reached
138         */
139        /*
140         * Return MSR to its reset state
141         */
142        li      r3,0
143        mtmsr   r3
144        isync
145
146        /*
147         * Call reset entry point
148         */
149        lis     r3,0xfff0
150        ori     r3,r3,0x100
151        mtlr    r3
152        blr
153.Lstart:
154        .size   _start,.Lstart-_start
155
156        .comm   environ,4,4
Note: See TracBrowser for help on using the repository browser.