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

4.115
Last change on this file since 48449a8 was 48449a8, checked in by Joel Sherrill <joel.sherrill@…>, on 10/06/11 at 16:46:36

2011-10-06 Gedare Bloom <giddyup44@…>

PR 1920/bsp

  • shared/helenos/kernel/sparc64/src/sun4u/takemmu.S, shared/start/start.S, shared/startup/bspgetworkarea.c, shared/startup/linkcmds: Fix BSP memory use to support more than 4 MB of RAM.
  • Property mode set to 100644
File size: 4.3 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 * $Id$
44 */
45
46#include <rtems/asm.h>
47#include <rtems/score/cpu.h>
48
49#define PSTATE_PRIV_BIT 4
50
51.register %g2, #scratch
52.register %g3, #scratch
53.register %g6, #scratch
54.register %g7, #scratch
55
56#if 0
57#define _BSP_DEBUG
58#endif
59
60#if _BSP_DEBUG
61/*
62 * This is for debug and script support to identify RTEMS app termination
63 */
64.section        .data
65        .align 8
66_end_token_string:
67        .asciz "END_TOKEN\n"
68#endif
69
70.section BOOTSTRAP, "ax"
71
72PUBLIC(_start)
73  .global _start
74  SYM(_start):
75    start:
76    b 1f
77    nop
78
79    /*
80     * This header forces SILO to load the image at 0x4000.
81     * More precisely, SILO will think this is an old version of Linux.
82     */
83    .ascii "HdrS"
84    .word 0
85    .half 0
86    .half 0
87    .half 0
88    .half 0
89    .global silo_ramdisk_image
90    silo_ramdisk_image:
91    .word 0
92    .global silo_ramdisk_size
93    silo_ramdisk_size:
94    .word 0
95
96    .align 8
97    1: 
98    /*
99     * Disable interrupts and disable address masking.
100     */
101    wrpr %g0, PSTATE_PRIV_BIT, %pstate
102
103    wrpr %g0, SPARC_NUMBER_OF_REGISTER_WINDOWS - 2, %cansave    ! set maximum saveable windows
104    wrpr %g0, 0, %canrestore            ! get rid of windows we will never need again
105    wrpr %g0, 0, %otherwin                      ! make sure the window state is consistent
106    wrpr %g0, SPARC_NUMBER_OF_REGISTER_WINDOWS - 1, %cleanwin   ! prevent needless clean_window traps for kernel
107
108  /* g4 needs to be cleared for gcc */
109  mov %g0, %g4
110
111  /* Clear the bss */
112        setx    SYM(bss_start), %l0, %g2        ! g2 = start of bss
113        setx    SYM(_end), %l0, %g3                 ! g3 = end of bss
114zerobss:
115        stx     %g0, [%g2]
116        add     %g2, 8, %g2
117        cmp     %g2, %g3
118        bleu,a  zerobss
119        nop
120
121  /* Install stack */
122setstack:
123        set SYM(StackStart), %sp
124        add %sp, -STACK_BIAS, %sp
125
126  /* BSP-specific pre-bootcard initializations */
127  call SYM(_BSP_init)
128  nop
129
130        setx ofw_cif, %l0, %l1
131 
132        call ofw_init           ! initialize OpenFirmware
133        stx %o4, [%l1]
134
135  call bootstrap
136  nop
137
138
139  /* Set up ISR handler for interrupt enable/disable */
140        setx SYM(syscall), %l0, %o1
141        setx param_space, %l0, %o2
142        call SYM(_CPU_ISR_install_raw_handler)
143        mov 0x100, %o0
144
145  /* Don't need to copy initialized data to RAM--link puts all in RAM already */
146
147        mov     %g0, %o0                ! clear command line passed to main
148        call SYM(boot_card)
149        sub     %sp, 0x60, %sp          ! make room on stack (necessary?)
150
151#if _BSP_DEBUG
152  /* execution returns here when RTEMS terminates */
153        sethi %hi(_end_token_string), %g1
154        add %g1, %lo(_end_token_string), %o0
155        call SYM(printk)
156        nop
157#endif
158
159  call SYM(halt)
160  nop
161
162halted: nop
163            b SYM(halted)
164
165  .align CPU_ALIGNMENT
166  param_space:
167        .space 8
168
169    .global _fini
170    _fini:
171    nop
172    nop
173
174    .global _init
175    _init:
176    nop
177    nop
Note: See TracBrowser for help on using the repository browser.