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