pmap.h revision 1.38
11.38Sthorpej/* $NetBSD: pmap.h,v 1.38 2003/04/02 07:35:55 thorpej Exp $ */ 21.10Scgd 31.1Smw/* 41.1Smw * Copyright (c) 1987 Carnegie-Mellon University 51.1Smw * Copyright (c) 1991 Regents of the University of California. 61.1Smw * All rights reserved. 71.1Smw * 81.1Smw * This code is derived from software contributed to Berkeley by 91.1Smw * the Systems Programming Group of the University of Utah Computer 101.1Smw * Science Department. 111.1Smw * 121.1Smw * Redistribution and use in source and binary forms, with or without 131.1Smw * modification, are permitted provided that the following conditions 141.1Smw * are met: 151.1Smw * 1. Redistributions of source code must retain the above copyright 161.1Smw * notice, this list of conditions and the following disclaimer. 171.1Smw * 2. Redistributions in binary form must reproduce the above copyright 181.1Smw * notice, this list of conditions and the following disclaimer in the 191.1Smw * documentation and/or other materials provided with the distribution. 201.1Smw * 3. All advertising materials mentioning features or use of this software 211.1Smw * must display the following acknowledgement: 221.1Smw * This product includes software developed by the University of 231.1Smw * California, Berkeley and its contributors. 241.1Smw * 4. Neither the name of the University nor the names of its contributors 251.1Smw * may be used to endorse or promote products derived from this software 261.1Smw * without specific prior written permission. 271.1Smw * 281.1Smw * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 291.1Smw * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 301.1Smw * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 311.1Smw * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 321.1Smw * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 331.1Smw * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 341.1Smw * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 351.1Smw * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 361.1Smw * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 371.1Smw * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 381.1Smw * SUCH DAMAGE. 391.1Smw * 401.3Smw * @(#)pmap.h 7.6 (Berkeley) 5/10/91 411.1Smw */ 421.7Schopps#ifndef _MACHINE_PMAP_H_ 431.7Schopps#define _MACHINE_PMAP_H_ 441.1Smw 451.1Smw/* 461.15Schopps * Pmap stuff 471.1Smw */ 481.1Smwstruct pmap { 491.16Schopps pt_entry_t *pm_ptab; /* KVA of page table */ 501.16Schopps st_entry_t *pm_stab; /* KVA of segment table */ 511.16Schopps int pm_stfree; /* 040: free lev2 blocks */ 521.16Schopps u_int *pm_stpa; /* 040: ST phys addr */ 531.16Schopps short pm_sref; /* segment table ref count */ 541.16Schopps short pm_count; /* pmap reference count */ 551.16Schopps long pm_ptpages; /* more stats: PT pages */ 561.31Schs struct simplelock pm_lock; /* lock on pmap */ 571.1Smw struct pmap_statistics pm_stats; /* pmap statistics */ 581.1Smw}; 591.1Smw 601.16Schoppstypedef struct pmap *pmap_t; 611.16Schopps 621.16Schopps/* 631.16Schopps * On the 040 we keep track of which level 2 blocks are already in use 641.16Schopps * with the pm_stfree mask. Bits are arranged from LSB (block 0) to MSB 651.16Schopps * (block 31). For convenience, the level 1 table is considered to be 661.16Schopps * block 0. 671.16Schopps * 681.16Schopps * MAX[KU]L2SIZE control how many pages of level 2 descriptors are allowed. 691.16Schopps * for the kernel and users. 16 implies only the initial "segment table" 701.16Schopps * page is used. WARNING: don't change MAXUL2SIZE unless you can allocate 711.16Schopps * physically contiguous pages for the ST in pmap.c! 721.16Schopps */ 731.16Schopps#define MAXKL2SIZE 32 741.16Schopps#define MAXUL2SIZE 16 751.16Schopps#define l2tobm(n) (1 << (n)) 761.16Schopps#define bmtol2(n) (ffs(n) - 1) 771.1Smw 781.1Smw/* 791.1Smw * Macros for speed 801.1Smw */ 811.21Sthorpej#define PMAP_ACTIVATE(pmap, loadhw) \ 821.18Sthorpej{ \ 831.21Sthorpej if ((loadhw)) \ 841.27Sis loadustp(m68k_btop((paddr_t)(pmap)->pm_stpa)); \ 851.18Sthorpej} 861.1Smw 871.1Smw/* 881.32Schs * For each struct vm_page, there is a list of all currently valid virtual 891.1Smw * mappings of that page. An entry is a pv_entry_t, the list is pv_table. 901.1Smw */ 911.1Smwtypedef struct pv_entry { 921.1Smw struct pv_entry *pv_next; /* next pv_entry */ 931.1Smw struct pmap *pv_pmap; /* pmap where mapping lies */ 941.27Sis vaddr_t pv_va; /* virtual address for mapping */ 951.9Schopps u_int *pv_ptste; /* non-zero if VA maps a PT page */ 961.1Smw struct pmap *pv_ptpmap; /* if pv_ptste, pmap for PT page */ 971.1Smw int pv_flags; /* flags */ 981.1Smw} *pv_entry_t; 991.1Smw 1001.1Smw#define PV_CI 0x01 /* all entries must be cache inhibited */ 1011.1Smw#define PV_PTPAGE 0x02 /* entry maps a page table page */ 1021.1Smw 1031.16Schoppsstruct pv_page; 1041.16Schopps 1051.16Schoppsstruct pv_page_info { 1061.16Schopps TAILQ_ENTRY(pv_page) pgi_list; 1071.16Schopps struct pv_entry *pgi_freelist; 1081.16Schopps int pgi_nfree; 1091.16Schopps}; 1101.16Schopps 1111.16Schopps/* 1121.16Schopps * This is basically: 1131.38Sthorpej * ((PAGE_SIZE - sizeof(struct pv_page_info)) / sizeof(struct pv_entry)) 1141.16Schopps */ 1151.16Schopps#define NPVPPG 340 1161.16Schopps 1171.16Schoppsstruct pv_page { 1181.16Schopps struct pv_page_info pvp_pgi; 1191.16Schopps struct pv_entry pvp_pv[NPVPPG]; 1201.16Schopps}; 1211.16Schopps 1221.13Sjtc#ifdef _KERNEL 1231.34Saymericextern u_int *Sysmap; 1241.34Saymericextern caddr_t vmmap; /* map for mem, dumps, etc. */ 1251.34Saymericextern struct pmap kernel_pmap_store; 1261.18Sthorpej 1271.12Smycroft#define pmap_kernel() (&kernel_pmap_store) 1281.18Sthorpej 1291.16Schopps#define active_pmap(pm) \ 1301.37Sthorpej ((pm) == pmap_kernel() || \ 1311.37Sthorpej (pm) == curproc->p_vmspace->vm_map.pmap) 1321.18Sthorpej#define active_user_pmap(pm) \ 1331.18Sthorpej (curproc && \ 1341.37Sthorpej (pm) != pmap_kernel() && \ 1351.37Sthorpej (pm) == curproc->p_vmspace->vm_map.pmap) 1361.18Sthorpej 1371.1Smw#define pmap_resident_count(pmap) ((pmap)->pm_stats.resident_count) 1381.16Schopps#define pmap_wired_count(pmap) ((pmap)->pm_stats.wired_count) 1391.28Sthorpej 1401.33Schris#define pmap_update(pmap) /* nothing (yet) */ 1411.35Schs 1421.35Schsstatic __inline void 1431.36Schspmap_remove_all(struct pmap *pmap) 1441.35Schs{ 1451.35Schs /* Nothing. */ 1461.35Schs} 1471.23Scgd 1481.27Sisvaddr_t pmap_map __P((vaddr_t, paddr_t, paddr_t, int)); 1491.27Sisvoid pmap_procwr __P((struct proc *, vaddr_t, u_long)); 1501.26Sis#define PMAP_NEED_PROCWR 1511.18Sthorpej 1521.13Sjtc#endif /* _KERNEL */ 1531.1Smw 1541.7Schopps#endif /* !_MACHINE_PMAP_H_ */ 155