aboutsummaryrefslogtreecommitdiffstats
path: root/tools/libxc/xc_bvtsched.c
blob: aeaddcfb040ca6c16693e9fea64c8223bdbfb124 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/******************************************************************************
 * xc_bvtsched.c
 * 
 * API for manipulating parameters of the Borrowed Virtual Time scheduler.
 * 
 * Copyright (c) 2003, K A Fraser.
 */

#include "xc_private.h"

int xc_bvtsched_global_set(int xc_handle,
                           unsigned long ctx_allow)
{
    dom0_op_t op;

    op.cmd = DOM0_SCHEDCTL;
    op.u.schedctl.sched_id = SCHED_BVT;
    op.u.schedctl.direction = SCHED_INFO_PUT;
    op.u.schedctl.u.bvt.ctx_allow = ctx_allow;

    return do_dom0_op(xc_handle, &op);
}

int xc_bvtsched_global_get(int xc_handle,
                           unsigned long *ctx_allow)
{
    dom0_op_t op;
    int ret;
    
    op.cmd = DOM0_SCHEDCTL;
    op.u.schedctl.sched_id = SCHED_BVT;
    op.u.schedctl.direction = SCHED_INFO_GET;

    ret = do_dom0_op(xc_handle, &op);

    *ctx_allow = op.u.schedctl.u.bvt.ctx_allow;

    return ret;
}

int xc_bvtsched_domain_set(int xc_handle,
                           u32 domid,
                           unsigned long mcuadv,
                           unsigned long warp,
                           unsigned long warpl,
                           unsigned long warpu)
{
    dom0_op_t op;
    struct bvt_adjdom *bvtadj = &op.u.adjustdom.u.bvt;

    op.cmd = DOM0_ADJUSTDOM;
    op.u.adjustdom.domain  = (domid_t)domid;
    op.u.adjustdom.sched_id = SCHED_BVT;
    op.u.adjustdom.direction = SCHED_INFO_PUT;

    bvtadj->mcu_adv = mcuadv;
    bvtadj->warp    = warp;
    bvtadj->warpl   = warpl;
    bvtadj->warpu   = warpu;
    return do_dom0_op(xc_handle, &op);
}


int xc_bvtsched_domain_get(int xc_handle,
                           u32 domid,
                           unsigned long *mcuadv,
                           unsigned long *warp,
                           unsigned long *warpl,
                           unsigned long *warpu)
{
    
    dom0_op_t op;
    int ret;
    struct bvt_adjdom *adjptr = &op.u.adjustdom.u.bvt;

    op.cmd = DOM0_ADJUSTDOM;
    op.u.adjustdom.domain  = (domid_t)domid;
    op.u.adjustdom.sched_id = SCHED_BVT;
    op.u.adjustdom.direction = SCHED_INFO_GET;

    ret = do_dom0_op(xc_handle, &op);

    *mcuadv = adjptr->mcu_adv;
    *warp   = adjptr->warp;
    *warpl  = adjptr->warpl;
    *warpu  = adjptr->warpu;
    return ret;
}