1 /* SPDX-License-Identifier: Apache-2.0 */
2 /*
3  * Copyright (c) 2023 EPAM Systems
4  */
5 
6 #include <zephyr/kernel.h>
7 #include <zephyr/xen/public/memory.h>
8 #include <zephyr/xen/public/xen.h>
9 
10 /**
11  * Add mapping for specified page frame in Xen domain physmap.
12  *
13  * @param domid	domain id, where mapping will be added. For unprivileged should
14  *		be DOMID_SELF.
15  * @param idx	index into space being mapped.
16  * @param space	XENMAPSPACE_* mapping space identifier.
17  * @param gpfn	page frame where the source mapping page should appear.
18  * @return	zero on success, negative errno on error.
19  */
20 int xendom_add_to_physmap(int domid, unsigned long idx, unsigned int space,
21 			  xen_pfn_t gpfn);
22 
23 /**
24  * Add mapping for specified set of page frames to Xen domain physmap.
25  *
26  * @param domid		domain id, where mapping will be added. For unprivileged
27  *			should be DOMID_SELF.
28  * @param foreign_domid	for gmfn_foreign - domain id, whose pages being mapped,
29  *			0 for other.
30  * @param space		XENMAPSPACE_* mapping space identifier.
31  * @param size		number of page frames being mapped.
32  * @param idxs		array of indexes into space being mapped.
33  * @param gpfns		array of page frames where the mapping should appear.
34  * @param errs		array of per-index error codes.
35  * @return		zero on success, negative errno on error.
36  */
37 int xendom_add_to_physmap_batch(int domid, int foreign_domid,
38 				unsigned int space, unsigned int size,
39 				xen_ulong_t *idxs, xen_pfn_t *gpfns, int *errs);
40 
41 /**
42  * Removes page frame from Xen domain physmap.
43  *
44  * @param domid	domain id, whose page is going to be removed. For unprivileged
45  *		should be DOMID_SELF.
46  * @param gpfn	page frame number, that needs to be removed
47  * @return	zero on success, negative errno on error.
48  */
49 int xendom_remove_from_physmap(int domid, xen_pfn_t gpfn);
50 
51 /**
52  * Populate specified Xen domain page frames with memory.
53  *
54  * @param domid		domain id, where mapping will be added. For unprivileged
55  *			should be DOMID_SELF.
56  * @param extent_order	size/alignment of each extent (size is 2^extent_order),
57  *			e.g. 0 for 4K extents, 9 for 2M etc.
58  * @param nr_extents	number of page frames being populated.
59  * @param mem_flags	N/A, should be 0 for Arm.
60  * @param extent_start	page frame bases of extents to populate with memory.
61  * @return		number of populated frames success, negative errno on
62  *			error.
63  */
64 int xendom_populate_physmap(int domid, unsigned int extent_order,
65 			    unsigned int nr_extents, unsigned int mem_flags,
66 			    xen_pfn_t *extent_start);
67