xref: /dflybsd-src/sys/platform/pc64/x86_64/ipl_funcs.c (revision 0a80a44543b5ffea91e63fae292695da66efde51)
1b2b3ffcdSSimon Schubert /*-
2b2b3ffcdSSimon Schubert  * Copyright (c) 1997 Bruce Evans.
3b2b3ffcdSSimon Schubert  * All rights reserved.
4b2b3ffcdSSimon Schubert  *
5b2b3ffcdSSimon Schubert  * Redistribution and use in source and binary forms, with or without
6b2b3ffcdSSimon Schubert  * modification, are permitted provided that the following conditions
7b2b3ffcdSSimon Schubert  * are met:
8b2b3ffcdSSimon Schubert  * 1. Redistributions of source code must retain the above copyright
9b2b3ffcdSSimon Schubert  *    notice, this list of conditions and the following disclaimer.
10b2b3ffcdSSimon Schubert  * 2. Redistributions in binary form must reproduce the above copyright
11b2b3ffcdSSimon Schubert  *    notice, this list of conditions and the following disclaimer in the
12b2b3ffcdSSimon Schubert  *    documentation and/or other materials provided with the distribution.
13b2b3ffcdSSimon Schubert  *
14b2b3ffcdSSimon Schubert  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15b2b3ffcdSSimon Schubert  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16b2b3ffcdSSimon Schubert  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17b2b3ffcdSSimon Schubert  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18b2b3ffcdSSimon Schubert  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19b2b3ffcdSSimon Schubert  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20b2b3ffcdSSimon Schubert  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21b2b3ffcdSSimon Schubert  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22b2b3ffcdSSimon Schubert  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23b2b3ffcdSSimon Schubert  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24b2b3ffcdSSimon Schubert  * SUCH DAMAGE.
25b2b3ffcdSSimon Schubert  *
26b2b3ffcdSSimon Schubert  * $FreeBSD: src/sys/i386/isa/ipl_funcs.c,v 1.32.2.5 2002/12/17 18:04:02 sam Exp $
27b2b3ffcdSSimon Schubert  */
28b2b3ffcdSSimon Schubert 
29b2b3ffcdSSimon Schubert #include <sys/param.h>
30b2b3ffcdSSimon Schubert #include <sys/systm.h>
31b2b3ffcdSSimon Schubert #include <sys/kernel.h>
32b2b3ffcdSSimon Schubert #include <sys/sysctl.h>
33b2b3ffcdSSimon Schubert #include <sys/proc.h>
34b2b3ffcdSSimon Schubert #include <sys/interrupt.h>
35b2b3ffcdSSimon Schubert #include <machine/globaldata.h>
36b2b3ffcdSSimon Schubert 
37b2b3ffcdSSimon Schubert /*
38b2b3ffcdSSimon Schubert  * Bits in the spending bitmap variable must be set atomically because
39b2b3ffcdSSimon Schubert  * spending may be manipulated by interrupts or other cpu's without holding
40b2b3ffcdSSimon Schubert  * any locks.
41b2b3ffcdSSimon Schubert  *
42b2b3ffcdSSimon Schubert  * Note: setbits uses a locked or, making simple cases MP safe.
43b2b3ffcdSSimon Schubert  */
44b2b3ffcdSSimon Schubert #define DO_SETBITS(name, var, bits) 					\
45b2b3ffcdSSimon Schubert void									\
46b2b3ffcdSSimon Schubert name(void)								\
47b2b3ffcdSSimon Schubert {									\
48b2b3ffcdSSimon Schubert 	struct mdglobaldata *gd = mdcpu;				\
49b2b3ffcdSSimon Schubert 	atomic_set_int_nonlocked(var, bits);				\
50*2a418930SMatthew Dillon 	atomic_set_int(&gd->mi.gd_reqflags, RQF_INTPEND);		\
51b2b3ffcdSSimon Schubert }									\
52b2b3ffcdSSimon Schubert 
53b2b3ffcdSSimon Schubert DO_SETBITS(setdelayed,   &gd->gd_spending, loadandclear(&gd->gd_sdelayed))
54b2b3ffcdSSimon Schubert 
55b2b3ffcdSSimon Schubert DO_SETBITS(setsoftcamnet,&gd->gd_spending, SWI_CAMNET_PENDING)
56b2b3ffcdSSimon Schubert DO_SETBITS(setsoftcambio,&gd->gd_spending, SWI_CAMBIO_PENDING)
57b2b3ffcdSSimon Schubert /*DO_SETBITS(setsoftunused02, &gd->gd_spending, SWI_UNUSED02_PENDING)*/
58b2b3ffcdSSimon Schubert /*DO_SETBITS(setsoftunused01,   &gd->gd_spending, SWI_UNUSED01_PENDING)*/
59b2b3ffcdSSimon Schubert DO_SETBITS(setsofttty,   &gd->gd_spending, SWI_TTY_PENDING)
60b2b3ffcdSSimon Schubert DO_SETBITS(setsoftvm,	 &gd->gd_spending, SWI_VM_PENDING)
61b2b3ffcdSSimon Schubert DO_SETBITS(setsofttq,	 &gd->gd_spending, SWI_TQ_PENDING)
62b2b3ffcdSSimon Schubert DO_SETBITS(setsoftcrypto,&gd->gd_spending, SWI_CRYPTO_PENDING)
63b2b3ffcdSSimon Schubert 
64b2b3ffcdSSimon Schubert /*DO_SETBITS(schedsoftcamnet, &gd->gd_sdelayed, SWI_CAMNET_PENDING)*/
65b2b3ffcdSSimon Schubert /*DO_SETBITS(schedsoftcambio, &gd->gd_sdelayed, SWI_CAMBIO_PENDING)*/
66b2b3ffcdSSimon Schubert /*DO_SETBITS(schedsoftunused01, &gd->gd_sdelayed, SWI_UNUSED01_PENDING)*/
67b2b3ffcdSSimon Schubert DO_SETBITS(schedsofttty, &gd->gd_sdelayed, SWI_TTY_PENDING)
68b2b3ffcdSSimon Schubert /*DO_SETBITS(schedsoftvm, &gd->gd_sdelayed, SWI_VM_PENDING)*/
69b2b3ffcdSSimon Schubert /*DO_SETBITS(schedsofttq, &gd->gd_sdelayed, SWI_TQ_PENDING)*/
70b2b3ffcdSSimon Schubert /* YYY schedsoft what? */
71b2b3ffcdSSimon Schubert 
72