URL
https://opencores.org/ocsvn/or1k/or1k/trunk
Subversion Repositories or1k
[/] [or1k/] [trunk/] [newlib/] [libgloss/] [sparc/] [crt0.S] - Rev 1773
Go to most recent revision | Compare with Previous | Blame | View Log
/** C startup code for the Fujitsu SPARClite demo board** Copyright (c) 1995, 1996 Cygnus Support** The authors hereby grant permission to use, copy, modify, distribute,* and license this software and its documentation for any purpose, provided* that existing copyright notices are retained in all copies and that this* notice is included verbatim in any distributions. No written agreement,* license, or royalty fee is required for any of the authorized uses.* Modifications to this software may be copyrighted by their authors* and need not follow the licensing terms described here, provided that* the new terms are clearly indicated on the first page of each file where* they apply.*/#include "asm.h".data.align 8.ascii "DaTa" ! this is the first address in the data section.long SYM(sdata)SYM(environ):.long 0.text.align 8.globl SYM(_start)SYM(_start):.globl SYM(start)SYM(start):/* see if the stack is already setup. if not, then default* to using the value of %sp as set by the ROM monitor*/sethi %hi(__stack), %g1or %g1,%lo(__stack),%g1cmp %g0,%g1be 1fmov %g1, %sp ! set the stack pointermov %sp, %fp1:/* zero the bss section */sethi %hi(__bss_start),%g2or %g2,%lo(__bss_start),%g2 ! start of bsssethi %hi(_end),%g3or %g3,%lo(_end),%g3 ! end of bssmov %g0,%g1 ! so std has two zeroszerobss:std %g0,[%g2]add %g2,8,%g2cmp %g2,%g3bleu,a zerobssnop/** copy prom & trap vectors to sram.*/set 0x30000000, %l0set 0xfff8, %l1tst %l1 ! Set condition codescopyloop:ldd [%l1], %l2std %l2, [%l0 + %l1]bg copyloopdeccc 8, %l1set 0x30000000, %l0 ! Base of new trap vectormov %l0, %tbr ! Install the new tbrset SYM(win_ovf_trap), %l1 ! Setup window overflow trapldd [%l1], %l2std %l2, [%l0 + 5 * 16]ldd [%l1 + 8], %l2std %l2, [%l0 + 5 * 16 + 8]set SYM(win_unf_trap), %l1 ! Setup window underflow trapldd [%l1], %l2std %l2, [%l0 + 6 * 16]ldd [%l1 + 8], %l2std %l2, [%l0 + 6 * 16 + 8]/** Try enabling the FPU by setting EF. If that causes a trap, then we probably* don't have an FPU.*/ldd [%l0 + 2 * 16], %l4 ! Save original trap routineset SYM(no_fpu_trap), %l1 ! Install new oneldd [%l1], %l2std %l2, [%l0 + 2 * 16]mov %psr, %l0sethi %hi(0x1000), %l1bset %l1, %l0! mov %l0, %psrstd %l4, [2 * 16] ! Restore original trap routine/** Move the data segment from it's ROM address to RAM where it* belongs.*/relocd:#if 0 /* This code is broken. FIXME */set (_sdata),%g2 ! %g2 = start of data in aout fileset SYM(environ),%g4 ! %g4 = actual data base addressset (_edata),%g3 ! %g3 = end of where data should gosubcc %g3, %g4, %g5 ! %g5 = length of datasubcc %g4, %g2, %g0 ! need to relocate data ?ble initld [%g4], %g6subcc %g6, 1, %g0be initmvdata:subcc %g5, 8, %g5ldd [%g2 + %g5], %g6bg mvdata#endif/** initialize target specific stuff. Only execute these* functions it they exist.*/init:sethi %hi(SYM(hardware_init_hook)), %g1or %g1,%lo(SYM(hardware_init_hook)),%g1cmp %g0,%g1be 1fnopcall SYM(hardware_init_hook)nop1:sethi %hi(SYM(software_init_hook)), %g1or %g1,%lo(SYM(software_init_hook)),%g1cmp %g0,%g1be 2fnopcall SYM(software_init_hook)nop2:call SYM(main)nop/* call exit from the C library so atexit gets called, and the* C++ destructors get run. This calls our exit routine below* when it's done.*/call SYM(exit)nop/** This should drop control back to the ROM monitor, if there is* one.*/.globl SYM(_exit)SYM(_exit):call 0nop/** Trap handlers.*/.align 8SYM(win_ovf_trap):sethi %hi(SYM(win_ovf)), %l3jmpl %lo(SYM(win_ovf))+%l3, %g0mov %wim, %l0nopSYM(win_unf_trap):sethi %hi(SYM(win_unf)), %l3jmpl %lo(SYM(win_unf))+%l3, %g0mov %wim, %l0nopSYM(no_fpu_trap): ! Come here when no fpu exists.jmpl %l2, %g0 ! This just skips therett %l2+4 ! offending instruction.
Go to most recent revision | Compare with Previous | Blame | View Log
