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
20 .ascii "DaTa" ! this is the first address in the data section
32 /* see if the stack is already setup. if not, then default
33 * to using the value of %sp as set by the ROM monitor
35 sethi %hi(__stack), %g1
36 or %g1,%lo(__stack),%g1
39 mov %g1, %sp ! set the stack pointer
43 /* zero the bss section */
44 sethi %hi(__bss_start),%g2
45 or %g2,%lo(__bss_start),%g2 ! start of bss
47 or %g3,%lo(_end),%g3 ! end of bss
48 mov %g0,%g1 ! so std has two zeros
57 * copy prom & trap vectors to sram.
61 tst %l1 ! Set condition codes
69 set 0x30000000, %l0 ! Base of new trap vector
70 mov %l0, %tbr ! Install the new tbr
72 set SYM(win_ovf_trap), %l1 ! Setup window overflow trap
74 std %l2, [%l0 + 5 * 16]
76 std %l2, [%l0 + 5 * 16 + 8]
78 set SYM(win_unf_trap), %l1 ! Setup window underflow trap
80 std %l2, [%l0 + 6 * 16]
82 std %l2, [%l0 + 6 * 16 + 8]
85 * Try enabling the FPU by setting EF. If that causes a trap, then we probably
89 ldd [%l0 + 2 * 16], %l4 ! Save original trap routine
90 set SYM(no_fpu_trap), %l1 ! Install new one
92 std %l2, [%l0 + 2 * 16]
95 sethi %hi(0x1000), %l1
99 std %l4, [2 * 16] ! Restore original trap routine
103 * Move the data segment from it's ROM address to RAM where it
108 #if 0 /* This code is broken. FIXME */
109 set (_sdata),%g2 ! %g2 = start of data in aout file
110 set SYM(environ),%g4 ! %g4 = actual data base address
111 set (_edata),%g3 ! %g3 = end of where data should go
112 subcc %g3, %g4, %g5 ! %g5 = length of data
114 subcc %g4, %g2, %g0 ! need to relocate data ?
126 * initialize target specific stuff. Only execute these
127 * functions it they exist.
130 sethi %hi(SYM(hardware_init_hook)), %g1
131 or %g1,%lo(SYM(hardware_init_hook)),%g1
135 call SYM(hardware_init_hook)
139 sethi %hi(SYM(software_init_hook)), %g1
140 or %g1,%lo(SYM(software_init_hook)),%g1
144 call SYM(software_init_hook)
150 /* call exit from the C library so atexit gets called, and the
151 * C++ destructors get run. This calls our exit routine below
158 * This should drop control back to the ROM monitor, if there is
173 sethi %hi(SYM(win_ovf)), %l3
174 jmpl %lo(SYM(win_ovf))+%l3, %g0
179 sethi %hi(SYM(win_unf)), %l3
180 jmpl %lo(SYM(win_unf))+%l3, %g0
184 SYM(no_fpu_trap): ! Come here when no fpu exists.
185 jmpl %l2, %g0 ! This just skips the
186 rett %l2+4 ! offending instruction.