xref: /original-bsd/sys/pmax/include/pmap.h (revision c3e32dec)
1 /*
2  * Copyright (c) 1987 Carnegie-Mellon University
3  * Copyright (c) 1992 Regents of the University of California.
4  * All rights reserved.
5  *
6  * This code is derived from software contributed to Berkeley by
7  * Ralph Campbell.
8  *
9  * %sccs.include.redist.c%
10  *
11  *	@(#)pmap.h	7.8 (Berkeley) 06/02/93
12  */
13 
14 #ifndef	_PMAP_MACHINE_
15 #define	_PMAP_MACHINE_
16 
17 /*
18  * The user address space is 2Gb (0x0 - 0x80000000).
19  * User programs are laid out in memory as follows:
20  *			address
21  *	USRTEXT		0x00001000
22  *	USRDATA		USRTEXT + text_size
23  *	USRSTACK	0x7FFFFFFF
24  *
25  * The user address space is mapped using a two level structure where
26  * virtual address bits 30..22 are used to index into a segment table which
27  * points to a page worth of PTEs (4096 page can hold 1024 PTEs).
28  * Bits 21..12 are then used to index a PTE which describes a page within
29  * a segment.
30  *
31  * The wired entries in the TLB will contain the following:
32  *	0-1	(UPAGES)	for curproc user struct and kernel stack.
33  *
34  * Note: The kernel doesn't use the same data structures as user programs.
35  * All the PTE entries are stored in a single array in Sysmap which is
36  * dynamically allocated at boot time.
37  */
38 
39 #define pmax_trunc_seg(x)	((vm_offset_t)(x) & ~SEGOFSET)
40 #define pmax_round_seg(x)	(((vm_offset_t)(x) + SEGOFSET) & ~SEGOFSET)
41 #define pmap_segmap(m, v)	((m)->pm_segtab->seg_tab[((v) >> SEGSHIFT)])
42 
43 #define PMAP_SEGTABSIZE		512
44 
45 union pt_entry;
46 
47 struct segtab {
48 	union pt_entry	*seg_tab[PMAP_SEGTABSIZE];
49 };
50 
51 /*
52  * Machine dependent pmap structure.
53  */
54 typedef struct pmap {
55 	int			pm_count;	/* pmap reference count */
56 	simple_lock_data_t	pm_lock;	/* lock on pmap */
57 	struct pmap_statistics	pm_stats;	/* pmap statistics */
58 	int			pm_tlbpid;	/* address space tag */
59 	u_int			pm_tlbgen;	/* TLB PID generation number */
60 	struct segtab		*pm_segtab;	/* pointers to pages of PTEs */
61 } *pmap_t;
62 
63 /*
64  * Defines for pmap_attributes[phys_mach_page];
65  */
66 #define PMAP_ATTR_MOD	0x01	/* page has been modified */
67 #define PMAP_ATTR_REF	0x02	/* page has been referenced */
68 
69 #ifdef	KERNEL
70 extern	char *pmap_attributes;		/* reference and modify bits */
71 extern	struct pmap kernel_pmap_store;
72 #define kernel_pmap (&kernel_pmap_store)
73 #define	pmap_wired_count(pmap) 	((pmap)->pm_stats.wired_count)
74 #endif	/* KERNEL */
75 
76 #endif	/* _PMAP_MACHINE_ */
77