xref: /csrg-svn/sys/hp300/include/pmap.h (revision 53928)
145754Smckusick /*
245754Smckusick  * Copyright (c) 1987 Carnegie-Mellon University
345754Smckusick  * Copyright (c) 1991 Regents of the University of California.
445754Smckusick  * All rights reserved.
545754Smckusick  *
645754Smckusick  * This code is derived from software contributed to Berkeley by
749622Smckusick  * the Systems Programming Group of the University of Utah Computer
849622Smckusick  * Science Department.
945754Smckusick  *
1049631Sbostic  * %sccs.include.redist.c%
1149631Sbostic  *
12*53928Shibler  *	@(#)pmap.h	7.9 (Berkeley) 06/05/92
1345754Smckusick  */
1445754Smckusick 
1545754Smckusick #ifndef	_PMAP_MACHINE_
1648461Skarels #define	_PMAP_MACHINE_
1745754Smckusick 
1845754Smckusick #define HP_PAGE_SIZE	NBPG
19*53928Shibler #if defined(HP380)
20*53928Shibler #define HP_SEG_SIZE	(mmutype == MMU_68040 ? 0x40000 : NBSEG)
21*53928Shibler #else
2245754Smckusick #define HP_SEG_SIZE	NBSEG
23*53928Shibler #endif
2445754Smckusick 
25*53928Shibler #define hp300_trunc_seg(x)	(((unsigned)(x)) & ~(HP_SEG_SIZE-1))
26*53928Shibler #define hp300_round_seg(x)	hp300_trunc_seg((unsigned)(x) + HP_SEG_SIZE-1)
27*53928Shibler 
2845754Smckusick /*
2945754Smckusick  * Pmap stuff
3045754Smckusick  */
3145754Smckusick struct pmap {
3248461Skarels 	struct pte		*pm_ptab;	/* KVA of page table */
3348461Skarels 	struct ste		*pm_stab;	/* KVA of segment table */
3448461Skarels 	int			pm_stchanged;	/* ST changed */
35*53928Shibler 	int			pm_stfree;	/* 040: free lev2 blocks */
36*53928Shibler 	struct ste		*pm_stpa;	/* 040: ST phys addr */
3745754Smckusick 	short			pm_sref;	/* segment table ref count */
3845754Smckusick 	short			pm_count;	/* pmap reference count */
3945754Smckusick 	simple_lock_data_t	pm_lock;	/* lock on pmap */
4045754Smckusick 	struct pmap_statistics	pm_stats;	/* pmap statistics */
4145754Smckusick 	long			pm_ptpages;	/* more stats: PT pages */
4245754Smckusick };
4345754Smckusick 
4445754Smckusick typedef struct pmap	*pmap_t;
4545754Smckusick 
4652604Smckusick extern struct pmap	kernel_pmap_store;
4752604Smckusick #define kernel_pmap (&kernel_pmap_store)
4845754Smckusick 
4945754Smckusick /*
50*53928Shibler  * On the 040 we keep track of which level 2 blocks are already in use
51*53928Shibler  * with the pm_stfree mask.  Bits are arranged from LSB (block 0) to MSB
52*53928Shibler  * (block 31).  For convenience, the level 1 table is considered to be
53*53928Shibler  * block 0.
54*53928Shibler  *
55*53928Shibler  * MAX[KU]L2SIZE control how many pages of level 2 descriptors are allowed.
56*53928Shibler  * for the kernel and users.  8 implies only the initial "segment table"
57*53928Shibler  * page is used.  WARNING: don't change MAXUL2SIZE unless you can allocate
58*53928Shibler  * physically contiguous pages for the ST in pmap.c!
59*53928Shibler  */
60*53928Shibler #define	MAXKL2SIZE	16
61*53928Shibler #define MAXUL2SIZE	8
62*53928Shibler #define l2tobm(n)	(1 << (n))
63*53928Shibler #define	bmtol2(n)	(ffs(n) - 1)
64*53928Shibler 
65*53928Shibler /*
6645754Smckusick  * Macros for speed
6745754Smckusick  */
6848461Skarels #define PMAP_ACTIVATE(pmapp, pcbp, iscurproc) \
6948461Skarels 	if ((pmapp) != NULL && (pmapp)->pm_stchanged) { \
70*53928Shibler 		(pcbp)->pcb_ustp = hp300_btop((vm_offset_t)(pmapp)->pm_stpa); \
7148461Skarels 		if (iscurproc) \
7245754Smckusick 			loadustp((pcbp)->pcb_ustp); \
7345754Smckusick 		(pmapp)->pm_stchanged = FALSE; \
7445754Smckusick 	}
7545754Smckusick #define PMAP_DEACTIVATE(pmapp, pcbp)
7645754Smckusick 
7745754Smckusick /*
7845754Smckusick  * For each vm_page_t, there is a list of all currently valid virtual
7945754Smckusick  * mappings of that page.  An entry is a pv_entry_t, the list is pv_table.
8045754Smckusick  */
8145754Smckusick typedef struct pv_entry {
8245754Smckusick 	struct pv_entry	*pv_next;	/* next pv_entry */
8348461Skarels 	struct pmap	*pv_pmap;	/* pmap where mapping lies */
8445754Smckusick 	vm_offset_t	pv_va;		/* virtual address for mapping */
8548461Skarels 	struct ste	*pv_ptste;	/* non-zero if VA maps a PT page */
8648461Skarels 	struct pmap	*pv_ptpmap;	/* if pv_ptste, pmap for PT page */
8745754Smckusick 	int		pv_flags;	/* flags */
8845754Smckusick } *pv_entry_t;
8945754Smckusick 
9045754Smckusick #define	PV_CI		0x01	/* all entries must be cache inhibited */
9145754Smckusick #define PV_PTPAGE	0x02	/* entry maps a page table page */
9245754Smckusick 
9345754Smckusick #ifdef	KERNEL
9445754Smckusick pv_entry_t	pv_table;		/* array of entries, one per page */
9545754Smckusick 
9645754Smckusick #define pa_index(pa)		atop(pa - vm_first_phys)
9745754Smckusick #define pa_to_pvh(pa)		(&pv_table[pa_index(pa)])
9845754Smckusick 
9945754Smckusick #define	pmap_resident_count(pmap)	((pmap)->pm_stats.resident_count)
10045754Smckusick 
10148461Skarels extern	struct pte *Sysmap;
10248461Skarels extern	char *vmmap;			/* map for mem, dumps, etc. */
10345754Smckusick #endif	KERNEL
10445754Smckusick 
10545754Smckusick #endif	_PMAP_MACHINE_
106