153975Sfujita /* 253975Sfujita * Copyright (c) 1987 Carnegie-Mellon University 353975Sfujita * Copyright (c) 1992 OMRON Corporation. 453975Sfujita * Copyright (c) 1991, 1992 Regents of the University of California. 553975Sfujita * All rights reserved. 653975Sfujita * 753975Sfujita * This code is derived from software contributed to Berkeley by 853975Sfujita * the Systems Programming Group of the University of Utah Computer 953975Sfujita * Science Department. 1053975Sfujita * 1153975Sfujita * %sccs.include.redist.c% 1253975Sfujita * 1353975Sfujita * OMRON: $Id: pmap.h,v 1.2 92/06/14 06:29:43 moti Exp $ 1453975Sfujita * 15*54577Sfujita * @(#)pmap.h 7.2 (Berkeley) 06/30/92 1653975Sfujita */ 1753975Sfujita 1853975Sfujita #ifndef _PMAP_MACHINE_ 1953975Sfujita #define _PMAP_MACHINE_ 2053975Sfujita 2153975Sfujita #define LUNA_PAGE_SIZE NBPG 2253975Sfujita #define LUNA_SEG_SIZE NBSEG 2353975Sfujita 2453975Sfujita #define luna_trunc_seg(x) (((unsigned)(x)) & ~(LUNA_SEG_SIZE-1)) 2553975Sfujita #define luna_round_seg(x) luna_trunc_seg((unsigned)(x) + LUNA_SEG_SIZE-1) 2653975Sfujita 2753975Sfujita /* 2853975Sfujita * Pmap stuff 2953975Sfujita */ 3053975Sfujita struct pmap { 3153975Sfujita struct pte *pm_ptab; /* KVA of page table */ 3253975Sfujita struct ste *pm_stab; /* KVA of segment table */ 3353975Sfujita int pm_stchanged; /* ST changed */ 3453975Sfujita int pm_stfree; /* 040: free lev2 blocks */ 3553975Sfujita struct ste *pm_stpa; /* 040: ST phys addr */ 3653975Sfujita short pm_sref; /* segment table ref count */ 3753975Sfujita short pm_count; /* pmap reference count */ 3853975Sfujita simple_lock_data_t pm_lock; /* lock on pmap */ 3953975Sfujita struct pmap_statistics pm_stats; /* pmap statistics */ 4053975Sfujita long pm_ptpages; /* more stats: PT pages */ 4153975Sfujita }; 4253975Sfujita 4353975Sfujita typedef struct pmap *pmap_t; 4453975Sfujita 4553975Sfujita extern struct pmap kernel_pmap_store; 4653975Sfujita #define kernel_pmap (&kernel_pmap_store) 4753975Sfujita 4853975Sfujita /* 4953975Sfujita * On the 040 we keep track of which level 2 blocks are already in use 5053975Sfujita * with the pm_stfree mask. Bits are arranged from LSB (block 0) to MSB 5153975Sfujita * (block 31). For convenience, the level 1 table is considered to be 5253975Sfujita * block 0. 5353975Sfujita * 5453975Sfujita * MAX[KU]L2SIZE control how many pages of level 2 descriptors are allowed. 5553975Sfujita * for the kernel and users. 8 implies only the initial "segment table" 5653975Sfujita * page is used. WARNING: don't change MAXUL2SIZE unless you can allocate 5753975Sfujita * physically contiguous pages for the ST in pmap.c! 5853975Sfujita */ 5953975Sfujita #define MAXKL2SIZE 16 6053975Sfujita #define MAXUL2SIZE 8 6153975Sfujita #define l2tobm(n) (1 << (n)) 6253975Sfujita #define bmtol2(n) (ffs(n) - 1) 6353975Sfujita 6453975Sfujita /* 6553975Sfujita * Macros for speed 6653975Sfujita */ 6753975Sfujita #define PMAP_ACTIVATE(pmapp, pcbp, iscurproc) \ 6853975Sfujita if ((pmapp) != NULL && (pmapp)->pm_stchanged) { \ 69*54577Sfujita (pcbp)->pcb_ustp = luna_btop((vm_offset_t)(pmapp)->pm_stpa); \ 7053975Sfujita if (iscurproc) \ 7153975Sfujita loadustp((pcbp)->pcb_ustp); \ 7253975Sfujita (pmapp)->pm_stchanged = FALSE; \ 7353975Sfujita } 7453975Sfujita #define PMAP_DEACTIVATE(pmapp, pcbp) 7553975Sfujita 7653975Sfujita /* 7753975Sfujita * For each vm_page_t, there is a list of all currently valid virtual 7853975Sfujita * mappings of that page. An entry is a pv_entry_t, the list is pv_table. 7953975Sfujita */ 8053975Sfujita typedef struct pv_entry { 8153975Sfujita struct pv_entry *pv_next; /* next pv_entry */ 8253975Sfujita struct pmap *pv_pmap; /* pmap where mapping lies */ 8353975Sfujita vm_offset_t pv_va; /* virtual address for mapping */ 8453975Sfujita struct ste *pv_ptste; /* non-zero if VA maps a PT page */ 8553975Sfujita struct pmap *pv_ptpmap; /* if pv_ptste, pmap for PT page */ 8653975Sfujita int pv_flags; /* flags */ 8753975Sfujita } *pv_entry_t; 8853975Sfujita 8953975Sfujita #define PV_CI 0x01 /* all entries must be cache inhibited */ 9053975Sfujita #define PV_PTPAGE 0x02 /* entry maps a page table page */ 9153975Sfujita 9253975Sfujita #ifdef KERNEL 9353975Sfujita pv_entry_t pv_table; /* array of entries, one per page */ 9453975Sfujita 9553975Sfujita #define pa_index(pa) atop(pa - vm_first_phys) 9653975Sfujita #define pa_to_pvh(pa) (&pv_table[pa_index(pa)]) 9753975Sfujita 9853975Sfujita #define pmap_resident_count(pmap) ((pmap)->pm_stats.resident_count) 9953975Sfujita 10053975Sfujita extern struct pte *Sysmap; 10153975Sfujita extern char *vmmap; /* map for mem, dumps, etc. */ 10253975Sfujita 10353975Sfujita /* 10453975Sfujita * definitions LUNA IO space mapping 10553975Sfujita */ 10653975Sfujita struct physmap { 10753975Sfujita int pm_phys; 10853975Sfujita int pm_size; 10953975Sfujita int pm_cache; 11053975Sfujita } ; 11153975Sfujita 11253975Sfujita #endif 11353975Sfujita 11453975Sfujita #endif _PMAP_MACHINE_ 115