source: trunk/libs/newlib/src/libgloss/sparc_leon/locore.S @ 450

Last change on this file since 450 was 444, checked in by satin@…, 6 years ago

add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc

File size: 4.1 KB
Line 
1/*
2 * Copyright (c) 2011 Aeroflex Gaisler
3 *
4 * BSD license:
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 * THE SOFTWARE.
23 */
24
25 
26/* The traptable has to be the first code in a boot PROM. */
27
28#include <asm-leon/head.h>
29               
30#define TRAP(H)  mov %psr, %l0; sethi %hi(H), %l4; jmp %l4+%lo(H); nop;
31#define TRAPL(H)  nop; sethi %hi(H), %g1; jmp %g1+%lo(H); nop;
32#define TRAP_ENTRY(H) rd %psr, %l0; b H; rd %wim, %l3; nop;
33
34#define WIM_INIT 2
35#ifdef _SOFT_FLOAT
36#define PSR_INIT 0x0e0
37#else
38#define PSR_INIT 0x10e0
39#endif
40
41#define NUMREGWINDOWS 8
42
43/* Unexcpected trap will halt the processor by forcing it to error state */
44#define BAD_TRAP ta 0; nop; nop; nop;
45
46/* Software trap. Treat as BAD_TRAP */
47#define SOFT_TRAP BAD_TRAP
48
49  .seg    "text"
50  .global _trap_table, start, _start, cpuinit, leonbare_irq_entry, _hardreset
51  .global _window_overflow, _window_underflow, _flush_windows, _fpdis_enable
52  /*.global _nwindows, _leon_version, _nwindows_min1*/
53
54       
55!
56! Startup code for standalone system. Wash IU and FPU (if present) registers.
57! The registers have to be written to initiate the parity bits.
58!
59        .section .text
60        /* ------- */
61        .weak   _hardreset
62        .set    _hardreset,_hardreset_libgloss
63        /* ------- */
64       
65        .global _hardreset_custom_weak, _hardreset_real, _cleanregs_custom_weak, _hardreset_custom_svt_weak
66
67_hardreset_real:
68        nop
69_hardreset_libgloss:
70        set     _hardreset_custom_weak, %g1  ! possible mkprom init code here, default links to dummy _hardreset_custom_dummy
71        call     %g1
72         nop
73       
74        set     _trap_table, %g1        ! Initialize TBR
75        mov     %g1, %tbr
76       
77        set     _hardreset_custom_svt_weak, %g1 ! give mkprom svt chance to reset tbr
78        call     %g1
79         nop
80       
81        set     _cleanregs_custom_weak, %g1
82        call     %g1
83         nop
84
85#ifdef _FLAT
86        mov     %g0, %wim
87#else
88/*      ! assume that %sp is correct use cwp of psr to set the next window as invalid
89        mov     %psr, %g2    ! extract cwp
90        and     0x1f, %g2,%g2
91        set     0x1, %g3
92        sll     %g3,%g2,%g3  ! the bit mask for cwp
93
94        sll     %g3, 1, %g4  ! rotate one to left
95        sethi %hi(_nwindows_min1), %g5  ! NWINDOWS-1
96        ld [%g5+%lo(_nwindows_min1)], %g5
97        srl  %g3, %g5, %g5
98        or   %g5, %g4, %g5
99        mov  %g5, %wim
100        nop; nop; nop */
101#endif
102       
103/*
104        mov     %psr, %g2
105        set     0x202, %g3
106        sll     %g3, %g2, %g2
107        mov     %g2, %wim
108        nop; nop; nop
1091:
110*/
111        ! -------------------------------
112        ! only cpu 0 initializes
113/*      mov     %psr, %g5
114        srl     %g5, 24, %g5
115        and     %g5, 3, %g5
116        subcc   %g5, 3, %g0             ! leon2: 0 or 2, leon3: 3
117        bne     callcpuinit
118        nop
119*/
120       
121        rd     %asr17,%g5
122        srl    %g5,28,%g5
123        cmp %g5,%g0
124         bne slavego
125        nop
126       
127callcpuinit:     
128        call    cpuinit
129         nop
130       
131        call    pnpinit
132         nop
133       
134slavego:       
135        ! -------------------------------
136       
137        sub     %sp, 0x40, %sp          ! room for main to save args
138        call    _start
139        nop
140
141        mov     1, %g1
142        ta      0                       ! Halt if _main would return ...
143        nop
144
145        .global _fpdis,_fpdis_svt
146_fpdis_svt:
147_fpdis:
148        set     0x1000, %l4
149        andcc   %l0, %l4, %l3
150        bne,a   4f
151        andn    %l0, %l4, %l0
152        ta      0
1534:
154        mov      %l0, %psr              ! restore %psr
155        nop; nop; nop
156        jmp  %l2                        ! Jump to nPC
157        rett  %l2 + 4
158
159       
160/*
161!''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
162        .section .bss
163        .global _nwindows, _leon_version, _nwindows_min1
164_nwindows:
165        .word 8
166_nwindows_min1:
167        .word 7
168_leon_version:
169        .word 3
170*/
Note: See TracBrowser for help on using the repository browser.