Tue Aug 15 09:25:00 2017 UTC ()
Reduce the diff between amd64 and i386, and style.


(maxv)
diff -r1.6 -r1.7 src/sys/arch/amd64/amd64/rbus_machdep.c
diff -r1.26 -r1.27 src/sys/arch/i386/i386/rbus_machdep.c

cvs diff -r1.6 -r1.7 src/sys/arch/amd64/amd64/rbus_machdep.c (expand / switch to unified diff)

--- src/sys/arch/amd64/amd64/rbus_machdep.c 2014/06/29 23:21:28 1.6
+++ src/sys/arch/amd64/amd64/rbus_machdep.c 2017/08/15 09:25:00 1.7
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: rbus_machdep.c,v 1.6 2014/06/29 23:21:28 jakllsch Exp $ */ 1/* $NetBSD: rbus_machdep.c,v 1.7 2017/08/15 09:25:00 maxv Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1999 4 * Copyright (c) 1999
5 * HAYAKAWA Koichi. All rights reserved. 5 * HAYAKAWA Koichi. 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.
@@ -16,27 +16,27 @@ @@ -16,27 +16,27 @@
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28#include <sys/cdefs.h> 28#include <sys/cdefs.h>
29__KERNEL_RCSID(0, "$NetBSD: rbus_machdep.c,v 1.6 2014/06/29 23:21:28 jakllsch Exp $"); 29__KERNEL_RCSID(0, "$NetBSD: rbus_machdep.c,v 1.7 2017/08/15 09:25:00 maxv Exp $");
30 30
31#include "opt_pcifixup.h" 31#include "opt_pcifixup.h"
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/extent.h> 35#include <sys/extent.h>
36 36
37#include <sys/sysctl.h> 37#include <sys/sysctl.h>
38 38
39#include <sys/bus.h> 39#include <sys/bus.h>
40#include <dev/cardbus/rbus.h> 40#include <dev/cardbus/rbus.h>
41 41
42#include <sys/device.h> 42#include <sys/device.h>
@@ -113,17 +113,17 @@ rbus_pccbb_parent_io(struct pci_attach_a @@ -113,17 +113,17 @@ rbus_pccbb_parent_io(struct pci_attach_a
113 extern struct extent *ioport_ex; 113 extern struct extent *ioport_ex;
114 struct extent *ex = ioport_ex; 114 struct extent *ex = ioport_ex;
115 115
116#if defined(PCI_ADDR_FIXUP) 116#if defined(PCI_ADDR_FIXUP)
117 if (pciaddr.extent_port != NULL) 117 if (pciaddr.extent_port != NULL)
118 ex = pciaddr.extent_port; 118 ex = pciaddr.extent_port;
119#endif 119#endif
120 120
121 start = RBUS_IO_BASE; 121 start = RBUS_IO_BASE;
122 size = RBUS_IO_SIZE; 122 size = RBUS_IO_SIZE;
123 123
124 ret = rbus_new_root_share(pa->pa_iot, ex, start, size, 0); 124 ret = rbus_new_root_share(pa->pa_iot, ex, start, size, 0);
125 if (ret == NULL) 125 if (ret == NULL)
126 panic("failed to alloc I/O space"); 126 panic("failed to alloc I/O space");
127 127
128 return ret; 128 return ret;
129} 129}

cvs diff -r1.26 -r1.27 src/sys/arch/i386/i386/rbus_machdep.c (expand / switch to unified diff)

--- src/sys/arch/i386/i386/rbus_machdep.c 2011/07/01 18:14:15 1.26
+++ src/sys/arch/i386/i386/rbus_machdep.c 2017/08/15 09:25:00 1.27
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: rbus_machdep.c,v 1.26 2011/07/01 18:14:15 dyoung Exp $ */ 1/* $NetBSD: rbus_machdep.c,v 1.27 2017/08/15 09:25:00 maxv Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1999 4 * Copyright (c) 1999
5 * HAYAKAWA Koichi. All rights reserved. 5 * HAYAKAWA Koichi. 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.
@@ -16,37 +16,35 @@ @@ -16,37 +16,35 @@
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28#include <sys/cdefs.h> 28#include <sys/cdefs.h>
29__KERNEL_RCSID(0, "$NetBSD: rbus_machdep.c,v 1.26 2011/07/01 18:14:15 dyoung Exp $"); 29__KERNEL_RCSID(0, "$NetBSD: rbus_machdep.c,v 1.27 2017/08/15 09:25:00 maxv Exp $");
30 30
31#include "opt_pcibios.h" 31#include "opt_pcibios.h"
32#include "opt_pcifixup.h" 32#include "opt_pcifixup.h"
33 33
34#include <sys/param.h> 34#include <sys/param.h>
35#include <sys/systm.h> 35#include <sys/systm.h>
36#include <sys/extent.h> 36#include <sys/extent.h>
37 37
38#include <uvm/uvm_extern.h> 
39 
40#include <sys/sysctl.h> 38#include <sys/sysctl.h>
41 39
42#include <sys/bus.h> 40#include <sys/bus.h>
43#include <dev/cardbus/rbus.h> 41#include <dev/cardbus/rbus.h>
44 42
45#include <sys/device.h> 43#include <sys/device.h>
46#include <dev/isa/isareg.h> 44#include <dev/isa/isareg.h>
47#include <dev/isa/isavar.h> 45#include <dev/isa/isavar.h>
48 46
49#include <dev/pci/pcivar.h> 47#include <dev/pci/pcivar.h>
50#if defined(PCI_ADDR_FIXUP) 48#if defined(PCI_ADDR_FIXUP)
51#include <arch/x86/pci/pci_addr_fixup.h> 49#include <arch/x86/pci/pci_addr_fixup.h>
52#endif 50#endif
@@ -78,53 +76,53 @@ bus_addr_t rbus_min_start = RBUS_MIN_STA @@ -78,53 +76,53 @@ bus_addr_t rbus_min_start = RBUS_MIN_STA
78 * 76 *
79 * Thus, a general strategy of setting rbus_min_start to the amount of 77 * Thus, a general strategy of setting rbus_min_start to the amount of
80 * memory seems in order. However, the actually amount of memory is 78 * memory seems in order. However, the actually amount of memory is
81 * generally slightly more than the amount found, e.g. 1014MB vs 1024, 79 * generally slightly more than the amount found, e.g. 1014MB vs 1024,
82 * or 2046 vs 2048. 80 * or 2046 vs 2048.
83 */ 81 */
84void 82void
85rbus_min_start_hint(psize_t ram) 83rbus_min_start_hint(psize_t ram)
86{ 84{
87#ifdef RBUS_MIN_START_FORCED 85#ifdef RBUS_MIN_START_FORCED
88 aprint_debug("rbus: rbus_min_start from config at %#0" PRIxPADDR "\n", 86 aprint_debug("rbus: rbus_min_start from config at %#0" PRIxPADDR "\n",
89 rbus_min_start); 87 rbus_min_start);
90#else 88#else
91 if (ram <= 192*1024*1024UL) { 89 if (ram <= 192*1024*1024UL) {
92 /* 90 /*
93 * <= 192 MB, so try 0.5 GB. This will work on 91 * <= 192 MB, so try 0.5 GB. This will work on
94 * Thinkpad 600E (2645-4AU), which fails at 1GB, and 92 * Thinkpad 600E (2645-4AU), which fails at 1GB, and
95 * on some other older machines that may have trouble 93 * on some other older machines that may have trouble
96 * with addresses needing more than 20 bits. 94 * with addresses needing more than 20 bits.
97 */ 95 */
98 rbus_min_start = 512 * 1024 * 1024UL; 96 rbus_min_start = 512 * 1024 * 1024UL;
99 } 97 }
100 98
101 if (ram >= 1024*1024*1024UL) { 99 if (ram >= 1024*1024*1024UL) {
102 /* 100 /*
103 * > 1GB, so try 2 GB. 101 * > 1GB, so try 2 GB.
104 */ 102 */
105 rbus_min_start = 2 * 1024 * 1024 * 1024UL; 103 rbus_min_start = 2 * 1024 * 1024 * 1024UL;
106 } 104 }
107 105
108 /* XXX Not tested in > 2 GB case. */ 106 /* XXX Not tested in > 2 GB case. */
109 if (ram > 2 * 1024*1024*1024UL) { 107 if (ram > 2 * 1024*1024*1024UL) {
110 /* 108 /*
111 * > 2 GB, so try 3 GB. 109 * > 2 GB, so try 3 GB.
112 */ 110 */
113 rbus_min_start = 3 * 1024 * 1024 * 1024UL; 111 rbus_min_start = 3 * 1024 * 1024 * 1024UL;
114 } 112 }
115 113
116 aprint_debug("rbus: rbus_min_start set to %#0" PRIxPADDR "\n", 114 aprint_debug("rbus: rbus_min_start set to %#0" PRIxPADDR "\n",
117 rbus_min_start); 115 rbus_min_start);
118#endif 116#endif
119} 117}
120 118
121 119
122/* 120/*
123 * rbus_tag_t rbus_fakeparent_mem(struct pci_attach_args *pa) 121 * rbus_tag_t rbus_fakeparent_mem(struct pci_attach_args *pa)
124 * 122 *
125 * This function makes an rbus tag for memory space. This rbus tag 123 * This function makes an rbus tag for memory space. This rbus tag
126 * shares the all memory region of ex_iomem. 124 * shares the all memory region of ex_iomem.
127 */ 125 */
128rbus_tag_t 126rbus_tag_t
129rbus_pccbb_parent_mem(struct pci_attach_args *pa) 127rbus_pccbb_parent_mem(struct pci_attach_args *pa)
130{ 128{
@@ -141,48 +139,48 @@ rbus_pccbb_parent_mem(struct pci_attach_ @@ -141,48 +139,48 @@ rbus_pccbb_parent_mem(struct pci_attach_
141 start = ex->ex_start; 139 start = ex->ex_start;
142 140
143 /* 141 /*
144 * XXX: unfortunately, iomem_ex cannot be used for the dynamic 142 * XXX: unfortunately, iomem_ex cannot be used for the dynamic
145 * bus_space allocation. There are some hidden memory (or 143 * bus_space allocation. There are some hidden memory (or
146 * some obstacles which are not recognised by the kernel) in 144 * some obstacles which are not recognised by the kernel) in
147 * the region governed by iomem_ex. So I decide to use only 145 * the region governed by iomem_ex. So I decide to use only
148 * very high address region. 146 * very high address region.
149 * 147 *
150 * If pcibios_addr_fixup() succeeded, the PCI device is using an area 148 * If pcibios_addr_fixup() succeeded, the PCI device is using an area
151 * which is not recognised by the kernel as already reserved. 149 * which is not recognised by the kernel as already reserved.
152 */ 150 */
153 151
154 if (start < rbus_min_start)  152 if (start < rbus_min_start)
155 start = rbus_min_start; 153 start = rbus_min_start;
156 154
157 size = ex->ex_end - start; 155 size = ex->ex_end - start;
158  156
159 return rbus_new_root_share(pa->pa_memt, ex, start, size, 0); 157 return rbus_new_root_share(pa->pa_memt, ex, start, size, 0);
160} 158}
161 159
162 160
163/* 161/*
164 * rbus_tag_t rbus_pccbb_parent_io(struct pci_attach_args *pa) 162 * rbus_tag_t rbus_pccbb_parent_io(struct pci_attach_args *pa)
165 */ 163 */
166rbus_tag_t 164rbus_tag_t
167rbus_pccbb_parent_io(struct pci_attach_args *pa) 165rbus_pccbb_parent_io(struct pci_attach_args *pa)
168{ 166{
169 bus_addr_t start; 167 bus_addr_t start;
170 bus_size_t size; 168 bus_size_t size;
171 rbus_tag_t ret; 169 rbus_tag_t ret;
172 extern struct extent *ioport_ex; 170 extern struct extent *ioport_ex;
173 struct extent *ex = ioport_ex; 171 struct extent *ex = ioport_ex;
174 172
175#if defined(PCI_ADDR_FIXUP) 173#if defined(PCI_ADDR_FIXUP)
176 if (pciaddr.extent_port != NULL) 174 if (pciaddr.extent_port != NULL)
177 ex = pciaddr.extent_port; 175 ex = pciaddr.extent_port;
178#endif 176#endif
179 177
180 start = RBUS_IO_BASE; 178 start = RBUS_IO_BASE;
181 size = RBUS_IO_SIZE; 179 size = RBUS_IO_SIZE;
182 180
183 ret = rbus_new_root_share(pa->pa_iot, ex, start, size, 0); 181 ret = rbus_new_root_share(pa->pa_iot, ex, start, size, 0);
184 if (ret == NULL) 182 if (ret == NULL)
185 panic("failed to alloc I/O space"); 183 panic("failed to alloc I/O space");
186 184
187 return ret; 185 return ret;
188} 186}