performance improvements
[unix-history] / usr / src / sys / hp300 / include / pmap.h
CommitLineData
8f961915
KM
1/*
2 * Copyright (c) 1987 Carnegie-Mellon University
3 * Copyright (c) 1991 Regents of the University of California.
4 * All rights reserved.
5 *
6 * This code is derived from software contributed to Berkeley by
4a4de5a4
KM
7 * the Systems Programming Group of the University of Utah Computer
8 * Science Department.
8f961915 9 *
08693cad
KB
10 * %sccs.include.redist.c%
11 *
7dda3bdd 12 * @(#)pmap.h 7.11 (Berkeley) %G%
8f961915
KM
13 */
14
15#ifndef _PMAP_MACHINE_
0390aac7 16#define _PMAP_MACHINE_
8f961915
KM
17
18#define HP_PAGE_SIZE NBPG
9acfa6cd
MH
19#if defined(HP380)
20#define HP_SEG_SIZE (mmutype == MMU_68040 ? 0x40000 : NBSEG)
21#else
8f961915 22#define HP_SEG_SIZE NBSEG
9acfa6cd
MH
23#endif
24
25#define hp300_trunc_seg(x) (((unsigned)(x)) & ~(HP_SEG_SIZE-1))
26#define hp300_round_seg(x) hp300_trunc_seg((unsigned)(x) + HP_SEG_SIZE-1)
8f961915 27
8f961915
KM
28/*
29 * Pmap stuff
30 */
8f961915 31struct pmap {
0390aac7
MK
32 struct pte *pm_ptab; /* KVA of page table */
33 struct ste *pm_stab; /* KVA of segment table */
34 int pm_stchanged; /* ST changed */
9acfa6cd
MH
35 int pm_stfree; /* 040: free lev2 blocks */
36 struct ste *pm_stpa; /* 040: ST phys addr */
8f961915
KM
37 short pm_sref; /* segment table ref count */
38 short pm_count; /* pmap reference count */
39 simple_lock_data_t pm_lock; /* lock on pmap */
40 struct pmap_statistics pm_stats; /* pmap statistics */
41 long pm_ptpages; /* more stats: PT pages */
42};
43
44typedef struct pmap *pmap_t;
45
9987c59a 46extern struct pmap kernel_pmap_store;
7dda3bdd
MH
47
48#define kernel_pmap (&kernel_pmap_store)
49#define active_pmap(pm) \
50 ((pm) == kernel_pmap || (pm) == curproc->p_vmspace->vm_map.pmap)
8f961915 51
9acfa6cd
MH
52/*
53 * On the 040 we keep track of which level 2 blocks are already in use
54 * with the pm_stfree mask. Bits are arranged from LSB (block 0) to MSB
55 * (block 31). For convenience, the level 1 table is considered to be
56 * block 0.
57 *
58 * MAX[KU]L2SIZE control how many pages of level 2 descriptors are allowed.
59 * for the kernel and users. 8 implies only the initial "segment table"
60 * page is used. WARNING: don't change MAXUL2SIZE unless you can allocate
61 * physically contiguous pages for the ST in pmap.c!
62 */
1b48877e 63#define MAXKL2SIZE 32
9acfa6cd
MH
64#define MAXUL2SIZE 8
65#define l2tobm(n) (1 << (n))
66#define bmtol2(n) (ffs(n) - 1)
67
8f961915
KM
68/*
69 * Macros for speed
70 */
0390aac7
MK
71#define PMAP_ACTIVATE(pmapp, pcbp, iscurproc) \
72 if ((pmapp) != NULL && (pmapp)->pm_stchanged) { \
9acfa6cd 73 (pcbp)->pcb_ustp = hp300_btop((vm_offset_t)(pmapp)->pm_stpa); \
0390aac7 74 if (iscurproc) \
8f961915
KM
75 loadustp((pcbp)->pcb_ustp); \
76 (pmapp)->pm_stchanged = FALSE; \
77 }
78#define PMAP_DEACTIVATE(pmapp, pcbp)
79
80/*
81 * For each vm_page_t, there is a list of all currently valid virtual
82 * mappings of that page. An entry is a pv_entry_t, the list is pv_table.
83 */
84typedef struct pv_entry {
85 struct pv_entry *pv_next; /* next pv_entry */
0390aac7 86 struct pmap *pv_pmap; /* pmap where mapping lies */
8f961915 87 vm_offset_t pv_va; /* virtual address for mapping */
0390aac7
MK
88 struct ste *pv_ptste; /* non-zero if VA maps a PT page */
89 struct pmap *pv_ptpmap; /* if pv_ptste, pmap for PT page */
8f961915
KM
90 int pv_flags; /* flags */
91} *pv_entry_t;
92
7dda3bdd
MH
93#define PV_CI 0x01 /* header: all entries are cache inhibited */
94#define PV_PTPAGE 0x02 /* header: entry maps a page table page */
8f961915
KM
95
96#ifdef KERNEL
7dda3bdd
MH
97#if defined(HP320) || defined(HP350)
98#define HAVEVAC /* include cheezy VAC support */
99#endif
100
8f961915
KM
101pv_entry_t pv_table; /* array of entries, one per page */
102
103#define pa_index(pa) atop(pa - vm_first_phys)
104#define pa_to_pvh(pa) (&pv_table[pa_index(pa)])
105
106#define pmap_resident_count(pmap) ((pmap)->pm_stats.resident_count)
107
0390aac7
MK
108extern struct pte *Sysmap;
109extern char *vmmap; /* map for mem, dumps, etc. */
8f961915
KM
110#endif KERNEL
111
112#endif _PMAP_MACHINE_