From 3c345377fe333510cc16f4f5eda9796d36ec6e06 Mon Sep 17 00:00:00 2001 From: tsutsui Date: Wed, 2 Dec 2009 15:47:45 +0000 Subject: [PATCH] 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@. --- sys/arch/m68k/include/pcb.h | 5 ++++- sys/arch/m68k/include/pmap_motorola.h | 6 +++++- sys/arch/m68k/m68k/pmap_motorola.c | 22 ++++++++++++++++++++-- 3 files changed, 29 insertions(+), 4 deletions(-) diff --git a/sys/arch/m68k/include/pcb.h b/sys/arch/m68k/include/pcb.h index e911a38720ad..6241095f255e 100644 --- a/sys/arch/m68k/include/pcb.h +++ b/sys/arch/m68k/include/pcb.h @@ -1,4 +1,4 @@ -/* $NetBSD: pcb.h,v 1.7 2007/03/04 06:00:04 christos Exp $ */ +/* $NetBSD: pcb.h,v 1.8 2009/12/02 15:47:45 tsutsui Exp $ */ /* * Copyright (c) 1982, 1986, 1990, 1993 @@ -105,4 +105,7 @@ struct pcb { struct md_coredump { int md_exec[16]; /* exec structure for HP-UX core dumps */ }; + +extern struct pcb *curpcb; + #endif /* _M68K_PCB_H_ */ diff --git a/sys/arch/m68k/include/pmap_motorola.h b/sys/arch/m68k/include/pmap_motorola.h index 497c72f4ec8f..3ab4645577ab 100644 --- a/sys/arch/m68k/include/pmap_motorola.h +++ b/sys/arch/m68k/include/pmap_motorola.h @@ -1,4 +1,4 @@ -/* $NetBSD: pmap_motorola.h,v 1.21 2009/08/26 00:30:02 thorpej Exp $ */ +/* $NetBSD: pmap_motorola.h,v 1.22 2009/12/02 15:47:45 tsutsui Exp $ */ /* * Copyright (c) 1991, 1993 @@ -191,6 +191,10 @@ extern char *vmmap; /* map for mem, dumps, etc. */ extern void *CADDR1, *CADDR2; extern void *msgbufaddr; +/* for lwp0 uarea initialization after MMU enabled */ +extern vaddr_t lwp0uarea; +void pmap_bootstrap_finalize(void); + vaddr_t pmap_map(vaddr_t, paddr_t, paddr_t, int); void pmap_procwr(struct proc *, vaddr_t, size_t); #define PMAP_NEED_PROCWR diff --git a/sys/arch/m68k/m68k/pmap_motorola.c b/sys/arch/m68k/m68k/pmap_motorola.c index 061f62486d14..34adacf3c330 100644 --- a/sys/arch/m68k/m68k/pmap_motorola.c +++ b/sys/arch/m68k/m68k/pmap_motorola.c @@ -1,4 +1,4 @@ -/* $NetBSD: pmap_motorola.c,v 1.51 2009/11/23 00:11:44 rmind Exp $ */ +/* $NetBSD: pmap_motorola.c,v 1.52 2009/12/02 15:47:45 tsutsui Exp $ */ /*- * Copyright (c) 1999 The NetBSD Foundation, Inc. @@ -117,7 +117,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: pmap_motorola.c,v 1.51 2009/11/23 00:11:44 rmind Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pmap_motorola.c,v 1.52 2009/12/02 15:47:45 tsutsui Exp $"); #include #include @@ -240,6 +240,8 @@ struct pmap *const kernel_pmap_ptr = &kernel_pmap_store; struct vm_map *st_map, *pt_map; struct vm_map_kernel st_map_store, pt_map_store; +vaddr_t lwp0uarea; /* lwp0 u-area VA, initialized in bootstrap */ + paddr_t avail_start; /* PA of first available physical page */ paddr_t avail_end; /* PA of last available physical page */ vsize_t mem_size; /* memory size in bytes */ @@ -313,6 +315,22 @@ void pmap_check_wiring(const char *, vaddr_t); #define PRM_CFLUSH 0x02 #define PRM_KEEPPTPAGE 0x04 +/* + * pmap_bootstrap_finalize: [ INTERFACE ] + * + * Initialize lwp0 uarea, curlwp, and curpcb after MMU is turned on, + * using lwp0uarea variable saved during pmap_bootstrap(). + */ +void +pmap_bootstrap_finalize(void) +{ + + memset((void *)lwp0uarea, 0, USPACE); + uvm_lwp_setuarea(&lwp0, lwp0uarea); + curlwp = &lwp0; + curpcb = lwp_getpcb(&lwp0); +} + /* * pmap_virtual_space: [ INTERFACE ] *