Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/sh3 new pmap designed for SH3/SH4.
details: https://anonhg.NetBSD.org/src/rev/0c2fd2a904a3
branches: trunk
changeset: 526729:0c2fd2a904a3
user: uch <uch%NetBSD.org@localhost>
date: Thu May 09 12:28:08 2002 +0000
description:
new pmap designed for SH3/SH4.
diffstat:
sys/arch/sh3/include/param.h | 38 +-
sys/arch/sh3/include/pcb.h | 73 +-
sys/arch/sh3/include/pmap.h | 431 +----
sys/arch/sh3/include/proc.h | 6 +-
sys/arch/sh3/include/pte.h | 116 +-
sys/arch/sh3/include/vmparam.h | 158 +-
sys/arch/sh3/sh3/Locore.c | 69 +-
sys/arch/sh3/sh3/locore_subr.S | 174 +-
sys/arch/sh3/sh3/pmap.c | 3716 +++++++++------------------------------
sys/arch/sh3/sh3/sh3_machdep.c | 190 +-
sys/arch/sh3/sh3/vm_machdep.c | 147 +-
11 files changed, 1300 insertions(+), 3818 deletions(-)
diffs (truncated from 5973 to 300 lines):
diff -r c361ca9dc8a2 -r 0c2fd2a904a3 sys/arch/sh3/include/param.h
--- a/sys/arch/sh3/include/param.h Thu May 09 12:27:04 2002 +0000
+++ b/sys/arch/sh3/include/param.h Thu May 09 12:28:08 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: param.h,v 1.10 2002/04/28 17:10:35 uch Exp $ */
+/* $NetBSD: param.h,v 1.11 2002/05/09 12:28:08 uch Exp $ */
/*-
* Copyright (c) 2002 The NetBSD Foundation, Inc. All rights reserved.
@@ -43,10 +43,18 @@
* SuperH dependent constants.
*/
+#ifndef _SH3_PARAM_H_
+#define _SH3_PARAM_H_
+
#if defined(_KERNEL) && !defined(_LOCORE)
-#include <machine/cpu.h>
+#include <sh3/cpu.h>
#endif
+/* NetBSD/sh3 is 4KB page */
+#define PGSHIFT 12
+#define NBPG (1 << PGSHIFT)
+#define PGOFSET (NBPG - 1)
+
/*
* Round p (pointer or byte index) up to a correctly-aligned value
* for all data types (int, long, ...). The result is u_int and
@@ -62,11 +70,6 @@
#define ALIGN(p) (((u_int)(p) + ALIGNBYTES) & ~ALIGNBYTES)
#define ALIGNED_POINTER(p, t) ((((u_long)(p)) & (sizeof(t) - 1)) == 0)
-#define PGSHIFT 12 /* LOG2(NBPG) */
-#define NBPG (1 << PGSHIFT) /* bytes/page */
-#define PGOFSET (NBPG - 1) /* byte offset into page */
-#define NPTEPG (NBPG / (sizeof(pt_entry_t)))
-
#define DEV_BSHIFT 9 /* log2(DEV_BSIZE) */
#define DEV_BSIZE (1 << DEV_BSHIFT)
#define BLKDEV_IOSIZE 2048
@@ -135,23 +138,4 @@
/* bytes to disk blocks */
#define dbtob(x) ((x) << DEV_BSHIFT)
#define btodb(x) ((x) >> DEV_BSHIFT)
-
-/*
- * Map a ``block device block'' to a file system block.
- * This should be device dependent, and should use the bsize
- * field from the disk label.
- * For now though just use DEV_BSIZE.
- */
-#define bdbtofsb(bn) ((bn) / (BLKDEV_IOSIZE / DEV_BSIZE))
-
-/*
- * Mach derived conversion macros
- */
-#define sh3_round_pdr(x) ((((unsigned)(x)) + PDOFSET) & ~PDOFSET)
-#define sh3_trunc_pdr(x) ((unsigned)(x) & ~PDOFSET)
-#define sh3_btod(x) ((unsigned)(x) >> PDSHIFT)
-#define sh3_dtob(x) ((unsigned)(x) << PDSHIFT)
-#define sh3_round_page(x) ((((unsigned)(x)) + PGOFSET) & ~PGOFSET)
-#define sh3_trunc_page(x) ((unsigned)(x) & ~PGOFSET)
-#define sh3_btop(x) ((unsigned)(x) >> PGSHIFT)
-#define sh3_ptob(x) ((unsigned)(x) << PGSHIFT)
+#endif /* !_SH3_PARAM_H_ */
diff -r c361ca9dc8a2 -r 0c2fd2a904a3 sys/arch/sh3/include/pcb.h
--- a/sys/arch/sh3/include/pcb.h Thu May 09 12:27:04 2002 +0000
+++ b/sys/arch/sh3/include/pcb.h Thu May 09 12:28:08 2002 +0000
@@ -1,13 +1,11 @@
-/* $NetBSD: pcb.h,v 1.6 2002/04/28 17:10:36 uch Exp $ */
+/* $NetBSD: pcb.h,v 1.7 2002/05/09 12:28:08 uch Exp $ */
/*-
- * Copyright (c) 2002 The NetBSD Foundation, Inc. All rights reserved.
- * Copyright (c) 1995 Charles M. Hannum. All rights reserved.
- * Copyright (c) 1990 The Regents of the University of California.
+ * Copyright (c) 2002 The NetBSD Foundation, Inc.
* All rights reserved.
*
- * This code is derived from software contributed to Berkeley by
- * William Jolitz.
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by UCHIYAMA Yasushi.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -19,30 +17,23 @@
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
+ * This product includes software developed by the NetBSD
+ * Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * @(#)pcb.h 5.10 (Berkeley) 5/12/91
- */
-
-/*
- * SH3 process control block
- * T.Horiuchi Brains Corp. 05/27/1998
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _SH3_PCB_H_
@@ -51,26 +42,10 @@
#include <sh3/frame.h>
struct pcb {
- struct switchframe pcb_sf;
- vaddr_t pcb_sp; /* kernel stack top */
- vaddr_t pcb_fp; /* frame top */
- int pageDirReg; /* Page Directory of this process */
- int pcb_flags;
- caddr_t pcb_onfault; /* copyin/out fault recovery */
- int fusubail;
- struct pmap *pcb_pmap; /* back pointer to our pmap */
+ struct switchframe pcb_sf; /* kernel context for resume */
+ caddr_t pcb_onfault; /* for copyin/out fault */
+ int pcb_faultbail; /* bail out before call uvm_fault. */
};
-/*
- * The pcb is augmented with machine-dependent additional data for
- * core dumps. For the SH3, there is nothing to add.
- */
-struct md_coredump {
- long md_pad[8];
-};
-
-#ifdef _KERNEL
-extern struct pcb *curpcb; /* our current running pcb */
-#endif
-
+extern struct pcb *curpcb;
#endif /* !_SH3_PCB_H_ */
diff -r c361ca9dc8a2 -r 0c2fd2a904a3 sys/arch/sh3/include/pmap.h
--- a/sys/arch/sh3/include/pmap.h Thu May 09 12:27:04 2002 +0000
+++ b/sys/arch/sh3/include/pmap.h Thu May 09 12:28:08 2002 +0000
@@ -1,9 +1,12 @@
-/* $NetBSD: pmap.h,v 1.22 2002/04/28 17:10:36 uch Exp $ */
+/* $NetBSD: pmap.h,v 1.23 2002/05/09 12:28:08 uch Exp $ */
-/*
- * Copyright (c) 1997 Charles D. Cranor and Washington University.
+/*-
+ * Copyright (c) 2002 The NetBSD Foundation, Inc.
* All rights reserved.
*
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by UCHIYAMA Yasushi.
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@@ -13,389 +16,65 @@
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgment:
- * This product includes software developed by Charles D. Cranor and
- * Washington University.
- * 4. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
+ * must display the following acknowledgement:
+ * This product includes software developed by the NetBSD
+ * Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
*/
/*
- * pmap.h: see pmap.c for the history of this pmap module.
+ * NetBSD/sh3 pmap:
+ * pmap.pm_ptp[512] ... 512 slot of page table page
+ * page table page contains 1024 PTEs. (PAGE_SIZE / sizeof(pt_entry_t))
+ * | PTP 11bit | PTOFSET 10bit | PGOFSET 12bit |
*/
#ifndef _SH3_PMAP_H_
#define _SH3_PMAP_H_
+#include <sys/queue.h>
+#include <sh3/pte.h>
-#include <sh3/cache.h>
-#include <sh3/psl.h>
-#include <sh3/pte.h>
-#include <uvm/uvm_object.h>
+#define PMAP_NEED_PROCWR
+#define PMAP_STEAL_MEMORY
+#define PMAP_GROWKERNEL
-/*
- * see pte.h for a description of i386 MMU terminology and hardware
- * interface.
- *
- * a pmap describes a processes' 4GB virtual address space. this
- * virtual address space can be broken up into 1024 4MB regions which
- * are described by PDEs in the PDP. the PDEs are defined as follows:
- *
- * (ranges are inclusive -> exclusive, just like vm_map_entry start/end)
- * (the following assumes that KERNBASE is 0xf0000000)
- *
- * PDE#s VA range usage
- * 0->959 0x0 -> 0xefc00000 user address space, note that the
- * max user address is 0xefbfe000
- * the final two pages in the last 4MB
- * used to be reserved for the UAREA
- * but now are no longer used
- * 959 0xefc00000-> recursive mapping of PDP (used for
- * 0xf0000000 linear mapping of PTPs)
- * 960->1023 0xf0000000-> kernel address space (constant
- * 0xffc00000 across all pmap's/processes)
- * 1023 0xffc00000-> "alternate" recursive PDP mapping
- * <end> (for other pmaps)
- *
- *
- * note: a recursive PDP mapping provides a way to map all the PTEs for
- * a 4GB address space into a linear chunk of virtual memory. in other
- * words, the PTE for page 0 is the first int mapped into the 4MB recursive
- * area. the PTE for page 1 is the second int. the very last int in the
- * 4MB range is the PTE that maps VA 0xffffe000 (the last page in a 4GB
- * address).
- *
- * all pmap's PD's must have the same values in slots 960->1023 so that
- * the kernel is always mapped in every process. these values are loaded
- * into the PD at pmap creation time.
- *
- * at any one time only one pmap can be active on a processor. this is
- * the pmap whose PDP is pointed to by processor register %cr3. this pmap
- * will have all its PTEs mapped into memory at the recursive mapping
- * point (slot #959 as show above). when the pmap code wants to find the
- * PTE for a virtual address, all it has to do is the following:
- *
- * address of PTE = (959 * 4MB) + (VA / NBPG) * sizeof(pt_entry_t)
- * = 0xefc00000 + (VA / 4096) * 4
- *
- * what happens if the pmap layer is asked to perform an operation
- * on a pmap that is not the one which is currently active? in that
- * case we take the PA of the PDP of non-active pmap and put it in
- * slot 1023 of the active pmap. this causes the non-active pmap's
- * PTEs to get mapped in the final 4MB of the 4GB address space
- * (e.g. starting at 0xffc00000).
- *
- * the following figure shows the effects of the recursive PDP mapping:
- *
- * PDP (%cr3)
- * +----+
Home |
Main Index |
Thread Index |
Old Index