Jeremy Fitzhardinge | 18f19aa | 2010-05-14 12:38:24 +0100 | [diff] [blame] | 1 | /* Simple wrappers around HVM functions */ |
| 2 | #ifndef XEN_HVM_H__ |
| 3 | #define XEN_HVM_H__ |
| 4 | |
| 5 | #include <xen/interface/hvm/params.h> |
Sheng Yang | 38e20b0 | 2010-05-14 12:40:51 +0100 | [diff] [blame] | 6 | #include <asm/xen/hypercall.h> |
Jeremy Fitzhardinge | 18f19aa | 2010-05-14 12:38:24 +0100 | [diff] [blame] | 7 | |
Konrad Rzeszutek Wilk | 6d877e6 | 2012-10-19 15:01:46 -0400 | [diff] [blame] | 8 | static const char *param_name(int op) |
| 9 | { |
| 10 | #define PARAM(x) [HVM_PARAM_##x] = #x |
| 11 | static const char *const names[] = { |
| 12 | PARAM(CALLBACK_IRQ), |
| 13 | PARAM(STORE_PFN), |
| 14 | PARAM(STORE_EVTCHN), |
| 15 | PARAM(PAE_ENABLED), |
| 16 | PARAM(IOREQ_PFN), |
| 17 | PARAM(BUFIOREQ_PFN), |
| 18 | PARAM(TIMER_MODE), |
| 19 | PARAM(HPET_ENABLED), |
| 20 | PARAM(IDENT_PT), |
| 21 | PARAM(DM_DOMAIN), |
| 22 | PARAM(ACPI_S_STATE), |
| 23 | PARAM(VM86_TSS), |
| 24 | PARAM(VPT_ALIGN), |
| 25 | PARAM(CONSOLE_PFN), |
| 26 | PARAM(CONSOLE_EVTCHN), |
| 27 | }; |
| 28 | #undef PARAM |
| 29 | |
| 30 | if (op >= ARRAY_SIZE(names)) |
| 31 | return "unknown"; |
| 32 | |
| 33 | if (!names[op]) |
| 34 | return "reserved"; |
| 35 | |
| 36 | return names[op]; |
| 37 | } |
Jeremy Fitzhardinge | 18f19aa | 2010-05-14 12:38:24 +0100 | [diff] [blame] | 38 | static inline int hvm_get_parameter(int idx, uint64_t *value) |
| 39 | { |
| 40 | struct xen_hvm_param xhv; |
| 41 | int r; |
| 42 | |
| 43 | xhv.domid = DOMID_SELF; |
| 44 | xhv.index = idx; |
| 45 | r = HYPERVISOR_hvm_op(HVMOP_get_param, &xhv); |
| 46 | if (r < 0) { |
Konrad Rzeszutek Wilk | 6d877e6 | 2012-10-19 15:01:46 -0400 | [diff] [blame] | 47 | printk(KERN_ERR "Cannot get hvm parameter %s (%d): %d!\n", |
| 48 | param_name(idx), idx, r); |
Jeremy Fitzhardinge | 18f19aa | 2010-05-14 12:38:24 +0100 | [diff] [blame] | 49 | return r; |
| 50 | } |
| 51 | *value = xhv.value; |
| 52 | return r; |
| 53 | } |
| 54 | |
Sheng Yang | 38e20b0 | 2010-05-14 12:40:51 +0100 | [diff] [blame] | 55 | #define HVM_CALLBACK_VIA_TYPE_VECTOR 0x2 |
| 56 | #define HVM_CALLBACK_VIA_TYPE_SHIFT 56 |
| 57 | #define HVM_CALLBACK_VECTOR(x) (((uint64_t)HVM_CALLBACK_VIA_TYPE_VECTOR)<<\ |
| 58 | HVM_CALLBACK_VIA_TYPE_SHIFT | (x)) |
| 59 | |
Jeremy Fitzhardinge | 18f19aa | 2010-05-14 12:38:24 +0100 | [diff] [blame] | 60 | #endif /* XEN_HVM_H__ */ |