(res_isourserver): Fix cast.
[glibc/pb-stable.git] / sysdeps / standalone / i960 / start.S
blobd86fb1440ffcc2d9190de32c1da6c2d40132dbbf
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 Library General Public License as
8    published by the Free Software Foundation; either version 2 of the
9    License, or (at your option) any later version.
11    The GNU C Library is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14    Library General Public License for more details.
16    You should have received a copy of the GNU Library General Public
17    License along with the GNU C Library; see the file COPYING.LIB.  If not,
18    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19    Boston, MA 02111-1307, USA.  */
21 /*  entry.s
22  *
23  *  This file contains the entry point for the application.
24  *  The name of this entry point is compiler dependent.
25  *  It jumps to the BSP which is responsible for performing
26  *  all initialization.
27  *
28  */
30          .text
31          .globl  start                  # GNU960 default entry point
33 start:
34         mov     3, r12
35         modpc   r12, r12, r12         # enable tracing/trace faults
36         mov     g5, g5                # NOP
37         mov     0, g14                # initialize constant for C
39         /*
40          * zero out uninitialized data area
41          */
42 zerobss:
43         lda     _end, r4        /* find end of .bss */
44         lda     _bss_start, r5  /* find beginning of .bss */
45         ldconst 0, r6
47 loop:   st      r6, (r5)        /* to zero out uninitialized */
48         addo    4, r5, r5       /* data area                 */
49         cmpobl  r5, r4, loop    /* loop until _end reached   */
52         lda     heap_memory, r12      /* tell C lib where heap is */
53         st      r12,___C_heap_start
54         lda     heap_size, r12        /* tell C lib how big heap is */
55         st      r12,___C_heap_size
56         lda     stack_memory,r12      /* set up stack pointer: */
57         mov     r12, sp
58         mov     0, g14           /* initialize constant for C */
60         call    init_frames
61         ret                      /* return to monitor */
63 init_frames:
64         ldconst 0x3b001000, g0
65         ldconst 0x00009107, g1
66         modac   g1, g0, g0       /* set AC controls */
68         /*
69          * Call application mainline.
70          *      Someday, real values of argc and argv will be set up.
71          *      For now, they are set to 0.
72          */
74         callx   __Board_Initialize    /* Initialize the board */
76         ldconst 0,g0
77         ldconst 0,g1
78         ldconst 0,g2
79         callx   ___libc_init          /* initialize the library and */
80                                       /*   call main */
81         /*
82          * if we return from main, we have "fallen" off the end
83          * of the program, therefore status is 0
84          * so move 0 to g0 (exit parameter)
85          */
87         mov     0, g0
88         callx   __exit
89         ret
93  *  Data Declarations.  Start with a macro which helps declare space.
94  */
96 #define DECLARE_SPACE(_name,_space,_align) \
97           .globl   _name ; \
98           .align   _align ; \
99 .comm     _name##,_space
101 #define DECLARE_LABEL(_name) \
102           .globl   _name ; \
103 _name##:
105 #define DECLARE_PTR(_name) DECLARE_SPACE(_name,4,2)
106 #define DECLARE_U32(_name) DECLARE_SPACE(_name,4,2)
107 #define DECLARE_U16(_name) DECLARE_SPACE(_name,2,1)
110  *  Require environment stuff
111  */
113 DECLARE_LABEL(_environ)
114 DECLARE_PTR(environ)
116 DECLARE_LABEL(_errno)
117 DECLARE_U32(errno)
120  *  Stack Size and Space
121  */
123         .set stack_size, 0x20000
125 DECLARE_SPACE(stack_memory,stack_size,4)
126 DECLARE_LABEL(stack_end)
129  *  Heap Size and Space
130  */
132         .set heap_size, 0x20000
134 DECLARE_SPACE(heap_memory,heap_size,4)
135 DECLARE_LABEL(heap_end)