xref: /illumos-gate/usr/src/compat/bhyve/amd64/machine/vmparam.h (revision d0b3c59ba652f183eeec1414dd9fbdc56bf05cc8)
1 /*
2  * This file and its contents are supplied under the terms of the
3  * Common Development and Distribution License ("CDDL"), version 1.0.
4  * You may only use this file in accordance with the terms of version
5  * 1.0 of the CDDL.
6  *
7  * A full copy of the text of the CDDL should have accompanied this
8  * source.  A copy of the CDDL is also available via the Internet at
9  * http://www.illumos.org/license/CDDL.
10  */
11 
12 /*
13  * Copyright 2013 Pluribus Networks Inc.
14  * Copyright 2019 Joyent, Inc.
15  */
16 
17 #ifndef _COMPAT_FREEBSD_AMD64_MACHINE_VMPARAM_H_
18 #define	_COMPAT_FREEBSD_AMD64_MACHINE_VMPARAM_H_
19 
20 extern caddr_t kpm_vbase;
21 extern size_t kpm_size;
22 
23 static inline uintptr_t
phys_to_dmap(uintptr_t pa)24 phys_to_dmap(uintptr_t pa)
25 {
26 	ASSERT3U(pa, <, kpm_size);
27 	return ((uintptr_t)kpm_vbase + pa);
28 }
29 
30 static inline uintptr_t
dmap_to_phys(uintptr_t kva)31 dmap_to_phys(uintptr_t kva)
32 {
33 	const uintptr_t base = (uintptr_t)kpm_vbase;
34 
35 	ASSERT3U(kva, >=, base);
36 	ASSERT3U(kva, <, base + kpm_size);
37 
38 	return (kva - base);
39 }
40 
41 #define	PHYS_TO_DMAP(x)	phys_to_dmap(x)
42 #define	DMAP_TO_PHYS(x)	dmap_to_phys(x)
43 
44 
45 #endif	/* _COMPAT_FREEBSD_AMD64_MACHINE_VMPARAM_H_ */
46