| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: pmap.c,v 1.166 2011/06/03 17:03:53 tsutsui Exp $ */ | | 1 | /* $NetBSD: pmap.c,v 1.167 2012/01/29 16:24:51 para Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 1996 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 1996 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 Adam Glass and Gordon W. Ross. | | 8 | * by Adam Glass and Gordon W. Ross. |
9 | * | | 9 | * |
10 | * Redistribution and use in source and binary forms, with or without | | 10 | * Redistribution and use in source and binary forms, with or without |
11 | * modification, are permitted provided that the following conditions | | 11 | * modification, are permitted provided that the following conditions |
12 | * are met: | | 12 | * are met: |
13 | * 1. Redistributions of source code must retain the above copyright | | 13 | * 1. Redistributions of source code must retain the above copyright |
14 | * notice, this list of conditions and the following disclaimer. | | 14 | * notice, this list of conditions and the following disclaimer. |
| @@ -70,35 +70,35 @@ | | | @@ -70,35 +70,35 @@ |
70 | * to handle some I/O then going back to sleep (i.e. nfsd). | | 70 | * to handle some I/O then going back to sleep (i.e. nfsd). |
71 | * If and when such a process returns to user-mode, it will | | 71 | * If and when such a process returns to user-mode, it will |
72 | * fault and be given a real context at that time. | | 72 | * fault and be given a real context at that time. |
73 | * | | 73 | * |
74 | * This also lets context switch be fast, because all we need | | 74 | * This also lets context switch be fast, because all we need |
75 | * to do there for the MMU is slam the context register. | | 75 | * to do there for the MMU is slam the context register. |
76 | * | | 76 | * |
77 | * Project2: Use a private pool of PV elements. This pool can be | | 77 | * Project2: Use a private pool of PV elements. This pool can be |
78 | * fixed size because the total mapped virtual space supported by | | 78 | * fixed size because the total mapped virtual space supported by |
79 | * the MMU H/W (and this pmap) is fixed for all time. | | 79 | * the MMU H/W (and this pmap) is fixed for all time. |
80 | */ | | 80 | */ |
81 | | | 81 | |
82 | #include <sys/cdefs.h> | | 82 | #include <sys/cdefs.h> |
83 | __KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.166 2011/06/03 17:03:53 tsutsui Exp $"); | | 83 | __KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.167 2012/01/29 16:24:51 para Exp $"); |
84 | | | 84 | |
85 | #include "opt_ddb.h" | | 85 | #include "opt_ddb.h" |
86 | #include "opt_pmap_debug.h" | | 86 | #include "opt_pmap_debug.h" |
87 | | | 87 | |
88 | #include <sys/param.h> | | 88 | #include <sys/param.h> |
89 | #include <sys/systm.h> | | 89 | #include <sys/systm.h> |
90 | #include <sys/proc.h> | | 90 | #include <sys/proc.h> |
91 | #include <sys/malloc.h> | | 91 | #include <sys/kmem.h> |
92 | #include <sys/pool.h> | | 92 | #include <sys/pool.h> |
93 | #include <sys/queue.h> | | 93 | #include <sys/queue.h> |
94 | #include <sys/kcore.h> | | 94 | #include <sys/kcore.h> |
95 | #include <sys/atomic.h> | | 95 | #include <sys/atomic.h> |
96 | | | 96 | |
97 | #include <uvm/uvm.h> | | 97 | #include <uvm/uvm.h> |
98 | | | 98 | |
99 | #include <machine/cpu.h> | | 99 | #include <machine/cpu.h> |
100 | #include <machine/dvma.h> | | 100 | #include <machine/dvma.h> |
101 | #include <machine/idprom.h> | | 101 | #include <machine/idprom.h> |
102 | #include <machine/kcore.h> | | 102 | #include <machine/kcore.h> |
103 | #include <machine/mon.h> | | 103 | #include <machine/mon.h> |
104 | #include <machine/pmap.h> | | 104 | #include <machine/pmap.h> |
| @@ -1839,27 +1839,27 @@ pmap_map(vaddr_t va, paddr_t pa, paddr_t | | | @@ -1839,27 +1839,27 @@ pmap_map(vaddr_t va, paddr_t pa, paddr_t |
1839 | pmap_enter(kernel_pmap, va, pa, prot, 0); | | 1839 | pmap_enter(kernel_pmap, va, pa, prot, 0); |
1840 | va += PAGE_SIZE; | | 1840 | va += PAGE_SIZE; |
1841 | pa += PAGE_SIZE; | | 1841 | pa += PAGE_SIZE; |
1842 | sz -= PAGE_SIZE; | | 1842 | sz -= PAGE_SIZE; |
1843 | } while (sz > 0); | | 1843 | } while (sz > 0); |
1844 | pmap_update(kernel_pmap); | | 1844 | pmap_update(kernel_pmap); |
1845 | return(va); | | 1845 | return(va); |
1846 | } | | 1846 | } |
1847 | | | 1847 | |
1848 | void | | 1848 | void |
1849 | pmap_user_init(pmap_t pmap) | | 1849 | pmap_user_init(pmap_t pmap) |
1850 | { | | 1850 | { |
1851 | int i; | | 1851 | int i; |
1852 | pmap->pm_segmap = malloc(sizeof(char)*NUSEG, M_VMPMAP, M_WAITOK); | | 1852 | pmap->pm_segmap = kmem_alloc(sizeof(char)*NUSEG, KM_SLEEP); |
1853 | for (i = 0; i < NUSEG; i++) { | | 1853 | for (i = 0; i < NUSEG; i++) { |
1854 | pmap->pm_segmap[i] = SEGINV; | | 1854 | pmap->pm_segmap[i] = SEGINV; |
1855 | } | | 1855 | } |
1856 | } | | 1856 | } |
1857 | | | 1857 | |
1858 | /* | | 1858 | /* |
1859 | * Create and return a physical map. | | 1859 | * Create and return a physical map. |
1860 | * | | 1860 | * |
1861 | * If the size specified for the map | | 1861 | * If the size specified for the map |
1862 | * is zero, the map is an actual physical | | 1862 | * is zero, the map is an actual physical |
1863 | * map, and may be referenced by the | | 1863 | * map, and may be referenced by the |
1864 | * hardware. | | 1864 | * hardware. |
1865 | * | | 1865 | * |
| @@ -1890,27 +1890,27 @@ pmap_release(struct pmap *pmap) | | | @@ -1890,27 +1890,27 @@ pmap_release(struct pmap *pmap) |
1890 | s = splvm(); | | 1890 | s = splvm(); |
1891 | | | 1891 | |
1892 | if (pmap == kernel_pmap) | | 1892 | if (pmap == kernel_pmap) |
1893 | panic("pmap_release: kernel_pmap!"); | | 1893 | panic("pmap_release: kernel_pmap!"); |
1894 | | | 1894 | |
1895 | if (has_context(pmap)) { | | 1895 | if (has_context(pmap)) { |
1896 | #ifdef PMAP_DEBUG | | 1896 | #ifdef PMAP_DEBUG |
1897 | if (pmap_debug & PMD_CONTEXT) | | 1897 | if (pmap_debug & PMD_CONTEXT) |
1898 | printf("pmap_release(%p): free ctx %d\n", | | 1898 | printf("pmap_release(%p): free ctx %d\n", |
1899 | pmap, pmap->pm_ctxnum); | | 1899 | pmap, pmap->pm_ctxnum); |
1900 | #endif | | 1900 | #endif |
1901 | context_free(pmap); | | 1901 | context_free(pmap); |
1902 | } | | 1902 | } |
1903 | free(pmap->pm_segmap, M_VMPMAP); | | 1903 | kmem_free(pmap->pm_segmap, sizeof(char)*NUSEG); |
1904 | pmap->pm_segmap = NULL; | | 1904 | pmap->pm_segmap = NULL; |
1905 | | | 1905 | |
1906 | splx(s); | | 1906 | splx(s); |
1907 | } | | 1907 | } |
1908 | | | 1908 | |
1909 | | | 1909 | |
1910 | /* | | 1910 | /* |
1911 | * Retire the given physical map from service. | | 1911 | * Retire the given physical map from service. |
1912 | * Should only be called if the map contains | | 1912 | * Should only be called if the map contains |
1913 | * no valid mappings. | | 1913 | * no valid mappings. |
1914 | */ | | 1914 | */ |
1915 | void | | 1915 | void |
1916 | pmap_destroy(pmap_t pmap) | | 1916 | pmap_destroy(pmap_t pmap) |