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

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

Cannot write directly to ICACHE_ASI on sun4v.

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