pmap.h revision 1.1
11.1Stsutsui/* $NetBSD: pmap.h,v 1.1 1999/12/09 14:53:12 tsutsui Exp $ */ 21.1Stsutsui 31.1Stsutsui/* 41.1Stsutsui * Copyright (c) 1987 Carnegie-Mellon University 51.1Stsutsui * Copyright (c) 1991, 1993 61.1Stsutsui * The Regents of the University of California. All rights reserved. 71.1Stsutsui * 81.1Stsutsui * This code is derived from software contributed to Berkeley by 91.1Stsutsui * the Systems Programming Group of the University of Utah Computer 101.1Stsutsui * Science Department. 111.1Stsutsui * 121.1Stsutsui * Redistribution and use in source and binary forms, with or without 131.1Stsutsui * modification, are permitted provided that the following conditions 141.1Stsutsui * are met: 151.1Stsutsui * 1. Redistributions of source code must retain the above copyright 161.1Stsutsui * notice, this list of conditions and the following disclaimer. 171.1Stsutsui * 2. Redistributions in binary form must reproduce the above copyright 181.1Stsutsui * notice, this list of conditions and the following disclaimer in the 191.1Stsutsui * documentation and/or other materials provided with the distribution. 201.1Stsutsui * 3. All advertising materials mentioning features or use of this software 211.1Stsutsui * must display the following acknowledgement: 221.1Stsutsui * This product includes software developed by the University of 231.1Stsutsui * California, Berkeley and its contributors. 241.1Stsutsui * 4. Neither the name of the University nor the names of its contributors 251.1Stsutsui * may be used to endorse or promote products derived from this software 261.1Stsutsui * without specific prior written permission. 271.1Stsutsui * 281.1Stsutsui * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 291.1Stsutsui * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 301.1Stsutsui * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 311.1Stsutsui * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 321.1Stsutsui * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 331.1Stsutsui * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 341.1Stsutsui * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 351.1Stsutsui * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 361.1Stsutsui * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 371.1Stsutsui * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 381.1Stsutsui * SUCH DAMAGE. 391.1Stsutsui * 401.1Stsutsui * @(#)pmap.h 8.1 (Berkeley) 6/10/93 411.1Stsutsui */ 421.1Stsutsui 431.1Stsutsui#ifndef _NEWS68K_PMAP_H_ 441.1Stsutsui#define _NEWS68K_PMAP_H_ 451.1Stsutsui 461.1Stsutsui#include <machine/cpu.h> 471.1Stsutsui#include <machine/pte.h> 481.1Stsutsui 491.1Stsutsui/* 501.1Stsutsui * Pmap stuff 511.1Stsutsui */ 521.1Stsutsuistruct pmap { 531.1Stsutsui pt_entry_t *pm_ptab; /* KVA of page table */ 541.1Stsutsui st_entry_t *pm_stab; /* KVA of segment table */ 551.1Stsutsui int pm_stfree; /* 040: free lev2 blocks */ 561.1Stsutsui st_entry_t *pm_stpa; /* 040: ST phys addr */ 571.1Stsutsui short pm_sref; /* segment table ref count */ 581.1Stsutsui short pm_count; /* pmap reference count */ 591.1Stsutsui simple_lock_data_t pm_lock; /* lock on pmap */ 601.1Stsutsui struct pmap_statistics pm_stats; /* pmap statistics */ 611.1Stsutsui long pm_ptpages; /* more stats: PT pages */ 621.1Stsutsui}; 631.1Stsutsui 641.1Stsutsuitypedef struct pmap *pmap_t; 651.1Stsutsui 661.1Stsutsui/* 671.1Stsutsui * On the 040 we keep track of which level 2 blocks are already in use 681.1Stsutsui * with the pm_stfree mask. Bits are arranged from LSB (block 0) to MSB 691.1Stsutsui * (block 31). For convenience, the level 1 table is considered to be 701.1Stsutsui * block 0. 711.1Stsutsui * 721.1Stsutsui * MAX[KU]L2SIZE control how many pages of level 2 descriptors are allowed. 731.1Stsutsui * for the kernel and users. 8 implies only the initial "segment table" 741.1Stsutsui * page is used. WARNING: don't change MAXUL2SIZE unless you can allocate 751.1Stsutsui * physically contiguous pages for the ST in pmap.c! 761.1Stsutsui */ 771.1Stsutsui#define MAXKL2SIZE 32 781.1Stsutsui#define MAXUL2SIZE 8 791.1Stsutsui#define l2tobm(n) (1 << (n)) 801.1Stsutsui#define bmtol2(n) (ffs(n) - 1) 811.1Stsutsui 821.1Stsutsui/* 831.1Stsutsui * Macros for speed 841.1Stsutsui */ 851.1Stsutsui#define PMAP_ACTIVATE(pmap, loadhw) \ 861.1Stsutsui{ \ 871.1Stsutsui if ((loadhw)) \ 881.1Stsutsui loadustp(m68k_btop((paddr_t)(pmap)->pm_stpa)); \ 891.1Stsutsui} 901.1Stsutsui 911.1Stsutsui/* 921.1Stsutsui * For each vm_page_t, there is a list of all currently valid virtual 931.1Stsutsui * mappings of that page. An entry is a pv_entry, the list is pv_table. 941.1Stsutsui */ 951.1Stsutsuistruct pv_entry { 961.1Stsutsui struct pv_entry *pv_next; /* next pv_entry */ 971.1Stsutsui struct pmap *pv_pmap; /* pmap where mapping lies */ 981.1Stsutsui vaddr_t pv_va; /* virtual address for mapping */ 991.1Stsutsui st_entry_t *pv_ptste; /* non-zero if VA maps a PT page */ 1001.1Stsutsui struct pmap *pv_ptpmap; /* if pv_ptste, pmap for PT page */ 1011.1Stsutsui int pv_flags; /* flags */ 1021.1Stsutsui}; 1031.1Stsutsui 1041.1Stsutsui#define PV_CI 0x01 /* header: all entries are cache inhibited */ 1051.1Stsutsui#define PV_PTPAGE 0x02 /* header: entry maps a page table page */ 1061.1Stsutsui 1071.1Stsutsuistruct pv_page; 1081.1Stsutsui 1091.1Stsutsuistruct pv_page_info { 1101.1Stsutsui TAILQ_ENTRY(pv_page) pgi_list; 1111.1Stsutsui struct pv_entry *pgi_freelist; 1121.1Stsutsui int pgi_nfree; 1131.1Stsutsui}; 1141.1Stsutsui 1151.1Stsutsui/* 1161.1Stsutsui * This is basically: 1171.1Stsutsui * ((NBPG - sizeof(struct pv_page_info)) / sizeof(struct pv_entry)) 1181.1Stsutsui */ 1191.1Stsutsui#define NPVPPG 170 1201.1Stsutsui 1211.1Stsutsuistruct pv_page { 1221.1Stsutsui struct pv_page_info pvp_pgi; 1231.1Stsutsui struct pv_entry pvp_pv[NPVPPG]; 1241.1Stsutsui}; 1251.1Stsutsui 1261.1Stsutsuiextern struct pmap kernel_pmap_store; 1271.1Stsutsui 1281.1Stsutsui#define pmap_kernel() (&kernel_pmap_store) 1291.1Stsutsui#define active_pmap(pm) \ 1301.1Stsutsui ((pm) == pmap_kernel() || (pm) == curproc->p_vmspace->vm_map.pmap) 1311.1Stsutsui#define active_user_pmap(pm) \ 1321.1Stsutsui (curproc && \ 1331.1Stsutsui (pm) != pmap_kernel() && (pm) == curproc->p_vmspace->vm_map.pmap) 1341.1Stsutsui 1351.1Stsutsuiextern struct pv_entry *pv_table; /* array of entries, one per page */ 1361.1Stsutsui 1371.1Stsutsui#define pmap_page_index(pa) atop(pa - vm_first_phys) 1381.1Stsutsui#define pmap_resident_count(pmap) ((pmap)->pm_stats.resident_count) 1391.1Stsutsui#define pmap_wired_count(pmap) ((pmap)->pm_stats.wired_count) 1401.1Stsutsui 1411.1Stsutsuiextern pt_entry_t *Sysmap; 1421.1Stsutsuiextern char *vmmap; /* map for mem, dumps, etc. */ 1431.1Stsutsui 1441.1Stsutsuivaddr_t pmap_map __P((vaddr_t, paddr_t, paddr_t, int)); 1451.1Stsutsuivoid pmap_procwr __P((struct proc *, vaddr_t, u_long)); 1461.1Stsutsui#define PMAP_NEED_PROCWR 1471.1Stsutsui 1481.1Stsutsui#ifdef CACHE_HAVE_VAC 1491.1Stsutsuivoid pmap_prefer __P((vaddr_t, vaddr_t *)); 1501.1Stsutsui#define PMAP_PREFER(foff, vap) pmap_prefer((foff), (vap)) 1511.1Stsutsui#endif 1521.1Stsutsui 1531.1Stsutsui#endif /* !_NEWS68K_PMAP_H_ */ 154