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