Thu Aug 11 22:26:19 2011 UTC ()
pmap_memory isn't a static array anymore so sizeof doesn't work on it


(jmcneill)
diff -r1.6 -r1.7 src/sys/arch/usermode/usermode/pmap.c

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

--- src/sys/arch/usermode/usermode/pmap.c 2011/08/10 01:32:44 1.6
+++ src/sys/arch/usermode/usermode/pmap.c 2011/08/11 22:26:18 1.7
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: pmap.c,v 1.6 2011/08/10 01:32:44 jmcneill Exp $ */ 1/* $NetBSD: pmap.c,v 1.7 2011/08/11 22:26:18 jmcneill Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2007 Jared D. McNeill <jmcneill@invisible.ca> 4 * Copyright (c) 2007 Jared D. McNeill <jmcneill@invisible.ca>
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.
@@ -17,58 +17,59 @@ @@ -17,58 +17,59 @@
17 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 17 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
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__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.6 2011/08/10 01:32:44 jmcneill Exp $"); 30__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.7 2011/08/11 22:26:18 jmcneill Exp $");
31 31
32#include <sys/types.h> 32#include <sys/types.h>
33#include <sys/param.h> 33#include <sys/param.h>
34#include <sys/mutex.h> 34#include <sys/mutex.h>
35#include <sys/buf.h> 35#include <sys/buf.h>
36 36
37#include <uvm/uvm_page.h> 37#include <uvm/uvm_page.h>
38#include <uvm/uvm_pmap.h> 38#include <uvm/uvm_pmap.h>
39 39
40#include "opt_memsize.h" 40#include "opt_memsize.h"
41 41
42extern void * calloc(size_t, size_t); 42extern void * calloc(size_t, size_t);
43 43
44static struct pmap pmap_kernel_store; 44static struct pmap pmap_kernel_store;
45struct pmap * const kernel_pmap_ptr = &pmap_kernel_store; 45struct pmap * const kernel_pmap_ptr = &pmap_kernel_store;
46 46
47static uint8_t *pmap_memory; 47static uint8_t *pmap_memory;
 48static vsize_t pmap_memory_size = 1024 * MEMSIZE;
48static vaddr_t virtual_avail, virtual_end; 49static vaddr_t virtual_avail, virtual_end;
49static vaddr_t pmap_maxkvaddr; 50static vaddr_t pmap_maxkvaddr;
50 51
51void pmap_bootstrap(void); 52void pmap_bootstrap(void);
52 53
53void 54void
54pmap_bootstrap(void) 55pmap_bootstrap(void)
55{ 56{
56 pmap_memory = calloc(1, 1024 * MEMSIZE); 57 pmap_memory = calloc(1, pmap_memory_size);
57 if (pmap_memory == NULL) 58 if (pmap_memory == NULL)
58 panic("pmap_bootstrap: no memory"); 59 panic("pmap_bootstrap: no memory");
59 60
60 virtual_avail = (vaddr_t)pmap_memory; 61 virtual_avail = (vaddr_t)pmap_memory;
61 virtual_end = virtual_avail + sizeof(pmap_memory); 62 virtual_end = virtual_avail + pmap_memory_size;
62 63
63 uvm_page_physload(atop(virtual_avail), 64 uvm_page_physload(atop(virtual_avail),
64 atop(virtual_end), 65 atop(virtual_end),
65 atop(virtual_avail + PAGE_SIZE), 66 atop(virtual_avail + PAGE_SIZE),
66 atop(virtual_end),  67 atop(virtual_end),
67 VM_FREELIST_DEFAULT); 68 VM_FREELIST_DEFAULT);
68 69
69 virtual_avail += PAGE_SIZE; 70 virtual_avail += PAGE_SIZE;
70 71
71 pmap_maxkvaddr = VM_MIN_KERNEL_ADDRESS; 72 pmap_maxkvaddr = VM_MIN_KERNEL_ADDRESS;
72#if 0 73#if 0
73 kmeminit_nkmempages(); 74 kmeminit_nkmempages();
74 bufsz = buf_memcalc(); 75 bufsz = buf_memcalc();