| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: pmap_motorola.c,v 1.51 2009/11/23 00:11:44 rmind Exp $ */ | | 1 | /* $NetBSD: pmap_motorola.c,v 1.52 2009/12/02 15:47:45 tsutsui Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 1999 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 1999 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. | | 8 | * by Jason R. Thorpe. |
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. |
| @@ -107,27 +107,27 @@ | | | @@ -107,27 +107,27 @@ |
107 | * of virtual-to-physical mappings must be done as | | 107 | * of virtual-to-physical mappings must be done as |
108 | * requested. | | 108 | * requested. |
109 | * | | 109 | * |
110 | * In order to cope with hardware architectures which | | 110 | * In order to cope with hardware architectures which |
111 | * make virtual-to-physical map invalidates expensive, | | 111 | * make virtual-to-physical map invalidates expensive, |
112 | * this module may delay invalidate or reduced protection | | 112 | * this module may delay invalidate or reduced protection |
113 | * operations until such time as they are actually | | 113 | * operations until such time as they are actually |
114 | * necessary. This module is given full information as | | 114 | * necessary. This module is given full information as |
115 | * to which processors are currently using which maps, | | 115 | * to which processors are currently using which maps, |
116 | * and to when physical maps must be made correct. | | 116 | * and to when physical maps must be made correct. |
117 | */ | | 117 | */ |
118 | | | 118 | |
119 | #include <sys/cdefs.h> | | 119 | #include <sys/cdefs.h> |
120 | __KERNEL_RCSID(0, "$NetBSD: pmap_motorola.c,v 1.51 2009/11/23 00:11:44 rmind Exp $"); | | 120 | __KERNEL_RCSID(0, "$NetBSD: pmap_motorola.c,v 1.52 2009/12/02 15:47:45 tsutsui Exp $"); |
121 | | | 121 | |
122 | #include <sys/param.h> | | 122 | #include <sys/param.h> |
123 | #include <sys/systm.h> | | 123 | #include <sys/systm.h> |
124 | #include <sys/proc.h> | | 124 | #include <sys/proc.h> |
125 | #include <sys/malloc.h> | | 125 | #include <sys/malloc.h> |
126 | #include <sys/pool.h> | | 126 | #include <sys/pool.h> |
127 | | | 127 | |
128 | #include <machine/pte.h> | | 128 | #include <machine/pte.h> |
129 | | | 129 | |
130 | #include <uvm/uvm.h> | | 130 | #include <uvm/uvm.h> |
131 | | | 131 | |
132 | #include <machine/cpu.h> | | 132 | #include <machine/cpu.h> |
133 | #include <m68k/cacheops.h> | | 133 | #include <m68k/cacheops.h> |
| @@ -230,26 +230,28 @@ struct kpt_page *kpt_pages; | | | @@ -230,26 +230,28 @@ struct kpt_page *kpt_pages; |
230 | * Segtabzero is an empty segment table which all processes share til they | | 230 | * Segtabzero is an empty segment table which all processes share til they |
231 | * reference something. | | 231 | * reference something. |
232 | */ | | 232 | */ |
233 | st_entry_t *Sysseg; | | 233 | st_entry_t *Sysseg; |
234 | pt_entry_t *Sysmap, *Sysptmap; | | 234 | pt_entry_t *Sysmap, *Sysptmap; |
235 | st_entry_t *Segtabzero, *Segtabzeropa; | | 235 | st_entry_t *Segtabzero, *Segtabzeropa; |
236 | vsize_t Sysptsize = VM_KERNEL_PT_PAGES; | | 236 | vsize_t Sysptsize = VM_KERNEL_PT_PAGES; |
237 | | | 237 | |
238 | static struct pmap kernel_pmap_store; | | 238 | static struct pmap kernel_pmap_store; |
239 | struct pmap *const kernel_pmap_ptr = &kernel_pmap_store; | | 239 | struct pmap *const kernel_pmap_ptr = &kernel_pmap_store; |
240 | struct vm_map *st_map, *pt_map; | | 240 | struct vm_map *st_map, *pt_map; |
241 | struct vm_map_kernel st_map_store, pt_map_store; | | 241 | struct vm_map_kernel st_map_store, pt_map_store; |
242 | | | 242 | |
| | | 243 | vaddr_t lwp0uarea; /* lwp0 u-area VA, initialized in bootstrap */ |
| | | 244 | |
243 | paddr_t avail_start; /* PA of first available physical page */ | | 245 | paddr_t avail_start; /* PA of first available physical page */ |
244 | paddr_t avail_end; /* PA of last available physical page */ | | 246 | paddr_t avail_end; /* PA of last available physical page */ |
245 | vsize_t mem_size; /* memory size in bytes */ | | 247 | vsize_t mem_size; /* memory size in bytes */ |
246 | vaddr_t virtual_avail; /* VA of first avail page (after kernel bss)*/ | | 248 | vaddr_t virtual_avail; /* VA of first avail page (after kernel bss)*/ |
247 | vaddr_t virtual_end; /* VA of last avail page (end of kernel AS) */ | | 249 | vaddr_t virtual_end; /* VA of last avail page (end of kernel AS) */ |
248 | int page_cnt; /* number of pages managed by VM system */ | | 250 | int page_cnt; /* number of pages managed by VM system */ |
249 | | | 251 | |
250 | bool pmap_initialized = false; /* Has pmap_init completed? */ | | 252 | bool pmap_initialized = false; /* Has pmap_init completed? */ |
251 | | | 253 | |
252 | struct pv_header { | | 254 | struct pv_header { |
253 | struct pv_entry pvh_first; /* first PV entry */ | | 255 | struct pv_entry pvh_first; /* first PV entry */ |
254 | uint16_t pvh_attrs; /* attributes: | | 256 | uint16_t pvh_attrs; /* attributes: |
255 | bits 0-7: PTE bits | | 257 | bits 0-7: PTE bits |
| @@ -304,26 +306,42 @@ void pmap_pinit(pmap_t); | | | @@ -304,26 +306,42 @@ void pmap_pinit(pmap_t); |
304 | void pmap_release(pmap_t); | | 306 | void pmap_release(pmap_t); |
305 | | | 307 | |
306 | #ifdef DEBUG | | 308 | #ifdef DEBUG |
307 | void pmap_pvdump(paddr_t); | | 309 | void pmap_pvdump(paddr_t); |
308 | void pmap_check_wiring(const char *, vaddr_t); | | 310 | void pmap_check_wiring(const char *, vaddr_t); |
309 | #endif | | 311 | #endif |
310 | | | 312 | |
311 | /* pmap_remove_mapping flags */ | | 313 | /* pmap_remove_mapping flags */ |
312 | #define PRM_TFLUSH 0x01 | | 314 | #define PRM_TFLUSH 0x01 |
313 | #define PRM_CFLUSH 0x02 | | 315 | #define PRM_CFLUSH 0x02 |
314 | #define PRM_KEEPPTPAGE 0x04 | | 316 | #define PRM_KEEPPTPAGE 0x04 |
315 | | | 317 | |
316 | /* | | 318 | /* |
| | | 319 | * pmap_bootstrap_finalize: [ INTERFACE ] |
| | | 320 | * |
| | | 321 | * Initialize lwp0 uarea, curlwp, and curpcb after MMU is turned on, |
| | | 322 | * using lwp0uarea variable saved during pmap_bootstrap(). |
| | | 323 | */ |
| | | 324 | void |
| | | 325 | pmap_bootstrap_finalize(void) |
| | | 326 | { |
| | | 327 | |
| | | 328 | memset((void *)lwp0uarea, 0, USPACE); |
| | | 329 | uvm_lwp_setuarea(&lwp0, lwp0uarea); |
| | | 330 | curlwp = &lwp0; |
| | | 331 | curpcb = lwp_getpcb(&lwp0); |
| | | 332 | } |
| | | 333 | |
| | | 334 | /* |
317 | * pmap_virtual_space: [ INTERFACE ] | | 335 | * pmap_virtual_space: [ INTERFACE ] |
318 | * | | 336 | * |
319 | * Report the range of available kernel virtual address | | 337 | * Report the range of available kernel virtual address |
320 | * space to the VM system during bootstrap. | | 338 | * space to the VM system during bootstrap. |
321 | * | | 339 | * |
322 | * This is only an interface function if we do not use | | 340 | * This is only an interface function if we do not use |
323 | * pmap_steal_memory()! | | 341 | * pmap_steal_memory()! |
324 | * | | 342 | * |
325 | * Note: no locking is necessary in this function. | | 343 | * Note: no locking is necessary in this function. |
326 | */ | | 344 | */ |
327 | void | | 345 | void |
328 | pmap_virtual_space(vaddr_t *vstartp, vaddr_t *vendp) | | 346 | pmap_virtual_space(vaddr_t *vstartp, vaddr_t *vendp) |
329 | { | | 347 | { |