1 /*
2  * Copyright (c) 2021 EPAM Systems
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 #include <zephyr/arch/arm64/hypercall.h>
8 #include <zephyr/xen/hvm.h>
9 #include <zephyr/xen/public/hvm/hvm_op.h>
10 #include <zephyr/xen/public/hvm/params.h>
11 
12 #include <zephyr/kernel.h>
13 
hvm_set_parameter(int idx,uint64_t value)14 int hvm_set_parameter(int idx, uint64_t value)
15 {
16 	struct xen_hvm_param xhv;
17 
18 	xhv.domid = DOMID_SELF;
19 	xhv.index = idx;
20 	xhv.value = value;
21 
22 	return HYPERVISOR_hvm_op(HVMOP_set_param, &xhv);
23 }
24 
hvm_get_parameter(int idx,uint64_t * value)25 int hvm_get_parameter(int idx, uint64_t *value)
26 {
27 	int ret = 0;
28 	struct xen_hvm_param xhv;
29 
30 	xhv.domid = DOMID_SELF;
31 	xhv.index = idx;
32 
33 	ret = HYPERVISOR_hvm_op(HVMOP_get_param, &xhv);
34 	if (ret < 0) {
35 		return ret;
36 	}
37 
38 	*value = xhv.value;
39 	return ret;
40 }
41