2 * C startup code for the Fujitsu SPARClite demo board
4 * Copyright (c) 1995, 1996 Cygnus Support
6 * The authors hereby grant permission to use, copy, modify, distribute,
7 * and license this software and its documentation for any purpose, provided
8 * that existing copyright notices are retained in all copies and that this
9 * notice is included verbatim in any distributions. No written agreement,
10 * license, or royalty fee is required for any of the authorized uses.
11 * Modifications to this software may be copyrighted by their authors
12 * and need not follow the licensing terms described here, provided that
13 * the new terms are clearly indicated on the first page of each file where
18 #ifdef TARGET_CPU_SPARC64
19 #define STACK_BIAS 2047
20 #define SAVE_SIZE -128
25 .register %g2, #scratch
26 .register %g3, #scratch
30 SYM(environ): ! this is the first address in the data section
43 /* see if the stack is already setup. if not, then default
44 * to using the value of %sp as set by the ROM monitor
46 sethi %hi(__stack), %g1
47 or %g1,%lo(__stack),%g1
52 sub %g1, STACK_BIAS, %g1
54 mov %g1, %sp ! set the stack pointer
58 /* zero the bss section */
59 sethi %hi(__bss_start),%g2
60 or %g2,%lo(__bss_start),%g2 ! start of bss
62 or %g3,%lo(_end),%g3 ! end of bss
63 mov %g0,%g1 ! so std has two zeros
72 * initialize target specific stuff. Only execute these
73 * functions it they exist.
76 sethi %hi(SYM(hardware_init_hook)), %g1
77 or %g1,%lo(SYM(hardware_init_hook)),%g1
81 call SYM(hardware_init_hook)
85 sethi %hi(SYM(software_init_hook)), %g1
86 or %g1,%lo(SYM(software_init_hook)),%g1
90 call SYM(software_init_hook)
93 set SYM(__sigtramp), %o0
94 call SYM(__install_signal_handler)
105 call SYM(__getProgramArgs)
114 /* call exit from the C library so atexit gets called, and the
115 * C++ destructors get run. This calls our exit routine below
122 save %sp,SAVE_SIZE,%sp
123 set __CTOR_LIST__,%l0
144 save %sp,SAVE_SIZE,%sp
145 set __DTOR_LIST__,%l0