Mon Dec 30 22:13:47 2019 UTC ()
PR port-sparc/54789: Sparc boot fails with "Trap 0x21 while interrupts disabled"

Remove assumption that cpu_info is smaller than 1kB.


(ad)
diff -r1.1 -r1.2 src/sys/arch/sparc/dev/apc.c
diff -r1.103 -r1.104 src/sys/arch/sparc/include/cpu.h
diff -r1.5 -r1.6 src/sys/arch/sparc/sparc/clkctrl.c
diff -r1.12 -r1.13 src/sys/arch/sparc/sparc/lock_stubs.s
diff -r1.274 -r1.275 src/sys/arch/sparc/sparc/locore.s
diff -r1.47 -r1.48 src/sys/arch/sparc/sparc/msiiep.c

cvs diff -r1.1 -r1.2 src/sys/arch/sparc/dev/apc.c (expand / switch to unified diff)

--- src/sys/arch/sparc/dev/apc.c 2010/01/15 20:57:12 1.1
+++ src/sys/arch/sparc/dev/apc.c 2019/12/30 22:13:46 1.2
@@ -1,61 +1,61 @@ @@ -1,61 +1,61 @@
1/* $NetBSD: apc.c,v 1.1 2010/01/15 20:57:12 bouyer Exp $ */ 1/* $NetBSD: apc.c,v 1.2 2019/12/30 22:13:46 ad Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2010 Manuel Bouyer. 4 * Copyright (c) 2010 Manuel Bouyer.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright 11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the 12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution. 13 * documentation and/or other materials provided with the distribution.
14 * 14 *
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */ 25 */
26 26
27#include <sys/cdefs.h> 27#include <sys/cdefs.h>
28__KERNEL_RCSID(0, "$NetBSD: apc.c,v 1.1 2010/01/15 20:57:12 bouyer Exp $"); 28__KERNEL_RCSID(0, "$NetBSD: apc.c,v 1.2 2019/12/30 22:13:46 ad Exp $");
29 29
30 30
31/* 31/*
32 * driver for the power management functions of the Aurora Personality Chip 32 * driver for the power management functions of the Aurora Personality Chip
33 * on SPARCstation-4/5 and derivatives 33 * on SPARCstation-4/5 and derivatives
34 */ 34 */
35 35
36#include <sys/param.h> 36#include <sys/param.h>
37#include <sys/systm.h> 37#include <sys/systm.h>
38#include <sys/errno.h> 38#include <sys/errno.h>
39#include <sys/device.h> 39#include <sys/device.h>
40#include <sys/bus.h> 40#include <sys/bus.h>
41 41
42#include <machine/autoconf.h> 42#include <machine/autoconf.h>
43 43
44#include <sparc/dev/apcreg.h> 44#include <sparc/dev/apcreg.h>
45 45
46static int apcmatch(device_t, struct cfdata *, void *); 46static int apcmatch(device_t, struct cfdata *, void *);
47static void apcattach(device_t, device_t, void *); 47static void apcattach(device_t, device_t, void *);
48static void apc_cpu_sleep(struct cpu_info *); 48static void apc_cpu_sleep(void);
49 49
50struct apc_softc { 50struct apc_softc {
51 device_t sc_dev; 51 device_t sc_dev;
52 bus_space_tag_t sc_bt; 52 bus_space_tag_t sc_bt;
53 bus_space_handle_t sc_bh; 53 bus_space_handle_t sc_bh;
54}; 54};
55 55
56struct apc_softc *apc = NULL; 56struct apc_softc *apc = NULL;
57 57
58CFATTACH_DECL_NEW(apc, sizeof(struct apc_softc), 58CFATTACH_DECL_NEW(apc, sizeof(struct apc_softc),
59 apcmatch, apcattach, NULL, NULL); 59 apcmatch, apcattach, NULL, NULL);
60 60
61 61
@@ -76,22 +76,22 @@ apcattach(device_t parent, device_t self @@ -76,22 +76,22 @@ apcattach(device_t parent, device_t self
76 76
77 sc->sc_bt = sa->sa_bustag; 77 sc->sc_bt = sa->sa_bustag;
78 if (sbus_bus_map(sa->sa_bustag, 78 if (sbus_bus_map(sa->sa_bustag,
79 sa->sa_slot, sa->sa_offset, APC_REG_SIZE, 0, &sc->sc_bh) != 0) { 79 sa->sa_slot, sa->sa_offset, APC_REG_SIZE, 0, &sc->sc_bh) != 0) {
80 aprint_error(": cannot map registers\n"); 80 aprint_error(": cannot map registers\n");
81 return; 81 return;
82 } 82 }
83 aprint_normal("\n"); 83 aprint_normal("\n");
84 apc = sc; 84 apc = sc;
85 curcpu()->idlespin = apc_cpu_sleep; 85 curcpu()->idlespin = apc_cpu_sleep;
86} 86}
87 87
88static void 88static void
89apc_cpu_sleep(struct cpu_info *ci) 89apc_cpu_sleep(void)
90{ 90{
91 uint8_t val; 91 uint8_t val;
92 if (apc == NULL) 92 if (apc == NULL)
93 return; 93 return;
94 val = bus_space_read_1(apc->sc_bt, apc->sc_bh, APC_IDLE_REG); 94 val = bus_space_read_1(apc->sc_bt, apc->sc_bh, APC_IDLE_REG);
95 bus_space_write_1(apc->sc_bt, apc->sc_bh, APC_IDLE_REG, 95 bus_space_write_1(apc->sc_bt, apc->sc_bh, APC_IDLE_REG,
96 val | APC_IDLE_REG_IDLE); 96 val | APC_IDLE_REG_IDLE);
97} 97}

cvs diff -r1.103 -r1.104 src/sys/arch/sparc/include/cpu.h (expand / switch to unified diff)

--- src/sys/arch/sparc/include/cpu.h 2019/12/01 15:34:45 1.103
+++ src/sys/arch/sparc/include/cpu.h 2019/12/30 22:13:47 1.104
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: cpu.h,v 1.103 2019/12/01 15:34:45 ad Exp $ */ 1/* $NetBSD: cpu.h,v 1.104 2019/12/30 22:13:47 ad Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1992, 1993 4 * Copyright (c) 1992, 1993
5 * The Regents of the University of California. All rights reserved. 5 * The Regents of the University of California. All rights reserved.
6 * 6 *
7 * This software was developed by the Computer Systems Engineering group 7 * This software was developed by the Computer Systems Engineering group
8 * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and 8 * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
9 * contributed to Berkeley. 9 * contributed to Berkeley.
10 * 10 *
11 * All advertising materials mentioning features or use of this software 11 * All advertising materials mentioning features or use of this software
12 * must display the following acknowledgement: 12 * must display the following acknowledgement:
13 * This product includes software developed by the University of 13 * This product includes software developed by the University of
14 * California, Lawrence Berkeley Laboratory. 14 * California, Lawrence Berkeley Laboratory.
@@ -364,27 +364,27 @@ struct cpu_info { @@ -364,27 +364,27 @@ struct cpu_info {
364 /* hardware-assisted block operation routines */ 364 /* hardware-assisted block operation routines */
365 void (*hwbcopy)(const void *from, void *to, size_t len); 365 void (*hwbcopy)(const void *from, void *to, size_t len);
366 void (*hwbzero)(void *buf, size_t len); 366 void (*hwbzero)(void *buf, size_t len);
367 367
368 /* routine to clear mbus-sbus buffers */ 368 /* routine to clear mbus-sbus buffers */
369 void (*mbusflush)(void); 369 void (*mbusflush)(void);
370#endif 370#endif
371 371
372 /* 372 /*
373 * Memory error handler; parity errors, unhandled NMIs and other 373 * Memory error handler; parity errors, unhandled NMIs and other
374 * unrecoverable faults end up here. 374 * unrecoverable faults end up here.
375 */ 375 */
376 void (*memerr)(unsigned, u_int, u_int, struct trapframe *); 376 void (*memerr)(unsigned, u_int, u_int, struct trapframe *);
377 void (*idlespin)(struct cpu_info *); 377 void (*idlespin)(void);
378 /* Module Control Registers */ 378 /* Module Control Registers */
379 /*bus_space_handle_t*/ long ci_mbusport; 379 /*bus_space_handle_t*/ long ci_mbusport;
380 /*bus_space_handle_t*/ long ci_mxccregs; 380 /*bus_space_handle_t*/ long ci_mxccregs;
381 381
382 u_int ci_tt; /* Last trap (if tracing) */ 382 u_int ci_tt; /* Last trap (if tracing) */
383 383
384 /* 384 /*
385 * Start/End VA's of this cpu_info region; we upload the other pages 385 * Start/End VA's of this cpu_info region; we upload the other pages
386 * in this region that aren't part of the cpu_info to uvm. 386 * in this region that aren't part of the cpu_info to uvm.
387 */ 387 */
388 vaddr_t ci_free_sva1, ci_free_eva1, ci_free_sva2, ci_free_eva2; 388 vaddr_t ci_free_sva1, ci_free_eva1, ci_free_sva2, ci_free_eva2;
389 389
390 struct evcnt ci_savefpstate; 390 struct evcnt ci_savefpstate;

cvs diff -r1.5 -r1.6 src/sys/arch/sparc/sparc/clkctrl.c (expand / switch to unified diff)

--- src/sys/arch/sparc/sparc/clkctrl.c 2011/07/17 23:32:37 1.5
+++ src/sys/arch/sparc/sparc/clkctrl.c 2019/12/30 22:13:47 1.6
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: clkctrl.c,v 1.5 2011/07/17 23:32:37 mrg Exp $ */ 1/* $NetBSD: clkctrl.c,v 1.6 2019/12/30 22:13:47 ad Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2005 Michael Lorenz 4 * Copyright (c) 2005 Michael Lorenz
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright 11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the 12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution. 13 * documentation and/or other materials provided with the distribution.
14 * 14 *
@@ -16,45 +16,45 @@ @@ -16,45 +16,45 @@
16 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 16 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
17 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 17 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 18 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
19 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 * POSSIBILITY OF SUCH DAMAGE. 25 * POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28#include <sys/cdefs.h> 28#include <sys/cdefs.h>
29__KERNEL_RCSID(0, "$NetBSD: clkctrl.c,v 1.5 2011/07/17 23:32:37 mrg Exp $"); 29__KERNEL_RCSID(0, "$NetBSD: clkctrl.c,v 1.6 2019/12/30 22:13:47 ad Exp $");
30 30
31#include <sys/param.h> 31#include <sys/param.h>
32#include <sys/systm.h> 32#include <sys/systm.h>
33#include <sys/device.h> 33#include <sys/device.h>
34#include <sys/kernel.h> 34#include <sys/kernel.h>
35 35
36#include <machine/autoconf.h> 36#include <machine/autoconf.h>
37#include <machine/cpu.h> 37#include <machine/cpu.h>
38 38
39#include <sparc/sparc/vaddrs.h> 39#include <sparc/sparc/vaddrs.h>
40 40
41static int clkctrl_match(device_t, cfdata_t, void *); 41static int clkctrl_match(device_t, cfdata_t, void *);
42static void clkctrl_attach(device_t, device_t, void *); 42static void clkctrl_attach(device_t, device_t, void *);
43 43
44CFATTACH_DECL_NEW(clkctrl, 0, 44CFATTACH_DECL_NEW(clkctrl, 0,
45 clkctrl_match, clkctrl_attach, NULL, NULL); 45 clkctrl_match, clkctrl_attach, NULL, NULL);
46 46
47static void tadpole_cpu_sleep(struct cpu_info *); 47static void tadpole_cpu_sleep(void);
48volatile uint8_t *clkctrl_reg = NULL; 48volatile uint8_t *clkctrl_reg = NULL;
49 49
50static int 50static int
51clkctrl_match(device_t parent, cfdata_t cf, void *aux) 51clkctrl_match(device_t parent, cfdata_t cf, void *aux)
52{ 52{
53 union obio_attach_args *uoba = aux; 53 union obio_attach_args *uoba = aux;
54 54
55 if ((uoba->uoba_isobio4 != 0) || (clkctrl_reg != NULL)) 55 if ((uoba->uoba_isobio4 != 0) || (clkctrl_reg != NULL))
56 return (0); 56 return (0);
57 57
58 return (strcmp("clk-ctrl", uoba->uoba_sbus.sa_name) == 0); 58 return (strcmp("clk-ctrl", uoba->uoba_sbus.sa_name) == 0);
59} 59}
60 60
@@ -81,19 +81,20 @@ clkctrl_attach(device_t parent, device_t @@ -81,19 +81,20 @@ clkctrl_attach(device_t parent, device_t
81 clkctrl_reg = (volatile uint8_t *)bus_space_vaddr(sa->sa_bustag, bh); 81 clkctrl_reg = (volatile uint8_t *)bus_space_vaddr(sa->sa_bustag, bh);
82 82
83#ifdef DEBUG 83#ifdef DEBUG
84 printf(" reg: %x", (uint32_t)clkctrl_reg); 84 printf(" reg: %x", (uint32_t)clkctrl_reg);
85#endif 85#endif
86 cur = curcpu(); 86 cur = curcpu();
87 cur->idlespin = tadpole_cpu_sleep; 87 cur->idlespin = tadpole_cpu_sleep;
88 88
89 printf("\n"); 89 printf("\n");
90} 90}
91 91
92/* ARGSUSED */ 92/* ARGSUSED */
93static void 93static void
94tadpole_cpu_sleep(struct cpu_info *ci) 94tadpole_cpu_sleep(void)
95{ 95{
 96
96 if (clkctrl_reg == 0) 97 if (clkctrl_reg == 0)
97 return; 98 return;
98 *clkctrl_reg = 0; 99 *clkctrl_reg = 0;
99} 100}

cvs diff -r1.12 -r1.13 src/sys/arch/sparc/sparc/lock_stubs.s (expand / switch to unified diff)

--- src/sys/arch/sparc/sparc/lock_stubs.s 2008/05/25 15:56:12 1.12
+++ src/sys/arch/sparc/sparc/lock_stubs.s 2019/12/30 22:13:47 1.13
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: lock_stubs.s,v 1.12 2008/05/25 15:56:12 chs Exp $ */ 1/* $NetBSD: lock_stubs.s,v 1.13 2019/12/30 22:13:47 ad Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2002, 2007 The NetBSD Foundation, Inc. 4 * Copyright (c) 2002, 2007 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Jason R. Thorpe and Andrew Doran 8 * by Jason R. Thorpe and Andrew Doran
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -112,76 +112,78 @@ ENTRY(mutex_exit) @@ -112,76 +112,78 @@ ENTRY(mutex_exit)
112 nop 112 nop
113 ldub [%o0 + MTX_LOCK], %o3 ! get has-waiters indicator 113 ldub [%o0 + MTX_LOCK], %o3 ! get has-waiters indicator
114 tst %o3 ! has waiters? 114 tst %o3 ! has waiters?
115 bnz _C_LABEL(mutex_wakeup) ! yes, hard case 115 bnz _C_LABEL(mutex_wakeup) ! yes, hard case
116 st %g0, [%o0] ! and release lock 116 st %g0, [%o0] ! and release lock
117 retl 117 retl
118 nop 118 nop
119 119
120#if 0 /* does not work for MP yet */ 120#if 0 /* does not work for MP yet */
121/* 121/*
122 * void mutex_spin_enter(kmutex_t *); 122 * void mutex_spin_enter(kmutex_t *);
123 */ 123 */
124ENTRY(mutex_spin_enter) 124ENTRY(mutex_spin_enter)
125 sethi %hi(CPUINFO_VA), %o4 125 sethi %hi(CPUINFO_VA+CPUINFO_MTX_COUNT), %o4
126 ld [ %o4 + CPUINFO_MTX_COUNT ], %o5 126 ld [ %o4 + %lo(CPUINFO_VA+CPUINFO_MTX_COUNT) ], %o5
127 sub %o5, 1, %o1 127 sub %o5, 1, %o1
128 st %o1, [ %o4 + CPUINFO_MTX_COUNT ] 128 st %o1, [ %o4 + %lo(CPUINFO_VA+CPUINFO_MTX_COUNT) ]
129 ldub [ %o0 + MTX_IPL ], %o2 129 ldub [ %o0 + MTX_IPL ], %o2
130 rd %psr, %o1 130 rd %psr, %o1
131 sll %o2, 8, %o2 131 sll %o2, 8, %o2
132 and %o1, PSR_PIL, %o3 132 and %o1, PSR_PIL, %o3
133 cmp %o3, %o2 133 cmp %o3, %o2
134 bge 1f 134 bge 1f
135 tst %o5 135 tst %o5
136 andn %o1, PSR_PIL, %o1 136 andn %o1, PSR_PIL, %o1
137 wr %o2, %o1, %psr 137 wr %o2, %o1, %psr
138 nop 138 nop
139 nop 139 nop
140 nop 140 nop
141 tst %o5 141 tst %o5
1421: 1421:
 143 sethi %hi(CPUINFO_VA+CPUINFO_MTX_OLDSPL), %o4
143 bz,a 2f 144 bz,a 2f
144 st %o3, [ %o4 + CPUINFO_MTX_OLDSPL ] 145 st %o3, [ %o4 + %lo(CPUINFO_VA+CPUINFO_MTX_OLDSPL) ]
1452: 1462:
146#if defined(MULTIPROCESSOR) || defined(DIAGNOSTIC) 147#if defined(MULTIPROCESSOR) || defined(DIAGNOSTIC)
147 ldstub [ %o0 + MTX_LOCK ], %o2 148 ldstub [ %o0 + MTX_LOCK ], %o2
148 tst %o2 149 tst %o2
149 bnz _C_LABEL(mutex_spin_retry) 150 bnz _C_LABEL(mutex_spin_retry)
150 nop 151 nop
151#endif 152#endif
152 retl 153 retl
153 nop 154 nop
154 155
155/* 156/*
156 * void mutex_spin_exit(kmutex_t *); 157 * void mutex_spin_exit(kmutex_t *);
157 */ 158 */
158ENTRY(mutex_spin_exit) 159ENTRY(mutex_spin_exit)
159 160
160#if defined(DIAGNOSTIC) 161#if defined(DIAGNOSTIC)
161 ldub [ %o0 + MTX_LOCK ], %o1 162 ldub [ %o0 + MTX_LOCK ], %o1
162 tst %o1 163 tst %o1
163 bz _C_LABEL(mutex_vector_exit) 164 bz _C_LABEL(mutex_vector_exit)
164 nop 165 nop
165 clrb [ %o0 + MTX_LOCK ] 166 clrb [ %o0 + MTX_LOCK ]
166#elif defined(MULTIPROCESSOR) 167#elif defined(MULTIPROCESSOR)
167 clrb [ %o0 + MTX_LOCK ] 168 clrb [ %o0 + MTX_LOCK ]
168#endif 169#endif
169 sethi %hi(CPUINFO_VA), %o2 170 sethi %hi(CPUINFO_VA+CPUINFO_MTX_OLDSPL), %o2
170 ld [ %o2 + CPUINFO_MTX_OLDSPL ], %o3 171 ld [ %o2 + %lo(CPUINFO_VA+CPUINFO_MTX_OLDSPL) ], %o3
171 ld [ %o2 + CPUINFO_MTX_COUNT ], %o1 172 sethi %hi(CPUINFO_VA+CPUINFO_MTX_COUNT), %o2
 173 ld [ %o2 + %lo(CPUINFO_VA+CPUINFO_MTX_COUNT) ], %o1
172 addcc %o1, 1, %o4 174 addcc %o1, 1, %o4
173 bnz 1f 175 bnz 1f
174 st %o4, [ %o2 + CPUINFO_MTX_COUNT ] 176 st %o4, [ %o2 + %lo(CPUINFO_VA+CPUINFO_MTX_COUNT) ]
175 rd %psr, %o1 177 rd %psr, %o1
176 andn %o1, PSR_PIL, %o1 178 andn %o1, PSR_PIL, %o1
177 wr %o3, %o1, %psr 179 wr %o3, %o1, %psr
178 nop 180 nop
179 nop 181 nop
180 nop 182 nop
1811: 1831:
182 retl 184 retl
183 nop 185 nop
184 186
185#endif 187#endif
186 188
187#endif /* LOCKDEBUG */ 189#endif /* LOCKDEBUG */

cvs diff -r1.274 -r1.275 src/sys/arch/sparc/sparc/locore.s (expand / switch to unified diff)

--- src/sys/arch/sparc/sparc/locore.s 2019/06/07 00:18:26 1.274
+++ src/sys/arch/sparc/sparc/locore.s 2019/12/30 22:13:47 1.275
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: locore.s,v 1.274 2019/06/07 00:18:26 mrg Exp $ */ 1/* $NetBSD: locore.s,v 1.275 2019/12/30 22:13:47 ad Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1996 Paul Kranenburg 4 * Copyright (c) 1996 Paul Kranenburg
5 * Copyright (c) 1996 5 * Copyright (c) 1996
6 * The President and Fellows of Harvard College. All rights reserved. 6 * The President and Fellows of Harvard College. All rights reserved.
7 * Copyright (c) 1992, 1993 7 * Copyright (c) 1992, 1993
8 * The Regents of the University of California. All rights reserved. 8 * The Regents of the University of California. All rights reserved.
9 * 9 *
10 * This software was developed by the Computer Systems Engineering group 10 * This software was developed by the Computer Systems Engineering group
11 * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and 11 * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
12 * contributed to Berkeley. 12 * contributed to Berkeley.
13 * 13 *
14 * All advertising materials mentioning features or use of this software 14 * All advertising materials mentioning features or use of this software
@@ -1944,30 +1944,31 @@ memfault_sun4c: @@ -1944,30 +1944,31 @@ memfault_sun4c:
1944 ld [%sp + CCFSZ + 20], %g1 ! restore g1 through g7 1944 ld [%sp + CCFSZ + 20], %g1 ! restore g1 through g7
1945 ldd [%sp + CCFSZ + 24], %g2 1945 ldd [%sp + CCFSZ + 24], %g2
1946 ldd [%sp + CCFSZ + 32], %g4 1946 ldd [%sp + CCFSZ + 32], %g4
1947 ldd [%sp + CCFSZ + 40], %g6 1947 ldd [%sp + CCFSZ + 40], %g6
1948 wr %l4, 0, %y ! restore y 1948 wr %l4, 0, %y ! restore y
1949 b return_from_trap 1949 b return_from_trap
1950 wr %l0, 0, %psr 1950 wr %l0, 0, %psr
1951 /* NOTREACHED */ 1951 /* NOTREACHED */
1952#endif /* SUN4C */ 1952#endif /* SUN4C */
1953 1953
1954#if defined(SUN4M) 1954#if defined(SUN4M)
1955_ENTRY(memfault_sun4m) 1955_ENTRY(memfault_sun4m)
1956memfault_sun4m: 1956memfault_sun4m:
1957 sethi %hi(CPUINFO_VA), %l4 1957 sethi %hi(CPUINFO_VA+CPUINFO_GETSYNCFLT), %l4
1958 ld [%l4 + %lo(CPUINFO_VA+CPUINFO_GETSYNCFLT)], %l5 1958 ld [%l4 + %lo(CPUINFO_VA+CPUINFO_GETSYNCFLT)], %l5
 1959 sethi %hi(CPUINFO_VA+CPUINFO_SYNCFLTDUMP), %l4
1959 jmpl %l5, %l7 1960 jmpl %l5, %l7
1960 or %l4, %lo(CPUINFO_SYNCFLTDUMP), %l4 1961 or %l4, %lo(CPUINFO_VA+CPUINFO_SYNCFLTDUMP), %l4
1961 TRAP_SETUP(-CCFSZ-80) 1962 TRAP_SETUP(-CCFSZ-80)
1962 ! tally fault (curcpu()->cpu_data.cpu_nfault++) (clobbers %o0,%o1,%o2) 1963 ! tally fault (curcpu()->cpu_data.cpu_nfault++) (clobbers %o0,%o1,%o2)
1963 INCR64(CPUINFO_VA + CPUINFO_NFAULT) 1964 INCR64(CPUINFO_VA + CPUINFO_NFAULT)
1964 1965
1965 st %g1, [%sp + CCFSZ + 20] ! save g1 1966 st %g1, [%sp + CCFSZ + 20] ! save g1
1966 rd %y, %l4 ! save y 1967 rd %y, %l4 ! save y
1967 1968
1968 std %g2, [%sp + CCFSZ + 24] ! save g2, g3 1969 std %g2, [%sp + CCFSZ + 24] ! save g2, g3
1969 std %g4, [%sp + CCFSZ + 32] ! save g4, g5 1970 std %g4, [%sp + CCFSZ + 32] ! save g4, g5
1970 std %g6, [%sp + CCFSZ + 40] ! sneak in g6, g7 1971 std %g6, [%sp + CCFSZ + 40] ! sneak in g6, g7
1971 1972
1972 ! retrieve sync fault status/address 1973 ! retrieve sync fault status/address
1973 sethi %hi(CPUINFO_VA+CPUINFO_SYNCFLTDUMP), %o0 1974 sethi %hi(CPUINFO_VA+CPUINFO_SYNCFLTDUMP), %o0
@@ -2509,72 +2510,72 @@ softintr_common: @@ -2509,72 +2510,72 @@ softintr_common:
2509 sll %l3, 2, %l5 2510 sll %l3, 2, %l5
2510 2511
2511 set CPUINFO_VA + CPUINFO_SINTRCNT, %l4 ! sintrcnt[intlev].ev_count++; 2512 set CPUINFO_VA + CPUINFO_SINTRCNT, %l4 ! sintrcnt[intlev].ev_count++;
2512 sll %l3, EV_STRUCTSHIFT, %o2 2513 sll %l3, EV_STRUCTSHIFT, %o2
2513 ldd [%l4 + %o2], %o0 2514 ldd [%l4 + %o2], %o0
2514 std %l2, [%sp + CCFSZ + 8] ! set up intrframe/clockframe 2515 std %l2, [%sp + CCFSZ + 8] ! set up intrframe/clockframe
2515 inccc %o1 2516 inccc %o1
2516 addx %o0, 0, %o0 2517 addx %o0, 0, %o0
2517 std %o0, [%l4 + %o2] 2518 std %o0, [%l4 + %o2]
2518 2519
2519 set _C_LABEL(sintrhand), %l4! %l4 = sintrhand[intlev]; 2520 set _C_LABEL(sintrhand), %l4! %l4 = sintrhand[intlev];
2520 ld [%l4 + %l5], %l4 2521 ld [%l4 + %l5], %l4
2521 2522
2522 sethi %hi(CPUINFO_VA), %o2 2523 sethi %hi(CPUINFO_VA+CPUINFO_IDEPTH), %o2
2523 ld [ %o2 + CPUINFO_IDEPTH ], %o3 2524 ld [ %o2 + %lo(CPUINFO_VA+CPUINFO_IDEPTH) ], %o3
2524 inc %o3 2525 inc %o3
2525 st %o3, [ %o2 + CPUINFO_IDEPTH ] 2526 st %o3, [ %o2 + %lo(CPUINFO_VA+CPUINFO_IDEPTH) ]
2526 2527
2527 b 3f 2528 b 3f
2528 st %fp, [%sp + CCFSZ + 16] 2529 st %fp, [%sp + CCFSZ + 16]
2529 2530
25301: ld [%l4 + IH_CLASSIPL], %o2 ! ih->ih_classipl 25311: ld [%l4 + IH_CLASSIPL], %o2 ! ih->ih_classipl
2531 rd %psr, %o3 ! (bits already shifted to PIL field) 2532 rd %psr, %o3 ! (bits already shifted to PIL field)
2532 andn %o3, PSR_PIL, %o3 ! %o3 = psr & ~PSR_PIL 2533 andn %o3, PSR_PIL, %o3 ! %o3 = psr & ~PSR_PIL
2533 wr %o3, %o2, %psr ! splraise(ih->ih_classipl) 2534 wr %o3, %o2, %psr ! splraise(ih->ih_classipl)
2534 ld [%l4 + IH_FUN], %o1 2535 ld [%l4 + IH_FUN], %o1
2535 ld [%l4 + IH_ARG], %o0 2536 ld [%l4 + IH_ARG], %o0
2536 nop ! one more isns before touching ICC 2537 nop ! one more isns before touching ICC
2537 tst %o0 2538 tst %o0
2538 bz,a 2f 2539 bz,a 2f
2539 add %sp, CCFSZ, %o0 2540 add %sp, CCFSZ, %o0
25402: jmpl %o1, %o7 ! (void)(*ih->ih_fun)(...) 25412: jmpl %o1, %o7 ! (void)(*ih->ih_fun)(...)
2541 ld [%l4 + IH_NEXT], %l4 ! and ih = ih->ih_next 2542 ld [%l4 + IH_NEXT], %l4 ! and ih = ih->ih_next
25423: tst %l4 ! while ih != NULL 25433: tst %l4 ! while ih != NULL
2543 bnz 1b 2544 bnz 1b
2544 nop 2545 nop
2545 2546
2546 sethi %hi(CPUINFO_VA), %o2 2547 sethi %hi(CPUINFO_VA+CPUINFO_IDEPTH), %o2
2547 ld [ %o2 + CPUINFO_IDEPTH ], %o3 2548 ld [ %o2 + %lo(CPUINFO_VA+CPUINFO_IDEPTH) ], %o3
2548 dec %o3 2549 dec %o3
2549 st %o3, [ %o2 + CPUINFO_IDEPTH ] 2550 st %o3, [ %o2 + %lo(CPUINFO_VA+CPUINFO_IDEPTH) ]
2550 2551
2551 mov %l7, %g1 2552 mov %l7, %g1
2552 wr %l6, 0, %y 2553 wr %l6, 0, %y
2553 ldd [%sp + CCFSZ + 24], %g2 2554 ldd [%sp + CCFSZ + 24], %g2
2554 ldd [%sp + CCFSZ + 32], %g4 2555 ldd [%sp + CCFSZ + 32], %g4
2555 ldd [%sp + CCFSZ + 40], %g6 2556 ldd [%sp + CCFSZ + 40], %g6
2556 b return_from_trap 2557 b return_from_trap
2557 wr %l0, 0, %psr 2558 wr %l0, 0, %psr
2558 2559
2559 /* 2560 /*
2560 * _sparc_interrupt{44c,4m} is exported for paranoia checking 2561 * _sparc_interrupt{44c,4m} is exported for paranoia checking
2561 * (see intr.c). 2562 * (see intr.c).
2562 */ 2563 */
2563#if defined(SUN4M) 2564#if defined(SUN4M)
2564_ENTRY(_C_LABEL(sparc_interrupt4m)) 2565_ENTRY(_C_LABEL(sparc_interrupt4m))
2565#if !defined(MSIIEP) /* "normal" sun4m */ 2566#if !defined(MSIIEP) /* "normal" sun4m */
2566 sethi %hi(CPUINFO_VA), %l6 2567 sethi %hi(CPUINFO_VA+CPUINFO_INTREG), %l6
2567 ld [%l6 + CPUINFO_INTREG], %l7 2568 ld [%l6 + %lo(CPUINFO_VA+CPUINFO_INTREG)], %l7
2568 mov 1, %l4 2569 mov 1, %l4
2569 ld [%l7 + ICR_PI_PEND_OFFSET], %l5 ! get pending interrupts 2570 ld [%l7 + ICR_PI_PEND_OFFSET], %l5 ! get pending interrupts
2570 sll %l4, %l3, %l4 ! hw intr bits are in the lower halfword 2571 sll %l4, %l3, %l4 ! hw intr bits are in the lower halfword
2571 2572
2572 btst %l4, %l5 ! has pending hw intr at this level? 2573 btst %l4, %l5 ! has pending hw intr at this level?
2573 bnz sparc_interrupt_common 2574 bnz sparc_interrupt_common
2574 nop 2575 nop
2575 2576
2576 ! both softint pending and clear bits are in upper halfwords of 2577 ! both softint pending and clear bits are in upper halfwords of
2577 ! their respective registers so shift the test bit in %l4 up there 2578 ! their respective registers so shift the test bit in %l4 up there
2578 sll %l4, 16, %l4 2579 sll %l4, 16, %l4
2579 2580
2580 st %l4, [%l7 + ICR_PI_CLR_OFFSET] ! ack soft intr 2581 st %l4, [%l7 + ICR_PI_CLR_OFFSET] ! ack soft intr
@@ -2694,30 +2695,30 @@ sparc_interrupt_common: @@ -2694,30 +2695,30 @@ sparc_interrupt_common:
2694 sll %l3, 2, %l5 2695 sll %l3, 2, %l5
2695 2696
2696 set CPUINFO_VA + CPUINFO_INTRCNT, %l4 ! intrcnt[intlev].ev_count++; 2697 set CPUINFO_VA + CPUINFO_INTRCNT, %l4 ! intrcnt[intlev].ev_count++;
2697 sll %l3, EV_STRUCTSHIFT, %o2 2698 sll %l3, EV_STRUCTSHIFT, %o2
2698 ldd [%l4 + %o2], %o0 2699 ldd [%l4 + %o2], %o0
2699 std %l2, [%sp + CCFSZ + 8] ! set up intrframe/clockframe 2700 std %l2, [%sp + CCFSZ + 8] ! set up intrframe/clockframe
2700 inccc %o1 2701 inccc %o1
2701 addx %o0, 0, %o0 2702 addx %o0, 0, %o0
2702 std %o0, [%l4 + %o2] 2703 std %o0, [%l4 + %o2]
2703 2704
2704 set _C_LABEL(intrhand), %l4 ! %l4 = intrhand[intlev]; 2705 set _C_LABEL(intrhand), %l4 ! %l4 = intrhand[intlev];
2705 ld [%l4 + %l5], %l4 2706 ld [%l4 + %l5], %l4
2706 2707
2707 sethi %hi(CPUINFO_VA), %o2 2708 sethi %hi(CPUINFO_VA+CPUINFO_IDEPTH), %o2
2708 ld [ %o2 + CPUINFO_IDEPTH ], %o3 2709 ld [ %o2 + %lo(CPUINFO_VA+CPUINFO_IDEPTH) ], %o3
2709 inc %o3 2710 inc %o3
2710 st %o3, [ %o2 + CPUINFO_IDEPTH ] 2711 st %o3, [ %o2 + %lo(CPUINFO_VA+CPUINFO_IDEPTH) ]
2711 2712
2712 b 3f 2713 b 3f
2713 st %fp, [%sp + CCFSZ + 16] 2714 st %fp, [%sp + CCFSZ + 16]
2714 2715
27151: ld [%l4 + IH_CLASSIPL], %o2 ! ih->ih_classipl 27161: ld [%l4 + IH_CLASSIPL], %o2 ! ih->ih_classipl
2716 rd %psr, %o3 ! (bits already shifted to PIL field) 2717 rd %psr, %o3 ! (bits already shifted to PIL field)
2717 andn %o3, PSR_PIL, %o3 ! %o3 = psr & ~PSR_PIL 2718 andn %o3, PSR_PIL, %o3 ! %o3 = psr & ~PSR_PIL
2718 wr %o3, %o2, %psr ! splraise(ih->ih_classipl) 2719 wr %o3, %o2, %psr ! splraise(ih->ih_classipl)
2719 ld [%l4 + IH_FUN], %o1 2720 ld [%l4 + IH_FUN], %o1
2720 ld [%l4 + IH_ARG], %o0 2721 ld [%l4 + IH_ARG], %o0
2721 nop ! one more isns before touching ICC 2722 nop ! one more isns before touching ICC
2722 tst %o0 2723 tst %o0
2723 bz,a 2f 2724 bz,a 2f
@@ -2732,49 +2733,49 @@ sparc_interrupt_common: @@ -2732,49 +2733,49 @@ sparc_interrupt_common:
2732 nop 2733 nop
2733 2734
2734 /* Unhandled interrupts while cold cause IPL to be raised to `high' */ 2735 /* Unhandled interrupts while cold cause IPL to be raised to `high' */
2735 sethi %hi(_C_LABEL(cold)), %o0 2736 sethi %hi(_C_LABEL(cold)), %o0
2736 ld [%o0 + %lo(_C_LABEL(cold))], %o0 2737 ld [%o0 + %lo(_C_LABEL(cold))], %o0
2737 tst %o0 ! if (cold) { 2738 tst %o0 ! if (cold) {
2738 bnz,a 4f ! splhigh(); 2739 bnz,a 4f ! splhigh();
2739 or %l0, 0xf00, %l0 ! } else 2740 or %l0, 0xf00, %l0 ! } else
2740 2741
2741 call _C_LABEL(strayintr) ! strayintr(&intrframe) 2742 call _C_LABEL(strayintr) ! strayintr(&intrframe)
2742 add %sp, CCFSZ, %o0 2743 add %sp, CCFSZ, %o0
2743 /* all done: restore registers and go return */ 2744 /* all done: restore registers and go return */
27444: 27454:
2745 sethi %hi(CPUINFO_VA), %o2 2746 sethi %hi(CPUINFO_VA+CPUINFO_IDEPTH), %o2
2746 ld [ %o2 + CPUINFO_IDEPTH ], %o3 2747 ld [ %o2 + %lo(CPUINFO_VA+CPUINFO_IDEPTH) ], %o3
2747 dec %o3 2748 dec %o3
2748 st %o3, [ %o2 + CPUINFO_IDEPTH ] 2749 st %o3, [ %o2 + %lo(CPUINFO_VA+CPUINFO_IDEPTH) ]
2749 2750
2750 mov %l7, %g1 2751 mov %l7, %g1
2751 wr %l6, 0, %y 2752 wr %l6, 0, %y
2752 ldd [%sp + CCFSZ + 24], %g2 2753 ldd [%sp + CCFSZ + 24], %g2
2753 ldd [%sp + CCFSZ + 32], %g4 2754 ldd [%sp + CCFSZ + 32], %g4
2754 ldd [%sp + CCFSZ + 40], %g6 2755 ldd [%sp + CCFSZ + 40], %g6
2755 b return_from_trap 2756 b return_from_trap
2756 wr %l0, 0, %psr 2757 wr %l0, 0, %psr
2757 2758
2758#if defined(MULTIPROCESSOR) 2759#if defined(MULTIPROCESSOR)
2759/* 2760/*
2760 * Level 14 software interrupt: fast IPI 2761 * Level 14 software interrupt: fast IPI
2761 * <%l0,%l1,%l2> = <psr, pc, npc> 2762 * <%l0,%l1,%l2> = <psr, pc, npc>
2762 * %l3 = int level 2763 * %l3 = int level
2763 * %l6 = &cpuinfo 2764 * %l6 = &cpuinfo
2764 */ 2765 */
2765lev14_softint: 2766lev14_softint:
2766 sethi %hi(CPUINFO_VA), %l7 2767 sethi %hi(CPUINFO_VA+CPUINFO_LEV14), %l7
2767 ldd [%l7 + CPUINFO_LEV14], %l4 2768 ldd [%l7 + %lo(CPUINFO_VA+CPUINFO_LEV14)], %l4
2768 inccc %l5 2769 inccc %l5
2769 addx %l4, %g0, %l4 2770 addx %l4, %g0, %l4
2770 std %l4, [%l7 + CPUINFO_LEV14] 2771 std %l4, [%l7 + CPUINFO_LEV14]
2771 2772
2772 ld [%l6 + CPUINFO_XMSG_TRAP], %l7 2773 ld [%l6 + CPUINFO_XMSG_TRAP], %l7
2773#ifdef DIAGNOSTIC 2774#ifdef DIAGNOSTIC
2774 tst %l7 2775 tst %l7
2775 bz sparc_interrupt4m_bogus 2776 bz sparc_interrupt4m_bogus
2776 nop 2777 nop
2777#endif 2778#endif
2778 jmp %l7 2779 jmp %l7
2779 ld [%l6 + CPUINFO_XMSG_ARG0], %l3 ! prefetch 1st arg 2780 ld [%l6 + CPUINFO_XMSG_ARG0], %l3 ! prefetch 1st arg
2780 2781
@@ -4951,33 +4952,33 @@ Lnosaveoldlwp: @@ -4951,33 +4952,33 @@ Lnosaveoldlwp:
4951 add %o0, 4, %o1 4952 add %o0, 4, %o1
4952 st %o0, [%l3 + TF_PC] ! store rewound %pc 4953 st %o0, [%l3 + TF_PC] ! store rewound %pc
4953 st %o1, [%l3 + TF_NPC] ! and %npc 4954 st %o1, [%l3 + TF_NPC] ! and %npc
4954 4955
4955Lsw_noras: 4956Lsw_noras:
4956 4957
4957 ret 4958 ret
4958 restore ! return (oldlwp) 4959 restore ! return (oldlwp)
4959 4960
4960/* 4961/*
4961 * Call the idlespin() function if it exists, otherwise just return. 4962 * Call the idlespin() function if it exists, otherwise just return.
4962 */ 4963 */
4963ENTRY(cpu_idle) 4964ENTRY(cpu_idle)
4964 sethi %hi(CPUINFO_VA), %o0 4965 sethi %hi(CPUINFO_VA+CPUINFO_IDLESPIN), %o0
4965 ld [%o0 + CPUINFO_IDLESPIN], %o1 4966 ld [%o0 + %lo(CPUINFO_VA+CPUINFO_IDLESPIN)], %o1
4966 tst %o1 4967 tst %o1
4967 bz 1f 4968 bz 1f
4968 nop 4969 nop
4969 jmp %o1 4970 jmp %o1
4970 nop ! CPUINFO_VA is already in %o0 4971 nop
49711: 49721:
4972 retl 4973 retl
4973 nop 4974 nop
4974 4975
4975/* 4976/*
4976 * Snapshot the current process so that stack frames are up to date. 4977 * Snapshot the current process so that stack frames are up to date.
4977 * Only used just before a crash dump. 4978 * Only used just before a crash dump.
4978 */ 4979 */
4979ENTRY(snapshot) 4980ENTRY(snapshot)
4980 std %o6, [%o0 + PCB_SP] ! save sp 4981 std %o6, [%o0 + PCB_SP] ! save sp
4981 rd %psr, %o1 ! save psr 4982 rd %psr, %o1 ! save psr
4982 st %o1, [%o0 + PCB_PSR] 4983 st %o1, [%o0 + PCB_PSR]
4983 4984
@@ -5631,28 +5632,28 @@ Lkcerr: @@ -5631,28 +5632,28 @@ Lkcerr:
5631 * savefpstate(struct fpstate *f); 5632 * savefpstate(struct fpstate *f);
5632 * ipi_savefpstate(struct fpstate *f); 5633 * ipi_savefpstate(struct fpstate *f);
5633 * 5634 *
5634 * Store the current FPU state. The first `st %fsr' may cause a trap; 5635 * Store the current FPU state. The first `st %fsr' may cause a trap;
5635 * our trap handler knows how to recover (by `returning' to savefpcont). 5636 * our trap handler knows how to recover (by `returning' to savefpcont).
5636 * 5637 *
5637 * The IPI version just deals with updating event counters first. 5638 * The IPI version just deals with updating event counters first.
5638 */ 5639 */
5639Lpanic_savefpstate: 5640Lpanic_savefpstate:
5640 .asciz "cpu%d: NULL fpstate" 5641 .asciz "cpu%d: NULL fpstate"
5641 _ALIGN 5642 _ALIGN
5642 5643
5643ENTRY(ipi_savefpstate) 5644ENTRY(ipi_savefpstate)
5644 sethi %hi(CPUINFO_VA), %o5 5645 sethi %hi(CPUINFO_VA+CPUINFO_SAVEFPSTATE), %o5
5645 ldd [%o5 + CPUINFO_SAVEFPSTATE], %o2 5646 ldd [%o5 + %lo(CPUINFO_VA+CPUINFO_SAVEFPSTATE)], %o2
5646 inccc %o3 5647 inccc %o3
5647 addx %o2, 0, %o2 5648 addx %o2, 0, %o2
5648 std %o2, [%o5 + CPUINFO_SAVEFPSTATE] 5649 std %o2, [%o5 + CPUINFO_SAVEFPSTATE]
5649 5650
5650ENTRY(savefpstate) 5651ENTRY(savefpstate)
5651 cmp %o0, 0 5652 cmp %o0, 0
5652 rd %psr, %o1 ! enable FP before we begin 5653 rd %psr, %o1 ! enable FP before we begin
5653 set PSR_EF, %o2 5654 set PSR_EF, %o2
5654 or %o1, %o2, %o1 5655 or %o1, %o2, %o1
5655 wr %o1, 0, %psr 5656 wr %o1, 0, %psr
5656 /* do some setup work while we wait for PSR_EF to turn on */ 5657 /* do some setup work while we wait for PSR_EF to turn on */
5657 set FSR_QNE, %o5 ! QNE = 0x2000, too big for immediate 5658 set FSR_QNE, %o5 ! QNE = 0x2000, too big for immediate
5658 clr %o3 ! qsize = 0; 5659 clr %o3 ! qsize = 0;
@@ -5845,34 +5846,36 @@ _ENTRY(_C_LABEL(cypress_get_syncflt)) @@ -5845,34 +5846,36 @@ _ENTRY(_C_LABEL(cypress_get_syncflt))
5845 set SRMMU_SFSR, %l5 5846 set SRMMU_SFSR, %l5
5846 lda [%l5] ASI_SRMMU, %l5 ! get sync fault status register 5847 lda [%l5] ASI_SRMMU, %l5 ! get sync fault status register
5847 jmp %l7 + 8 ! return to caller 5848 jmp %l7 + 8 ! return to caller
5848 st %l5, [%l4] ! => dump.sfsr 5849 st %l5, [%l4] ! => dump.sfsr
5849 5850
5850#if defined(MULTIPROCESSOR) && 0 /* notyet */ 5851#if defined(MULTIPROCESSOR) && 0 /* notyet */
5851/* 5852/*
5852 * Read Synchronous Fault Status registers. 5853 * Read Synchronous Fault Status registers.
5853 * On entry: %o0 == &sfsr, %o1 == &sfar 5854 * On entry: %o0 == &sfsr, %o1 == &sfar
5854 */ 5855 */
5855_ENTRY(_C_LABEL(smp_get_syncflt)) 5856_ENTRY(_C_LABEL(smp_get_syncflt))
5856 save %sp, -CCFSZ, %sp 5857 save %sp, -CCFSZ, %sp
5857 5858
5858 sethi %hi(CPUINFO_VA), %o4 5859 sethi %hi(CPUINFO_VA+CPUINFO_GETSYNCFLT), %o4
5859 ld [%l4 + %lo(CPUINFO_VA+CPUINFO_GETSYNCFLT)], %o5 5860 ld [%l4 + %lo(CPUINFO_VA+CPUINFO_GETSYNCFLT)], %o5
5860 clr %l1 5861 clr %l1
5861 clr %l3 5862 clr %l3
 5863 sethi %hi(CPUINFO_VA+CPUINFO_SYNCFLTDUMP), %o4
5862 jmpl %o5, %l7 5864 jmpl %o5, %l7
5863 or %o4, %lo(CPUINFO_SYNCFLTDUMP), %l4 5865 or %o4, %lo(CPUINFO_VA+CPUINFO_SYNCFLTDUMP), %l4
5864 5866
5865 ! load values out of the dump 5867 ! load values out of the dump
 5868 sethi %hi(CPUINFO_VA+CPUINFO_SYNCFLTDUMP), %o4
5866 ld [%o4 + %lo(CPUINFO_VA+CPUINFO_SYNCFLTDUMP)], %o5 5869 ld [%o4 + %lo(CPUINFO_VA+CPUINFO_SYNCFLTDUMP)], %o5
5867 st %o5, [%i0] 5870 st %o5, [%i0]
5868 ld [%o4 + %lo(CPUINFO_VA+CPUINFO_SYNCFLTDUMP+4)], %o5 5871 ld [%o4 + %lo(CPUINFO_VA+CPUINFO_SYNCFLTDUMP+4)], %o5
5869 st %o5, [%i1] 5872 st %o5, [%i1]
5870 ret 5873 ret
5871 restore 5874 restore
5872#endif /* MULTIPROCESSOR */ 5875#endif /* MULTIPROCESSOR */
5873 5876
5874/* 5877/*
5875 * Read Asynchronous Fault Status registers. 5878 * Read Asynchronous Fault Status registers.
5876 * On entry: %o0 == &afsr, %o1 == &afar 5879 * On entry: %o0 == &afsr, %o1 == &afar
5877 * Return 0 if async register are present. 5880 * Return 0 if async register are present.
5878 */ 5881 */

cvs diff -r1.47 -r1.48 src/sys/arch/sparc/sparc/msiiep.c (expand / switch to unified diff)

--- src/sys/arch/sparc/sparc/msiiep.c 2019/11/10 21:16:33 1.47
+++ src/sys/arch/sparc/sparc/msiiep.c 2019/12/30 22:13:47 1.48
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: msiiep.c,v 1.47 2019/11/10 21:16:33 chs Exp $ */ 1/* $NetBSD: msiiep.c,v 1.48 2019/12/30 22:13:47 ad Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2001 Valeriy E. Ushakov 4 * Copyright (c) 2001 Valeriy E. Ushakov
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -17,27 +17,27 @@ @@ -17,27 +17,27 @@
17 * 17 *
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 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 19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 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 24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 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 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. 27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */ 28 */
29#include <sys/cdefs.h> 29#include <sys/cdefs.h>
30__KERNEL_RCSID(0, "$NetBSD: msiiep.c,v 1.47 2019/11/10 21:16:33 chs Exp $"); 30__KERNEL_RCSID(0, "$NetBSD: msiiep.c,v 1.48 2019/12/30 22:13:47 ad Exp $");
31 31
32#include <sys/param.h> 32#include <sys/param.h>
33#include <sys/malloc.h> 33#include <sys/malloc.h>
34#include <sys/kernel.h> 34#include <sys/kernel.h>
35#include <sys/systm.h> 35#include <sys/systm.h>
36#include <sys/device.h> 36#include <sys/device.h>
37 37
38#include <uvm/uvm.h> 38#include <uvm/uvm.h>
39 39
40#define _SPARC_BUS_DMA_PRIVATE 40#define _SPARC_BUS_DMA_PRIVATE
41#include <sys/bus.h> 41#include <sys/bus.h>
42#include <machine/autoconf.h> 42#include <machine/autoconf.h>
43#include <machine/promlib.h> 43#include <machine/promlib.h>
@@ -62,27 +62,27 @@ __KERNEL_RCSID(0, "$NetBSD: msiiep.c,v 1 @@ -62,27 +62,27 @@ __KERNEL_RCSID(0, "$NetBSD: msiiep.c,v 1
62 * but I'd rather insulate the rest of the source from ms-IIep quirks. 62 * but I'd rather insulate the rest of the source from ms-IIep quirks.
63 */ 63 */
64 64
65/* 65/*
66 * "Stub" ms-IIep parent that knows how to attach various functions. 66 * "Stub" ms-IIep parent that knows how to attach various functions.
67 */ 67 */
68static int msiiep_match(device_t, cfdata_t, void *); 68static int msiiep_match(device_t, cfdata_t, void *);
69static void msiiep_attach(device_t, device_t, void *); 69static void msiiep_attach(device_t, device_t, void *);
70 70
71CFATTACH_DECL_NEW(msiiep, 0, msiiep_match, msiiep_attach, NULL, NULL); 71CFATTACH_DECL_NEW(msiiep, 0, msiiep_match, msiiep_attach, NULL, NULL);
72 72
73 73
74/* sleep in idle spin */ 74/* sleep in idle spin */
75static void msiiep_cpu_sleep(struct cpu_info *); 75static void msiiep_cpu_sleep(void);
76volatile uint32_t *msiiep_mid = NULL; 76volatile uint32_t *msiiep_mid = NULL;
77 77
78 78
79/* 79/*
80 * The real thing. 80 * The real thing.
81 */ 81 */
82static int mspcic_match(device_t, cfdata_t, void *); 82static int mspcic_match(device_t, cfdata_t, void *);
83static void mspcic_attach(device_t, device_t, void *); 83static void mspcic_attach(device_t, device_t, void *);
84static int mspcic_print(void *, const char *); 84static int mspcic_print(void *, const char *);
85 85
86CFATTACH_DECL_NEW(mspcic, sizeof(struct mspcic_softc), 86CFATTACH_DECL_NEW(mspcic, sizeof(struct mspcic_softc),
87 mspcic_match, mspcic_attach, NULL, NULL); 87 mspcic_match, mspcic_attach, NULL, NULL);
88 88
@@ -231,27 +231,27 @@ msiiep_attach(device_t parent, device_t  @@ -231,27 +231,27 @@ msiiep_attach(device_t parent, device_t
231 msa.msa_ma = ma; 231 msa.msa_ma = ma;
232 232
233 /* config timer/counter part of PCIC */ 233 /* config timer/counter part of PCIC */
234 msa.msa_name = "timer"; 234 msa.msa_name = "timer";
235 config_found(self, &msa, NULL); 235 config_found(self, &msa, NULL);
236 236
237 /* config PCI tree */ 237 /* config PCI tree */
238 msa.msa_name = "pcic"; 238 msa.msa_name = "pcic";
239 config_found(self, &msa, NULL); 239 config_found(self, &msa, NULL);
240} 240}
241 241
242/* ARGSUSED */ 242/* ARGSUSED */
243void 243void
244msiiep_cpu_sleep(struct cpu_info *ci) 244msiiep_cpu_sleep(void)
245{ 245{
246 uint32_t reg; 246 uint32_t reg;
247 247
248 if (msiiep_mid == 0) 248 if (msiiep_mid == 0)
249 return; 249 return;
250 reg = *msiiep_mid; 250 reg = *msiiep_mid;
251 *msiiep_mid = (reg & MID_MASK) | MID_STANDBY; 251 *msiiep_mid = (reg & MID_MASK) | MID_STANDBY;
252} 252}
253 253
254 254
255/* ====================================================================== 255/* ======================================================================
256 * 256 *
257 * Real ms-IIep PCIC driver. 257 * Real ms-IIep PCIC driver.