// SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2009, Microsoft Corporation. * * Authors: * Haiyang Zhang <[email protected]> * Hank Janssen <[email protected]> */ #define pr_fmt(fmt) … #include <linux/io.h> #include <linux/kernel.h> #include <linux/mm.h> #include <linux/slab.h> #include <linux/vmalloc.h> #include <linux/hyperv.h> #include <linux/random.h> #include <linux/clockchips.h> #include <linux/delay.h> #include <linux/interrupt.h> #include <clocksource/hyperv_timer.h> #include <asm/mshyperv.h> #include <linux/set_memory.h> #include "hyperv_vmbus.h" /* The one and only */ struct hv_context hv_context; /* * hv_init - Main initialization routine. * * This routine must be called before any other routines in here are called */ int hv_init(void) { … } /* * hv_post_message - Post a message using the hypervisor message IPC. * * This involves a hypercall. */ int hv_post_message(union hv_connection_id connection_id, enum hv_message_type message_type, void *payload, size_t payload_size) { … } int hv_synic_alloc(void) { … } void hv_synic_free(void) { … } /* * hv_synic_init - Initialize the Synthetic Interrupt Controller. * * If it is already initialized by another entity (ie x2v shim), we need to * retrieve the initialized message and event pages. Otherwise, we create and * initialize the message and event pages. */ void hv_synic_enable_regs(unsigned int cpu) { … } int hv_synic_init(unsigned int cpu) { … } void hv_synic_disable_regs(unsigned int cpu) { … } #define HV_MAX_TRIES … /* * Scan the event flags page of 'this' CPU looking for any bit that is set. If we find one * bit set, then wait for a few milliseconds. Repeat these steps for a maximum of 3 times. * Return 'true', if there is still any set bit after this operation; 'false', otherwise. * * If a bit is set, that means there is a pending channel interrupt. The expectation is * that the normal interrupt handling mechanism will find and process the channel interrupt * "very soon", and in the process clear the bit. */ static bool hv_synic_event_pending(void) { … } /* * hv_synic_cleanup - Cleanup routine for hv_synic_init(). */ int hv_synic_cleanup(unsigned int cpu) { … }