xref: /openbsd-src/sys/arch/m88k/include/pmap.h (revision 304d300a342105b838fdc1984181b64c8f803913)
1 /*	$OpenBSD: pmap.h,v 1.31 2024/02/14 06:16:53 miod Exp $	*/
2 /*
3  * Mach Operating System
4  * Copyright (c) 1991 Carnegie Mellon University
5  * Copyright (c) 1991 OMRON Corporation
6  * All Rights Reserved.
7  *
8  * Permission to use, copy, modify and distribute this software and its
9  * documentation is hereby granted, provided that both the copyright
10  * notice and this permission notice appear in all copies of the
11  * software, derivative works or modified versions, and any portions
12  * thereof, and that both notices appear in supporting documentation.
13  *
14  */
15 #ifndef _M88K_PMAP_H_
16 #define _M88K_PMAP_H_
17 
18 #ifdef	_KERNEL
19 
20 #include <machine/mmu.h>
21 
22 /*
23  * PMAP structure
24  */
25 
26 struct pmap {
27 	sdt_entry_t		*pm_stab;	/* virtual pointer to sdt */
28 	apr_t			 pm_apr;
29 	int			 pm_count;	/* reference count */
30 	struct pmap_statistics	pm_stats;	/* pmap statistics */
31 };
32 
33 /* 	The PV (Physical to virtual) List.
34  *
35  * For each vm_page_t, pmap keeps a list of all currently valid virtual
36  * mappings of that page. An entry is a pv_entry_t; the list is the
37  * pv_head_table. This is used by things like pmap_remove, when we must
38  * find and remove all mappings for a particular physical page.
39  */
40 /* XXX - struct pv_entry moved to vmparam.h because of include ordering issues */
41 
42 typedef struct pmap *pmap_t;
43 typedef struct pv_entry *pv_entry_t;
44 
45 extern	pmap_t		kernel_pmap;
46 extern	struct pmap	kernel_pmap_store;
47 extern	caddr_t		vmmap;
48 extern	apr_t		kernel_apr, userland_apr;
49 
50 #define	pmap_kernel()			(&kernel_pmap_store)
51 #define pmap_resident_count(pmap)	((pmap)->pm_stats.resident_count)
52 #define	pmap_wired_count(pmap)		((pmap)->pm_stats.wired_count)
53 
54 #define pmap_update(pmap)		do { /* nothing */ } while (0)
55 
56 #define	pmap_clear_modify(pg)		pmap_unsetbit(pg, PG_M)
57 #define	pmap_clear_reference(pg)	pmap_unsetbit(pg, PG_U)
58 
59 void	pmap_bootstrap(paddr_t, paddr_t);
60 void	pmap_bootstrap_cpu(cpuid_t);
61 void	pmap_cache_ctrl(vaddr_t, vaddr_t, u_int);
62 void	pmap_page_uncache(paddr_t);
63 int	pmap_set_modify(pmap_t, vaddr_t);
64 void	pmap_unmap_firmware(void);
65 boolean_t pmap_unsetbit(struct vm_page *, int);
66 
67 #define pmap_init_percpu()		do { /* nothing */ } while (0)
68 #define pmap_unuse_final(p)		/* nothing */
69 #define	pmap_remove_holes(vm)		do { /* nothing */ } while (0)
70 
71 int	pmap_translation_info(pmap_t, vaddr_t, paddr_t *, uint32_t *);
72 /*
73  * pmap_translation_info() return values
74  */
75 #define	PTI_INVALID	0
76 #define	PTI_PTE		1
77 #define	PTI_BATC	2
78 
79 #define	pmap_map_direct(pg)		((vaddr_t)VM_PAGE_TO_PHYS(pg))
80 vm_page_t pmap_unmap_direct(vaddr_t);
81 
82 #define	PMAP_CHECK_COPYIN	1
83 
84 #define	__HAVE_PMAP_DIRECT
85 #define	PMAP_STEAL_MEMORY
86 #define	__HAVE_PMAP_COLLECT
87 
88 #endif	/* _KERNEL */
89 
90 #ifndef _LOCORE
91 struct pv_entry {
92 	struct pv_entry	*pv_next;	/* next pv_entry */
93 	struct pmap	*pv_pmap;	/* pmap where mapping lies */
94 	vaddr_t		pv_va;		/* virtual address for mapping */
95 };
96 
97 struct vm_page_md {
98 	struct pv_entry pv_ent;
99 	int		pv_flags;
100 };
101 
102 #define	VM_MDPAGE_INIT(pg)						\
103 do {									\
104 	(pg)->mdpage.pv_ent.pv_next = NULL;				\
105 	(pg)->mdpage.pv_ent.pv_pmap = NULL;				\
106 	(pg)->mdpage.pv_ent.pv_va = 0;					\
107 	(pg)->mdpage.pv_flags = 0;					\
108 } while (0)
109 
110 #endif /* _LOCORE */
111 
112 #endif /* _M88K_PMAP_H_ */
113