hyperv.c (307278) | hyperv.c (307301) |
---|---|
1/*- 2 * Copyright (c) 2009-2012,2016 Microsoft Corp. 3 * Copyright (c) 2012 NetApp Inc. 4 * Copyright (c) 2012 Citrix Inc. 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 16 unchanged lines hidden (view full) --- 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 */ 28 29/** 30 * Implements low-level interactions with Hypver-V/Azure 31 */ 32#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2009-2012,2016 Microsoft Corp. 3 * Copyright (c) 2012 NetApp Inc. 4 * Copyright (c) 2012 Citrix Inc. 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 16 unchanged lines hidden (view full) --- 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 */ 28 29/** 30 * Implements low-level interactions with Hypver-V/Azure 31 */ 32#include <sys/cdefs.h> |
33__FBSDID("$FreeBSD: stable/11/sys/dev/hyperv/vmbus/hyperv.c 307278 2016-10-14 07:27:29Z sephe $"); | 33__FBSDID("$FreeBSD: stable/11/sys/dev/hyperv/vmbus/hyperv.c 307301 2016-10-14 07:47:35Z sephe $"); |
34 35#include <sys/param.h> 36#include <sys/kernel.h> 37#include <sys/malloc.h> 38#include <sys/pcpu.h> 39#include <sys/timetc.h> 40#include <machine/bus.h> 41#include <machine/md_var.h> --- 79 unchanged lines hidden (view full) --- 121uint64_t 122hypercall_post_message(bus_addr_t msg_paddr) 123{ 124 return hypercall_md(hypercall_context.hc_addr, 125 HYPERCALL_POST_MESSAGE, msg_paddr, 0); 126} 127 128/** | 34 35#include <sys/param.h> 36#include <sys/kernel.h> 37#include <sys/malloc.h> 38#include <sys/pcpu.h> 39#include <sys/timetc.h> 40#include <machine/bus.h> 41#include <machine/md_var.h> --- 79 unchanged lines hidden (view full) --- 121uint64_t 122hypercall_post_message(bus_addr_t msg_paddr) 123{ 124 return hypercall_md(hypercall_context.hc_addr, 125 HYPERCALL_POST_MESSAGE, msg_paddr, 0); 126} 127 128/** |
129 * @brief Post a message using the hypervisor message IPC. 130 * (This involves a hypercall.) 131 */ 132hv_vmbus_status 133hv_vmbus_post_msg_via_msg_ipc( 134 hv_vmbus_connection_id connection_id, 135 hv_vmbus_msg_type message_type, 136 void* payload, 137 size_t payload_size) 138{ 139 struct alignedinput { 140 uint64_t alignment8; 141 hv_vmbus_input_post_message msg; 142 }; 143 144 hv_vmbus_input_post_message* aligned_msg; 145 hv_vmbus_status status; 146 size_t addr; 147 148 if (payload_size > HV_MESSAGE_PAYLOAD_BYTE_COUNT) 149 return (EMSGSIZE); 150 151 addr = (size_t) malloc(sizeof(struct alignedinput), M_DEVBUF, 152 M_ZERO | M_NOWAIT); 153 KASSERT(addr != 0, 154 ("Error VMBUS: malloc failed to allocate message buffer!")); 155 if (addr == 0) 156 return (ENOMEM); 157 158 aligned_msg = (hv_vmbus_input_post_message*) 159 (HV_ALIGN_UP(addr, HV_HYPERCALL_PARAM_ALIGN)); 160 161 aligned_msg->connection_id = connection_id; 162 aligned_msg->message_type = message_type; 163 aligned_msg->payload_size = payload_size; 164 memcpy((void*) aligned_msg->payload, payload, payload_size); 165 166 status = hv_vmbus_do_hypercall( 167 HV_CALL_POST_MESSAGE, aligned_msg, 0) & 0xFFFF; 168 169 free((void *) addr, M_DEVBUF); 170 return (status); 171} 172 173/** | |
174 * @brief Signal an event on the specified connection using the hypervisor 175 * event IPC. (This involves a hypercall.) 176 */ 177hv_vmbus_status 178hv_vmbus_signal_event(void *con_id) 179{ 180 hv_vmbus_status status; 181 --- 208 unchanged lines hidden --- | 129 * @brief Signal an event on the specified connection using the hypervisor 130 * event IPC. (This involves a hypercall.) 131 */ 132hv_vmbus_status 133hv_vmbus_signal_event(void *con_id) 134{ 135 hv_vmbus_status status; 136 --- 208 unchanged lines hidden --- |