1/*
2 * Copyright 2019, Data61, CSIRO (ABN 41 687 119 230)
3 *
4 * SPDX-License-Identifier: BSD-2-Clause
5 */
6#pragma once
7
8/***
9 * @module vusb.h
10 * The libsel4vmmplatsupport vusb interface presents a Virtual USB driver for ARM-based VM's.
11 */
12
13#include <autoconf.h>
14#include <sel4vm/gen_config.h>
15#include <usbdrivers/gen_config.h>
16#ifdef CONFIG_LIB_USB
17
18#include <usb/usb_host.h>
19#include <sel4vm/guest_vm.h>
20#include <sel4/sel4.h>
21
22typedef struct vusb_device vusb_device_t;
23
24/***
25 * @function vm_install_vusb(vm, hcd, pbase, virq, vmm_ncap, vm_ncap, badge)
26 * Install a virtual usb device
27 * @param {vm_t *} vm               The VM in which to install the device
28 * @param {usb_host_t *} hcd        The USB host controller that should be used for USB transactions.
29 *                                  Calls made to this hcd may be redirected for filtering.
30 * @param {uintptr_t} pbase         The guest physical address of the device (2 pages)
31 * @param {int} virq                The virtual IRQ number for this device
32 * @param {seL4_CPtr} vmm_ncap      The capability to the endpoint at which the VMM waits for notifications.
33 * @param {seL4_CPtr} vm_ncap       The index at which to install a notification capability into the VM
34 * @param {int} badge               The seL4 badge which should be applied to the notification capability.
35 * @return                          A handle to the virtual usb device, or NULL on failure
36 */
37vusb_device_t *vm_install_vusb(vm_t *vm, usb_host_t *hcd, uintptr_t pbase,
38                               int virq, seL4_CPtr vmm_ncap, seL4_CPtr vm_ncap,
39                               int badge);
40
41
42/***
43 * @function vm_vusb_notify(vusb)
44 * This function should be called when a notification is received from the
45 * VM. The notification is identifyable by a message on the fault endpoint
46 * of the VM which has a badge that matches that which was passed into the
47 * vm_install_vusb function.
48 * @param {vusb_device_t *} vusb        A handle to a virtual usb device
49 */
50void vm_vusb_notify(vusb_device_t *vusb);
51
52#endif /* CONFIG_LIB_USB */
53