source: rtems/c/src/lib/libbsp/sparc64/shared/start/start.S @ d18560a

5
Last change on this file since d18560a was d18560a, checked in by Sebastian Huber <sebastian.huber@…>, on 11/11/16 at 10:16:33

sparc64: Rename CPU_Minimum_stack_frame

Rename SPARC64-specific CPU_Minimum_stack_frame to
SPARC64_Minimum_stack_frame. Rename SPARC64-specific
CPU_MINIMUM_STACK_FRAME_SIZE to SPARC64_MINIMUM_STACK_FRAME_SIZE.

Update #2809.

  • Property mode set to 100644
File size: 4.2 KB
Line 
1#
2# Copyright (c) 2006 Martin Decky
3# Copyright (c) 2006 Jakub Jermar
4# All rights reserved.
5#
6# Redistribution and use in source and binary forms, with or without
7# modification, are permitted provided that the following conditions
8# are met:
9#
10# - Redistributions of source code must retain the above copyright
11#   notice, this list of conditions and the following disclaimer.
12# - Redistributions in binary form must reproduce the above copyright
13#   notice, this list of conditions and the following disclaimer in the
14#   documentation and/or other materials provided with the distribution.
15# - The name of the author may not be used to endorse or promote products
16#   derived from this software without specific prior written permission.
17#
18# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28#
29
30/*
31 * start.S
32 *
33 * Start code for Sparc64 RTEMS
34 *
35 * This is based on the boot.S file of the HelenOS sparc64 architecture.
36 * http://www.helenos.org/
37 * ${helenos}/boot/arch/sparc64/loader/boot.S
38 *
39 * Modifications for the RTEMS executive are
40 *   COPYRIGHT (c) 2010 Gedare Bloom.
41 *   COPYRIGHT (c) 2010 Eugen Leontie.
42 */
43
44#include <rtems/asm.h>
45#include <rtems/score/cpu.h>
46
47#define PSTATE_PRIV_BIT 4
48
49.register %g2, #scratch
50.register %g3, #scratch
51.register %g6, #scratch
52.register %g7, #scratch
53
54.section BOOTSTRAP, "ax"
55
56PUBLIC(_start)
57  .global _start
58  SYM(_start):
59    start:
60    b 1f
61    nop
62
63    /*
64     * This header forces SILO to load the image at 0x4000.
65     * More precisely, SILO will think this is an old version of Linux.
66     */
67    .ascii "HdrS"
68    .word 0
69    .half 0
70    .half 0
71    .half 0
72    .half 0
73    .global silo_ramdisk_image
74    silo_ramdisk_image:
75    .word 0
76    .global silo_ramdisk_size
77    silo_ramdisk_size:
78    .word 0
79
80    .align 8
81    1: 
82    /*
83     * Disable interrupts and disable address masking.
84     */
85    wrpr %g0, PSTATE_PRIV_BIT, %pstate
86
87    wrpr %g0, SPARC_NUMBER_OF_REGISTER_WINDOWS - 2, %cansave    ! set maximum saveable windows
88    wrpr %g0, 0, %canrestore            ! get rid of windows we will never need again
89    wrpr %g0, 0, %otherwin                      ! make sure the window state is consistent
90    wrpr %g0, SPARC_NUMBER_OF_REGISTER_WINDOWS - 1, %cleanwin   ! prevent needless clean_window traps for kernel
91
92  /* g4 needs to be cleared for gcc */
93  mov %g0, %g4
94
95  /* Clear the bss */
96        setx    SYM(bss_start), %l0, %g2        ! g2 = start of bss
97        setx    SYM(_end), %l0, %g3                 ! g3 = end of bss
98zerobss:
99        stx     %g0, [%g2]
100        add     %g2, 8, %g2
101        cmp     %g2, %g3
102        bleu,a  zerobss
103        nop
104
105  /* Install stack */
106setstack:
107        set SYM(StackStart), %sp
108        add %sp, -STACK_BIAS, %sp
109
110  /* BSP-specific pre-bootcard initializations */
111  call SYM(_BSP_init)
112  nop
113
114        setx ofw_cif, %l0, %l1
115 
116        call ofw_init           ! initialize OpenFirmware
117        stx %o4, [%l1]
118
119  call bootstrap
120  nop
121
122
123  /* Set up ISR handler for interrupt enable/disable */
124        setx SYM(syscall), %l0, %o1
125        setx param_space, %l0, %o2
126        call SYM(_CPU_ISR_install_raw_handler)
127        mov 0x100, %o0
128
129  /* Don't need to copy initialized data to RAM--link puts all in RAM already */
130
131        mov     %g0, %o0                ! clear command line passed to main
132        call SYM(boot_card)
133        sub     %sp, 0x60, %sp          ! make room on stack (necessary?)
134
135  call SYM(halt)
136  nop
137
138halted: nop
139            b SYM(halted)
140
141.section BOOTSTRAP
142  .align CPU_ALIGNMENT
143  .space 32768 - SPARC64_MINIMUM_STACK_FRAME_SIZE ! 32K boot stack grows down
144  .global StackStart
145  StackStart:
146    .space SPARC64_MINIMUM_STACK_FRAME_SIZE ! initial stack frame
147
148.section BOOTSTRAP
149  .align CPU_ALIGNMENT
150  param_space:
151        .space 8
152
153.section .fini
154  .global _fini
155  _fini:
156    nop
157    retl
158    nop
159
160.section .init
161  .global _init
162  _init:
163    nop
164    retl
165    nop
Note: See TracBrowser for help on using the repository browser.