blob: a941bc18f8a854bce5dc5beb724bdd8a1b56870f [file] [log] [blame] [edit]
/*
* Copyright 2019, Data61
* Commonwealth Scientific and Industrial Research Organisation (CSIRO)
* ABN 41 687 119 230.
*
* This software may be distributed and modified according to the terms of
* the BSD 2-Clause license. Note that NO WARRANTY is provided.
* See "LICENSE_BSD2.txt" for details.
*
* @TAG(DATA61_BSD)
*/
#pragma once
/***
* @module generic_forward_device.h
* This interface facilitates the creation of a virtual device used for
* dispatching faults to external handlers. For example when using CAmkES,
* a device frame for a real device can be given to a different CAmkES component
* and this virtual device will forward read and write faults over a CAmkES
* interface so the component can perform or emulate the actions.
*/
#include <stdint.h>
#include <sel4vm/guest_vm.h>
#include <sel4vmmplatsupport/device.h>
typedef void (*forward_write_fn)(uint32_t addr, uint32_t value);
typedef uint32_t (*forward_read_fn)(uint32_t addr);
/***
* @struct generic_forward_cfg
* Interface for forwarding read and write faults
* @param {forward_write_fn} write_fn A callback for forwarding write faults
* @param {forward_read_fn} read_fn A callback for forwarding read faults
*/
struct generic_forward_cfg {
forward_write_fn write_fn;
forward_read_fn read_fn;
};
/***
* @function vm_install_generic_forward_device(vm, d, cfg)
* Install the virtual forwarding device into a VM instance
* @param {vm_t *} vm A handle to the VM
* @param {const struct device *} Virtual device being forwarded
* @param {struct generic_forward_cfg} Interface for forwarding the devices read and write faults
* @return -1 for error, otherwise 0 for success
*/
int vm_install_generic_forward_device(vm_t *vm, const struct device *d,
struct generic_forward_cfg cfg);