source: mainline/boot/arch/sparc64/loader/asm.S@ 86018c1

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 86018c1 was f238e86, checked in by Pavel Rimsky <pavel@…>, 16 years ago

Both sun4u and sun4v are compilable, sun4u feature-complete, sun4v reaches (at least) version_print.

  • Property mode set to 100644
File size: 3.8 KB
RevLine 
[b7b5f83]1#
[df4ed85]2# Copyright (c) 2006 Martin Decky
3# Copyright (c) 2006 Jakub Jermar
[b7b5f83]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
[a5f76758]30#include <stack.h>
31#include <register.h>
[2e672fd]32
[e731b0d]33.register %g2, #scratch
34.register %g3, #scratch
[da349da0]35
[b7b5f83]36.text
37
38.global halt
39.global memcpy
40.global jump_to_kernel
41
42halt:
[a1a83e5e]43 ba %xcc, halt
[b7b5f83]44 nop
[c82950a]45
[e731b0d]46memcpy:
47 mov %o0, %o3 ! save dst
48 add %o1, 7, %g1
49 and %g1, -8, %g1
50 cmp %o1, %g1
51 be,pn %xcc, 3f
52 add %o0, 7, %g1
53 mov 0, %g3
54
55 0:
56 brz,pn %o2, 2f
57 mov 0, %g2
58
59 1:
60 ldub [%g3 + %o1], %g1
61 add %g2, 1, %g2
62 cmp %o2, %g2
63 stb %g1, [%g3 + %o0]
64 bne,pt %xcc, 1b
65 mov %g2, %g3
66
67 2:
68 jmp %o7 + 8 ! exit point
69 mov %o3, %o0
70
71 3:
72 and %g1, -8, %g1
73 cmp %o0, %g1
74 bne,pt %xcc, 0b
75 mov 0, %g3
76 srlx %o2, 3, %g4
77 brz,pn %g4, 5f
78 mov 0, %g5
79
80 4:
81 sllx %g3, 3, %g2
82 add %g5, 1, %g3
83 ldx [%o1 + %g2], %g1
84 mov %g3, %g5
85 cmp %g4, %g3
86 bne,pt %xcc, 4b
87 stx %g1, [%o0 + %g2]
88
89 5:
90 and %o2, 7, %o2
91 brz,pn %o2, 2b
92 sllx %g4, 3, %g1
93 mov 0, %g2
94 add %g1, %o0, %o0
95 add %g1, %o1, %g4
96 mov 0, %g3
97
98 6:
99 ldub [%g2 + %g4], %g1
100 stb %g1, [%g2 + %o0]
101 add %g3, 1, %g2
102 cmp %o2, %g2
103 bne,pt %xcc, 6b
104 mov %g2, %g3
105
106 jmp %o7 + 8 ! exit point
107 mov %o3, %o0
[b7b5f83]108
109jump_to_kernel:
[0af4f9e]110 /*
[1eb154f]111 * We have copied code and now we need to guarantee cache coherence.
112 * 1. Make sure that the code we have moved has drained to main memory.
113 * 2. Invalidate I-cache.
114 * 3. Flush instruction pipeline.
[965dc18]115 */
[e731b0d]116
[f238e86]117#if defined (SUN4U)
[965dc18]118 /*
119 * US3 processors have a write-invalidate cache, so explicitly
120 * invalidating it is not required. Whether to invalidate I-cache
[e731b0d]121 * or not is decided according to the value of the 5th argument
122 * (subarchitecture).
[965dc18]123 */
[e731b0d]124 cmp %i4, 3
[a1a83e5e]125 be %xcc, 1f
[965dc18]126 nop
[e731b0d]127
128 0:
129 call icache_flush
130 nop
[f238e86]131#endif
[e731b0d]132 1:
133 membar #StoreStore
[965dc18]134
135 /*
136 * Flush the instruction pipeline.
137 */
[e731b0d]138 flush %i7
139
[94d614e]140 mov %o0, %l1
141 mov %o1, %o0
142 mov %o2, %o1
[45b26dad]143 mov %o3, %o2
[e731b0d]144 jmp %l1 ! jump to kernel
[94d614e]145 nop
[2e672fd]146
[e731b0d]147#define ICACHE_SIZE 8192
148#define ICACHE_LINE_SIZE 32
149#define ICACHE_SET_BIT (1 << 13)
150#define ASI_ICACHE_TAG 0x67
[1eb154f]151
152# Flush I-cache
153icache_flush:
[e731b0d]154 set ((ICACHE_SIZE - ICACHE_LINE_SIZE) | ICACHE_SET_BIT), %g1
155 stxa %g0, [%g1] ASI_ICACHE_TAG
156
157 0:
158 membar #Sync
159 subcc %g1, ICACHE_LINE_SIZE, %g1
160 bnz,pt %xcc, 0b
161
162 stxa %g0, [%g1] ASI_ICACHE_TAG
163 membar #Sync
[1eb154f]164 retl
165 ! SF Erratum #51
166 nop
[e731b0d]167
[2e672fd]168.global ofw
169ofw:
170 save %sp, -STACK_WINDOW_SAVE_AREA_SIZE, %sp
171 set ofw_cif, %l0
172 ldx [%l0], %l0
[e731b0d]173
[2e672fd]174 rdpr %pstate, %l1
175 and %l1, ~PSTATE_AM_BIT, %l2
176 wrpr %l2, 0, %pstate
[e731b0d]177
[2e672fd]178 jmpl %l0, %o7
179 mov %i0, %o0
[e731b0d]180
[2e672fd]181 wrpr %l1, 0, %pstate
[e731b0d]182
[2e672fd]183 ret
184 restore %o0, 0, %o0
Note: See TracBrowser for help on using the repository browser.