152131Smckusick /* 252131Smckusick * Copyright (c) 1987 Carnegie-Mellon University 3*63217Sbostic * Copyright (c) 1992, 1993 4*63217Sbostic * The Regents of the University of California. All rights reserved. 552131Smckusick * 652131Smckusick * This code is derived from software contributed to Berkeley by 752131Smckusick * Ralph Campbell. 852131Smckusick * 952131Smckusick * %sccs.include.redist.c% 1052131Smckusick * 11*63217Sbostic * @(#)pmap.h 8.1 (Berkeley) 06/10/93 1252131Smckusick */ 1352131Smckusick 1452131Smckusick #ifndef _PMAP_MACHINE_ 1552131Smckusick #define _PMAP_MACHINE_ 1652131Smckusick 1752131Smckusick /* 1859843Sralph * The user address space is 2Gb (0x0 - 0x80000000). 1959843Sralph * User programs are laid out in memory as follows: 2059843Sralph * address 2159843Sralph * USRTEXT 0x00001000 2259843Sralph * USRDATA USRTEXT + text_size 2359843Sralph * USRSTACK 0x7FFFFFFF 2459843Sralph * 2559843Sralph * The user address space is mapped using a two level structure where 2659843Sralph * virtual address bits 30..22 are used to index into a segment table which 2759843Sralph * points to a page worth of PTEs (4096 page can hold 1024 PTEs). 2859843Sralph * Bits 21..12 are then used to index a PTE which describes a page within 2959843Sralph * a segment. 3059843Sralph * 3152131Smckusick * The wired entries in the TLB will contain the following: 3259843Sralph * 0-1 (UPAGES) for curproc user struct and kernel stack. 3359843Sralph * 3459843Sralph * Note: The kernel doesn't use the same data structures as user programs. 3559843Sralph * All the PTE entries are stored in a single array in Sysmap which is 3659843Sralph * dynamically allocated at boot time. 3752131Smckusick */ 3852131Smckusick 3959843Sralph #define pmax_trunc_seg(x) ((vm_offset_t)(x) & ~SEGOFSET) 4059843Sralph #define pmax_round_seg(x) (((vm_offset_t)(x) + SEGOFSET) & ~SEGOFSET) 4159843Sralph #define pmap_segmap(m, v) ((m)->pm_segtab->seg_tab[((v) >> SEGSHIFT)]) 4252131Smckusick 4359843Sralph #define PMAP_SEGTABSIZE 512 4452131Smckusick 4559843Sralph union pt_entry; 4659843Sralph 4759843Sralph struct segtab { 4859843Sralph union pt_entry *seg_tab[PMAP_SEGTABSIZE]; 4959843Sralph }; 5059843Sralph 5152131Smckusick /* 5252131Smckusick * Machine dependent pmap structure. 5352131Smckusick */ 5452131Smckusick typedef struct pmap { 5552131Smckusick int pm_count; /* pmap reference count */ 5652131Smckusick simple_lock_data_t pm_lock; /* lock on pmap */ 5752131Smckusick struct pmap_statistics pm_stats; /* pmap statistics */ 5852131Smckusick int pm_tlbpid; /* address space tag */ 5959843Sralph u_int pm_tlbgen; /* TLB PID generation number */ 6059843Sralph struct segtab *pm_segtab; /* pointers to pages of PTEs */ 6152131Smckusick } *pmap_t; 6252131Smckusick 6352131Smckusick /* 6452131Smckusick * Defines for pmap_attributes[phys_mach_page]; 6552131Smckusick */ 6652131Smckusick #define PMAP_ATTR_MOD 0x01 /* page has been modified */ 6752131Smckusick #define PMAP_ATTR_REF 0x02 /* page has been referenced */ 6852131Smckusick 6952131Smckusick #ifdef KERNEL 7059843Sralph extern char *pmap_attributes; /* reference and modify bits */ 7159843Sralph extern struct pmap kernel_pmap_store; 7252605Smckusick #define kernel_pmap (&kernel_pmap_store) 7361000Shibler #define pmap_wired_count(pmap) ((pmap)->pm_stats.wired_count) 7459843Sralph #endif /* KERNEL */ 7559843Sralph 7659843Sralph #endif /* _PMAP_MACHINE_ */ 77