Wed Dec 2 15:47:45 2009 UTC ()
Add a common pmap_bootstrap_finalize() function which initializes
lwp0 uarea, curlwp, and curpcb after MMU is turned on, using
lwp0uarea variable saved during pmap_bootstrap() (or equivalent functions)
for pmap_motorola based ports.  Discussed with rmind@.


(tsutsui)
diff -r1.7 -r1.8 src/sys/arch/m68k/include/pcb.h
diff -r1.21 -r1.22 src/sys/arch/m68k/include/pmap_motorola.h
diff -r1.51 -r1.52 src/sys/arch/m68k/m68k/pmap_motorola.c

cvs diff -r1.7 -r1.8 src/sys/arch/m68k/include/pcb.h (expand / switch to unified diff)

--- src/sys/arch/m68k/include/pcb.h 2007/03/04 06:00:04 1.7
+++ src/sys/arch/m68k/include/pcb.h 2009/12/02 15:47:45 1.8
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: pcb.h,v 1.7 2007/03/04 06:00:04 christos Exp $ */ 1/* $NetBSD: pcb.h,v 1.8 2009/12/02 15:47:45 tsutsui Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1982, 1986, 1990, 1993 4 * Copyright (c) 1982, 1986, 1990, 1993
5 * The Regents of the University of California. All rights reserved. 5 * The Regents of the University of California. All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to Berkeley by 7 * This code is derived from software contributed to Berkeley by
8 * the Systems Programming Group of the University of Utah Computer 8 * the Systems Programming Group of the University of Utah Computer
9 * Science Department. 9 * Science Department.
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
@@ -95,14 +95,17 @@ struct pcb { @@ -95,14 +95,17 @@ struct pcb {
95 95
96/* Positions within pcb_regs[] of A6 and A7 (FP and SP). For m68k DDB. */ 96/* Positions within pcb_regs[] of A6 and A7 (FP and SP). For m68k DDB. */
97#define PCB_REGS_FP 10 97#define PCB_REGS_FP 10
98#define PCB_REGS_SP 11 98#define PCB_REGS_SP 11
99 99
100/* 100/*
101 * The pcb is augmented with machine-dependent additional data for 101 * The pcb is augmented with machine-dependent additional data for
102 * core dumps. For the hp300, this includes an HP-UX exec header 102 * core dumps. For the hp300, this includes an HP-UX exec header
103 * which is dumped for HP-UX processes. 103 * which is dumped for HP-UX processes.
104 */ 104 */
105struct md_coredump { 105struct md_coredump {
106 int md_exec[16]; /* exec structure for HP-UX core dumps */ 106 int md_exec[16]; /* exec structure for HP-UX core dumps */
107}; 107};
 108
 109extern struct pcb *curpcb;
 110
108#endif /* _M68K_PCB_H_ */ 111#endif /* _M68K_PCB_H_ */

cvs diff -r1.21 -r1.22 src/sys/arch/m68k/include/pmap_motorola.h (expand / switch to unified diff)

--- src/sys/arch/m68k/include/pmap_motorola.h 2009/08/26 00:30:02 1.21
+++ src/sys/arch/m68k/include/pmap_motorola.h 2009/12/02 15:47:45 1.22
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: pmap_motorola.h,v 1.21 2009/08/26 00:30:02 thorpej Exp $ */ 1/* $NetBSD: pmap_motorola.h,v 1.22 2009/12/02 15:47:45 tsutsui Exp $ */
2 2
3/*  3/*
4 * Copyright (c) 1991, 1993 4 * Copyright (c) 1991, 1993
5 * The Regents of the University of California. All rights reserved. 5 * The Regents of the University of California. All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to Berkeley by 7 * This code is derived from software contributed to Berkeley by
8 * the Systems Programming Group of the University of Utah Computer 8 * the Systems Programming Group of the University of Utah Computer
9 * Science Department. 9 * Science Department.
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
@@ -181,26 +181,30 @@ pmap_remove_all(struct pmap *pmap) @@ -181,26 +181,30 @@ pmap_remove_all(struct pmap *pmap)
181} 181}
182 182
183extern st_entry_t *Sysseg; 183extern st_entry_t *Sysseg;
184extern pt_entry_t *Sysmap, *Sysptmap; 184extern pt_entry_t *Sysmap, *Sysptmap;
185extern vsize_t Sysptsize; 185extern vsize_t Sysptsize;
186extern vsize_t mem_size; 186extern vsize_t mem_size;
187extern vaddr_t virtual_avail, virtual_end; 187extern vaddr_t virtual_avail, virtual_end;
188extern u_int protection_codes[]; 188extern u_int protection_codes[];
189 189
190extern char *vmmap; /* map for mem, dumps, etc. */ 190extern char *vmmap; /* map for mem, dumps, etc. */
191extern void *CADDR1, *CADDR2; 191extern void *CADDR1, *CADDR2;
192extern void *msgbufaddr; 192extern void *msgbufaddr;
193 193
 194/* for lwp0 uarea initialization after MMU enabled */
 195extern vaddr_t lwp0uarea;
 196void pmap_bootstrap_finalize(void);
 197
194vaddr_t pmap_map(vaddr_t, paddr_t, paddr_t, int); 198vaddr_t pmap_map(vaddr_t, paddr_t, paddr_t, int);
195void pmap_procwr(struct proc *, vaddr_t, size_t); 199void pmap_procwr(struct proc *, vaddr_t, size_t);
196#define PMAP_NEED_PROCWR 200#define PMAP_NEED_PROCWR
197 201
198#ifdef CACHE_HAVE_VAC 202#ifdef CACHE_HAVE_VAC
199void pmap_prefer(vaddr_t, vaddr_t *); 203void pmap_prefer(vaddr_t, vaddr_t *);
200#define PMAP_PREFER(foff, vap, sz, td) pmap_prefer((foff), (vap)) 204#define PMAP_PREFER(foff, vap, sz, td) pmap_prefer((foff), (vap))
201#endif 205#endif
202 206
203void _pmap_set_page_cacheable(struct pmap *, vaddr_t); 207void _pmap_set_page_cacheable(struct pmap *, vaddr_t);
204void _pmap_set_page_cacheinhibit(struct pmap *, vaddr_t); 208void _pmap_set_page_cacheinhibit(struct pmap *, vaddr_t);
205int _pmap_page_is_cacheable(struct pmap *, vaddr_t); 209int _pmap_page_is_cacheable(struct pmap *, vaddr_t);
206 210

cvs diff -r1.51 -r1.52 src/sys/arch/m68k/m68k/pmap_motorola.c (expand / switch to unified diff)

--- src/sys/arch/m68k/m68k/pmap_motorola.c 2009/11/23 00:11:44 1.51
+++ src/sys/arch/m68k/m68k/pmap_motorola.c 2009/12/02 15:47:45 1.52
@@ -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 */
233st_entry_t *Sysseg; 233st_entry_t *Sysseg;
234pt_entry_t *Sysmap, *Sysptmap; 234pt_entry_t *Sysmap, *Sysptmap;
235st_entry_t *Segtabzero, *Segtabzeropa; 235st_entry_t *Segtabzero, *Segtabzeropa;
236vsize_t Sysptsize = VM_KERNEL_PT_PAGES; 236vsize_t Sysptsize = VM_KERNEL_PT_PAGES;
237 237
238static struct pmap kernel_pmap_store; 238static struct pmap kernel_pmap_store;
239struct pmap *const kernel_pmap_ptr = &kernel_pmap_store; 239struct pmap *const kernel_pmap_ptr = &kernel_pmap_store;
240struct vm_map *st_map, *pt_map; 240struct vm_map *st_map, *pt_map;
241struct vm_map_kernel st_map_store, pt_map_store; 241struct vm_map_kernel st_map_store, pt_map_store;
242 242
 243vaddr_t lwp0uarea; /* lwp0 u-area VA, initialized in bootstrap */
 244
243paddr_t avail_start; /* PA of first available physical page */ 245paddr_t avail_start; /* PA of first available physical page */
244paddr_t avail_end; /* PA of last available physical page */ 246paddr_t avail_end; /* PA of last available physical page */
245vsize_t mem_size; /* memory size in bytes */ 247vsize_t mem_size; /* memory size in bytes */
246vaddr_t virtual_avail; /* VA of first avail page (after kernel bss)*/ 248vaddr_t virtual_avail; /* VA of first avail page (after kernel bss)*/
247vaddr_t virtual_end; /* VA of last avail page (end of kernel AS) */ 249vaddr_t virtual_end; /* VA of last avail page (end of kernel AS) */
248int page_cnt; /* number of pages managed by VM system */ 250int page_cnt; /* number of pages managed by VM system */
249 251
250bool pmap_initialized = false; /* Has pmap_init completed? */ 252bool pmap_initialized = false; /* Has pmap_init completed? */
251 253
252struct pv_header { 254struct 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);
304void pmap_release(pmap_t); 306void pmap_release(pmap_t);
305 307
306#ifdef DEBUG 308#ifdef DEBUG
307void pmap_pvdump(paddr_t); 309void pmap_pvdump(paddr_t);
308void pmap_check_wiring(const char *, vaddr_t); 310void 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 */
 324void
 325pmap_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 */
327void 345void
328pmap_virtual_space(vaddr_t *vstartp, vaddr_t *vendp) 346pmap_virtual_space(vaddr_t *vstartp, vaddr_t *vendp)
329{ 347{