xref: /illumos-gate/usr/src/uts/intel/sys/vmm_drv.h (revision 6446bd46ed1b4e9f69da153665f82181ccaedad5)
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 /* This file is dual-licensed; see usr/src/contrib/bhyve/LICENSE */
12 
13 /*
14  * Copyright 2019 Joyent, Inc.
15  * Copyright 2021 Oxide Computer Company
16  */
17 
18 #ifndef _VMM_DRV_H_
19 #define	_VMM_DRV_H_
20 
21 #ifdef	_KERNEL
22 
23 #include <sys/file.h>
24 #include <sys/stdbool.h>
25 
26 struct vmm_hold;
27 typedef struct vmm_hold vmm_hold_t;
28 
29 struct vmm_lease;
30 typedef struct vmm_lease vmm_lease_t;
31 
32 /*
33  * This is effectively a synonym for the bhyve-internal 'struct vm_page' type.
34  * Use of `vmm_page_t *` instead allows us to keep those implementation details
35  * hidden from vmm_drv consumers.
36  */
37 struct vmm_page;
38 typedef struct vmm_page vmm_page_t;
39 
40 /*
41  * Because of tangled headers, this definitions mirrors its ioport_handler_t
42  * counterpart in vmm_kernel.h.
43  */
44 typedef int (*vmm_drv_iop_cb_t)(void *, bool, uint16_t, uint8_t, uint32_t *);
45 
46 extern int vmm_drv_hold(file_t *, cred_t *, vmm_hold_t **);
47 extern void vmm_drv_rele(vmm_hold_t *);
48 extern boolean_t vmm_drv_release_reqd(vmm_hold_t *);
49 
50 extern vmm_lease_t *vmm_drv_lease_sign(vmm_hold_t *, boolean_t (*)(void *),
51     void *);
52 extern void vmm_drv_lease_break(vmm_hold_t *, vmm_lease_t *);
53 extern boolean_t vmm_drv_lease_expired(vmm_lease_t *);
54 
55 extern vmm_page_t *vmm_drv_page_hold(vmm_lease_t *, uintptr_t, int);
56 extern void vmm_drv_page_release(vmm_page_t *);
57 extern void vmm_drv_page_release_chain(vmm_page_t *);
58 extern const void *vmm_drv_page_readable(const vmm_page_t *);
59 extern void *vmm_drv_page_writable(const vmm_page_t *);
60 extern void vmm_drv_page_chain(vmm_page_t *, vmm_page_t *);
61 extern vmm_page_t *vmm_drv_page_next(const vmm_page_t *);
62 
63 extern int vmm_drv_msi(vmm_lease_t *, uint64_t, uint64_t);
64 
65 extern int vmm_drv_ioport_hook(vmm_hold_t *, uint16_t, vmm_drv_iop_cb_t, void *,
66     void **);
67 extern void vmm_drv_ioport_unhook(vmm_hold_t *, void **);
68 #endif /* _KERNEL */
69 
70 #endif /* _VMM_DRV_H_ */
71