1 /*- 2 * Copyright (c) 2018 VMware, Inc. 3 * 4 * SPDX-License-Identifier: (BSD-2-Clause OR GPL-2.0) 5 * 6 * $FreeBSD$ 7 */ 8 9 /* Driver for VMware Virtual Machine Communication Interface (VMCI) device. */ 10 11 #ifndef _VMCI_H_ 12 #define _VMCI_H_ 13 14 #include <sys/param.h> 15 #include <sys/lock.h> 16 #include <sys/mutex.h> 17 #include <sys/systm.h> 18 #include <sys/taskqueue.h> 19 20 #include <machine/bus.h> 21 22 #include "vmci_datagram.h" 23 #include "vmci_kernel_if.h" 24 25 /* VMCI device vendor and device ID */ 26 #define VMCI_VMWARE_VENDOR_ID 0x15AD 27 #define VMCI_VMWARE_DEVICE_ID 0x0740 28 29 #define VMCI_VERSION 1 30 31 struct vmci_dma_alloc { 32 bus_dma_tag_t dma_tag; 33 caddr_t dma_vaddr; 34 bus_addr_t dma_paddr; 35 bus_dmamap_t dma_map; 36 bus_size_t dma_size; 37 }; 38 39 struct vmci_interrupt { 40 struct resource *vmci_irq; 41 int vmci_rid; 42 void *vmci_handler; 43 }; 44 45 struct vmci_softc { 46 device_t vmci_dev; 47 48 struct mtx vmci_spinlock; 49 50 struct resource *vmci_res0; 51 bus_space_tag_t vmci_iot0; 52 bus_space_handle_t vmci_ioh0; 53 unsigned int vmci_ioaddr; 54 struct resource *vmci_res1; 55 bus_space_tag_t vmci_iot1; 56 bus_space_handle_t vmci_ioh1; 57 58 struct vmci_dma_alloc vmci_notifications_bitmap; 59 60 int vmci_num_intr; 61 vmci_intr_type vmci_intr_type; 62 struct vmci_interrupt vmci_intrs[VMCI_MAX_INTRS]; 63 struct task vmci_interrupt_dq_task; 64 struct task vmci_interrupt_bm_task; 65 66 struct task vmci_delayed_work_task; 67 struct mtx vmci_delayed_work_lock; 68 vmci_list(vmci_delayed_work_info) vmci_delayed_work_infos; 69 70 unsigned int capabilities; 71 }; 72 73 int vmci_dma_malloc(bus_size_t size, bus_size_t align, 74 struct vmci_dma_alloc *dma); 75 void vmci_dma_free(struct vmci_dma_alloc *); 76 int vmci_schedule_delayed_work_fn(vmci_work_fn *work_fn, void *data); 77 78 #endif /* !_VMCI_H_ */ 79