source: mainline/boot/arch/sparc64/src/asm.S@ b9c229b

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since b9c229b was b9c229b, checked in by Jakub Jermar <jakub@…>, 14 years ago

Allocate an ABI-compliant stack frame.

  • Property mode set to 100644
File size: 3.8 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#include <arch/arch.h>
31
32#define ICACHE_SIZE 8192
33#define ICACHE_LINE_SIZE 32
34#define ICACHE_SET_BIT (1 << 13)
35#define ASI_ICACHE_TAG 0x67
36
37.register %g2, #scratch
38.register %g3, #scratch
39.register %g6, #scratch
40.register %g7, #scratch
41
42.global start
43.global halt
44.global jump_to_kernel
45
46.section BOOTSTRAP, "ax"
47
48start:
49 ba %xcc, 1f
50 nop
51
52/*
53 * This header forces SILO to load the image at 0x4000.
54 * More precisely, SILO will think this is an old version of Linux.
55 */
56.ascii "HdrS"
57.word 0
58.half 0
59.half 0
60.half 0
61.half 0
62.word 0
63.word 0
64
65.align 8
661:
67 ! Disable interrupts and disable address masking.
68
69 wrpr %g0, PSTATE_PRIV_BIT, %pstate
70
71 wrpr %g0, NWINDOWS - 2, %cansave ! Set maximum saveable windows
72 wrpr %g0, 0, %canrestore ! Get rid of windows we will never need again
73 wrpr %g0, 0, %otherwin ! Make sure the window state is consistent
74 wrpr %g0, NWINDOWS - 1, %cleanwin ! Prevent needless clean_window traps for kernel
75
76 set initial_stack, %sp
77 add %sp, -STACK_BIAS, %sp
78
79 set ofw_cif, %l0
80
81 ! Initialize OpenFirmware
82
83 call ofw_init
84 stx %o4, [%l0]
85
86 ba %xcc, bootstrap
87 nop
88
89.align STACK_ALIGNMENT
90 .space STACK_SIZE
91initial_stack:
92 .space STACK_WINDOW_SAVE_AREA_SIZE
93
94.text
95
96halt:
97 ba %xcc, halt
98 nop
99
100jump_to_kernel:
101 /*
102 * Guarantee cache coherence:
103 * 1. Make sure that the code we have moved has drained to main memory.
104 * 2. Invalidate I-cache.
105 * 3. Flush instruction pipeline.
106 */
107
108 /*
109 * US3 processors have a write-invalidate cache, so explicitly
110 * invalidating it is not required. Whether to invalidate I-cache
111 * or not is decided according to the value of the 3rd argument
112 * (subarch).
113 */
114 cmp %o2, SUBARCH_US3
115 be %xcc, 1f
116 nop
117
118 0:
119 call icache_flush
120 nop
121
122 1:
123 membar #StoreStore
124
125 /*
126 * Flush the instruction pipeline.
127 */
128 flush %i7
129
130 ! Jump to kernel
131 jmp %o3
132 nop
133
134# Flush I-cache
135icache_flush:
136 set ((ICACHE_SIZE - ICACHE_LINE_SIZE) | ICACHE_SET_BIT), %g1
137 stxa %g0, [%g1] ASI_ICACHE_TAG
138
139 0:
140 membar #Sync
141 subcc %g1, ICACHE_LINE_SIZE, %g1
142 bnz,pt %xcc, 0b
143
144 stxa %g0, [%g1] ASI_ICACHE_TAG
145 membar #Sync
146 retl
147
148 ! SF Erratum #51
149
150 nop
151
152.global ofw
153ofw:
154 save %sp, -(STACK_WINDOW_SAVE_AREA_SIZE + STACK_ARG_SAVE_AREA_SIZE), %sp
155 set ofw_cif, %l0
156 ldx [%l0], %l0
157
158 rdpr %pstate, %l1
159 and %l1, ~PSTATE_AM_BIT, %l2
160 wrpr %l2, 0, %pstate
161
162 jmpl %l0, %o7
163 mov %i0, %o0
164
165 wrpr %l1, 0, %pstate
166
167 ret
168 restore %o0, 0, %o0
Note: See TracBrowser for help on using the repository browser.