Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
0002 /*
0003  * Copyright (c) Microsoft Corporation.
0004  *
0005  * Author:
0006  *   Haiyang Zhang <haiyangz@microsoft.com>
0007  *
0008  * This small module is a helper driver allows other drivers to
0009  * have a common interface with the Hyper-V PCI frontend driver.
0010  */
0011 
0012 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
0013 
0014 #include <linux/kernel.h>
0015 #include <linux/module.h>
0016 #include <linux/hyperv.h>
0017 
0018 struct hyperv_pci_block_ops hvpci_block_ops;
0019 EXPORT_SYMBOL_GPL(hvpci_block_ops);
0020 
0021 int hyperv_read_cfg_blk(struct pci_dev *dev, void *buf, unsigned int buf_len,
0022             unsigned int block_id, unsigned int *bytes_returned)
0023 {
0024     if (!hvpci_block_ops.read_block)
0025         return -EOPNOTSUPP;
0026 
0027     return hvpci_block_ops.read_block(dev, buf, buf_len, block_id,
0028                       bytes_returned);
0029 }
0030 EXPORT_SYMBOL_GPL(hyperv_read_cfg_blk);
0031 
0032 int hyperv_write_cfg_blk(struct pci_dev *dev, void *buf, unsigned int len,
0033              unsigned int block_id)
0034 {
0035     if (!hvpci_block_ops.write_block)
0036         return -EOPNOTSUPP;
0037 
0038     return hvpci_block_ops.write_block(dev, buf, len, block_id);
0039 }
0040 EXPORT_SYMBOL_GPL(hyperv_write_cfg_blk);
0041 
0042 int hyperv_reg_block_invalidate(struct pci_dev *dev, void *context,
0043                 void (*block_invalidate)(void *context,
0044                              u64 block_mask))
0045 {
0046     if (!hvpci_block_ops.reg_blk_invalidate)
0047         return -EOPNOTSUPP;
0048 
0049     return hvpci_block_ops.reg_blk_invalidate(dev, context,
0050                           block_invalidate);
0051 }
0052 EXPORT_SYMBOL_GPL(hyperv_reg_block_invalidate);
0053 
0054 static void __exit exit_hv_pci_intf(void)
0055 {
0056 }
0057 
0058 static int __init init_hv_pci_intf(void)
0059 {
0060     return 0;
0061 }
0062 
0063 module_init(init_hv_pci_intf);
0064 module_exit(exit_hv_pci_intf);
0065 
0066 MODULE_DESCRIPTION("Hyper-V PCI Interface");
0067 MODULE_LICENSE("GPL v2");