hyperv/vmbus: Declare Synic message and event w/ proper types

Avoid ugly casts.

MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D6446
This commit is contained in:
sephe 2016-05-23 07:14:04 +00:00
parent 7fe01c346d
commit 9b8c2e4a6f
3 changed files with 17 additions and 14 deletions

View File

@ -333,8 +333,8 @@ vmbus_event_proc(struct vmbus_softc *sc, int cpu)
{
hv_vmbus_synic_event_flags *event;
event = ((hv_vmbus_synic_event_flags *)
hv_vmbus_g_context.syn_ic_event_page[cpu]) + HV_VMBUS_MESSAGE_SINT;
event = hv_vmbus_g_context.syn_ic_event_page[cpu] +
HV_VMBUS_MESSAGE_SINT;
/*
* On Host with Win8 or above, the event page can be checked directly
@ -349,8 +349,8 @@ vmbus_event_proc_compat(struct vmbus_softc *sc __unused, int cpu)
{
hv_vmbus_synic_event_flags *event;
event = ((hv_vmbus_synic_event_flags *)
hv_vmbus_g_context.syn_ic_event_page[cpu]) + HV_VMBUS_MESSAGE_SINT;
event = hv_vmbus_g_context.syn_ic_event_page[cpu] +
HV_VMBUS_MESSAGE_SINT;
if (atomic_testandclear_int(&event->flags32[0], 0)) {
vmbus_event_flags_proc(

View File

@ -79,8 +79,9 @@ vmbus_msg_task(void *arg __unused, int pending __unused)
{
hv_vmbus_message *msg;
msg = ((hv_vmbus_message *)hv_vmbus_g_context.syn_ic_msg_page[curcpu]) +
msg = hv_vmbus_g_context.syn_ic_msg_page[curcpu] +
HV_VMBUS_MESSAGE_SINT;
for (;;) {
const hv_vmbus_channel_msg_table_entry *entry;
hv_vmbus_channel_msg_header *hdr;
@ -134,9 +135,8 @@ static inline int
hv_vmbus_isr(struct trapframe *frame)
{
struct vmbus_softc *sc = vmbus_get_softc();
hv_vmbus_message *msg, *msg_base;
int cpu = curcpu;
hv_vmbus_message *msg;
void *page_addr;
/*
* The Windows team has advised that we check for events
@ -146,8 +146,8 @@ hv_vmbus_isr(struct trapframe *frame)
sc->vmbus_event_proc(sc, cpu);
/* Check if there are actual msgs to be process */
page_addr = hv_vmbus_g_context.syn_ic_msg_page[cpu];
msg = ((hv_vmbus_message *)page_addr) + HV_VMBUS_TIMER_SINT;
msg_base = hv_vmbus_g_context.syn_ic_msg_page[cpu];
msg = msg_base + HV_VMBUS_TIMER_SINT;
/* we call eventtimer process the message */
if (msg->header.message_type == HV_MESSAGE_TIMER_EXPIRED) {
@ -178,7 +178,7 @@ hv_vmbus_isr(struct trapframe *frame)
}
}
msg = ((hv_vmbus_message *)page_addr) + HV_VMBUS_MESSAGE_SINT;
msg = msg_base + HV_VMBUS_MESSAGE_SINT;
if (msg->header.message_type != HV_MESSAGE_TYPE_NONE) {
taskqueue_enqueue(hv_vmbus_g_context.hv_msg_tq[cpu],
&hv_vmbus_g_context.hv_msg_task[cpu]);

View File

@ -197,11 +197,14 @@ enum {
#define HV_HYPERCALL_PARAM_ALIGN sizeof(uint64_t)
struct vmbus_message;
union vmbus_event_flags;
typedef struct {
hv_bool_uint8_t syn_ic_initialized;
hv_vmbus_handle syn_ic_msg_page[MAXCPU];
hv_vmbus_handle syn_ic_event_page[MAXCPU];
struct vmbus_message *syn_ic_msg_page[MAXCPU];
union vmbus_event_flags *syn_ic_event_page[MAXCPU];
/*
* For FreeBSD cpuid to Hyper-V vcpuid mapping.
*/
@ -303,7 +306,7 @@ typedef struct {
/*
* Define synthetic interrupt controller message format
*/
typedef struct {
typedef struct vmbus_message {
hv_vmbus_msg_header header;
union {
uint64_t payload[HV_MESSAGE_PAYLOAD_QWORD_COUNT];
@ -578,7 +581,7 @@ typedef struct {
/*
* Define the synthetic interrupt controller event flags format
*/
typedef union {
typedef union vmbus_event_flags {
uint8_t flags8[HV_EVENT_FLAGS_BYTE_COUNT];
uint32_t flags32[HV_EVENT_FLAGS_DWORD_COUNT];
unsigned long flagsul[HV_EVENT_FLAGS_ULONG_COUNT];