Sat Dec 22 08:35:04 2018 UTC ()
Style, once again.


(maxv)
diff -r1.3 -r1.4 src/sys/arch/amd64/amd64/amd64_mainbus.c
diff -r1.3 -r1.4 src/sys/arch/i386/i386/i386_mainbus.c
diff -r1.1 -r1.2 src/sys/arch/x86/x86/mainbus.c
diff -r1.3 -r1.4 src/sys/arch/xen/x86/xen_mainbus.c

cvs diff -r1.3 -r1.4 src/sys/arch/amd64/amd64/amd64_mainbus.c (expand / switch to unified diff)

--- src/sys/arch/amd64/amd64/amd64_mainbus.c 2018/12/22 07:45:58 1.3
+++ src/sys/arch/amd64/amd64/amd64_mainbus.c 2018/12/22 08:35:04 1.4
@@ -1,15 +1,16 @@ @@ -1,15 +1,16 @@
1/* $NetBSD: amd64_mainbus.c,v 1.3 2018/12/22 07:45:58 cherry Exp $ */ 1/* $NetBSD: amd64_mainbus.c,v 1.4 2018/12/22 08:35:04 maxv Exp $ */
2/* NetBSD: mainbus.c,v 1.39 2018/12/02 08:19:44 cherry Exp */ 2/* NetBSD: mainbus.c,v 1.39 2018/12/02 08:19:44 cherry Exp */
 3
3/* 4/*
4 * Copyright (c) 1996 Christopher G. Demetriou. All rights reserved. 5 * Copyright (c) 1996 Christopher G. Demetriou. All rights reserved.
5 * 6 *
6 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
8 * are met: 9 * are met:
9 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
14 * 3. All advertising materials mentioning features or use of this software 15 * 3. All advertising materials mentioning features or use of this software
15 * must display the following acknowledgement: 16 * must display the following acknowledgement:
@@ -21,27 +22,27 @@ @@ -21,27 +22,27 @@
21 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 22 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 24 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 25 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
25 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 */ 32 */
32 33
33#include <sys/cdefs.h> 34#include <sys/cdefs.h>
34__KERNEL_RCSID(0, "$NetBSD: amd64_mainbus.c,v 1.3 2018/12/22 07:45:58 cherry Exp $"); 35__KERNEL_RCSID(0, "$NetBSD: amd64_mainbus.c,v 1.4 2018/12/22 08:35:04 maxv Exp $");
35 36
36#include <sys/param.h> 37#include <sys/param.h>
37#include <sys/systm.h> 38#include <sys/systm.h>
38#include <sys/device.h> 39#include <sys/device.h>
39#include <sys/reboot.h> 40#include <sys/reboot.h>
40#include <sys/bus.h> 41#include <sys/bus.h>
41 42
42#include <dev/isa/isavar.h> 43#include <dev/isa/isavar.h>
43#include <dev/pci/pcivar.h> 44#include <dev/pci/pcivar.h>
44 45
45#include <dev/isa/isareg.h> 46#include <dev/isa/isareg.h>
46 47
47#include "pci.h" 48#include "pci.h"
@@ -95,60 +96,59 @@ union amd64_mainbus_attach_args { @@ -95,60 +96,59 @@ union amd64_mainbus_attach_args {
95#if NACPICA > 0 96#if NACPICA > 0
96 struct acpibus_attach_args mba_acpi; 97 struct acpibus_attach_args mba_acpi;
97#endif 98#endif
98 struct apic_attach_args aaa_caa; 99 struct apic_attach_args aaa_caa;
99#if NIPMI > 0 100#if NIPMI > 0
100 struct ipmi_attach_args mba_ipmi; 101 struct ipmi_attach_args mba_ipmi;
101#endif 102#endif
102}; 103};
103 104
104/* 105/*
105 * This is set when the ISA bus is attached. If it's not set by the 106 * This is set when the ISA bus is attached. If it's not set by the
106 * time it's checked below, then mainbus attempts to attach an ISA. 107 * time it's checked below, then mainbus attempts to attach an ISA.
107 */ 108 */
108int isa_has_been_seen; 109int isa_has_been_seen;
109struct x86_isa_chipset x86_isa_chipset; 110struct x86_isa_chipset x86_isa_chipset;
110#if NISA > 0 111#if NISA > 0
111static const struct isabus_attach_args mba_iba = { 112static const struct isabus_attach_args mba_iba = {
112 ._iba_busname = "isa", 113 ._iba_busname = "isa",
113 .iba_dmat = &isa_bus_dma_tag, 114 .iba_dmat = &isa_bus_dma_tag,
114 .iba_ic = &x86_isa_chipset 115 .iba_ic = &x86_isa_chipset
115}; 116};
116#endif 117#endif
117 118
118#if defined(MPBIOS) || NACPICA > 0 119#if defined(MPBIOS) || NACPICA > 0
119struct mp_bus *mp_busses; 120struct mp_bus *mp_busses;
120int mp_nbus; 121int mp_nbus;
121struct mp_intr_map *mp_intrs; 122struct mp_intr_map *mp_intrs;
122int mp_nintr; 123int mp_nintr;
123  124
124int mp_isa_bus = -1; 125int mp_isa_bus = -1;
125int mp_eisa_bus = -1; 126int mp_eisa_bus = -1;
126 127
127extern bool acpi_present; 128extern bool acpi_present;
128extern bool mpacpi_active; 129extern bool mpacpi_active;
129 130
130# ifdef MPVERBOSE 131# ifdef MPVERBOSE
131# if MPVERBOSE > 0 132# if MPVERBOSE > 0
132int mp_verbose = MPVERBOSE; 133int mp_verbose = MPVERBOSE;
133# else 134# else
134int mp_verbose = 1; 135int mp_verbose = 1;
135# endif 136# endif
136# else 137# else
137int mp_verbose = 0; 138int mp_verbose = 0;
138# endif 139# endif
139#endif 140#endif
140 141
141 
142/* 142/*
143 * Probe for the mainbus; always succeeds. 143 * Probe for the mainbus; always succeeds.
144 */ 144 */
145int 145int
146amd64_mainbus_match(device_t parent, cfdata_t match, void *aux) 146amd64_mainbus_match(device_t parent, cfdata_t match, void *aux)
147{ 147{
148 148
149 return 1; 149 return 1;
150} 150}
151 151
152/* 152/*
153 * Attach the mainbus. 153 * Attach the mainbus.
154 */ 154 */
@@ -212,39 +212,38 @@ amd64_mainbus_attach(device_t parent, de @@ -212,39 +212,38 @@ amd64_mainbus_attach(device_t parent, de
212#endif 212#endif
213#if defined(MPBIOS) && defined(MPBIOS_SCANPCI) 213#if defined(MPBIOS) && defined(MPBIOS_SCANPCI)
214 if (npcibus == 0 && mpbios_scanned != 0) 214 if (npcibus == 0 && mpbios_scanned != 0)
215 npcibus = mp_pci_scan(self, &mba.mba_pba, pcibusprint); 215 npcibus = mp_pci_scan(self, &mba.mba_pba, pcibusprint);
216#endif 216#endif
217 if (npcibus == 0) 217 if (npcibus == 0)
218 config_found_ia(self, "pcibus", &mba.mba_pba, 218 config_found_ia(self, "pcibus", &mba.mba_pba,
219 pcibusprint); 219 pcibusprint);
220 220
221#if NACPICA > 0 221#if NACPICA > 0
222 if (mp_verbose) 222 if (mp_verbose)
223 acpi_pci_link_state(); 223 acpi_pci_link_state();
224#endif 224#endif
225 
226 } 225 }
227#endif 226#endif
228 227
229#if NISA > 0 228#if NISA > 0
230 if (isa_has_been_seen == 0) { 229 if (isa_has_been_seen == 0) {
231 mba.mba_iba = mba_iba; 230 mba.mba_iba = mba_iba;
232 mba.mba_iba.iba_iot = x86_bus_space_io; 231 mba.mba_iba.iba_iot = x86_bus_space_io;
233 mba.mba_iba.iba_memt = x86_bus_space_mem; 232 mba.mba_iba.iba_memt = x86_bus_space_mem;
234 config_found_ia(self, "isabus", &mba.mba_iba, isabusprint); 233 config_found_ia(self, "isabus", &mba.mba_iba, isabusprint);
235 } 234 }
236#endif 235#endif
237 236
238 if (!pmf_device_register(self, NULL, NULL)) 237 if (!pmf_device_register(self, NULL, NULL))
239 aprint_error_dev(self, "couldn't establish power handler\n"); 238 aprint_error_dev(self, "couldn't establish power handler\n");
240} 239}
241 240
242int 241int
243amd64_mainbus_print(void *aux, const char *pnp) 242amd64_mainbus_print(void *aux, const char *pnp)
244{ 243{
245 union amd64_mainbus_attach_args *mba = aux; 244 union amd64_mainbus_attach_args *mba = aux;
246 245
247 if (pnp) 246 if (pnp)
248 aprint_normal("%s at %s", mba->mba_busname, pnp); 247 aprint_normal("%s at %s", mba->mba_busname, pnp);
249 return (UNCONF); 248 return UNCONF;
250} 249}

cvs diff -r1.3 -r1.4 src/sys/arch/i386/i386/i386_mainbus.c (expand / switch to unified diff)

--- src/sys/arch/i386/i386/i386_mainbus.c 2018/12/22 07:45:58 1.3
+++ src/sys/arch/i386/i386/i386_mainbus.c 2018/12/22 08:35:04 1.4
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: i386_mainbus.c,v 1.3 2018/12/22 07:45:58 cherry Exp $ */ 1/* $NetBSD: i386_mainbus.c,v 1.4 2018/12/22 08:35:04 maxv Exp $ */
2/* NetBSD: mainbus.c,v 1.104 2018/12/02 08:19:44 cherry Exp */ 2/* NetBSD: mainbus.c,v 1.104 2018/12/02 08:19:44 cherry Exp */
3 3
4/* 4/*
5 * Copyright (c) 1996 Christopher G. Demetriou. All rights reserved. 5 * Copyright (c) 1996 Christopher G. Demetriou. 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.
@@ -22,27 +22,27 @@ @@ -22,27 +22,27 @@
22 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 22 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 24 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 25 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
27 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
31 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 */ 32 */
33 33
34#include <sys/cdefs.h> 34#include <sys/cdefs.h>
35__KERNEL_RCSID(0, "$NetBSD: i386_mainbus.c,v 1.3 2018/12/22 07:45:58 cherry Exp $"); 35__KERNEL_RCSID(0, "$NetBSD: i386_mainbus.c,v 1.4 2018/12/22 08:35:04 maxv Exp $");
36 36
37#include <sys/param.h> 37#include <sys/param.h>
38#include <sys/systm.h> 38#include <sys/systm.h>
39#include <sys/device.h> 39#include <sys/device.h>
40#include <sys/reboot.h> 40#include <sys/reboot.h>
41#include <sys/bus.h> 41#include <sys/bus.h>
42 42
43#include <dev/isa/isavar.h> 43#include <dev/isa/isavar.h>
44#include <dev/eisa/eisavar.h> 44#include <dev/eisa/eisavar.h>
45#include <dev/pci/pcivar.h> 45#include <dev/pci/pcivar.h>
46 46
47#include <dev/isa/isareg.h> /* for ISA_HOLE_VADDR */ 47#include <dev/isa/isareg.h> /* for ISA_HOLE_VADDR */
48 48
@@ -114,49 +114,49 @@ union i386_mainbus_attach_args { @@ -114,49 +114,49 @@ union i386_mainbus_attach_args {
114 struct apic_attach_args aaa_caa; 114 struct apic_attach_args aaa_caa;
115#if NACPICA > 0 115#if NACPICA > 0
116 struct acpibus_attach_args mba_acpi; 116 struct acpibus_attach_args mba_acpi;
117#endif 117#endif
118#if NIPMI > 0 118#if NIPMI > 0
119 struct ipmi_attach_args mba_ipmi; 119 struct ipmi_attach_args mba_ipmi;
120#endif 120#endif
121}; 121};
122 122
123/* 123/*
124 * This is set when the ISA bus is attached. If it's not set by the 124 * This is set when the ISA bus is attached. If it's not set by the
125 * time it's checked below, then mainbus attempts to attach an ISA. 125 * time it's checked below, then mainbus attempts to attach an ISA.
126 */ 126 */
127int isa_has_been_seen; 127int isa_has_been_seen;
128struct x86_isa_chipset x86_isa_chipset; 128struct x86_isa_chipset x86_isa_chipset;
129#if NISA > 0 129#if NISA > 0
130static const struct isabus_attach_args mba_iba = { 130static const struct isabus_attach_args mba_iba = {
131 ._iba_busname = "isa", 131 ._iba_busname = "isa",
132 .iba_dmat = &isa_bus_dma_tag, 132 .iba_dmat = &isa_bus_dma_tag,
133 .iba_ic = &x86_isa_chipset 133 .iba_ic = &x86_isa_chipset
134}; 134};
135#endif 135#endif
136 136
137/* 137/*
138 * Same as above, but for EISA. 138 * Same as above, but for EISA.
139 */ 139 */
140int eisa_has_been_seen; 140int eisa_has_been_seen;
141 141
142#if defined(MPBIOS) || NACPICA > 0 142#if defined(MPBIOS) || NACPICA > 0
143struct mp_bus *mp_busses; 143struct mp_bus *mp_busses;
144int mp_nbus; 144int mp_nbus;
145struct mp_intr_map *mp_intrs; 145struct mp_intr_map *mp_intrs;
146int mp_nintr; 146int mp_nintr;
147  147
148int mp_isa_bus = -1; /* XXX */ 148int mp_isa_bus = -1; /* XXX */
149int mp_eisa_bus = -1; /* XXX */ 149int mp_eisa_bus = -1; /* XXX */
150 150
151extern bool acpi_present; 151extern bool acpi_present;
152extern bool mpacpi_active; 152extern bool mpacpi_active;
153 153
154# ifdef MPVERBOSE 154# ifdef MPVERBOSE
155# if MPVERBOSE > 0 155# if MPVERBOSE > 0
156int mp_verbose = MPVERBOSE; 156int mp_verbose = MPVERBOSE;
157# else 157# else
158int mp_verbose = 1; 158int mp_verbose = 1;
159# endif 159# endif
160# else 160# else
161int mp_verbose = 0; 161int mp_verbose = 0;
162# endif 162# endif

cvs diff -r1.1 -r1.2 src/sys/arch/x86/x86/mainbus.c (expand / switch to unified diff)

--- src/sys/arch/x86/x86/mainbus.c 2018/12/22 07:45:59 1.1
+++ src/sys/arch/x86/x86/mainbus.c 2018/12/22 08:35:04 1.2
@@ -1,16 +1,16 @@ @@ -1,16 +1,16 @@
1/* $NetBSD: mainbus.c,v 1.1 2018/12/22 07:45:59 cherry Exp $ */ 1/* $NetBSD: mainbus.c,v 1.2 2018/12/22 08:35:04 maxv Exp $ */
2 2
3/*- 3/*
4 * Copyright (c) 2018 The NetBSD Foundation, Inc. 4 * Copyright (c) 2018 The NetBSD Foundation, Inc.
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.
15 * 15 *
16 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 16 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
@@ -18,27 +18,27 @@ @@ -18,27 +18,27 @@
18 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 18 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE. 26 * POSSIBILITY OF SUCH DAMAGE.
27 */ 27 */
28 28
29#include <sys/cdefs.h> 29#include <sys/cdefs.h>
30 30
31__KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.1 2018/12/22 07:45:59 cherry Exp $"); 31__KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.2 2018/12/22 08:35:04 maxv Exp $");
32 32
33#include <sys/param.h> 33#include <sys/param.h>
34#include <sys/systm.h> 34#include <sys/systm.h>
35#include <sys/device.h> 35#include <sys/device.h>
36#include <sys/reboot.h> 36#include <sys/reboot.h>
37 37
38#include <dev/pci/pcivar.h> 38#include <dev/pci/pcivar.h>
39 39
40#include <machine/cpuvar.h> 40#include <machine/cpuvar.h>
41#include <machine/mpbiosvar.h> 41#include <machine/mpbiosvar.h>
42#include <machine/mpacpi.h> 42#include <machine/mpacpi.h>
43 43
44#include "pci.h" 44#include "pci.h"
@@ -83,74 +83,73 @@ int mainbus_match(device_t, cfdata_t, vo @@ -83,74 +83,73 @@ int mainbus_match(device_t, cfdata_t, vo
83 83
84CFATTACH_DECL2_NEW(mainbus, sizeof(struct mainbus_softc), 84CFATTACH_DECL2_NEW(mainbus, sizeof(struct mainbus_softc),
85 mainbus_match, mainbus_attach, 85 mainbus_match, mainbus_attach,
86 NULL, NULL, 86 NULL, NULL,
87 mainbus_rescan, mainbus_childdetached); 87 mainbus_rescan, mainbus_childdetached);
88 88
89#if defined(__i386__) && !defined(XEN) 89#if defined(__i386__) && !defined(XEN)
90void i386_mainbus_childdetached(device_t, device_t); 90void i386_mainbus_childdetached(device_t, device_t);
91int i386_mainbus_rescan(device_t, const char *, const int *); 91int i386_mainbus_rescan(device_t, const char *, const int *);
92void i386_mainbus_attach(device_t, device_t, void *); 92void i386_mainbus_attach(device_t, device_t, void *);
93#endif 93#endif
94 94
95#if defined(__x86_64__) && !defined(XEN) 95#if defined(__x86_64__) && !defined(XEN)
96void 96void amd64_mainbus_attach(device_t, device_t, void *);
97amd64_mainbus_attach(device_t, device_t, void *); 
98#endif 97#endif
99 98
100#if defined(XEN) 99#if defined(XEN)
101void xen_mainbus_attach(device_t, device_t, void *); 100void xen_mainbus_attach(device_t, device_t, void *);
102#endif 101#endif
103 102
104static int 103static int
105mainbus_cpu_print(void *aux, const char *busname) 104mainbus_cpu_print(void *aux, const char *busname)
106{ 105{
107 char *cpuname = aux; 106 char *cpuname = aux;
108 107
109 if (busname) 108 if (busname)
110 aprint_normal("%s at %s", cpuname, busname); 109 aprint_normal("%s at %s", cpuname, busname);
111 return (UNCONF); 110 return UNCONF;
112} 111}
113 112
114/* 113/*
115 * On x86, cpus can be enumerated and attached to mainbus in mainly 114 * On x86, CPUs can be enumerated and attached to mainbus in mainly two ways
116 * two ways depending on the platform (configuration): 115 * depending on the platform (configuration): via MP BIOS tables, and via
117 * via MP BIOS tables, and via ACPI tables.  116 * ACPI tables.
118 * 117 *
119 * Since cpus are not an optional part of computers, this attachment 118 * Since CPUs are not an optional part of computers, this attachment is made
120 * is made common across all x86 architectures and modes, and thus 119 * common across all x86 architectures and modes, and thus hard-coded into
121 * hard coded into the boot path, with the exception of XEN PV domU. 120 * the boot path, with the exception of XEN PV domU.
122 * 121 *
123 * Along with cpus, apics come in various shapes and forms, and to 122 * Along with CPUs, APICs come in various shapes and forms, and to accommodate
124 * accommodate for the configurable ioapic topology, the "ioapicbus" 123 * for the configurable ioapic topology, the "ioapicbus" is also enumerated
125 * is also enumerated here as part of the mpbios/mpacpi probe path. 124 * here as part of the mpbios/mpacpi probe path.
126 * 125 *
127 * All other busses are attached variously depending on the 126 * All other busses are attached variously depending on the platform
128 * platform architecture and config(5) 127 * architecture and config(5).
129 * 128 *
130 * These configurations and attach orderings for various platforms are 129 * These configurations and attach orderings for various platforms are
131 * currently respectively driven in the functions: 130 * currently respectively driven in the functions:
132 * 131 *
133 * i386_mainbus_attach(); 132 * i386_mainbus_attach();
134 * amd64_mainbus_attach(); 133 * amd64_mainbus_attach();
135 * xen_mainbus_attach(); 134 * xen_mainbus_attach();
136 * 135 *
137 * This arrangement gives us the flexibility to do things such as 136 * This arrangement gives us the flexibility to do things such as dynamic
138 * dynamic attach path traversal at boot time, depending on the 137 * attach path traversal at boot time, depending on the "mode" of operation,
139 * "mode" of operation, ie; virtualition aware or native. 138 * ie: virtualition aware or native.
140 * 139 *
141 * For (a contrived) eg: XEN PVHVM would allow us to attach pci(9) 140 * For (a contrived) eg: XEN PVHVM would allow us to attach pci(9) either via
142 * either via hypervisorbus or mainbus depending on if the kernel is 141 * hypervisorbus or mainbus depending on if the kernel is running under the
143 * running under the hypervisor or not. 142 * hypervisor or not.
144 */ 143 */
145 144
146static void 145static void
147x86_cpubus_attach(device_t self) 146x86_cpubus_attach(device_t self)
148{ 147{
149 int numcpus = 0; 148 int numcpus = 0;
150 149
151#if NPCI > 0 150#if NPCI > 0
152 151
153#ifdef __HAVE_PCI_MSI_MSIX 152#ifdef __HAVE_PCI_MSI_MSIX
154 msipic_init(); 153 msipic_init();
155#endif 154#endif
156 155
@@ -184,38 +183,37 @@ x86_cpubus_attach(device_t self) @@ -184,38 +183,37 @@ x86_cpubus_attach(device_t self)
184 */ 183 */
185 if (acpi_present) 184 if (acpi_present)
186 mpacpi_active = mpacpi_scan_apics(self, &numcpus) != 0; 185 mpacpi_active = mpacpi_scan_apics(self, &numcpus) != 0;
187 186
188 if (!mpacpi_active) { 187 if (!mpacpi_active) {
189#endif 188#endif
190#ifdef MPBIOS 189#ifdef MPBIOS
191 if (mpbios_probe(self)) 190 if (mpbios_probe(self))
192 mpbios_scan(self, &numcpus); 191 mpbios_scan(self, &numcpus);
193 else 192 else
194#endif 193#endif
195 if (numcpus == 0) { 194 if (numcpus == 0) {
196 struct cpu_attach_args caa; 195 struct cpu_attach_args caa;
197  196
198 memset(&caa, 0, sizeof(caa)); 197 memset(&caa, 0, sizeof(caa));
199 caa.cpu_number = 0; 198 caa.cpu_number = 0;
200 caa.cpu_role = CPU_ROLE_SP; 199 caa.cpu_role = CPU_ROLE_SP;
201 caa.cpu_func = 0; 200 caa.cpu_func = 0;
202  201
203 config_found_ia(self, "cpubus", &caa, mainbus_cpu_print); 202 config_found_ia(self, "cpubus", &caa, mainbus_cpu_print);
204 } 203 }
205#if NACPICA > 0  204#if NACPICA > 0
206 } 205 }
207#endif 206#endif
208 
209} 207}
210 208
211int 209int
212mainbus_match(device_t parent, cfdata_t match, void *aux) 210mainbus_match(device_t parent, cfdata_t match, void *aux)
213{ 211{
214 212
215 return 1; 213 return 1;
216} 214}
217 215
218void 216void
219mainbus_attach(device_t parent, device_t self, void *aux) 217mainbus_attach(device_t parent, device_t self, void *aux)
220{ 218{
221 219
@@ -228,28 +226,30 @@ mainbus_attach(device_t parent, device_t @@ -228,28 +226,30 @@ mainbus_attach(device_t parent, device_t
228 x86_cpubus_attach(self); 226 x86_cpubus_attach(self);
229 227
230#if defined(__i386__) && !defined(XEN) 228#if defined(__i386__) && !defined(XEN)
231 i386_mainbus_attach(parent, self, aux); 229 i386_mainbus_attach(parent, self, aux);
232#elif defined(__x86_64__) && !defined(XEN) 230#elif defined(__x86_64__) && !defined(XEN)
233 amd64_mainbus_attach(parent, self, aux); 231 amd64_mainbus_attach(parent, self, aux);
234#endif 232#endif
235#if defined(XEN) 233#if defined(XEN)
236 } 234 }
237 xen_mainbus_attach(parent, self, aux); 235 xen_mainbus_attach(parent, self, aux);
238#endif 236#endif
239} 237}
240 238
241int mainbus_rescan(device_t self, const char *ifattr, const int *locators) 239int
 240mainbus_rescan(device_t self, const char *ifattr, const int *locators)
242{ 241{
243#if defined(__i386__) && !defined(XEN) 242#if defined(__i386__) && !defined(XEN)
244 return i386_mainbus_rescan(self, ifattr, locators); 243 return i386_mainbus_rescan(self, ifattr, locators);
245#endif 244#endif
246 return ENOTTY; /* Inappropriate ioctl for this device */ 245 return ENOTTY; /* Inappropriate ioctl for this device */
247} 246}
248 247
249void mainbus_childdetached(device_t self, device_t child) 248void
 249mainbus_childdetached(device_t self, device_t child)
250{ 250{
251#if defined(__i386__) && !defined(XEN) 251#if defined(__i386__) && !defined(XEN)
252 i386_mainbus_childdetached(self, child); 252 i386_mainbus_childdetached(self, child);
253#endif 253#endif
254} 254}
255 255

cvs diff -r1.3 -r1.4 src/sys/arch/xen/x86/xen_mainbus.c (expand / switch to unified diff)

--- src/sys/arch/xen/x86/xen_mainbus.c 2018/12/22 07:45:58 1.3
+++ src/sys/arch/xen/x86/xen_mainbus.c 2018/12/22 08:35:04 1.4
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: xen_mainbus.c,v 1.3 2018/12/22 07:45:58 cherry Exp $ */ 1/* $NetBSD: xen_mainbus.c,v 1.4 2018/12/22 08:35:04 maxv Exp $ */
2/* NetBSD: mainbus.c,v 1.19 2017/05/23 08:54:39 nonaka Exp */ 2/* NetBSD: mainbus.c,v 1.19 2017/05/23 08:54:39 nonaka Exp */
3/* NetBSD: mainbus.c,v 1.53 2003/10/27 14:11:47 junyoung Exp */ 3/* NetBSD: mainbus.c,v 1.53 2003/10/27 14:11:47 junyoung Exp */
4 4
5/* 5/*
6 * Copyright (c) 1996 Christopher G. Demetriou. All rights reserved. 6 * Copyright (c) 1996 Christopher G. Demetriou. All rights reserved.
7 * 7 *
8 * Redistribution and use in source and binary forms, with or without 8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions 9 * modification, are permitted provided that the following conditions
10 * are met: 10 * are met:
11 * 1. Redistributions of source code must retain the above copyright 11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer. 12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright 13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the 14 * notice, this list of conditions and the following disclaimer in the
@@ -23,27 +23,27 @@ @@ -23,27 +23,27 @@
23 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 23 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
24 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 24 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
25 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 25 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
26 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 26 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
27 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 27 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
28 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
32 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 */ 33 */
34 34
35#include <sys/cdefs.h> 35#include <sys/cdefs.h>
36__KERNEL_RCSID(0, "$NetBSD: xen_mainbus.c,v 1.3 2018/12/22 07:45:58 cherry Exp $"); 36__KERNEL_RCSID(0, "$NetBSD: xen_mainbus.c,v 1.4 2018/12/22 08:35:04 maxv Exp $");
37 37
38#include <sys/param.h> 38#include <sys/param.h>
39#include <sys/systm.h> 39#include <sys/systm.h>
40#include <sys/device.h> 40#include <sys/device.h>
41 41
42#include <sys/bus.h> 42#include <sys/bus.h>
43 43
44#include "hypervisor.h" 44#include "hypervisor.h"
45#include "pci.h" 45#include "pci.h"
46 46
47#include "opt_xen.h" 47#include "opt_xen.h"
48#include "opt_mpbios.h" 48#include "opt_mpbios.h"
49#include "opt_pcifixup.h" 49#include "opt_pcifixup.h"
@@ -57,46 +57,46 @@ __KERNEL_RCSID(0, "$NetBSD: xen_mainbus. @@ -57,46 +57,46 @@ __KERNEL_RCSID(0, "$NetBSD: xen_mainbus.
57#include <machine/i82093var.h> 57#include <machine/i82093var.h>
58 58
59#include <xen/xen.h> 59#include <xen/xen.h>
60#include <xen/hypervisor.h> 60#include <xen/hypervisor.h>
61 61
62#if NIPMI > 0 62#if NIPMI > 0
63#include <x86/ipmivar.h> 63#include <x86/ipmivar.h>
64#endif 64#endif
65 65
66#if NPCI > 0 66#if NPCI > 0
67#include <dev/pci/pcivar.h> 67#include <dev/pci/pcivar.h>
68#if NACPICA > 0 68#if NACPICA > 0
69#include <dev/acpi/acpivar.h> 69#include <dev/acpi/acpivar.h>
70#include <xen/mpacpi.h>  70#include <xen/mpacpi.h>
71#endif /* NACPICA > 0 */ 71#endif /* NACPICA > 0 */
72#ifdef MPBIOS 72#ifdef MPBIOS
73#include <machine/mpbiosvar.h>  73#include <machine/mpbiosvar.h>
74#endif /* MPBIOS */ 74#endif /* MPBIOS */
75#ifdef PCI_BUS_FIXUP 75#ifdef PCI_BUS_FIXUP
76#include <arch/x86/pci/pci_bus_fixup.h> 76#include <arch/x86/pci/pci_bus_fixup.h>
77#ifdef PCI_ADDR_FIXUP 77#ifdef PCI_ADDR_FIXUP
78#include <arch/x86/pci/pci_addr_fixup.h> 78#include <arch/x86/pci/pci_addr_fixup.h>
79#endif  79#endif
80#endif 80#endif
81 81
82#if defined(MPBIOS) || NACPICA > 0 82#if defined(MPBIOS) || NACPICA > 0
83struct mp_bus *mp_busses; 83struct mp_bus *mp_busses;
84int mp_nbus; 84int mp_nbus;
85struct mp_intr_map *mp_intrs; 85struct mp_intr_map *mp_intrs;
86int mp_nintr; 86int mp_nintr;
87  87
88int mp_isa_bus = -1; /* XXX */ 88int mp_isa_bus = -1; /* XXX */
89int mp_eisa_bus = -1; /* XXX */ 89int mp_eisa_bus = -1; /* XXX */
90 90
91#ifdef MPVERBOSE 91#ifdef MPVERBOSE
92int mp_verbose = 1; 92int mp_verbose = 1;
93#else /* MPVERBOSE */ 93#else /* MPVERBOSE */
94int mp_verbose = 0; 94int mp_verbose = 0;
95#endif /* MPVERBOSE */ 95#endif /* MPVERBOSE */
96#endif /* defined(MPBIOS) || NACPICA > 0 */ 96#endif /* defined(MPBIOS) || NACPICA > 0 */
97#endif /* NPCI > 0 */ 97#endif /* NPCI > 0 */
98 98
99extern bool acpi_present; 99extern bool acpi_present;
100extern bool mpacpi_active; 100extern bool mpacpi_active;
101 101
102int xen_mainbus_match(device_t, cfdata_t, void *); 102int xen_mainbus_match(device_t, cfdata_t, void *);
@@ -138,25 +138,24 @@ xen_mainbus_attach(device_t parent, devi @@ -138,25 +138,24 @@ xen_mainbus_attach(device_t parent, devi
138 mba.mba_ipmi.iaa_memt = x86_bus_space_mem; 138 mba.mba_ipmi.iaa_memt = x86_bus_space_mem;
139 if (ipmi_probe(&mba.mba_ipmi)) 139 if (ipmi_probe(&mba.mba_ipmi))
140 config_found_ia(self, "ipmibus", &mba.mba_ipmi, 0); 140 config_found_ia(self, "ipmibus", &mba.mba_ipmi, 0);
141#endif 141#endif
142 142
143#if NHYPERVISOR > 0 143#if NHYPERVISOR > 0
144 mba.mba_haa.haa_busname = "hypervisor"; 144 mba.mba_haa.haa_busname = "hypervisor";
145 config_found_ia(self, "hypervisorbus", &mba.mba_haa, xen_mainbus_print); 145 config_found_ia(self, "hypervisorbus", &mba.mba_haa, xen_mainbus_print);
146#endif 146#endif
147 147
148 /* save/restore for Xen */ 148 /* save/restore for Xen */
149 if (!pmf_device_register(self, NULL, NULL)) 149 if (!pmf_device_register(self, NULL, NULL))
150 aprint_error_dev(self, "couldn't establish power handler\n"); 150 aprint_error_dev(self, "couldn't establish power handler\n");
151 
152} 151}
153 152
154int 153int
155xen_mainbus_print(void *aux, const char *pnp) 154xen_mainbus_print(void *aux, const char *pnp)
156{ 155{
157 union xen_mainbus_attach_args *mba = aux; 156 union xen_mainbus_attach_args *mba = aux;
158 157
159 if (pnp) 158 if (pnp)
160 aprint_normal("%s at %s", mba->mba_busname, pnp); 159 aprint_normal("%s at %s", mba->mba_busname, pnp);
161 return (UNCONF); 160 return UNCONF;
162} 161}