| @@ -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 | |
1917 | int | | 1917 | static int |
1918 | sparc_bus_map(bus_space_tag_t t, bus_addr_t ba, bus_size_t size, int flags, | | 1918 | sparc_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; |
1925 | static vaddr_t iobase; | | 1925 | static 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 | |
1984 | int | | 1984 | static int |
1985 | sparc_bus_map_large(bus_space_tag_t t, int slot, bus_size_t offset, | | 1985 | sparc_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 | |
1999 | int | | 1998 | int |
| | | 1999 | sparc_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 | |
| | | 2011 | int |
2000 | sparc_bus_unmap(bus_space_tag_t t, bus_space_handle_t bh, bus_size_t size) | | 2012 | sparc_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 | |
2015 | int | | 2027 | int |
2016 | sparc_bus_subregion(bus_space_tag_t tag, bus_space_handle_t handle, | | 2028 | sparc_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 | |