pmap.h revision 1.10
1/*	$OpenBSD: pmap.h,v 1.10 2020/07/02 21:51:05 kettenis Exp $	*/
2
3/*
4 * Copyright (c) 2020 Mark Kettenis <kettenis@openbsd.org>
5 *
6 * Permission to use, copy, modify, and distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
9 *
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 */
18
19#ifndef _MACHINE_PMAP_H_
20#define _MACHINE_PMAP_H_
21
22#include <machine/pte.h>
23
24/* V->P mapping data */
25#define VP_IDX1_CNT	256
26#define VP_IDX1_MASK	(VP_IDX1_CNT - 1)
27#define VP_IDX1_POS 	20
28#define VP_IDX2_CNT	256
29#define VP_IDX2_MASK	(VP_IDX2_CNT - 1)
30#define VP_IDX2_POS 	12
31
32struct pmap {
33	LIST_HEAD(,slb_desc)	pm_slbd;
34	int			pm_refs;
35	struct pmap_statistics	pm_stats;
36	struct mutex		pm_mtx;
37	struct slb		pm_slb[32];
38};
39
40typedef struct pmap *pmap_t;
41
42#define PG_PMAP_MOD	PG_PMAP0
43#define PG_PMAP_REF	PG_PMAP1
44#define PG_PMAP_EXE	PG_PMAP2
45#define PG_PMAP_UC	PG_PMAP3
46
47#define PMAP_CACHE_DEFAULT	0
48#define PMAP_CACHE_CI		1	/* cache inhibit */
49#define PMAP_CACHE_WB		3	/* write-back cached */
50
51/*
52 * MD flags that we use for pmap_enter (in the pa):
53 */
54#define PMAP_PA_MASK	~((paddr_t)PAGE_MASK) /* to remove the flags */
55#define PMAP_NOCACHE	0x1		/* map uncached */
56
57struct vm_page_md {
58	struct mutex pv_mtx;
59	LIST_HEAD(,pte_desc) pv_list;
60};
61
62#define VM_MDPAGE_INIT(pg) do {                 \
63	mtx_init(&(pg)->mdpage.pv_mtx, IPL_VM); \
64	LIST_INIT(&((pg)->mdpage.pv_list)); 	\
65} while (0)
66
67extern struct pmap kernel_pmap_store;
68
69#define pmap_kernel()	(&kernel_pmap_store)
70#define pmap_resident_count(pm) ((pm)->pm_stats.resident_count)
71
72#define pmap_unuse_final(p)
73#define pmap_remove_holes(vm)
74#define pmap_update(pm)
75
76void	pmap_bootstrap(void);
77
78struct slb_desc *pmap_slbd_lookup(pmap_t, vaddr_t);
79void	pmap_slbd_cache(pmap_t, struct slb_desc *);
80
81int	pmap_set_user_slb(pmap_t, vaddr_t, vaddr_t *, vsize_t *);
82void	pmap_unset_user_slb(void);
83
84#ifdef DDB
85struct pte;
86struct pte *pmap_get_kernel_pte(vaddr_t);
87#endif
88
89#endif /* _MACHINE_PMAP_H_ */
90