xref: /original-bsd/sys/luna68k/include/pmap.h (revision 68d9582f)
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  *
15  *	@(#)pmap.h	7.1 (Berkeley) 06/15/92
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  */
30 struct 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 
43 typedef struct pmap	*pmap_t;
44 
45 extern 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) { \
69 		(pcbp)->pcb_ustp = \
70 		    luna_btop(pmap_extract(kernel_pmap, \
71 			((vm_offset_t)(pmapp)->pm_stab))); \
72 		if (iscurproc) \
73 			loadustp((pcbp)->pcb_ustp); \
74 		(pmapp)->pm_stchanged = FALSE; \
75 	}
76 #define PMAP_DEACTIVATE(pmapp, pcbp)
77 
78 /*
79  * For each vm_page_t, there is a list of all currently valid virtual
80  * mappings of that page.  An entry is a pv_entry_t, the list is pv_table.
81  */
82 typedef struct pv_entry {
83 	struct pv_entry	*pv_next;	/* next pv_entry */
84 	struct pmap	*pv_pmap;	/* pmap where mapping lies */
85 	vm_offset_t	pv_va;		/* virtual address for mapping */
86 	struct ste	*pv_ptste;	/* non-zero if VA maps a PT page */
87 	struct pmap	*pv_ptpmap;	/* if pv_ptste, pmap for PT page */
88 	int		pv_flags;	/* flags */
89 } *pv_entry_t;
90 
91 #define	PV_CI		0x01	/* all entries must be cache inhibited */
92 #define PV_PTPAGE	0x02	/* entry maps a page table page */
93 
94 #ifdef	KERNEL
95 pv_entry_t	pv_table;		/* array of entries, one per page */
96 
97 #define pa_index(pa)		atop(pa - vm_first_phys)
98 #define pa_to_pvh(pa)		(&pv_table[pa_index(pa)])
99 
100 #define	pmap_resident_count(pmap)	((pmap)->pm_stats.resident_count)
101 
102 extern	struct pte *Sysmap;
103 extern	char *vmmap;			/* map for mem, dumps, etc. */
104 
105 /*
106  * definitions LUNA IO space mapping
107  */
108 struct physmap {
109 	int pm_phys;
110 	int pm_size;
111 	int pm_cache;
112 } ;
113 
114 #endif
115 
116 #endif	_PMAP_MACHINE_
117