vmparam.h revision 1.3
11.3Smatt/* $NetBSD: vmparam.h,v 1.3 2011/01/18 01:02:54 matt Exp $ */ 21.1Smatt/*- 31.3Smatt * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc. 41.1Smatt * All rights reserved. 51.1Smatt * 61.1Smatt * This code is derived from software contributed to The NetBSD Foundation 71.3Smatt * by Raytheon BBN Technologies Corp and Defense Advanced Research Projects 81.3Smatt * Agency and which was developed by Matt Thomas of 3am Software Foundry. 91.3Smatt * 101.3Smatt * This material is based upon work supported by the Defense Advanced Research 111.3Smatt * Projects Agency and Space and Naval Warfare Systems Center, Pacific, under 121.3Smatt * Contract No. N66001-09-C-2073. 131.3Smatt * Approved for Public Release, Distribution Unlimited 141.1Smatt * 151.1Smatt * Redistribution and use in source and binary forms, with or without 161.1Smatt * modification, are permitted provided that the following conditions 171.1Smatt * are met: 181.1Smatt * 1. Redistributions of source code must retain the above copyright 191.1Smatt * notice, this list of conditions and the following disclaimer. 201.1Smatt * 2. Redistributions in binary form must reproduce the above copyright 211.1Smatt * notice, this list of conditions and the following disclaimer in the 221.1Smatt * documentation and/or other materials provided with the distribution. 231.1Smatt * 241.1Smatt * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 251.1Smatt * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 261.1Smatt * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 271.1Smatt * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 281.1Smatt * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 291.1Smatt * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 301.1Smatt * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 311.1Smatt * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 321.1Smatt * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 331.1Smatt * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 341.1Smatt * POSSIBILITY OF SUCH DAMAGE. 351.1Smatt */ 361.1Smatt 371.1Smatt#ifndef _POWERPC_BOOKE_VMPARAM_H_ 381.1Smatt#define _POWERPC_BOOKE_VMPARAM_H_ 391.1Smatt 401.1Smatt/* 411.1Smatt * Most of the definitions in this can be overriden by a machine-specific 421.1Smatt * vmparam.h if required. Otherwise a port can just include this file 431.1Smatt * get the right thing to happen. 441.1Smatt */ 451.1Smatt 461.1Smatt/* 471.1Smatt * BookE processors have 4K pages. Override the PAGE_* definitions to be 481.1Smatt * compile-time constants. 491.1Smatt */ 501.1Smatt#define PAGE_SHIFT 12 511.1Smatt#define PAGE_SIZE (1 << PAGE_SHIFT) 521.1Smatt#define PAGE_MASK (PAGE_SIZE - 1) 531.1Smatt 541.1Smatt#ifndef USRSTACK 551.1Smatt#define USRSTACK VM_MAXUSER_ADDRESS 561.1Smatt#endif 571.1Smatt 581.1Smatt#ifndef MAXTSIZ 591.1Smatt#define MAXTSIZ (2*256*1024*1024) /* maximum text size */ 601.1Smatt#endif 611.1Smatt 621.1Smatt#ifndef MAXDSIZ 631.3Smatt#define MAXDSIZ (13*256*1024*1024U) /* maximum data size */ 641.1Smatt#endif 651.1Smatt 661.1Smatt#ifndef MAXSSIZ 671.1Smatt#define MAXSSIZ (1*256*1024*1024-PAGE_SIZE) /* maximum stack size */ 681.1Smatt#endif 691.1Smatt 701.1Smatt#ifndef DFLDSIZ 711.1Smatt#define DFLDSIZ (256*1024*1024) /* default data size */ 721.1Smatt#endif 731.1Smatt 741.1Smatt#ifndef DFLSSIZ 751.1Smatt#define DFLSSIZ (2*1024*1024) /* default stack size */ 761.1Smatt#endif 771.1Smatt 781.1Smatt/* 791.1Smatt * Default number of pages in the user raw I/O map. 801.1Smatt */ 811.1Smatt#ifndef USRIOSIZE 821.1Smatt#define USRIOSIZE 1024 831.1Smatt#endif 841.1Smatt 851.1Smatt/* 861.1Smatt * The number of seconds for a process to be blocked before being 871.1Smatt * considered very swappable. 881.1Smatt */ 891.1Smatt#ifndef MAXSLP 901.1Smatt#define MAXSLP 20 911.1Smatt#endif 921.1Smatt 931.1Smatt/* 941.1Smatt * Some system constants 951.1Smatt */ 961.1Smatt 971.1Smatt#define VM_MIN_ADDRESS ((vaddr_t) 0) 981.3Smatt#define VM_MAXUSER_ADDRESS ((vaddr_t) /* -32768 */ 0x7fff8000) 991.1Smatt#define VM_MAX_ADDRESS VM_MAXUSER_ADDRESS 1001.1Smatt#define VM_MIN_KERNEL_ADDRESS ((vaddr_t) 0xe4000000) 1011.1Smatt#define VM_MAX_KERNEL_ADDRESS ((vaddr_t) 0xfefff000) 1021.1Smatt 1031.1Smatt/* 1041.1Smatt * The address to which unspecified mapping requests default 1051.1Smatt * Put the stack in it's own segment and start mmaping at the 1061.1Smatt * top of the next lower segment. 1071.1Smatt */ 1081.1Smatt#ifdef _KERNEL_OPT 1091.1Smatt#include "opt_uvm.h" 1101.1Smatt#endif 1111.1Smatt#define __USE_TOPDOWN_VM 1121.1Smatt#define VM_DEFAULT_ADDRESS(da, sz) \ 1131.3Smatt ((VM_MAXUSER_ADDRESS - MAXSSIZ) - round_page(sz)) 1141.1Smatt 1151.1Smatt#ifndef VM_PHYSSEG_MAX 1161.1Smatt#define VM_PHYSSEG_MAX 16 1171.1Smatt#endif 1181.1Smatt#define VM_PHYSSEG_STRAT VM_PSTRAT_BIGFIRST 1191.1Smatt 1201.1Smatt#ifndef VM_PHYS_SIZE 1211.1Smatt#define VM_PHYS_SIZE (USRIOSIZE * PAGE_SIZE) 1221.1Smatt#endif 1231.1Smatt 1241.1Smatt#define VM_NFREELIST 2 /* 16 distinct memory segments */ 1251.1Smatt#define VM_FREELIST_DEFAULT 0 1261.1Smatt#define VM_FREELIST_FIRST16 1 1271.1Smatt#define VM_FREELIST_MAX 2 1281.1Smatt 1291.3Smatt#ifndef VM_NFREELIST 1301.3Smatt#define VM_NFREELIST 16 /* 16 distinct memory segments */ 1311.3Smatt#define VM_FREELIST_DEFAULT 0 1321.3Smatt#define VM_FREELIST_MAX 1 1331.3Smatt#endif 1341.1Smatt 1351.1Smatt#define __HAVE_VM_PAGE_MD 1361.3Smatt#ifndef _LOCORE 1371.1Smatt 1381.3Smatttypedef struct pv_entry { 1391.1Smatt struct pv_entry *pv_next; 1401.1Smatt struct pmap *pv_pmap; 1411.1Smatt vaddr_t pv_va; 1421.3Smatt} *pv_entry_t; 1431.3Smatt 1441.3Smatt#define VM_PAGE_MD_REFERENCED 0x0001 /* page has been recently referenced */ 1451.3Smatt#define VM_PAGE_MD_MODIFIED 0x0002 /* page has been modified */ 1461.3Smatt#define VM_PAGE_MD_POOLPAGE 0x0004 /* page is used as a poolpage */ 1471.3Smatt#define VM_PAGE_MD_EXECPAGE 0x0008 /* page is exec mapped */ 1481.3Smatt#if 0 1491.3Smatt#define VM_PAGE_MD_UNCACHED 0x0010 /* page is mapped uncached */ 1501.3Smatt#endif 1511.3Smatt 1521.3Smatt#ifdef VM_PAGE_MD_UNCACHED 1531.3Smatt#define VM_PAGE_MD_CACHED_P(pg) (((pg)->mdpage.mdpg_attrs & VM_PAGE_MD_UNCACHED) == 0) 1541.3Smatt#define VM_PAGE_MD_UNCACHED_P(pg) (((pg)->mdpage.mdpg_attrs & VM_PAGE_MD_UNCACHED) != 0) 1551.3Smatt#endif 1561.3Smatt#define VM_PAGE_MD_MODIFIED_P(pg) (((pg)->mdpage.mdpg_attrs & VM_PAGE_MD_MODIFIED) != 0) 1571.3Smatt#define VM_PAGE_MD_REFERENCED_P(pg) (((pg)->mdpage.mdpg_attrs & VM_PAGE_MD_REFERENCED) != 0) 1581.3Smatt#define VM_PAGE_MD_POOLPAGE_P(pg) (((pg)->mdpage.mdpg_attrs & VM_PAGE_MD_POOLPAGE) != 0) 1591.3Smatt#define VM_PAGE_MD_EXECPAGE_P(pg) (((pg)->mdpage.mdpg_attrs & VM_PAGE_MD_EXECPAGE) != 0) 1601.1Smatt 1611.1Smattstruct vm_page_md { 1621.3Smatt struct pv_entry mdpg_first; /* pv_entry first */ 1631.3Smatt#ifdef MULTIPROCESSOR 1641.3Smatt volatile u_int mdpg_attrs; /* page attributes */ 1651.3Smatt kmutex_t *mdpg_lock; /* pv list lock */ 1661.3Smatt#define VM_PAGE_PVLIST_LOCK_INIT(pg) \ 1671.3Smatt (pg)->mdpage.mdpg_lock = NULL 1681.3Smatt#define VM_PAGE_PVLIST_LOCKED_P(pg) \ 1691.3Smatt (mutex_owner((pg)->mdpage.mdpg_lock) != 0) 1701.3Smatt#define VM_PAGE_PVLIST_LOCK(pg, list_change) \ 1711.3Smatt pmap_pvlist_lock(pg, list_change) 1721.3Smatt#define VM_PAGE_PVLIST_UNLOCK(pg) \ 1731.3Smatt mutex_spin_exit((pg)->mdpage.mdpg_lock); 1741.3Smatt#define VM_PAGE_PVLIST_GEN(pg) ((uint16_t)(pg->mdpage.mdpg_attrs >> 16)) 1751.3Smatt#else 1761.3Smatt u_int mdpg_attrs; /* page attributes */ 1771.3Smatt#define VM_PAGE_PVLIST_LOCK_INIT(pg) do { } while (/*CONSTCOND*/ 0) 1781.3Smatt#define VM_PAGE_PVLIST_LOCKED_P(pg) true 1791.3Smatt#define VM_PAGE_PVLIST_LOCK(pg, lc) (mutex_spin_enter(&pmap_pvlist_mutex), 0) 1801.3Smatt#define VM_PAGE_PVLIST_UNLOCK(pg) mutex_spin_exit(&pmap_pvlist_mutex) 1811.3Smatt#define VM_PAGE_PVLIST_GEN(pg) (0) 1821.3Smatt#endif 1831.1Smatt}; 1841.1Smatt 1851.3Smatt#define VM_MDPAGE_INIT(pg) \ 1861.3Smattdo { \ 1871.3Smatt (pg)->mdpage.mdpg_first.pv_next = NULL; \ 1881.3Smatt (pg)->mdpage.mdpg_first.pv_pmap = NULL; \ 1891.3Smatt (pg)->mdpage.mdpg_first.pv_va = (pg)->phys_addr; \ 1901.3Smatt VM_PAGE_PVLIST_LOCK_INIT(pg); \ 1911.3Smatt (pg)->mdpage.mdpg_attrs = 0; \ 1921.3Smatt} while (/* CONSTCOND */ 0) 1931.1Smatt 1941.3Smatt#endif /* _LOCORE */ 1951.1Smatt 1961.1Smatt#endif /* _POWERPC_BOOKE_VMPARAM_H_ */ 197