Home | History | Annotate | Line # | Download | only in oea
vmparam.h revision 1.10
      1 /*-
      2  * Copyright (c) 2001 The NetBSD Foundation, Inc.
      3  * All rights reserved.
      4  *
      5  * This code is derived from software contributed to The NetBSD Foundation
      6  * by Matt Thomas <matt (at) 3am-softwre.com> of Allegro Networks, Inc.
      7  *
      8  * Redistribution and use in source and binary forms, with or without
      9  * modification, are permitted provided that the following conditions
     10  * are met:
     11  * 1. Redistributions of source code must retain the above copyright
     12  *    notice, this list of conditions and the following disclaimer.
     13  * 2. Redistributions in binary form must reproduce the above copyright
     14  *    notice, this list of conditions and the following disclaimer in the
     15  *    documentation and/or other materials provided with the distribution.
     16  * 3. All advertising materials mentioning features or use of this software
     17  *    must display the following acknowledgement:
     18  *        This product includes software developed by the NetBSD
     19  *        Foundation, Inc. and its contributors.
     20  * 4. Neither the name of The NetBSD Foundation nor the names of its
     21  *    contributors may be used to endorse or promote products derived
     22  *    from this software without specific prior written permission.
     23  *
     24  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     25  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     26  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     27  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     28  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     29  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     30  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     31  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     32  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     33  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     34  * POSSIBILITY OF SUCH DAMAGE.
     35  */
     36 
     37 #ifndef _POWERPC_OEA_VMPARAM_H_
     38 #define _POWERPC_OEA_VMPARAM_H_
     39 
     40 #include <sys/queue.h>
     41 
     42 /*
     43  * Most of the definitions in this can be overriden by a machine-specific
     44  * vmparam.h if required.  Otherwise a port can just include this file
     45  * get the right thing to happen.
     46  */
     47 
     48 /*
     49  * OEA processors have 4K pages.  Override the PAGE_* definitions
     50  * to be compile-time constants.
     51  */
     52 #define	PAGE_SHIFT	12
     53 #define	PAGE_SIZE	(1 << PAGE_SHIFT)
     54 #define	PAGE_MASK	(PAGE_SIZE - 1)
     55 
     56 #ifndef	USRSTACK
     57 #define	USRSTACK		VM_MAXUSER_ADDRESS
     58 #endif
     59 
     60 #ifndef	USRSTACK32
     61 #define	USRSTACK32		((uint32_t)VM_MAXUSER_ADDRESS)
     62 #endif
     63 
     64 #ifndef	MAXTSIZ
     65 #define	MAXTSIZ			(64*1024*1024)		/* maximum text size */
     66 #endif
     67 
     68 #ifndef	MAXDSIZ
     69 #define	MAXDSIZ			(1024*1024*1024)	/* maximum data size */
     70 #endif
     71 
     72 #ifndef	MAXSSIZ
     73 #define	MAXSSIZ			(32*1024*1024)		/* maximum stack size */
     74 #endif
     75 
     76 #ifndef	DFLDSIZ
     77 #define	DFLDSIZ			(128*1024*1024)		/* default data size */
     78 #endif
     79 
     80 #ifndef	DFLSSIZ
     81 #define	DFLSSIZ			(2*1024*1024)		/* default stack size */
     82 #endif
     83 
     84 /*
     85  * Default maximum amount of shared memory pages
     86  */
     87 #ifndef SHMMAXPGS
     88 #define	SHMMAXPGS		1024
     89 #endif
     90 
     91 /*
     92  * Default number of pages in the user raw I/O map.
     93  */
     94 #ifndef USRIOSIZE
     95 #define	USRIOSIZE		1024
     96 #endif
     97 
     98 /*
     99  * The number of seconds for a process to be blocked before being
    100  * considered very swappable.
    101  */
    102 #ifndef MAXSLP
    103 #define	MAXSLP			20
    104 #endif
    105 
    106 /*
    107  * Segment handling stuff
    108  */
    109 #define	SEGMENT_LENGTH	( 0x10000000L)
    110 #define	SEGMENT_MASK	(~0x0fffffffL)
    111 
    112 /*
    113  * Macros to manipulate VSIDs
    114  */
    115 #if 0
    116 /*
    117  * Move the SR# to the top bits to make the lower bits entirely random
    118  * so to give better PTE distribution.
    119  */
    120 #define	VSID__KEYSHFT		(SR_VSID_WIDTH - SR_KEY_LEN)
    121 #define	VSID_SR_INCREMENT	((1L << VSID__KEYSHFT) - 1)
    122 #define VSID__HASHMASK		(VSID_SR_INCREMENT - 1)
    123 #define	VSID_MAKE(sr, hash) \
    124 	(( \
    125 	    (((sr) << VSID__KEYSHFT) | ((hash) & VSID__HASMASK))
    126 	    << SR_VSID_SHFT) & SR_VSID)
    127 #define	VSID_TO_SR(vsid) \
    128 	(((vsid) & SR_VSID) >> (SR_VSID_SHFT + VSID__KEYSHFT))
    129 #define	VSID_TO_HASH(vsid) \
    130 	(((vsid) & SR_VSID) >> SR_VSID_SHFT) & VSID__HASHMASK)
    131 #else
    132 #define	VSID__HASHSHFT		(SR_KEY_LEN)
    133 #define	VSID_SR_INCREMENT	(1L << 0)
    134 #define	VSID__KEYMASK		((1L << VSID__HASHSHFT) - 1)
    135 #define	VSID_MAKE(sr, hash) \
    136 	(( \
    137 	    (((hash) << VSID__HASHSHFT) | ((sr) & VSID__KEYMASK)) \
    138 	     << SR_VSID_SHFT) & SR_VSID)
    139 #define	VSID_TO_SR(vsid) \
    140 	(((vsid) >> SR_VSID_SHFT) & VSID__KEYMASK)
    141 #define	VSID_TO_HASH(vsid) \
    142 	(((vsid) & SR_VSID) >> (SR_VSID_SHFT + VSID__HASHSHFT))
    143 #endif
    144 
    145 /*
    146  * Fixed segments
    147  */
    148 #ifndef USER_SR
    149 #define	USER_SR			12
    150 #endif
    151 #ifndef KERNEL_SR
    152 #define	KERNEL_SR		13
    153 #endif
    154 #ifndef KERNEL2_SR
    155 #define	KERNEL2_SR		14
    156 #endif
    157 #define	KERNEL2_SEGMENT		VSID_MAKE(KERNEL2_SR, KERNEL_VSIDBITS)
    158 #define	KERNEL_VSIDBITS		0xfffff
    159 #define	PHYSMAP_VSIDBITS	0xffffe
    160 #define	PHYSMAPN_SEGMENT(s)	VSID_MAKE(s, PHYSMAP_VSIDBITS)
    161 #define	KERNEL_SEGMENT		VSID_MAKE(KERNEL_SR, KERNEL_VSIDBITS)
    162 #define	KERNELN_SEGMENT(s)	VSID_MAKE(s, KERNEL_VSIDBITS)
    163 /* XXXSL: need something here that will never be mapped */
    164 #define	EMPTY_SEGMENT		VSID_MAKE(0, 0xffffe)
    165 #define	USER_ADDR		((void *)(USER_SR << ADDR_SR_SHFT))
    166 
    167 /*
    168  * Some system constants
    169  */
    170 #ifndef	NPMAPS
    171 #define	NPMAPS		32768	/* Number of pmaps in system */
    172 #endif
    173 
    174 #define	VM_MIN_ADDRESS		((vaddr_t) 0)
    175 #define	VM_MAXUSER_ADDRESS	((vaddr_t) ~0xfffL)
    176 #define	VM_MAX_ADDRESS		VM_MAXUSER_ADDRESS
    177 #define	VM_MIN_KERNEL_ADDRESS	((vaddr_t) (KERNEL_SR << ADDR_SR_SHFT))
    178 #define	VM_MAX_KERNEL_ADDRESS	(VM_MIN_KERNEL_ADDRESS + 2*SEGMENT_LENGTH)
    179 
    180 /*
    181  * The address to which unspecified mapping requests default
    182  * Put the stack in it's own segment and start mmaping at the
    183  * top of the next lower segment.
    184  */
    185 #ifdef _KERNEL_OPT
    186 #include "opt_uvm.h"
    187 #endif
    188 #define	__USE_TOPDOWN_VM
    189 #define	VM_DEFAULT_ADDRESS(da, sz) \
    190 	(((VM_MAXUSER_ADDRESS - MAXSSIZ) & SEGMENT_MASK) - round_page(sz))
    191 
    192 #ifndef VM_PHYSSEG_MAX
    193 #define	VM_PHYSSEG_MAX		16
    194 #endif
    195 #define	VM_PHYSSEG_STRAT	VM_PSTRAT_BIGFIRST
    196 #define	VM_PHYSSEG_NOADD
    197 
    198 #ifndef VM_PHYS_SIZE
    199 #define	VM_PHYS_SIZE		(USRIOSIZE * PAGE_SIZE)
    200 #endif
    201 
    202 #ifndef VM_MAX_KERNEL_BUF
    203 #define	VM_MAX_KERNEL_BUF	(SEGMENT_LENGTH * 3 / 4)
    204 #endif
    205 
    206 #define	VM_NFREELIST		16	/* 16 distinct memory segments */
    207 #define	VM_FREELIST_DEFAULT	0
    208 #define	VM_FREELIST_FIRST256	1
    209 #define	VM_FREELIST_FIRST16	2
    210 #define	VM_FREELIST_MAX		3
    211 
    212 #ifndef _LOCORE
    213 
    214 LIST_HEAD(pvo_head, pvo_entry);
    215 
    216 #if __NetBSD_Version__ > 105180000
    217 #define	__HAVE_VM_PAGE_MD
    218 
    219 struct vm_page_md {
    220 	struct pvo_head mdpg_pvoh;
    221 	unsigned int mdpg_attrs;
    222 };
    223 
    224 #define	VM_MDPAGE_INIT(pg) do {			\
    225 	LIST_INIT(&(pg)->mdpage.mdpg_pvoh);	\
    226 	(pg)->mdpage.mdpg_attrs = 0;		\
    227 } while (/*CONSTCOND*/0)
    228 
    229 #else
    230 
    231 #define	__HAVE_PMAP_PHYSSEG
    232 
    233 struct pmap_physseg {
    234 	struct pvo_head *pvoh;
    235 	char *attrs;
    236 };
    237 
    238 #endif
    239 
    240 #endif	/* _LOCORE */
    241 
    242 #endif /* _POWERPC_OEA_VMPARAM_H_ */
    243