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

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since b9c7425 was e731b0d, checked in by Martin Decky <martin@…>, 16 years ago

make ppc32 OFW usage on par with sparc64, make appropriate modifications elsewhere

  • introduce ofw_tree_walk_by_device_type() to gather all OFW devices of a given type
  • ppc32 uses canonized OFW tree, mac-io and display devices are detected in kernel (not by the boot loader) by means of device type
  • various busses (PCI, EBUS, etc.) stay sparc64 specific for now
  • boot memcpy() is defined in a common way
  • BALLOC_MAX_SIZE is platform-dependent
  • ppc32 and sparc64 boot loaders cleanup (removal of obsolete stuff, data is not passed by global variables if not necessary, etc.)
  • balloc and OFW tree canonizer have now a provision to support different mapping of the data during boot time and kernel run-time
  • OFW tree canonizer uses balloc_rebase() to store pointers suitable for access during kernel run-time (with potentially different memory mapping than during boot time)
  • 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 <stack.h>
31#include <register.h>
32
33.register %g2, #scratch
34.register %g3, #scratch
35
36.text
37
38.global halt
39.global memcpy
40.global jump_to_kernel
41
42halt:
43 ba %xcc, halt
44 nop
45
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
108
109jump_to_kernel:
110 /*
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.
115 */
116
117 /*
118 * US3 processors have a write-invalidate cache, so explicitly
119 * invalidating it is not required. Whether to invalidate I-cache
120 * or not is decided according to the value of the 5th argument
121 * (subarchitecture).
122 */
123 cmp %i4, 3
124 be %xcc, 1f
125 nop
126
127 0:
128 call icache_flush
129 nop
130
131 1:
132 membar #StoreStore
133
134 /*
135 * Flush the instruction pipeline.
136 */
137 flush %i7
138
139 mov %o0, %l1
140 mov %o1, %o0
141 mov %o2, %o1
142 mov %o3, %o2
143 jmp %l1 ! jump to kernel
144 nop
145
146#define ICACHE_SIZE 8192
147#define ICACHE_LINE_SIZE 32
148#define ICACHE_SET_BIT (1 << 13)
149#define ASI_ICACHE_TAG 0x67
150
151# Flush I-cache
152icache_flush:
153 set ((ICACHE_SIZE - ICACHE_LINE_SIZE) | ICACHE_SET_BIT), %g1
154 stxa %g0, [%g1] ASI_ICACHE_TAG
155
156 0:
157 membar #Sync
158 subcc %g1, ICACHE_LINE_SIZE, %g1
159 bnz,pt %xcc, 0b
160
161 stxa %g0, [%g1] ASI_ICACHE_TAG
162 membar #Sync
163 retl
164 ! SF Erratum #51
165 nop
166
167.global ofw
168ofw:
169 save %sp, -STACK_WINDOW_SAVE_AREA_SIZE, %sp
170 set ofw_cif, %l0
171 ldx [%l0], %l0
172
173 rdpr %pstate, %l1
174 and %l1, ~PSTATE_AM_BIT, %l2
175 wrpr %l2, 0, %pstate
176
177 jmpl %l0, %o7
178 mov %i0, %o0
179
180 wrpr %l1, 0, %pstate
181
182 ret
183 restore %o0, 0, %o0
Note: See TracBrowser for help on using the repository browser.