2.3.3-74
[glibc.git] / sysdeps / standalone / i960 / start.S
blob579beb77fb16fd9907cadef23de0aafa65159c25
1 /* Copyright (C) 1994, 1997 Free Software Foundation, Inc.
2    Contributed by Joel Sherrill (jsherril@redstone-emh2.army.mil),
3      On-Line Applications Research Corporation.
4    This file is part of the GNU C Library.
6    The GNU C Library is free software; you can redistribute it and/or
7    modify it under the terms of the GNU Lesser General Public
8    License as published by the Free Software Foundation; either
9    version 2.1 of the License, or (at your option) any later version.
11    In addition to the permissions in the GNU Lesser General Public
12    License, the Free Software Foundation gives you unlimited
13    permission to link the compiled version of this file with other
14    programs, and to distribute those programs without any restriction
15    coming from the use of this file. (The GNU Lesser General Public
16    License restrictions do apply in other respects; for example, they
17    cover modification of the file, and distribution when not linked
18    into another program.)
20    Note that people who make modified versions of this file are not
21    obligated to grant this special exception for their modified
22    versions; it is their choice whether to do so. The GNU Lesser
23    General Public License gives permission to release a modified
24    version without this exception; this exception also makes it
25    possible to release a modified version which carries forward this
26    exception.
28    The GNU C Library is distributed in the hope that it will be useful,
29    but WITHOUT ANY WARRANTY; without even the implied warranty of
30    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
31    Lesser General Public License for more details.
33    You should have received a copy of the GNU Lesser General Public
34    License along with the GNU C Library; if not, write to the Free
35    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
36    02111-1307 USA.  */
38 /*  entry.s
39  *
40  *  This file contains the entry point for the application.
41  *  The name of this entry point is compiler dependent.
42  *  It jumps to the BSP which is responsible for performing
43  *  all initialization.
44  *
45  */
47          .text
48          .globl  start                  # GNU960 default entry point
50 start:
51         mov     3, r12
52         modpc   r12, r12, r12         # enable tracing/trace faults
53         mov     g5, g5                # NOP
54         mov     0, g14                # initialize constant for C
56         /*
57          * zero out uninitialized data area
58          */
59 zerobss:
60         lda     _end, r4        /* find end of .bss */
61         lda     _bss_start, r5  /* find beginning of .bss */
62         ldconst 0, r6
64 loop:   st      r6, (r5)        /* to zero out uninitialized */
65         addo    4, r5, r5       /* data area                 */
66         cmpobl  r5, r4, loop    /* loop until _end reached   */
69         lda     heap_memory, r12      /* tell C lib where heap is */
70         st      r12,___C_heap_start
71         lda     heap_size, r12        /* tell C lib how big heap is */
72         st      r12,___C_heap_size
73         lda     stack_memory,r12      /* set up stack pointer: */
74         mov     r12, sp
75         mov     0, g14           /* initialize constant for C */
77         call    init_frames
78         ret                      /* return to monitor */
80 init_frames:
81         ldconst 0x3b001000, g0
82         ldconst 0x00009107, g1
83         modac   g1, g0, g0       /* set AC controls */
85         /*
86          * Call application mainline.
87          *      Someday, real values of argc and argv will be set up.
88          *      For now, they are set to 0.
89          */
91         callx   __Board_Initialize    /* Initialize the board */
93         ldconst 0,g0
94         ldconst 0,g1
95         ldconst 0,g2
96         callx   ___libc_init          /* initialize the library and */
97                                       /*   call main */
98         /*
99          * if we return from main, we have "fallen" off the end
100          * of the program, therefore status is 0
101          * so move 0 to g0 (exit parameter)
102          */
104         mov     0, g0
105         callx   __exit
106         ret
110  *  Data Declarations.  Start with a macro which helps declare space.
111  */
113 #define DECLARE_SPACE(_name,_space,_align) \
114           .globl   _name ; \
115           .align   _align ; \
116 .comm     _name##,_space
118 #define DECLARE_LABEL(_name) \
119           .globl   _name ; \
120 _name##:
122 #define DECLARE_PTR(_name) DECLARE_SPACE(_name,4,2)
123 #define DECLARE_U32(_name) DECLARE_SPACE(_name,4,2)
124 #define DECLARE_U16(_name) DECLARE_SPACE(_name,2,1)
127  *  Require environment stuff
128  */
130 DECLARE_LABEL(_environ)
131 DECLARE_PTR(environ)
133 DECLARE_LABEL(_errno)
134 DECLARE_U32(errno)
137  *  Stack Size and Space
138  */
140         .set stack_size, 0x20000
142 DECLARE_SPACE(stack_memory,stack_size,4)
143 DECLARE_LABEL(stack_end)
146  *  Heap Size and Space
147  */
149         .set heap_size, 0x20000
151 DECLARE_SPACE(heap_memory,heap_size,4)
152 DECLARE_LABEL(heap_end)