Tue May 26 03:30:25 2009 UTC ()
do as phone suggested - remove sparc_bus_map_large() again and use a flag
instead ( BUS_SPACE_MAP_LARGE )


(macallan)
diff -r1.55 -r1.56 src/sys/arch/sparc/include/bus.h
diff -r1.293 -r1.294 src/sys/arch/sparc/sparc/machdep.c

cvs diff -r1.55 -r1.56 src/sys/arch/sparc/include/Attic/bus.h (expand / switch to unified diff)

--- src/sys/arch/sparc/include/Attic/bus.h 2009/04/16 16:55:00 1.55
+++ src/sys/arch/sparc/include/Attic/bus.h 2009/05/26 03:30:25 1.56
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: bus.h,v 1.55 2009/04/16 16:55:00 macallan Exp $ */ 1/* $NetBSD: bus.h,v 1.56 2009/05/26 03:30:25 macallan Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1996, 1997, 1998, 2001 The NetBSD Foundation, Inc. 4 * Copyright (c) 1996, 1997, 1998, 2001 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 of the Numerical Aerospace Simulation Facility, 8 * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
9 * NASA Ames Research Center. 9 * NASA Ames Research Center.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions 12 * modification, are permitted provided that the following conditions
13 * are met: 13 * are met:
14 * 1. Redistributions of source code must retain the above copyright 14 * 1. Redistributions of source code must retain the above copyright
@@ -235,29 +235,26 @@ static void *bus_intr_establish( @@ -235,29 +235,26 @@ static void *bus_intr_establish(
235 see machine/intr.h*/ 235 see machine/intr.h*/
236 int (*)(void *), /*handler*/ 236 int (*)(void *), /*handler*/
237 void *); /*handler arg*/ 237 void *); /*handler arg*/
238static void *bus_intr_establish2( 238static void *bus_intr_establish2(
239 bus_space_tag_t, 239 bus_space_tag_t,
240 int, /*bus-specific intr*/ 240 int, /*bus-specific intr*/
241 int, /*device class level, 241 int, /*device class level,
242 see machine/intr.h*/ 242 see machine/intr.h*/
243 int (*)(void *), /*handler*/ 243 int (*)(void *), /*handler*/
244 void *, /*handler arg*/ 244 void *, /*handler arg*/
245 void (*)(void)); /*optional fast vector*/ 245 void (*)(void)); /*optional fast vector*/
246 246
247 247
248int sparc_bus_map_large(bus_space_tag_t, int, bus_size_t, bus_size_t, int,  
249 bus_space_handle_t *); 
250 
251 248
252static __inline int 249static __inline int
253bus_space_map(t, a, s, f, hp) 250bus_space_map(t, a, s, f, hp)
254 bus_space_tag_t t; 251 bus_space_tag_t t;
255 bus_addr_t a; 252 bus_addr_t a;
256 bus_size_t s; 253 bus_size_t s;
257 int f; 254 int f;
258 bus_space_handle_t *hp; 255 bus_space_handle_t *hp;
259{ 256{
260 return (*t->sparc_bus_map)(t, a, s, f, (vaddr_t)0, hp); 257 return (*t->sparc_bus_map)(t, a, s, f, (vaddr_t)0, hp);
261} 258}
262 259
263static __inline int 260static __inline int
@@ -346,27 +343,27 @@ int bus_space_alloc(bus_space_tag_t t, b @@ -346,27 +343,27 @@ int bus_space_alloc(bus_space_tag_t t, b
346void bus_space_free(bus_space_tag_t t, bus_space_handle_t bsh, 343void bus_space_free(bus_space_tag_t t, bus_space_handle_t bsh,
347 bus_size_t size); 344 bus_size_t size);
348#endif 345#endif
349 346
350#define bus_space_vaddr(t, h) ((void)(t), (void *)(h)) 347#define bus_space_vaddr(t, h) ((void)(t), (void *)(h))
351 348
352/* flags for bus space map functions */ 349/* flags for bus space map functions */
353#define BUS_SPACE_MAP_CACHEABLE 0x0001 350#define BUS_SPACE_MAP_CACHEABLE 0x0001
354#define BUS_SPACE_MAP_LINEAR 0x0002 351#define BUS_SPACE_MAP_LINEAR 0x0002
355#define BUS_SPACE_MAP_PREFETCHABLE 0x0004 352#define BUS_SPACE_MAP_PREFETCHABLE 0x0004
356#define BUS_SPACE_MAP_BUS1 0x0100 /* placeholders for bus functions... */ 353#define BUS_SPACE_MAP_BUS1 0x0100 /* placeholders for bus functions... */
357#define BUS_SPACE_MAP_BUS2 0x0200 354#define BUS_SPACE_MAP_BUS2 0x0200
358#define BUS_SPACE_MAP_BUS3 0x0400 355#define BUS_SPACE_MAP_BUS3 0x0400
359#define BUS_SPACE_MAP_BUS4 0x0800 356#define BUS_SPACE_MAP_LARGE 0x0800 /* map outside IODEV range */
360 357
361 358
362/* flags for bus_space_barrier() */ 359/* flags for bus_space_barrier() */
363#define BUS_SPACE_BARRIER_READ 0x01 /* force read barrier */ 360#define BUS_SPACE_BARRIER_READ 0x01 /* force read barrier */
364#define BUS_SPACE_BARRIER_WRITE 0x02 /* force write barrier */ 361#define BUS_SPACE_BARRIER_WRITE 0x02 /* force write barrier */
365 362
366/* 363/*
367 * Device space probe assistant. 364 * Device space probe assistant.
368 * The optional callback function's arguments are: 365 * The optional callback function's arguments are:
369 * the temporary virtual address 366 * the temporary virtual address
370 * the passed `arg' argument 367 * the passed `arg' argument
371 */ 368 */
372int bus_space_probe( 369int bus_space_probe(

cvs diff -r1.293 -r1.294 src/sys/arch/sparc/sparc/machdep.c (expand / switch to unified diff)

--- src/sys/arch/sparc/sparc/machdep.c 2009/05/16 17:01:15 1.293
+++ src/sys/arch/sparc/sparc/machdep.c 2009/05/26 03:30:24 1.294
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: machdep.c,v 1.293 2009/05/16 17:01:15 cegger Exp $ */ 1/* $NetBSD: machdep.c,v 1.294 2009/05/26 03:30:24 macallan Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc. 4 * Copyright (c) 1996, 1997, 1998 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 of the Numerical Aerospace Simulation Facility, 8 * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
9 * NASA Ames Research Center. 9 * NASA Ames Research Center.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions 12 * modification, are permitted provided that the following conditions
13 * are met: 13 * are met:
14 * 1. Redistributions of source code must retain the above copyright 14 * 1. Redistributions of source code must retain the above copyright
@@ -61,27 +61,27 @@ @@ -61,27 +61,27 @@
61 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 61 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
62 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 62 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
63 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 63 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
64 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 64 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
65 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 65 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
66 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 66 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
67 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 67 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
68 * SUCH DAMAGE. 68 * SUCH DAMAGE.
69 * 69 *
70 * @(#)machdep.c 8.6 (Berkeley) 1/14/94 70 * @(#)machdep.c 8.6 (Berkeley) 1/14/94
71 */ 71 */
72 72
73#include <sys/cdefs.h> 73#include <sys/cdefs.h>
74__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.293 2009/05/16 17:01:15 cegger Exp $"); 74__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.294 2009/05/26 03:30:24 macallan Exp $");
75 75
76#include "opt_compat_netbsd.h" 76#include "opt_compat_netbsd.h"
77#include "opt_compat_sunos.h" 77#include "opt_compat_sunos.h"
78#include "opt_sparc_arch.h" 78#include "opt_sparc_arch.h"
79#include "opt_modular.h" 79#include "opt_modular.h"
80#include "opt_multiprocessor.h" 80#include "opt_multiprocessor.h"
81 81
82#include <sys/param.h> 82#include <sys/param.h>
83#include <sys/signal.h> 83#include <sys/signal.h>
84#include <sys/signalvar.h> 84#include <sys/signalvar.h>
85#include <sys/proc.h> 85#include <sys/proc.h>
86#include <sys/user.h> 86#include <sys/user.h>
87#include <sys/extent.h> 87#include <sys/extent.h>
@@ -1904,28 +1904,28 @@ bus_space_translate_address_generic(stru @@ -1904,28 +1904,28 @@ bus_space_translate_address_generic(stru
1904 1904
1905 if (rp->or_child_space != space) 1905 if (rp->or_child_space != space)
1906 continue; 1906 continue;
1907 1907
1908 /* We've found the connection to the parent bus. */ 1908 /* We've found the connection to the parent bus. */
1909 *bap = BUS_ADDR(rp->or_parent_space, 1909 *bap = BUS_ADDR(rp->or_parent_space,
1910 rp->or_parent_base + BUS_ADDR_PADDR(*bap)); 1910 rp->or_parent_base + BUS_ADDR_PADDR(*bap));
1911 return (0); 1911 return (0);
1912 } 1912 }
1913 1913
1914 return (EINVAL); 1914 return (EINVAL);
1915} 1915}
1916 1916
1917int 1917static int
1918sparc_bus_map(bus_space_tag_t t, bus_addr_t ba, bus_size_t size, int flags, 1918sparc_bus_map_iodev(bus_space_tag_t t, bus_addr_t ba, bus_size_t size, int flags,
1919 vaddr_t va, bus_space_handle_t *hp) 1919 vaddr_t va, bus_space_handle_t *hp)
1920{ 1920{
1921 vaddr_t v; 1921 vaddr_t v;
1922 paddr_t pa; 1922 paddr_t pa;
1923 unsigned int pmtype; 1923 unsigned int pmtype;
1924 bus_space_tag_t pt; 1924 bus_space_tag_t pt;
1925static vaddr_t iobase; 1925static vaddr_t iobase;
1926 1926
1927 /* 1927 /*
1928 * This base class bus map function knows about address range 1928 * This base class bus map function knows about address range
1929 * translation so bus drivers that need no other special 1929 * translation so bus drivers that need no other special
1930 * handling can just keep this method in their tags. 1930 * handling can just keep this method in their tags.
1931 * 1931 *
@@ -1971,50 +1971,62 @@ static vaddr_t iobase; @@ -1971,50 +1971,62 @@ static vaddr_t iobase;
1971 1971
1972 pa = trunc_page(pa); 1972 pa = trunc_page(pa);
1973 do { 1973 do {
1974 pmap_kenter_pa(v, pa | pmtype | PMAP_NC, 1974 pmap_kenter_pa(v, pa | pmtype | PMAP_NC,
1975 VM_PROT_READ | VM_PROT_WRITE); 1975 VM_PROT_READ | VM_PROT_WRITE);
1976 v += PAGE_SIZE; 1976 v += PAGE_SIZE;
1977 pa += PAGE_SIZE; 1977 pa += PAGE_SIZE;
1978 } while ((size -= PAGE_SIZE) > 0); 1978 } while ((size -= PAGE_SIZE) > 0);
1979 1979
1980 pmap_update(pmap_kernel()); 1980 pmap_update(pmap_kernel());
1981 return (0); 1981 return (0);
1982} 1982}
1983 1983
1984int 1984static int
1985sparc_bus_map_large(bus_space_tag_t t, int slot, bus_size_t offset, 1985sparc_bus_map_large(bus_space_tag_t t, bus_addr_t ba,
1986 bus_size_t size, int flags, bus_space_handle_t *hp) 1986 bus_size_t size, int flags, bus_space_handle_t *hp)
1987{ 1987{
1988 bus_addr_t pa = BUS_ADDR(slot,offset); 
1989 vaddr_t v = 0; 1988 vaddr_t v = 0;
1990 1989
1991 if (uvm_map(kernel_map, &v, size, NULL, 0, PAGE_SIZE, 1990 if (uvm_map(kernel_map, &v, size, NULL, 0, PAGE_SIZE,
1992 UVM_MAPFLAG(UVM_PROT_RW, UVM_PROT_RW, UVM_INH_SHARE, UVM_ADV_NORMAL, 1991 UVM_MAPFLAG(UVM_PROT_RW, UVM_PROT_RW, UVM_INH_SHARE, UVM_ADV_NORMAL,
1993 0)) == 0) { 1992 0)) == 0) {
1994 return sparc_bus_map(t, pa, size, flags, v, hp); 1993 return sparc_bus_map_iodev(t, ba, size, flags, v, hp);
1995 } 1994 }
1996 return -1; 1995 return -1;
1997} 1996}
1998 1997
1999int 1998int
 1999sparc_bus_map(bus_space_tag_t t, bus_addr_t ba,
 2000 bus_size_t size, int flags, vaddr_t va,
 2001 bus_space_handle_t *hp)
 2002{
 2003
 2004 if (flags & BUS_SPACE_MAP_LARGE) {
 2005 return sparc_bus_map_large(t, ba, size, flags, hp);
 2006 } else
 2007 return sparc_bus_map_iodev(t, ba, size, flags, va, hp);
 2008
 2009}
 2010
 2011int
2000sparc_bus_unmap(bus_space_tag_t t, bus_space_handle_t bh, bus_size_t size) 2012sparc_bus_unmap(bus_space_tag_t t, bus_space_handle_t bh, bus_size_t size)
2001{ 2013{
2002 vaddr_t va = trunc_page((vaddr_t)bh); 2014 vaddr_t va = trunc_page((vaddr_t)bh);
2003 2015
2004 /* 2016 /*
2005 * XXX 2017 * XXX
2006 * mappings from sparc_bus_map_large() probably need additional care 2018 * mappings with BUS_SPACE_MAP_LARGE need additional care here
2007 * here 2019 * we can just check if the VA is in the IODEV range
2008 */ 2020 */
2009 2021
2010 pmap_kremove(va, round_page(size)); 2022 pmap_kremove(va, round_page(size));
2011 pmap_update(pmap_kernel()); 2023 pmap_update(pmap_kernel());
2012 return (0); 2024 return (0);
2013} 2025}
2014 2026
2015int 2027int
2016sparc_bus_subregion(bus_space_tag_t tag, bus_space_handle_t handle, 2028sparc_bus_subregion(bus_space_tag_t tag, bus_space_handle_t handle,
2017 bus_size_t offset, bus_size_t size, 2029 bus_size_t offset, bus_size_t size,
2018 bus_space_handle_t *nhandlep) 2030 bus_space_handle_t *nhandlep)
2019{ 2031{
2020 2032