1 /******************************************************************************
2 * xc_arinc653.c
3 *
4 * XC interface to the ARINC653 scheduler
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to
8 * deal in the Software without restriction, including without limitation the
9 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10 * sell copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
23 *
24 * Copyright (c) 2010 DornerWorks, Ltd. <DornerWorks.com>
25 */
26
27 #include "xc_private.h"
28
29 int
xc_sched_arinc653_schedule_set(xc_interface * xch,uint32_t cpupool_id,struct xen_sysctl_arinc653_schedule * schedule)30 xc_sched_arinc653_schedule_set(
31 xc_interface *xch,
32 uint32_t cpupool_id,
33 struct xen_sysctl_arinc653_schedule *schedule)
34 {
35 int rc;
36 DECLARE_SYSCTL;
37 DECLARE_HYPERCALL_BOUNCE(
38 schedule,
39 sizeof(*schedule),
40 XC_HYPERCALL_BUFFER_BOUNCE_IN);
41
42 if ( xc_hypercall_bounce_pre(xch, schedule) )
43 return -1;
44
45 sysctl.cmd = XEN_SYSCTL_scheduler_op;
46 sysctl.u.scheduler_op.cpupool_id = cpupool_id;
47 sysctl.u.scheduler_op.sched_id = XEN_SCHEDULER_ARINC653;
48 sysctl.u.scheduler_op.cmd = XEN_SYSCTL_SCHEDOP_putinfo;
49 set_xen_guest_handle(sysctl.u.scheduler_op.u.sched_arinc653.schedule,
50 schedule);
51
52 rc = do_sysctl(xch, &sysctl);
53
54 xc_hypercall_bounce_post(xch, schedule);
55
56 return rc;
57 }
58
59 int
xc_sched_arinc653_schedule_get(xc_interface * xch,uint32_t cpupool_id,struct xen_sysctl_arinc653_schedule * schedule)60 xc_sched_arinc653_schedule_get(
61 xc_interface *xch,
62 uint32_t cpupool_id,
63 struct xen_sysctl_arinc653_schedule *schedule)
64 {
65 int rc;
66 DECLARE_SYSCTL;
67 DECLARE_HYPERCALL_BOUNCE(
68 schedule,
69 sizeof(*schedule),
70 XC_HYPERCALL_BUFFER_BOUNCE_OUT);
71
72 if ( xc_hypercall_bounce_pre(xch, schedule) )
73 return -1;
74
75 sysctl.cmd = XEN_SYSCTL_scheduler_op;
76 sysctl.u.scheduler_op.cpupool_id = cpupool_id;
77 sysctl.u.scheduler_op.sched_id = XEN_SCHEDULER_ARINC653;
78 sysctl.u.scheduler_op.cmd = XEN_SYSCTL_SCHEDOP_getinfo;
79 set_xen_guest_handle(sysctl.u.scheduler_op.u.sched_arinc653.schedule,
80 schedule);
81
82 rc = do_sysctl(xch, &sysctl);
83
84 xc_hypercall_bounce_post(xch, schedule);
85
86 return rc;
87 }
88