1 /* $OpenBSD: pmap.h,v 1.29 2023/04/13 15:23:22 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_unuse_final(p) /* nothing */ 68 #define pmap_remove_holes(vm) do { /* nothing */ } while (0) 69 70 int pmap_translation_info(pmap_t, vaddr_t, paddr_t *, uint32_t *); 71 /* 72 * pmap_translation_info() return values 73 */ 74 #define PTI_INVALID 0 75 #define PTI_PTE 1 76 #define PTI_BATC 2 77 78 #define pmap_map_direct(pg) ((vaddr_t)VM_PAGE_TO_PHYS(pg)) 79 #define pmap_unmap_direct(va) PHYS_TO_VM_PAGE((paddr_t)va) 80 81 #define PMAP_CHECK_COPYIN 1 82 83 #define __HAVE_PMAP_DIRECT 84 #define PMAP_STEAL_MEMORY 85 #define __HAVE_PMAP_COLLECT 86 87 #endif /* _KERNEL */ 88 89 #ifndef _LOCORE 90 struct pv_entry { 91 struct pv_entry *pv_next; /* next pv_entry */ 92 struct pmap *pv_pmap; /* pmap where mapping lies */ 93 vaddr_t pv_va; /* virtual address for mapping */ 94 }; 95 96 struct vm_page_md { 97 struct pv_entry pv_ent; 98 int pv_flags; 99 }; 100 101 #define VM_MDPAGE_INIT(pg) \ 102 do { \ 103 (pg)->mdpage.pv_ent.pv_next = NULL; \ 104 (pg)->mdpage.pv_ent.pv_pmap = NULL; \ 105 (pg)->mdpage.pv_ent.pv_va = 0; \ 106 (pg)->mdpage.pv_flags = 0; \ 107 } while (0) 108 109 #endif /* _LOCORE */ 110 111 #endif /* _M88K_PMAP_H_ */ 112