Changeset 46c20c8 in mainline for kernel/arch/sparc64/src
- Timestamp:
- 2010-11-26T20:08:10Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 45df59a
- Parents:
- fb150d78 (diff), ffdd2b9 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)links above to see all the changes relative to each parent. - Location:
- kernel/arch/sparc64/src
- Files:
-
- 17 added
- 1 deleted
- 15 edited
- 13 moved
-
asm.S (modified) (6 diffs)
-
console.c (modified) (4 diffs)
-
cpu/sun4u/cpu.c (moved) (moved from kernel/arch/sparc64/src/cpu/cpu.c ) (1 diff)
-
cpu/sun4v/cpu.c (added)
-
ddi/ddi.c (modified) (1 diff)
-
debug/stacktrace.c (modified) (1 diff)
-
debug/stacktrace_asm.S (modified) (1 diff)
-
drivers/fhc.c (modified) (1 diff)
-
drivers/kbd.c (modified) (1 diff)
-
drivers/niagara.c (added)
-
drivers/pci.c (modified) (2 diffs)
-
drivers/scr.c (modified) (3 diffs)
-
drivers/sgcn.c (modified) (2 diffs)
-
drivers/tick.c (modified) (4 diffs)
-
mm/cache.S (deleted)
-
mm/page.c (modified) (1 diff)
-
mm/sun4u/as.c (moved) (moved from kernel/arch/sparc64/src/mm/as.c ) (12 diffs)
-
mm/sun4u/frame.c (added)
-
mm/sun4u/tlb.c (moved) (moved from kernel/arch/sparc64/src/mm/tlb.c ) (13 diffs)
-
mm/sun4u/tsb.c (moved) (moved from kernel/arch/sparc64/src/mm/tsb.c ) (1 diff)
-
mm/sun4v/as.c (added)
-
mm/sun4v/frame.c (moved) (moved from kernel/arch/sparc64/src/mm/frame.c ) (2 diffs)
-
mm/sun4v/tlb.c (added)
-
mm/sun4v/tsb.c (added)
-
proc/sun4u/scheduler.c (moved) (moved from kernel/arch/sparc64/src/proc/scheduler.c )
-
proc/sun4v/scheduler.c (added)
-
smp/sun4u/ipi.c (moved) (moved from kernel/arch/sparc64/src/smp/ipi.c ) (2 diffs)
-
smp/sun4u/smp.c (moved) (moved from kernel/arch/sparc64/src/smp/smp.c ) (2 diffs)
-
smp/sun4v/ipi.c (added)
-
smp/sun4v/smp.c (added)
-
sun4u/asm.S (added)
-
sun4u/sparc64.c (added)
-
sun4u/start.S (moved) (moved from kernel/arch/sparc64/src/start.S ) (7 diffs)
-
sun4v/asm.S (moved) (moved from boot/arch/arm32/loader/asm.S ) (2 diffs)
-
sun4v/md.c (added)
-
sun4v/sparc64.c (moved) (moved from kernel/arch/sparc64/src/sparc64.c ) (3 diffs)
-
sun4v/start.S (added)
-
trap/exception.c (modified) (20 diffs)
-
trap/interrupt.c (modified) (3 diffs)
-
trap/sun4u/interrupt.c (added)
-
trap/sun4u/mmu.S (moved) (moved from kernel/arch/sparc64/src/trap/mmu.S )
-
trap/sun4u/trap_table.S (moved) (moved from kernel/arch/sparc64/src/trap/trap_table.S ) (2 diffs)
-
trap/sun4v/interrupt.c (added)
-
trap/sun4v/mmu.S (added)
-
trap/sun4v/trap_table.S (added)
-
trap/trap.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/sparc64/src/asm.S
rfb150d78 r46c20c8 1 # 2 #Copyright (c) 2005 Jakub Jermar3 #All rights reserved.4 # 5 #Redistribution and use in source and binary forms, with or without6 #modification, are permitted provided that the following conditions7 #are met:8 # 9 #- Redistributions of source code must retain the above copyright10 #notice, this list of conditions and the following disclaimer.11 #- Redistributions in binary form must reproduce the above copyright12 #notice, this list of conditions and the following disclaimer in the13 #documentation and/or other materials provided with the distribution.14 #- The name of the author may not be used to endorse or promote products15 #derived from this software without specific prior written permission.16 # 17 #THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR18 #IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES19 #OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.20 #IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,21 #INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT22 #NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,23 #DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY24 #THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT25 #(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF26 #THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.27 # 1 /* 2 * Copyright (c) 2005 Jakub Jermar 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 9 * - Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * - Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * - The name of the author may not be used to endorse or promote products 15 * derived from this software without specific prior written permission. 16 * 17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 */ 28 28 29 29 #include <arch/arch.h> 30 30 #include <arch/stack.h> 31 #include <arch/regdef.h>32 #include <arch/mm/mmu.h>33 31 34 32 .text 35 33 36 .register %g2, #scratch37 .register %g3, #scratch34 .register %g2, #scratch 35 .register %g3, #scratch 38 36 39 37 /* … … 42 40 .global memcpy 43 41 memcpy: 44 mov %o0, %o3 ! save dst 45 add %o1, 7, %g1 46 and %g1, -8, %g1 47 cmp %o1, %g1 48 be,pn %xcc, 3f 49 add %o0, 7, %g1 50 mov 0, %g3 51 0: 52 brz,pn %o2, 2f 53 mov 0, %g2 54 1: 55 ldub [%g3 + %o1], %g1 56 add %g2, 1, %g2 57 cmp %o2, %g2 58 stb %g1, [%g3 + %o0] 59 bne,pt %xcc, 1b 60 mov %g2, %g3 61 2: 62 jmp %o7 + 8 ! exit point 63 mov %o3, %o0 64 3: 65 and %g1, -8, %g1 66 cmp %o0, %g1 67 bne,pt %xcc, 0b 68 mov 0, %g3 69 srlx %o2, 3, %g4 70 brz,pn %g4, 5f 71 mov 0, %g5 72 4: 73 sllx %g3, 3, %g2 74 add %g5, 1, %g3 75 ldx [%o1 + %g2], %g1 76 mov %g3, %g5 77 cmp %g4, %g3 78 bne,pt %xcc, 4b 79 stx %g1, [%o0 + %g2] 80 5: 81 and %o2, 7, %o2 82 brz,pn %o2, 2b 83 sllx %g4, 3, %g1 84 mov 0, %g2 85 add %g1, %o0, %o0 86 add %g1, %o1, %g4 87 mov 0, %g3 88 6: 89 ldub [%g2 + %g4], %g1 90 stb %g1, [%g2 + %o0] 91 add %g3, 1, %g2 92 cmp %o2, %g2 93 bne,pt %xcc, 6b 94 mov %g2, %g3 95 96 jmp %o7 + 8 ! exit point 97 mov %o3, %o0 42 mov %o0, %o3 /* save dst */ 43 add %o1, 7, %g1 44 and %g1, -8, %g1 45 cmp %o1, %g1 46 be,pn %xcc, 3f 47 add %o0, 7, %g1 48 mov 0, %g3 49 50 0: 51 52 brz,pn %o2, 2f 53 mov 0, %g2 54 55 1: 56 57 ldub [%g3 + %o1], %g1 58 add %g2, 1, %g2 59 cmp %o2, %g2 60 stb %g1, [%g3 + %o0] 61 bne,pt %xcc, 1b 62 mov %g2, %g3 63 64 2: 65 66 jmp %o7 + 8 /* exit point */ 67 mov %o3, %o0 68 69 3: 70 71 and %g1, -8, %g1 72 cmp %o0, %g1 73 bne,pt %xcc, 0b 74 mov 0, %g3 75 srlx %o2, 3, %g4 76 brz,pn %g4, 5f 77 mov 0, %g5 78 79 4: 80 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 91 and %o2, 7, %o2 92 brz,pn %o2, 2b 93 sllx %g4, 3, %g1 94 mov 0, %g2 95 add %g1, %o0, %o0 96 add %g1, %o1, %g4 97 mov 0, %g3 98 99 6: 100 101 ldub [%g2 + %g4], %g1 102 stb %g1, [%g2 + %o0] 103 add %g3, 1, %g2 104 cmp %o2, %g2 105 bne,pt %xcc, 6b 106 mov %g2, %g3 107 108 jmp %o7 + 8 /* exit point */ 109 mov %o3, %o0 98 110 99 111 /* … … 102 114 .global memcpy_from_uspace 103 115 memcpy_from_uspace: 104 mov %o0, %o3 ! save dst 105 add %o1, 7, %g1 106 and %g1, -8, %g1 107 cmp %o1, %g1 108 be,pn %xcc, 3f 109 add %o0, 7, %g1 110 mov 0, %g3 111 0: 112 brz,pn %o2, 2f 113 mov 0, %g2 114 1: 115 lduba [%g3 + %o1] ASI_AIUS, %g1 116 add %g2, 1, %g2 117 cmp %o2, %g2 118 stb %g1, [%g3 + %o0] 119 bne,pt %xcc, 1b 120 mov %g2, %g3 121 2: 122 jmp %o7 + 8 ! exit point 123 mov %o3, %o0 124 3: 125 and %g1, -8, %g1 126 cmp %o0, %g1 127 bne,pt %xcc, 0b 128 mov 0, %g3 129 srlx %o2, 3, %g4 130 brz,pn %g4, 5f 131 mov 0, %g5 132 4: 133 sllx %g3, 3, %g2 134 add %g5, 1, %g3 135 ldxa [%o1 + %g2] ASI_AIUS, %g1 136 mov %g3, %g5 137 cmp %g4, %g3 138 bne,pt %xcc, 4b 139 stx %g1, [%o0 + %g2] 140 5: 141 and %o2, 7, %o2 142 brz,pn %o2, 2b 143 sllx %g4, 3, %g1 144 mov 0, %g2 145 add %g1, %o0, %o0 146 add %g1, %o1, %g4 147 mov 0, %g3 148 6: 149 lduba [%g2 + %g4] ASI_AIUS, %g1 150 stb %g1, [%g2 + %o0] 151 add %g3, 1, %g2 152 cmp %o2, %g2 153 bne,pt %xcc, 6b 154 mov %g2, %g3 155 156 jmp %o7 + 8 ! exit point 157 mov %o3, %o0 116 mov %o0, %o3 /* save dst */ 117 add %o1, 7, %g1 118 and %g1, -8, %g1 119 cmp %o1, %g1 120 be,pn %xcc, 3f 121 add %o0, 7, %g1 122 mov 0, %g3 123 124 0: 125 126 brz,pn %o2, 2f 127 mov 0, %g2 128 129 1: 130 131 lduba [%g3 + %o1] ASI_AIUS, %g1 132 add %g2, 1, %g2 133 cmp %o2, %g2 134 stb %g1, [%g3 + %o0] 135 bne,pt %xcc, 1b 136 mov %g2, %g3 137 138 2: 139 140 jmp %o7 + 8 /* exit point */ 141 mov %o3, %o0 142 143 3: 144 145 and %g1, -8, %g1 146 cmp %o0, %g1 147 bne,pt %xcc, 0b 148 mov 0, %g3 149 srlx %o2, 3, %g4 150 brz,pn %g4, 5f 151 mov 0, %g5 152 153 4: 154 155 sllx %g3, 3, %g2 156 add %g5, 1, %g3 157 ldxa [%o1 + %g2] ASI_AIUS, %g1 158 mov %g3, %g5 159 cmp %g4, %g3 160 bne,pt %xcc, 4b 161 stx %g1, [%o0 + %g2] 162 163 5: 164 165 and %o2, 7, %o2 166 brz,pn %o2, 2b 167 sllx %g4, 3, %g1 168 mov 0, %g2 169 add %g1, %o0, %o0 170 add %g1, %o1, %g4 171 mov 0, %g3 172 173 6: 174 175 lduba [%g2 + %g4] ASI_AIUS, %g1 176 stb %g1, [%g2 + %o0] 177 add %g3, 1, %g2 178 cmp %o2, %g2 179 bne,pt %xcc, 6b 180 mov %g2, %g3 181 182 jmp %o7 + 8 /* exit point */ 183 mov %o3, %o0 158 184 159 185 /* … … 162 188 .global memcpy_to_uspace 163 189 memcpy_to_uspace: 164 mov %o0, %o3 ! save dst 165 add %o1, 7, %g1 166 and %g1, -8, %g1 167 cmp %o1, %g1 168 be,pn %xcc, 3f 169 add %o0, 7, %g1 170 mov 0, %g3 171 0: 172 brz,pn %o2, 2f 173 mov 0, %g2 174 1: 175 ldub [%g3 + %o1], %g1 176 add %g2, 1, %g2 177 cmp %o2, %g2 178 stba %g1, [%g3 + %o0] ASI_AIUS 179 bne,pt %xcc, 1b 180 mov %g2, %g3 181 2: 182 jmp %o7 + 8 ! exit point 183 mov %o3, %o0 184 3: 185 and %g1, -8, %g1 186 cmp %o0, %g1 187 bne,pt %xcc, 0b 188 mov 0, %g3 189 srlx %o2, 3, %g4 190 brz,pn %g4, 5f 191 mov 0, %g5 192 4: 193 sllx %g3, 3, %g2 194 add %g5, 1, %g3 195 ldx [%o1 + %g2], %g1 196 mov %g3, %g5 197 cmp %g4, %g3 198 bne,pt %xcc, 4b 199 stxa %g1, [%o0 + %g2] ASI_AIUS 200 5: 201 and %o2, 7, %o2 202 brz,pn %o2, 2b 203 sllx %g4, 3, %g1 204 mov 0, %g2 205 add %g1, %o0, %o0 206 add %g1, %o1, %g4 207 mov 0, %g3 208 6: 209 ldub [%g2 + %g4], %g1 210 stba %g1, [%g2 + %o0] ASI_AIUS 211 add %g3, 1, %g2 212 cmp %o2, %g2 213 bne,pt %xcc, 6b 214 mov %g2, %g3 215 216 jmp %o7 + 8 ! exit point 217 mov %o3, %o0 190 mov %o0, %o3 /* save dst */ 191 add %o1, 7, %g1 192 and %g1, -8, %g1 193 cmp %o1, %g1 194 be,pn %xcc, 3f 195 add %o0, 7, %g1 196 mov 0, %g3 197 198 0: 199 200 brz,pn %o2, 2f 201 mov 0, %g2 202 203 1: 204 205 ldub [%g3 + %o1], %g1 206 add %g2, 1, %g2 207 cmp %o2, %g2 208 stba %g1, [%g3 + %o0] ASI_AIUS 209 bne,pt %xcc, 1b 210 mov %g2, %g3 211 212 2: 213 214 jmp %o7 + 8 /* exit point */ 215 mov %o3, %o0 216 217 3: 218 219 and %g1, -8, %g1 220 cmp %o0, %g1 221 bne,pt %xcc, 0b 222 mov 0, %g3 223 srlx %o2, 3, %g4 224 brz,pn %g4, 5f 225 mov 0, %g5 226 227 4: 228 229 sllx %g3, 3, %g2 230 add %g5, 1, %g3 231 ldx [%o1 + %g2], %g1 232 mov %g3, %g5 233 cmp %g4, %g3 234 bne,pt %xcc, 4b 235 stxa %g1, [%o0 + %g2] ASI_AIUS 236 237 5: 238 239 and %o2, 7, %o2 240 brz,pn %o2, 2b 241 sllx %g4, 3, %g1 242 mov 0, %g2 243 add %g1, %o0, %o0 244 add %g1, %o1, %g4 245 mov 0, %g3 246 247 6: 248 249 ldub [%g2 + %g4], %g1 250 stba %g1, [%g2 + %o0] ASI_AIUS 251 add %g3, 1, %g2 252 cmp %o2, %g2 253 bne,pt %xcc, 6b 254 mov %g2, %g3 255 256 jmp %o7 + 8 /* exit point */ 257 mov %o3, %o0 218 258 219 259 .global memcpy_from_uspace_failover_address … … 221 261 memcpy_from_uspace_failover_address: 222 262 memcpy_to_uspace_failover_address: 223 jmp %o7 + 8 ! exit point224 mov %g0, %o0 ! return 0 on failure263 jmp %o7 + 8 /* exit point */ 264 mov %g0, %o0 /* return 0 on failure */ 225 265 226 266 .global memsetb … … 234 274 nop 235 275 236 237 .macro WRITE_ALTERNATE_REGISTER reg, bit 238 rdpr %pstate, %g1 ! save PSTATE.PEF 239 wrpr %g0, (\bit | PSTATE_PRIV_BIT), %pstate 240 mov %o0, \reg 241 wrpr %g0, PSTATE_PRIV_BIT, %pstate 276 .global early_putchar 277 early_putchar: 242 278 retl 243 wrpr %g1, 0, %pstate ! restore PSTATE.PEF 244 .endm 245 246 .macro READ_ALTERNATE_REGISTER reg, bit 247 rdpr %pstate, %g1 ! save PSTATE.PEF 248 wrpr %g0, (\bit | PSTATE_PRIV_BIT), %pstate 249 mov \reg, %o0 250 wrpr %g0, PSTATE_PRIV_BIT, %pstate 251 retl 252 wrpr %g1, 0, %pstate ! restore PSTATE.PEF 253 .endm 254 255 .global write_to_ag_g6 256 write_to_ag_g6: 257 WRITE_ALTERNATE_REGISTER %g6, PSTATE_AG_BIT 258 259 .global write_to_ag_g7 260 write_to_ag_g7: 261 WRITE_ALTERNATE_REGISTER %g7, PSTATE_AG_BIT 262 263 .global write_to_ig_g6 264 write_to_ig_g6: 265 WRITE_ALTERNATE_REGISTER %g6, PSTATE_IG_BIT 266 267 .global read_from_ag_g7 268 read_from_ag_g7: 269 READ_ALTERNATE_REGISTER %g7, PSTATE_AG_BIT 270 271 272 /** Switch to userspace. 273 * 274 * %o0 Userspace entry address. 275 * %o1 Userspace stack pointer address. 276 * %o2 Userspace address of uarg structure. 277 */ 278 .global switch_to_userspace 279 switch_to_userspace: 280 save %o1, -(STACK_WINDOW_SAVE_AREA_SIZE + STACK_ARG_SAVE_AREA_SIZE), %sp 281 flushw 282 wrpr %g0, 0, %cleanwin ! avoid information leak 283 284 mov %i2, %o0 ! uarg 285 xor %o1, %o1, %o1 ! %o1 is defined to hold pcb_ptr 286 ! set it to 0 287 288 clr %i2 289 clr %i3 290 clr %i4 291 clr %i5 292 clr %i6 293 294 wrpr %g0, 1, %tl ! enforce mapping via nucleus 295 296 rdpr %cwp, %g1 297 wrpr %g1, TSTATE_IE_BIT, %tstate 298 wrpr %i0, 0, %tnpc 299 300 /* 301 * Set primary context according to secondary context. 302 * Secondary context has been already installed by 303 * higher-level functions. 304 */ 305 wr %g0, ASI_DMMU, %asi 306 ldxa [VA_SECONDARY_CONTEXT_REG] %asi, %g1 307 stxa %g1, [VA_PRIMARY_CONTEXT_REG] %asi 308 flush %i7 309 310 /* 311 * Spills and fills will be handled by the userspace handlers. 312 */ 313 wrpr %g0, WSTATE_OTHER(0) | WSTATE_NORMAL(1), %wstate 314 315 done ! jump to userspace 316 279 nop -
kernel/arch/sparc64/src/console.c
rfb150d78 r46c20c8 34 34 35 35 #include <arch/console.h> 36 #include < arch/types.h>36 #include <typedefs.h> 37 37 38 38 #include <arch/drivers/scr.h> … … 49 49 #include <arch.h> 50 50 #include <panic.h> 51 #include <str ing.h>51 #include <str.h> 52 52 #include <print.h> 53 53 … … 70 70 ofw_tree_node_t *screen = ofw_tree_lookup(prop_scr->value); 71 71 if (!screen) 72 panic("Cannot find %s.", prop_scr->value);72 panic("Cannot find %s.", (char *) prop_scr->value); 73 73 74 74 scr_init(screen); … … 83 83 ofw_tree_node_t *keyboard = ofw_tree_lookup(prop_kbd->value); 84 84 if (!keyboard) 85 panic("Cannot find %s.", prop_kbd->value);85 panic("Cannot find %s.", (char *) prop_kbd->value); 86 86 87 87 kbd_init(keyboard); -
kernel/arch/sparc64/src/cpu/sun4u/cpu.c
rfb150d78 r46c20c8 129 129 void cpu_print_report(cpu_t *m) 130 130 { 131 char *manuf, *impl; 131 const char *manuf; 132 const char *impl; 132 133 133 134 switch (m->arch.ver.manuf) { -
kernel/arch/sparc64/src/ddi/ddi.c
rfb150d78 r46c20c8 35 35 #include <ddi/ddi.h> 36 36 #include <proc/task.h> 37 #include < arch/types.h>37 #include <typedefs.h> 38 38 39 39 /** Enable I/O space range for task. -
kernel/arch/sparc64/src/debug/stacktrace.c
rfb150d78 r46c20c8 35 35 #include <stacktrace.h> 36 36 #include <syscall/copy.h> 37 #include <arch/types.h>38 37 #include <typedefs.h> 39 38 40 bool kernel_frame_pointer_validate(uintptr_t fp) 39 #include <arch.h> 40 #include <arch/stack.h> 41 #include <arch/trap/trap_table.h> 42 43 #if defined(SUN4V) 44 #include <arch/sun4v/arch.h> 45 #endif 46 47 #define FRAME_OFFSET_FP_PREV 14 48 #define FRAME_OFFSET_RA 15 49 50 extern void alloc_window_and_flush(void); 51 52 bool kernel_stack_trace_context_validate(stack_trace_context_t *ctx) 53 { 54 uintptr_t kstack; 55 56 #if defined(SUN4U) 57 kstack = read_from_ag_g6(); 58 #elif defined(SUN4V) 59 kstack = asi_u64_read(ASI_SCRATCHPAD, SCRATCHPAD_KSTACK); 60 #endif 61 62 kstack += STACK_BIAS; 63 kstack -= PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE; 64 65 if (THREAD && (ctx->fp == kstack)) 66 return false; 67 return ctx->fp != 0; 68 } 69 70 bool kernel_frame_pointer_prev(stack_trace_context_t *ctx, uintptr_t *prev) 71 { 72 uint64_t *stack = (void *) ctx->fp; 73 alloc_window_and_flush(); 74 *prev = stack[FRAME_OFFSET_FP_PREV] + STACK_BIAS; 75 return true; 76 } 77 78 bool kernel_return_address_get(stack_trace_context_t *ctx, uintptr_t *ra) 79 { 80 uint64_t *stack = (void *) ctx->fp; 81 alloc_window_and_flush(); 82 *ra = stack[FRAME_OFFSET_RA]; 83 return true; 84 } 85 86 bool uspace_stack_trace_context_validate(stack_trace_context_t *ctx) 41 87 { 42 88 return false; 43 89 } 44 90 45 bool kernel_frame_pointer_prev(uintptr_t fp, uintptr_t *prev)91 bool uspace_frame_pointer_prev(stack_trace_context_t *ctx, uintptr_t *prev) 46 92 { 47 93 return false; 48 94 } 49 95 50 bool kernel_return_address_get(uintptr_t fp, uintptr_t *ra) 51 { 52 return false; 53 } 54 55 bool uspace_frame_pointer_validate(uintptr_t fp) 56 { 57 return false; 58 } 59 60 bool uspace_frame_pointer_prev(uintptr_t fp, uintptr_t *prev) 61 { 62 return false; 63 } 64 65 bool uspace_return_address_get(uintptr_t fp, uintptr_t *ra) 96 bool uspace_return_address_get(stack_trace_context_t *ctx , uintptr_t *ra) 66 97 { 67 98 return false; -
kernel/arch/sparc64/src/debug/stacktrace_asm.S
rfb150d78 r46c20c8 27 27 # 28 28 29 #include <arch/stack.h> 30 29 31 .text 30 32 31 33 .global frame_pointer_get 32 34 .global program_counter_get 35 .global alloc_window_and_flush 33 36 34 37 frame_pointer_get: 38 # Add the stack bias to %sp to get the actual address. 35 39 retl 36 nop40 add %sp, STACK_BIAS, %o0 37 41 38 42 program_counter_get: 39 43 retl 40 nop44 mov %o7, %o0 41 45 46 alloc_window_and_flush: 47 save %sp, -(STACK_WINDOW_SAVE_AREA_SIZE+STACK_ARG_SAVE_AREA_SIZE), %sp 48 # Flush all other windows to memory so that we can read their contents. 49 flushw 50 ret 51 restore 52 -
kernel/arch/sparc64/src/drivers/fhc.c
rfb150d78 r46c20c8 44 44 #include <mm/page.h> 45 45 #include <mm/slab.h> 46 #include < arch/types.h>46 #include <typedefs.h> 47 47 #include <genarch/ofw/ofw_tree.h> 48 48 #include <genarch/ofw/fhc.h> -
kernel/arch/sparc64/src/drivers/kbd.c
rfb150d78 r46c20c8 39 39 #include <console/console.h> 40 40 #include <ddi/irq.h> 41 #include <mm/page.h> 41 42 #include <arch/mm/page.h> 42 #include < arch/types.h>43 #include <typedefs.h> 43 44 #include <align.h> 44 #include <str ing.h>45 #include <str.h> 45 46 #include <print.h> 46 47 #include <sysinfo/sysinfo.h> -
kernel/arch/sparc64/src/drivers/pci.c
rfb150d78 r46c20c8 41 41 #include <mm/page.h> 42 42 #include <mm/slab.h> 43 #include < arch/types.h>43 #include <typedefs.h> 44 44 #include <debug.h> 45 45 #include <print.h> 46 #include <str ing.h>46 #include <str.h> 47 47 #include <arch/asm.h> 48 48 #include <sysinfo/sysinfo.h> 49 49 50 50 #define SABRE_INTERNAL_REG 0 51 #define PSYCHO_INTERNAL_REG 2 51 #define PSYCHO_INTERNAL_REG 2 52 52 53 53 #define OBIO_IMR_BASE 0x200 … … 211 211 * Unsupported model. 212 212 */ 213 printf("Unsupported PCI controller model (%s).\n", prop->value); 213 printf("Unsupported PCI controller model (%s).\n", 214 (char *) prop->value); 214 215 } 215 216 -
kernel/arch/sparc64/src/drivers/scr.c
rfb150d78 r46c20c8 42 42 #include <console/chardev.h> 43 43 #include <console/console.h> 44 #include < arch/types.h>45 #include <str ing.h>44 #include <typedefs.h> 45 #include <str.h> 46 46 #include <align.h> 47 47 #include <print.h> … … 77 77 else if (str_cmp(name, "cgsix") == 0) 78 78 scr_type = SCR_CGSIX; 79 else if (str_cmp(name, "QEMU,VGA") == 0) 80 scr_type = SCR_QEMU_VGA; 79 81 80 82 if (scr_type == SCR_UNKNOWN) { … … 228 230 229 231 break; 232 233 case SCR_QEMU_VGA: 234 if (prop->size / sizeof(ofw_pci_reg_t) < 2) { 235 printf("Too few screen registers.\n"); 236 return; 237 } 238 239 pci_reg = &((ofw_pci_reg_t *) prop->value)[1]; 240 241 if (!ofw_pci_reg_absolutize(node, pci_reg, &pci_abs_reg)) { 242 printf("Failed to absolutize fb register.\n"); 243 return; 244 } 245 246 if (!ofw_pci_apply_ranges(node->parent, &pci_abs_reg, 247 &fb_addr)) { 248 printf("Failed to determine screen address.\n"); 249 return; 250 } 251 252 switch (fb_depth) { 253 case 8: 254 fb_scanline = fb_linebytes * (fb_depth >> 3); 255 visual = VISUAL_INDIRECT_8; 256 break; 257 case 16: 258 fb_scanline = fb_linebytes * (fb_depth >> 3); 259 visual = VISUAL_RGB_5_6_5_BE; 260 break; 261 case 24: 262 fb_scanline = fb_linebytes * 4; 263 visual = VISUAL_BGR_8_8_8_0; 264 break; 265 case 32: 266 fb_scanline = fb_linebytes * (fb_depth >> 3); 267 visual = VISUAL_RGB_0_8_8_8; 268 break; 269 default: 270 printf("Unsupported bits per pixel.\n"); 271 return; 272 } 273 break; 274 230 275 default: 231 276 panic("Unexpected type."); -
kernel/arch/sparc64/src/drivers/sgcn.c
rfb150d78 r46c20c8 40 40 #include <genarch/ofw/ofw_tree.h> 41 41 #include <debug.h> 42 #include <str ing.h>42 #include <str.h> 43 43 #include <print.h> 44 44 #include <mm/page.h> … … 132 132 static void init_sram_begin(void) 133 133 { 134 ASSERT(instance) 134 ASSERT(instance); 135 135 136 136 ofw_tree_node_t *chosen = ofw_tree_lookup("/chosen"); -
kernel/arch/sparc64/src/drivers/tick.c
rfb150d78 r46c20c8 27 27 */ 28 28 29 /** @addtogroup sparc64 29 /** @addtogroup sparc64 30 30 * @{ 31 31 */ … … 54 54 interrupt_register(14, "tick_int", tick_interrupt); 55 55 compare.int_dis = false; 56 compare.tick_cmpr = CPU->arch.clock_frequency / HZ; 56 compare.tick_cmpr = tick_counter_read() + 57 CPU->arch.clock_frequency / HZ; 57 58 CPU->arch.next_tick_cmpr = compare.tick_cmpr; 58 59 tick_compare_write(compare.value); 59 tick_write(0);60 60 61 #if defined (US3) 61 #if defined (US3) || defined (SUN4V) 62 62 /* disable STICK interrupts and clear any pending ones */ 63 63 tick_compare_reg_t stick_compare; … … 77 77 /** Process tick interrupt. 78 78 * 79 * @param n Interrupt Level, 14, (can be ignored)79 * @param n Interrupt Level (14, can be ignored) 80 80 * @param istate Interrupted state. 81 * 81 82 */ 82 void tick_interrupt( int n, istate_t *istate)83 void tick_interrupt(unsigned int n, istate_t *istate) 83 84 { 84 85 softint_reg_t softint, clear; … … 111 112 * overflow only in 146 years. 112 113 */ 113 drift = tick_ read() - CPU->arch.next_tick_cmpr;114 drift = tick_counter_read() - CPU->arch.next_tick_cmpr; 114 115 while (drift > CPU->arch.clock_frequency / HZ) { 115 116 drift -= CPU->arch.clock_frequency / HZ; 116 117 CPU->missed_clock_ticks++; 117 118 } 118 CPU->arch.next_tick_cmpr = tick_ read() +119 CPU->arch.next_tick_cmpr = tick_counter_read() + 119 120 (CPU->arch.clock_frequency / HZ) - drift; 120 121 tick_compare_write(CPU->arch.next_tick_cmpr); -
kernel/arch/sparc64/src/mm/page.c
rfb150d78 r46c20c8 33 33 */ 34 34 35 #include <mm/page.h> 35 36 #include <arch/mm/page.h> 36 37 #include <arch/mm/tlb.h> -
kernel/arch/sparc64/src/mm/sun4u/as.c
rfb150d78 r46c20c8 41 41 42 42 #ifdef CONFIG_TSB 43 43 44 #include <arch/mm/tsb.h> 44 45 #include <arch/memstr.h> … … 47 48 #include <bitops.h> 48 49 #include <macros.h> 50 49 51 #endif /* CONFIG_TSB */ 50 52 … … 58 60 } 59 61 60 int as_constructor_arch(as_t *as, int flags)62 int as_constructor_arch(as_t *as, unsigned int flags) 61 63 { 62 64 #ifdef CONFIG_TSB … … 64 66 * The order must be calculated with respect to the emulated 65 67 * 16K page size. 66 */ 67 int order = fnzb32(((ITSB_ENTRY_COUNT + DTSB_ENTRY_COUNT) * 68 * 69 */ 70 uint8_t order = fnzb32(((ITSB_ENTRY_COUNT + DTSB_ENTRY_COUNT) * 68 71 sizeof(tsb_entry_t)) >> FRAME_WIDTH); 69 72 70 73 uintptr_t tsb = (uintptr_t) frame_alloc(order, flags | FRAME_KA); 71 74 72 75 if (!tsb) 73 76 return -1; 74 77 75 78 as->arch.itsb = (tsb_entry_t *) tsb; 76 79 as->arch.dtsb = (tsb_entry_t *) (tsb + ITSB_ENTRY_COUNT * 77 80 sizeof(tsb_entry_t)); 78 81 79 82 memsetb(as->arch.itsb, 80 83 (ITSB_ENTRY_COUNT + DTSB_ENTRY_COUNT) * sizeof(tsb_entry_t), 0); 81 84 #endif 85 82 86 return 0; 83 87 } … … 93 97 sizeof(tsb_entry_t)) >> FRAME_WIDTH; 94 98 frame_free(KA2PA((uintptr_t) as->arch.itsb)); 99 95 100 return cnt; 96 101 #else … … 99 104 } 100 105 101 int as_create_arch(as_t *as, int flags)106 int as_create_arch(as_t *as, unsigned int flags) 102 107 { 103 108 #ifdef CONFIG_TSB 104 109 tsb_invalidate(as, 0, (size_t) -1); 105 110 #endif 111 106 112 return 0; 107 113 } … … 123 129 * 124 130 * Moreover, the as->asid is protected by asidlock, which is being held. 131 * 125 132 */ 126 133 … … 130 137 * secondary context register from the TL=1 code just before switch to 131 138 * userspace. 139 * 132 140 */ 133 141 ctx.v = 0; 134 142 ctx.context = as->asid; 135 143 mmu_secondary_context_write(ctx.v); 136 137 #ifdef CONFIG_TSB 144 145 #ifdef CONFIG_TSB 138 146 uintptr_t base = ALIGN_DOWN(config.base, 1 << KERNEL_PAGE_WIDTH); 139 147 140 148 ASSERT(as->arch.itsb && as->arch.dtsb); 141 149 142 150 uintptr_t tsb = (uintptr_t) as->arch.itsb; 143 151 144 152 if (!overlaps(tsb, 8 * MMU_PAGE_SIZE, base, 1 << KERNEL_PAGE_WIDTH)) { 145 153 /* … … 147 155 * by the locked 4M kernel DTLB entry. We need 148 156 * to map both TSBs explicitly. 157 * 149 158 */ 150 159 dtlb_demap(TLB_DEMAP_PAGE, TLB_DEMAP_NUCLEUS, tsb); 151 160 dtlb_insert_mapping(tsb, KA2PA(tsb), PAGESIZE_64K, true, true); 152 161 } 153 162 154 163 /* 155 164 * Setup TSB Base registers. 165 * 156 166 */ 157 167 tsb_base_reg_t tsb_base; 158 168 159 169 tsb_base.value = 0; 160 170 tsb_base.size = TSB_SIZE; 161 171 tsb_base.split = 0; 162 172 163 173 tsb_base.base = ((uintptr_t) as->arch.itsb) >> MMU_PAGE_WIDTH; 164 174 itsb_base_write(tsb_base.value); … … 175 185 * Clearing the extension registers will ensure that the value of the 176 186 * TSB Base register will be used as an address of TSB, making the code 177 * compatible with the US port. 187 * compatible with the US port. 188 * 178 189 */ 179 190 itsb_primary_extension_write(0); … … 195 206 void as_deinstall_arch(as_t *as) 196 207 { 197 198 208 /* 199 209 * Note that we don't and may not lock the address space. That's ok … … 201 211 * 202 212 * Moreover, the as->asid is protected by asidlock, which is being held. 203 */ 204 213 * 214 */ 215 205 216 #ifdef CONFIG_TSB 206 217 uintptr_t base = ALIGN_DOWN(config.base, 1 << KERNEL_PAGE_WIDTH); 207 218 208 219 ASSERT(as->arch.itsb && as->arch.dtsb); 209 220 210 221 uintptr_t tsb = (uintptr_t) as->arch.itsb; 211 222 212 223 if (!overlaps(tsb, 8 * MMU_PAGE_SIZE, base, 1 << KERNEL_PAGE_WIDTH)) { 213 224 /* -
kernel/arch/sparc64/src/mm/sun4u/tlb.c
rfb150d78 r46c20c8 27 27 */ 28 28 29 /** @addtogroup sparc64mm 29 /** @addtogroup sparc64mm 30 30 * @{ 31 31 */ … … 37 37 #include <mm/as.h> 38 38 #include <mm/asid.h> 39 #include <genarch/mm/page_ht.h>40 39 #include <arch/mm/frame.h> 41 40 #include <arch/mm/page.h> … … 45 44 #include <arch.h> 46 45 #include <print.h> 47 #include < arch/types.h>46 #include <typedefs.h> 48 47 #include <config.h> 49 48 #include <arch/trap/trap.h> … … 51 50 #include <panic.h> 52 51 #include <arch/asm.h> 52 #include <genarch/mm/page_ht.h> 53 53 54 54 #ifdef CONFIG_TSB … … 58 58 static void dtlb_pte_copy(pte_t *, size_t, bool); 59 59 static void itlb_pte_copy(pte_t *, size_t); 60 static void do_fast_instruction_access_mmu_miss_fault(istate_t *, const char *); 60 static void do_fast_instruction_access_mmu_miss_fault(istate_t *, uintptr_t, 61 const char *); 61 62 static void do_fast_data_access_mmu_miss_fault(istate_t *, tlb_tag_access_reg_t, 62 63 const char *); … … 64 65 tlb_tag_access_reg_t, const char *); 65 66 66 c har *context_encoding[] = {67 const char *context_encoding[] = { 67 68 "Primary", 68 69 "Secondary", … … 222 223 * Forward the page fault to the address space page fault 223 224 * handler. 224 */ 225 */ 225 226 page_table_unlock(AS, true); 226 227 if (as_page_fault(page_16k, PF_ACCESS_EXEC, istate) == 227 228 AS_PF_FAULT) { 228 229 do_fast_instruction_access_mmu_miss_fault(istate, 229 __func__);230 istate->tpc, __func__); 230 231 } 231 232 } … … 258 259 /* NULL access in kernel */ 259 260 do_fast_data_access_mmu_miss_fault(istate, tag, 260 __func__);261 "Dereferencing NULL pointer."); 261 262 } else if (page_8k >= end_of_identity) { 262 263 /* … … 359 360 static void print_tlb_entry(int i, tlb_tag_read_reg_t t, tlb_data_t d) 360 361 { 361 printf("% d: vpn=%#llx, context=%d, v=%d, size=%d, nfo=%d, "362 "ie=% d, soft2=%#x, pfn=%#x, soft=%#x, l=%d, "363 "cp=% d, cv=%d, e=%d, p=%d, w=%d, g=%d\n", i,t.vpn,362 printf("%u: vpn=%#" PRIx64 ", context=%u, v=%u, size=%u, nfo=%u, " 363 "ie=%u, soft2=%#x, pfn=%#x, soft=%#x, l=%u, " 364 "cp=%u, cv=%u, e=%u, p=%u, w=%u, g=%u\n", i, (uint64_t) t.vpn, 364 365 t.context, d.v, d.size, d.nfo, d.ie, d.soft2, 365 366 d.pfn, d.soft, d.l, d.cp, d.cv, d.e, d.p, d.w, d.g); … … 438 439 439 440 void do_fast_instruction_access_mmu_miss_fault(istate_t *istate, 440 const char *str) 441 { 442 fault_if_from_uspace(istate, "%s.", str); 443 dump_istate(istate); 444 panic("%s.", str); 441 uintptr_t va, const char *str) 442 { 443 fault_if_from_uspace(istate, "%s, address=%p.", str, (void *) va); 444 panic_memtrap(istate, PF_ACCESS_EXEC, va, str); 445 445 } 446 446 … … 451 451 452 452 va = tag.vpn << MMU_PAGE_WIDTH; 453 if (tag.context) { 454 fault_if_from_uspace(istate, "%s, Page=%p (ASID=%d).", str, va, 455 tag.context); 456 } 457 dump_istate(istate); 458 printf("Faulting page: %p, ASID=%d.\n", va, tag.context); 459 panic("%s.", str); 453 fault_if_from_uspace(istate, "%s, page=%p (asid=%u).", str, 454 (void *) va, tag.context); 455 panic_memtrap(istate, PF_ACCESS_UNKNOWN, va, str); 460 456 } 461 457 … … 466 462 467 463 va = tag.vpn << MMU_PAGE_WIDTH; 468 469 if (tag.context) { 470 fault_if_from_uspace(istate, "%s, Page=%p (ASID=%d).", str, va, 471 tag.context); 472 } 473 printf("Faulting page: %p, ASID=%d\n", va, tag.context); 474 dump_istate(istate); 475 panic("%s.", str); 476 } 477 478 void dump_sfsr_and_sfar(void) 464 fault_if_from_uspace(istate, "%s, page=%p (asid=%u).", str, 465 (void *) va, tag.context); 466 panic_memtrap(istate, PF_ACCESS_WRITE, va, str); 467 } 468 469 void describe_dmmu_fault(void) 479 470 { 480 471 tlb_sfsr_reg_t sfsr; … … 493 484 sfsr.e, sfsr.ct, sfsr.pr, sfsr.w, sfsr.ow, sfsr.fv); 494 485 #endif 486 487 printf("DTLB SFAR: address=%p\n", (void *) sfar); 488 489 dtlb_sfsr_write(0); 490 } 491 492 void dump_sfsr_and_sfar(void) 493 { 494 tlb_sfsr_reg_t sfsr; 495 uintptr_t sfar; 496 497 sfsr.value = dtlb_sfsr_read(); 498 sfar = dtlb_sfar_read(); 499 500 #if defined (US) 501 printf("DTLB SFSR: asi=%#x, ft=%#x, e=%d, ct=%d, pr=%d, w=%d, ow=%d, " 502 "fv=%d\n", sfsr.asi, sfsr.ft, sfsr.e, sfsr.ct, sfsr.pr, sfsr.w, 503 sfsr.ow, sfsr.fv); 504 #elif defined (US3) 505 printf("DTLB SFSR: nf=%d, asi=%#x, tm=%d, ft=%#x, e=%d, ct=%d, pr=%d, " 506 "w=%d, ow=%d, fv=%d\n", sfsr.nf, sfsr.asi, sfsr.tm, sfsr.ft, 507 sfsr.e, sfsr.ct, sfsr.pr, sfsr.w, sfsr.ow, sfsr.fv); 508 #endif 495 509 496 printf("DTLB SFAR: address=%p\n", sfar);510 printf("DTLB SFAR: address=%p\n", (void *) sfar); 497 511 498 512 dtlb_sfsr_write(0); -
kernel/arch/sparc64/src/mm/sun4u/tsb.c
rfb150d78 r46c20c8 38 38 #include <arch/barrier.h> 39 39 #include <mm/as.h> 40 #include < arch/types.h>40 #include <typedefs.h> 41 41 #include <macros.h> 42 42 #include <debug.h> -
kernel/arch/sparc64/src/mm/sun4v/frame.c
rfb150d78 r46c20c8 36 36 #include <mm/frame.h> 37 37 #include <arch/boot/boot.h> 38 #include < arch/types.h>38 #include <typedefs.h> 39 39 #include <config.h> 40 40 #include <align.h> 41 41 #include <macros.h> 42 42 43 uintptr_t last_frame = NULL; 44 45 /** Create memory zones according to information stored in bootinfo. 43 /** Create memory zones according to information stored in memmap. 46 44 * 47 * Walk the bootinfomemory map and create frame zones according to it.45 * Walk the memory map and create frame zones according to it. 48 46 */ 49 47 void frame_arch_init(void) 50 48 { 51 unsigned int i;52 pfn_t confdata;53 54 49 if (config.cpu_active == 1) { 55 for (i = 0; i < bootinfo.memmap.count; i++) { 56 uintptr_t start = bootinfo.memmap.zones[i].start; 57 size_t size = bootinfo.memmap.zones[i].size; 58 50 unsigned int i; 51 52 for (i = 0; i < memmap.cnt; i++) { 53 /* To be safe, make the available zone possibly smaller */ 54 uintptr_t new_start = ALIGN_UP((uintptr_t) memmap.zones[i].start, 55 FRAME_SIZE); 56 size_t new_size = ALIGN_DOWN(memmap.zones[i].size - 57 (new_start - ((uintptr_t) memmap.zones[i].start)), FRAME_SIZE); 58 59 59 /* 60 60 * The memmap is created by HelenOS boot loader. 61 61 * It already contains no holes. 62 62 */ 63 64 confdata = ADDR2PFN(start); 63 64 pfn_t confdata = ADDR2PFN(new_start); 65 65 66 if (confdata == ADDR2PFN(KA2PA(PFN2ADDR(0)))) 66 67 confdata = ADDR2PFN(KA2PA(PFN2ADDR(2))); 67 zone_create(ADDR2PFN(start),68 SIZE2FRAMES(ALIGN_DOWN(size, FRAME_SIZE)),68 69 zone_create(ADDR2PFN(new_start), SIZE2FRAMES(new_size), 69 70 confdata, 0); 70 last_frame = max(last_frame, start + ALIGN_UP(size,71 FRAME_SIZE));72 71 } 73 72 74 73 /* 75 74 * On sparc64, physical memory can start on a non-zero address. … … 80 79 frame_mark_unavailable(ADDR2PFN(KA2PA(PFN2ADDR(0))), 1); 81 80 } 82 83 end_of_identity = PA2KA(last_frame);84 81 } 85 82 -
kernel/arch/sparc64/src/smp/sun4u/ipi.c
rfb150d78 r46c20c8 99 99 status = asi_u64_read(ASI_INTR_DISPATCH_STATUS, 0); 100 100 if (status & INTR_DISPATCH_STATUS_BUSY) 101 panic("Interrupt Dispatch Status busy bit set .");101 panic("Interrupt Dispatch Status busy bit set\n"); 102 102 103 103 ASSERT(!(pstate_read() & PSTATE_IE_BIT)); … … 152 152 break; 153 153 default: 154 panic("Unknown IPI (%d). ", ipi);154 panic("Unknown IPI (%d).\n", ipi); 155 155 break; 156 156 } -
kernel/arch/sparc64/src/smp/sun4u/smp.c
rfb150d78 r46c20c8 41 41 #include <config.h> 42 42 #include <macros.h> 43 #include < arch/types.h>43 #include <typedefs.h> 44 44 #include <synch/synch.h> 45 45 #include <synch/waitq.h> … … 62 62 { 63 63 ofw_tree_node_t *node; 64 size_t cnt = 0;64 unsigned int cnt = 0; 65 65 66 66 if (is_us() || is_us_iii()) { -
kernel/arch/sparc64/src/sun4u/start.S
rfb150d78 r46c20c8 36 36 #include <arch/mm/tlb.h> 37 37 #include <arch/mm/tte.h> 38 #include <arch/mm/cache_spec.h> 38 39 39 40 #ifdef CONFIG_SMP … … 60 61 /* 61 62 * Here is where the kernel is passed control from the boot loader. 62 * 63 * 63 64 * The registers are expected to be in this state: 64 * - %o0 starting address of physical memory + bootstrap processor flag 65 * bits 63...1: physical memory starting address / 2 66 * bit 0: non-zero on BSP processor, zero on AP processors 67 * - %o1 bootinfo structure address (BSP only) 68 * - %o2 bootinfo structure size (BSP only) 65 * - %o0 starting address of physical memory 66 * + bootstrap processor flag 67 * bits 63...1: physical memory starting address / 2 68 * bit 0: non-zero on BSP processor, zero on AP processors 69 * - %o1 bootinfo structure address (BSP only) 70 * 69 71 * 70 72 * Moreover, we depend on boot having established the following environment: 71 * - TLBs are on 72 * - identity mapping for the kernel image 73 * - TLBs are on 74 * - identity mapping for the kernel image 75 * 73 76 */ 74 77 … … 267 270 or %l3, %l5, %l3 268 271 stx %l3, [%l4 + %lo(kernel_8k_tlb_data_template)] 269 270 /* 271 * Flush D-Cache. 272 */ 273 call dcache_flush 274 nop 275 272 273 ! flush the whole D-cache 274 set (DCACHE_SIZE - DCACHE_LINE_SIZE), %g1 275 stxa %g0, [%g1] ASI_DCACHE_TAG 276 277 0: 278 membar #Sync 279 subcc %g1, DCACHE_LINE_SIZE, %g1 280 bnz,pt %xcc, 0b 281 stxa %g0, [%g1] ASI_DCACHE_TAG 282 membar #Sync 283 276 284 /* 277 285 * So far, we have not touched the stack. … … 281 289 or %sp, %lo(temporary_boot_stack), %sp 282 290 sub %sp, STACK_BIAS, %sp 283 284 sethi %hi(bootinfo), %o0 285 call memcpy ! copy bootinfo 286 or %o0, %lo(bootinfo), %o0 287 291 292 /* 293 * Call arch_pre_main(bootinfo) 294 */ 288 295 call arch_pre_main 289 nop 290 296 mov %o1, %o0 297 298 /* 299 * Create the first stack frame. 300 */ 301 save %sp, -(STACK_WINDOW_SAVE_AREA_SIZE + STACK_ARG_SAVE_AREA_SIZE), %sp 302 flushw 303 add %g0, -STACK_BIAS, %fp 304 291 305 call main_bsp 292 306 nop … … 295 309 296 310 0: 297 ba %xcc, 0b 298 nop 311 ba,a %xcc, 0b 299 312 300 313 … … 346 359 ldx [%g1], %o6 347 360 361 /* 362 * Create the first stack frame. 363 */ 364 save %sp, -(STACK_WINDOW_SAVE_AREA_SIZE + STACK_ARG_SAVE_AREA_SIZE), %sp 365 flushw 366 add %g0, -STACK_BIAS, %fp 367 348 368 call main_ap 349 369 nop … … 353 373 354 374 0: 355 ba %xcc, 0b 356 nop 375 ba,a %xcc, 0b 357 376 358 377 -
kernel/arch/sparc64/src/sun4v/asm.S
rfb150d78 r46c20c8 1 1 # 2 # Copyright (c) 200 7 Michal Kebrt2 # Copyright (c) 2008 Pavel Rimsky 3 3 # All rights reserved. 4 4 # … … 27 27 # 28 28 29 #include <arch/mm/mmu.h> 30 #include <arch/regdef.h> 31 #include <arch/stack.h> 29 32 30 33 .text 31 34 32 .global memcpy 35 /** Switch to userspace. 36 * 37 * %o0 Userspace entry address. 38 * %o1 Userspace stack pointer address. 39 * %o2 Userspace address of uarg structure. 40 */ 41 .global switch_to_userspace 42 switch_to_userspace: 43 wrpr PSTATE_PRIV_BIT, %pstate 44 save %o1, -STACK_WINDOW_SAVE_AREA_SIZE, %sp 45 flushw 46 wrpr %g0, 0, %cleanwin ! avoid information leak 33 47 34 memcpy: 35 add r3, r1, #3 36 bic r3, r3, #3 37 cmp r1, r3 38 stmdb sp!, {r4, r5, lr} 39 mov r5, r0 40 beq 4f 41 1: 42 cmp r2, #0 43 movne ip, #0 44 beq 3f 45 2: 46 ldrb r3, [ip, r1] 47 strb r3, [ip, r0] 48 add ip, ip, #1 49 cmp ip, r2 50 bne 2b 51 3: 52 mov r0, r5 53 ldmia sp!, {r4, r5, pc} 54 4: 55 add r3, r0, #3 56 bic r3, r3, #3 57 cmp r0, r3 58 bne 1b 59 movs r4, r2, lsr #2 60 moveq lr, r4 61 beq 6f 62 mov lr, #0 63 mov ip, lr 64 5: 65 ldr r3, [ip, r1] 66 add lr, lr, #1 67 cmp lr, r4 68 str r3, [ip, r0] 69 add ip, ip, #4 70 bne 5b 71 6: 72 ands r4, r2, #3 73 beq 3b 74 mov r3, lr, lsl #2 75 add r0, r3, r0 76 add ip, r3, r1 77 mov r2, #0 78 7: 79 ldrb r3, [r2, ip] 80 strb r3, [r2, r0] 81 add r2, r2, #1 82 cmp r2, r4 83 bne 7b 84 b 3b 48 mov %i2, %o0 ! uarg 49 xor %o1, %o1, %o1 ! %o1 is defined to hold pcb_ptr 50 ! set it to 0 51 clr %i2 52 clr %i3 53 clr %i4 54 clr %i5 55 clr %i6 56 wrpr %g0, 1, %tl ! enforce mapping via nucleus 85 57 58 rdpr %cwp, %g1 59 wrpr %g1, TSTATE_IE_BIT, %tstate 60 wrpr %i0, 0, %tnpc 61 62 /* 63 * Set primary context according to secondary context. 64 * Secondary context has been already installed by 65 * higher-level functions. 66 */ 67 wr %g0, ASI_SECONDARY_CONTEXT_REG, %asi 68 ldxa [VA_SECONDARY_CONTEXT_REG] %asi, %g1 69 wr %g0, ASI_PRIMARY_CONTEXT_REG, %asi 70 stxa %g1, [VA_PRIMARY_CONTEXT_REG] %asi 71 flush %i7 86 72 73 /* 74 * Spills and fills will be handled by the userspace handlers. 75 */ 76 wrpr %g0, WSTATE_OTHER(0) | WSTATE_NORMAL(1), %wstate 77 done ! jump to userspace -
kernel/arch/sparc64/src/sun4v/sparc64.c
rfb150d78 r46c20c8 36 36 #include <debug.h> 37 37 #include <config.h> 38 #include <macros.h> 38 39 #include <arch/trap/trap.h> 39 40 #include <arch/console.h> 41 #include <arch/sun4v/md.h> 40 42 #include <console/console.h> 41 43 #include <arch/boot/boot.h> … … 48 50 #include <userspace.h> 49 51 #include <ddi/irq.h> 50 #include <string.h> 52 #include <str.h> 53 #include <arch/drivers/niagara.h> 51 54 52 bootinfo_t bootinfo;55 memmap_t memmap; 53 56 54 57 /** Perform sparc64-specific initialization before main_bsp() is called. */ 55 void arch_pre_main( void)58 void arch_pre_main(bootinfo_t *bootinfo) 56 59 { 57 60 /* Copy init task info. */ 58 init.cnt = bootinfo.taskmap.count;61 init.cnt = min3(bootinfo->taskmap.cnt, TASKMAP_MAX_RECORDS, CONFIG_INIT_TASKS); 59 62 60 uint32_t i; 61 62 for (i = 0; i < bootinfo.taskmap.count; i++) { 63 init.tasks[i].addr = (uintptr_t) bootinfo.taskmap.tasks[i].addr; 64 init.tasks[i].size = bootinfo.taskmap.tasks[i].size; 63 size_t i; 64 for (i = 0; i < init.cnt; i++) { 65 init.tasks[i].addr = (uintptr_t) bootinfo->taskmap.tasks[i].addr; 66 init.tasks[i].size = bootinfo->taskmap.tasks[i].size; 65 67 str_cpy(init.tasks[i].name, CONFIG_TASK_NAME_BUFLEN, 66 bootinfo .taskmap.tasks[i].name);68 bootinfo->taskmap.tasks[i].name); 67 69 } 68 70 69 /* Copy boot allocations info. */ 70 ballocs.base = bootinfo.ballocs.base; 71 ballocs.size = bootinfo.ballocs.size; 71 /* Copy physical memory map. */ 72 memmap.total = bootinfo->memmap.total; 73 memmap.cnt = min(bootinfo->memmap.cnt, MEMMAP_MAX_RECORDS); 74 for (i = 0; i < memmap.cnt; i++) { 75 memmap.zones[i].start = bootinfo->memmap.zones[i].start; 76 memmap.zones[i].size = bootinfo->memmap.zones[i].size; 77 } 72 78 73 ofw_tree_init(bootinfo.ofw_root);79 md_init(); 74 80 } 75 81 … … 103 109 void arch_post_smp_init(void) 104 110 { 105 standalone_sparc64_console_init();111 niagarain_init(); 106 112 } 107 113 -
kernel/arch/sparc64/src/trap/exception.c
rfb150d78 r46c20c8 44 44 #include <symtab.h> 45 45 46 void dump_istate(istate_t *istate) 47 { 48 char *tpcs, *tnpcs; 49 50 tpcs = symtab_fmt_name_lookup(istate->tpc); 51 tnpcs = symtab_fmt_name_lookup(istate->tnpc); 52 46 void istate_decode(istate_t *istate) 47 { 48 const char *tpcs = symtab_fmt_name_lookup(istate->tpc); 49 const char *tnpcs = symtab_fmt_name_lookup(istate->tnpc); 50 53 51 printf("TSTATE=%#" PRIx64 "\n", istate->tstate); 54 52 printf("TPC=%#" PRIx64 " (%s)\n", istate->tpc, tpcs); … … 60 58 { 61 59 fault_if_from_uspace(istate, "%s.", __func__); 62 dump_istate(istate); 63 panic("%s.", __func__); 60 panic_badtrap(istate, n, "%s.", __func__); 64 61 } 65 62 … … 68 65 { 69 66 fault_if_from_uspace(istate, "%s.", __func__); 70 dump_istate(istate); 71 panic("%s.", __func__); 67 panic_badtrap(istate, n, "%s.", __func__); 72 68 } 73 69 … … 76 72 { 77 73 fault_if_from_uspace(istate, "%s.", __func__); 78 dump_istate(istate); 79 panic("%s.", __func__); 74 panic_badtrap(istate, n, "%s.", __func__); 80 75 } 81 76 … … 84 79 { 85 80 fault_if_from_uspace(istate, "%s.", __func__); 86 dump_istate(istate); 87 panic("%s.", __func__); 81 panic_badtrap(istate, n, "%s.", __func__); 88 82 } 89 83 … … 92 86 { 93 87 fault_if_from_uspace(istate, "%s.", __func__); 94 dump_istate(istate); 95 panic("%s.", __func__); 88 panic_badtrap(istate, n, "%s.", __func__); 96 89 } 97 90 … … 100 93 { 101 94 fault_if_from_uspace(istate, "%s.", __func__); 102 dump_istate(istate); 103 panic("%s.", __func__); 95 panic_badtrap(istate, n, "%s.", __func__); 104 96 } 105 97 … … 120 112 #else 121 113 fault_if_from_uspace(istate, "%s.", __func__); 122 dump_istate(istate); 123 panic("%s.", __func__); 114 panic_badtrap(istate, n, "%s.", __func__); 124 115 #endif 125 116 } … … 129 120 { 130 121 fault_if_from_uspace(istate, "%s.", __func__); 131 dump_istate(istate); 132 panic("%s.", __func__); 122 panic_badtrap(istate, n, "%s.", __func__); 133 123 } 134 124 … … 137 127 { 138 128 fault_if_from_uspace(istate, "%s.", __func__); 139 dump_istate(istate); 140 panic("%s.", __func__); 129 panic_badtrap(istate, n, "%s.", __func__); 141 130 } 142 131 … … 145 134 { 146 135 fault_if_from_uspace(istate, "%s.", __func__); 147 dump_istate(istate); 148 panic("%s.", __func__); 136 panic_badtrap(istate, n, "%s.", __func__); 149 137 } 150 138 … … 153 141 { 154 142 fault_if_from_uspace(istate, "%s.", __func__); 155 dump_istate(istate); 156 panic("%s.", __func__); 143 panic_badtrap(istate, n, "%s.", __func__); 157 144 } 158 145 … … 161 148 { 162 149 fault_if_from_uspace(istate, "%s.", __func__); 163 dump_istate(istate); 164 dump_sfsr_and_sfar(); 165 panic("%s.", __func__); 150 panic_badtrap(istate, n, "%s.", __func__); 166 151 } 167 152 … … 170 155 { 171 156 fault_if_from_uspace(istate, "%s.", __func__); 172 dump_istate(istate); 173 panic("%s.", __func__); 157 panic_badtrap(istate, n, "%s.", __func__); 174 158 } 175 159 … … 178 162 { 179 163 fault_if_from_uspace(istate, "%s.", __func__); 180 dump_istate(istate); 181 panic("%s.", __func__); 164 panic_badtrap(istate, n, "%s.", __func__); 182 165 } 183 166 … … 186 169 { 187 170 fault_if_from_uspace(istate, "%s.", __func__); 188 dump_istate(istate); 189 panic("%s.", __func__); 171 panic_badtrap(istate, n, "%s.", __func__); 190 172 } 191 173 … … 194 176 { 195 177 fault_if_from_uspace(istate, "%s.", __func__); 196 dump_istate(istate); 197 panic("%s.", __func__); 178 panic_badtrap(istate, n, "%s.", __func__); 198 179 } 199 180 … … 202 183 { 203 184 fault_if_from_uspace(istate, "%s.", __func__); 204 dump_istate(istate); 205 panic("%s.", __func__); 185 panic_badtrap(istate, n, "%s.", __func__); 206 186 } 207 187 … … 210 190 { 211 191 fault_if_from_uspace(istate, "%s.", __func__); 212 dump_istate(istate); 213 panic("%s.", __func__); 192 panic_badtrap(istate, n, "%s.", __func__); 214 193 } 215 194 … … 218 197 { 219 198 fault_if_from_uspace(istate, "%s.", __func__); 220 dump_istate(istate); 221 panic("%s.", __func__); 199 panic_badtrap(istate, n, "%s.", __func__); 222 200 } 223 201 -
kernel/arch/sparc64/src/trap/interrupt.c
rfb150d78 r46c20c8 1 1 /* 2 2 * Copyright (c) 2005 Jakub Jermar 3 * Copyright (c) 2009 Pavel Rimsky 3 4 * All rights reserved. 4 5 * … … 34 35 35 36 #include <arch/interrupt.h> 37 #include <arch/trap/interrupt.h> 36 38 #include <arch/sparc64.h> 37 #include <arch/trap/interrupt.h>38 39 #include <interrupt.h> 39 40 #include <ddi/irq.h> 40 #include < arch/types.h>41 #include <typedefs.h> 41 42 #include <debug.h> 42 43 #include <arch/asm.h> … … 50 51 /** Register Interrupt Level Handler. 51 52 * 52 * @param n Interrupt Level (1 - 15). 53 * @param name Short descriptive string. 54 * @param f Handler. 53 * @param n Interrupt Level (1 - 15). 54 * @param name Short descriptive string. 55 * @param handler Handler. 56 * 55 57 */ 56 void interrupt_register( int n, const char *name, iroutine f)58 void interrupt_register(unsigned int n, const char *name, iroutine_t handler) 57 59 { 58 ASSERT(n >= IVT_FIRST && n <= IVT_ITEMS); 60 ASSERT(n >= IVT_FIRST); 61 ASSERT(n <= IVT_ITEMS); 59 62 60 exc_register(n - 1, name, f); 61 } 62 63 /** Process hardware interrupt. 64 * 65 * @param n Ignored. 66 * @param istate Ignored. 67 */ 68 void interrupt(int n, istate_t *istate) 69 { 70 uint64_t status; 71 uint64_t intrcv; 72 uint64_t data0; 73 status = asi_u64_read(ASI_INTR_DISPATCH_STATUS, 0); 74 if (status & (!INTR_DISPATCH_STATUS_BUSY)) 75 panic("Interrupt Dispatch Status busy bit not set."); 76 77 intrcv = asi_u64_read(ASI_INTR_RECEIVE, 0); 78 #if defined (US) 79 data0 = asi_u64_read(ASI_INTR_R, ASI_UDB_INTR_R_DATA_0); 80 #elif defined (US3) 81 data0 = asi_u64_read(ASI_INTR_R, VA_INTR_R_DATA_0); 82 #endif 83 84 irq_t *irq = irq_dispatch_and_lock(data0); 85 if (irq) { 86 /* 87 * The IRQ handler was found. 88 */ 89 irq->handler(irq); 90 /* 91 * See if there is a clear-interrupt-routine and call it. 92 */ 93 if (irq->cir) { 94 irq->cir(irq->cir_arg, irq->inr); 95 } 96 spinlock_unlock(&irq->lock); 97 } else if (data0 > config.base) { 98 /* 99 * This is a cross-call. 100 * data0 contains address of the kernel function. 101 * We call the function only after we verify 102 * it is one of the supported ones. 103 */ 104 #ifdef CONFIG_SMP 105 if (data0 == (uintptr_t) tlb_shootdown_ipi_recv) { 106 tlb_shootdown_ipi_recv(); 107 } 108 #endif 109 } else { 110 /* 111 * Spurious interrupt. 112 */ 113 #ifdef CONFIG_DEBUG 114 printf("cpu%u: spurious interrupt (intrcv=%#" PRIx64 115 ", data0=%#" PRIx64 ")\n", CPU->id, intrcv, data0); 116 #endif 117 } 118 119 membar(); 120 asi_u64_write(ASI_INTR_RECEIVE, 0, 0); 63 exc_register(n - IVT_FIRST, name, true, handler); 121 64 } 122 65 -
kernel/arch/sparc64/src/trap/sun4u/trap_table.S
rfb150d78 r46c20c8 481 481 be %xcc, 1f 482 482 nop 483 0: ba %xcc, 0b ! this is for debugging, if we ever get here 484 nop ! it will be easy to find 483 ! this is for debugging, if we ever get here it will be easy to find 484 0: ba,a %xcc, 0b 485 485 486 486 1: … … 546 546 547 547 .if NOT(\is_syscall) 548 ba %xcc, 1f 549 nop 548 ba,a %xcc, 1f 550 549 0: 551 550 save %sp, -PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE, %sp -
kernel/arch/sparc64/src/trap/trap.c
rfb150d78 r46c20c8 43 43 #include <memstr.h> 44 44 #include <debug.h> 45 #include < arch/types.h>45 #include <typedefs.h> 46 46 #include <arch/drivers/tick.h> 47 47
Note:
See TracChangeset
for help on using the changeset viewer.
