1 /* $OpenBSD: hvctl.h,v 1.2 2012/12/10 06:42:12 kettenis Exp $ */ 2 3 /* 4 * Copyright (c) 2012 Mark Kettenis 5 * 6 * Permission to use, copy, modify, and distribute this software for any 7 * purpose with or without fee is hereby granted, provided that the above 8 * copyright notice and this permission notice appear in all copies. 9 * 10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17 */ 18 19 struct hv_io { 20 uint64_t hi_cookie; 21 void *hi_addr; 22 size_t hi_len; 23 }; 24 25 #define HVIOCREAD _IOW('h', 0, struct hv_io) 26 #define HVIOCWRITE _IOW('h', 1, struct hv_io) 27 28 #define SIS_NORMAL 0x1 29 #define SIS_TRANSITION 0x2 30 #define SOFT_STATE_SIZE 32 31 32 #define GUEST_STATE_STOPPED 0x0 33 #define GUEST_STATE_RESETTING 0x1 34 #define GUEST_STATE_NORMAL 0x2 35 #define GUEST_STATE_SUSPENDED 0x3 36 #define GUEST_STATE_EXITING 0x4 37 #define GUEST_STATE_UNCONFIGURED 0xff 38 39 #define HVCTL_RES_STATUS_DATA_SIZE 40 40 41 struct hvctl_header { 42 uint16_t op; 43 uint16_t seq; 44 uint16_t chksum; 45 uint16_t status; 46 }; 47 48 struct hvctl_hello { 49 uint16_t major; 50 uint16_t minor; 51 }; 52 53 struct hvctl_challenge { 54 uint64_t code; 55 }; 56 57 struct hvctl_hvconfig { 58 uint64_t hv_membase; 59 uint64_t hv_memsize; 60 uint64_t hvmdp; 61 uint64_t del_reconf_hvmdp; 62 uint32_t del_reconf_gid; 63 }; 64 65 struct hvctl_reconfig { 66 uint64_t hvmdp; 67 uint32_t guestid; 68 }; 69 70 struct hvctl_guest_op { 71 uint32_t guestid; 72 uint32_t code; 73 }; 74 75 struct hvctl_res_status { 76 uint32_t res; 77 uint32_t resid; 78 uint32_t infoid; 79 uint32_t code; 80 uint8_t data[HVCTL_RES_STATUS_DATA_SIZE]; 81 }; 82 83 struct hvctl_rs_guest_state { 84 uint64_t state; 85 }; 86 87 struct hvctl_rs_guest_softstate { 88 uint8_t soft_state; 89 char soft_state_str[SOFT_STATE_SIZE]; 90 }; 91 92 struct hvctl_rs_guest_util { 93 uint64_t lifespan; 94 uint64_t wallclock_delta; 95 uint64_t active_delta; 96 uint64_t stopped_cycles; 97 uint64_t yielded_cycles; 98 }; 99 100 struct hvctl_msg { 101 struct hvctl_header hdr; 102 union { 103 struct hvctl_hello hello; 104 struct hvctl_challenge clnge; 105 struct hvctl_hvconfig hvcnf; 106 struct hvctl_reconfig reconfig; 107 struct hvctl_guest_op guestop; 108 struct hvctl_res_status resstat; 109 } msg; 110 }; 111 112 #define HVCTL_OP_HELLO 0 113 #define HVCTL_OP_CHALLENGE 1 114 #define HVCTL_OP_RESPONSE 2 115 #define HVCTL_OP_GET_HVCONFIG 3 116 #define HVCTL_OP_RECONFIGURE 4 117 #define HVCTL_OP_GUEST_START 5 118 #define HVCTL_OP_GUEST_STOP 6 119 #define HVCTL_OP_GUEST_PANIC 10 120 #define HVCTL_OP_GET_RES_STAT 11 121 122 #define HVCTL_ST_OK 0 123 124 #define HVCTL_RES_GUEST 0 125 126 #define HVCTL_INFO_GUEST_STATE 0 127 #define HVCTL_INFO_GUEST_SOFT_STATE 1 128 #define HVCTL_INFO_GUEST_UTILISATION 3 129 130