[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [win-pv-devel] [PATCH 11/14 v2] Add EVTCHN and GNTTAB interfaces
From: Owen Smith <owen.smith@xxxxxxxxxx> Adds query for EVTCHN and GNTTAB interfaces, and adds FdoGet[Evtchn|Gnttab]Interface functions Signed-off-by: Owen Smith <owen.smith@xxxxxxxxxx> --- include/cache_interface.h | 233 +++++++++++++++++++++++++++++ include/evtchn_interface.h | 357 +++++++++++++++++++++++++++++++++++++++++++++ include/gnttab_interface.h | 287 ++++++++++++++++++++++++++++++++++++ src/xencons/fdo.c | 48 +++++- src/xencons/fdo.h | 4 + 5 files changed, 926 insertions(+), 3 deletions(-) create mode 100755 include/cache_interface.h create mode 100755 include/evtchn_interface.h create mode 100755 include/gnttab_interface.h diff --git a/include/cache_interface.h b/include/cache_interface.h new file mode 100755 index 0000000..dae3ac6 --- /dev/null +++ b/include/cache_interface.h @@ -0,0 +1,233 @@ +/* Copyright (c) Citrix Systems Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, + * with or without modification, are permitted provided + * that the following conditions are met: + * + * * Redistributions of source code must retain the above + * copyright notice, this list of conditions and the + * following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the + * following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND + * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/*! \file cache_interface.h + \brief XENBUS CACHE Interface + + This interface provides access to XENBUS's object cache + implementation. +*/ + +#ifndef _XENBUS_CACHE_INTERFACE_H +#define _XENBUS_CACHE_INTERFACE_H + +#ifndef _WINDLL + +/*! \typedef XENBUS_CACHE + \brief Cache handle +*/ +typedef struct _XENBUS_CACHE XENBUS_CACHE, *PXENBUS_CACHE; + +/*! \typedef XENBUS_CACHE_ACQUIRE + \brief Acquire a reference to the CACHE interface + + \param Interface The interface header +*/ +typedef NTSTATUS +(*XENBUS_CACHE_ACQUIRE)( + IN PINTERFACE Interface + ); + +/*! \typedef XENBUS_CACHE_RELEASE + \brief Release a reference to the CACHE interface + + \param Interface The interface header +*/ +typedef VOID +(*XENBUS_CACHE_RELEASE)( + IN PINTERFACE Interface + ); + +/*! \typedef XENBUS_CACHE_CTOR + \brief Object creator callback + + \param Argument Context \a Argument supplied to \a XENBUS_CACHE_CREATE + \param Object Newly allocated object + + This callback is invoked just after a new object is allocated and may + be used to initialize any object data prior to its insertion into the + cache. +*/ +typedef NTSTATUS +(*XENBUS_CACHE_CTOR)( + IN PVOID Argument, + IN PVOID Object + ); + +/*! \typedef XENBUS_CACHE_DTOR + \brief Object destructor callback + + \param Argument Context \a Argument supplied to \a XENBUS_CACHE_CREATE + \param Object Object about to be freed + + This callback is invoked just after an object is removed from the + cache and before it is freed and may be used to tear down any object data. +*/ +typedef VOID +(*XENBUS_CACHE_DTOR)( + IN PVOID Argument, + IN PVOID Object + ); + +/*! \typedef XENBUS_CACHE_ACQUIRE_LOCK + \brief Cache lock callback + + \param Argument Context \a Argument supplied to \a XENBUS_CACHE_CREATE + + This callback is invoked if the cache implementation requires mutual + exclusion. +*/ +typedef VOID +(*XENBUS_CACHE_ACQUIRE_LOCK)( + IN PVOID Argument + ); + +/*! \typedef XENBUS_CACHE_RELEASE_LOCK + \brief Cache unlock callback + + \param Argument Context \a Argument supplied to \a XENBUS_CACHE_CREATE + + This callback is invoked to release the mutual exclusion lock acquired + by a previous invocation of \a XENBUS_CACHE_ACQUIRE_LOCK. +*/ +typedef VOID +(*XENBUS_CACHE_RELEASE_LOCK)( + IN PVOID Argument + ); + +/*! \typedef XENBUS_CACHE_CREATE + \brief Create a cache of objects of the given \a Size + + \param Interface The interface header + \param Name A name for the cache which will be used in debug output + \param Size The size of each object in bytes + \param Reservation The target minimum population of the cache + \param Ctor A callback which is invoked when a new object created + \param Dtor A callback which is invoked when an object is destroyed + \param AcquireLock A callback invoked to acquire a spinlock + \param ReleaseLock A callback invoked to release the spinlock + \param Argument An optional context argument passed to the callbacks + \param Cache A pointer to a cache handle to be initialized + + If a non-zero \a Reservation is specified then this method will fail + unless that number of objects can be immediately created. +*/ +typedef NTSTATUS +(*XENBUS_CACHE_CREATE)( + IN PINTERFACE Interface, + IN const CHAR *Name, + IN ULONG Size, + IN ULONG Reservation, + IN XENBUS_CACHE_CTOR Ctor, + IN XENBUS_CACHE_DTOR Dtor, + IN XENBUS_CACHE_ACQUIRE_LOCK AcquireLock, + IN XENBUS_CACHE_RELEASE_LOCK ReleaseLock, + IN PVOID Argument OPTIONAL, + OUT PXENBUS_CACHE *Cache + ); + +/*! \typedef XENBUS_CACHE_GET + \brief Get an object from a \a Cache + + \param Interface The interface header + \param Cache The cache handle + \param Locked If mutually exclusive access to the cache is already + guaranteed then set this to TRUE +*/ +typedef PVOID +(*XENBUS_CACHE_GET)( + IN PINTERFACE Interface, + IN PXENBUS_CACHE Cache, + IN BOOLEAN Locked + ); + +/*! \typedef XENBUS_CACHE_PUT + \brief Return an object to a \a Cache + + \param Interface The interface header + \param Cache The cache handle + \param Locked If mutually exclusive access to the cache is already + guaranteed then set this to TRUE +*/ +typedef VOID +(*XENBUS_CACHE_PUT)( + IN PINTERFACE Interface, + IN PXENBUS_CACHE Cache, + IN PVOID Object, + IN BOOLEAN Locked + ); + +/*! \typedef XENBUS_CACHE_DESTROY + \brief Destroy a \a Cache + + \param Interface The interface header + \param Cache The cache handle + + All objects must have been returned to the cache prior to destruction +*/ +typedef VOID +(*XENBUS_CACHE_DESTROY)( + IN PINTERFACE Interface, + IN PXENBUS_CACHE Cache + ); + +// {A98DFD78-416A-4949-92A5-E084F2F4B44E} +DEFINE_GUID(GUID_XENBUS_CACHE_INTERFACE, +0xa98dfd78, 0x416a, 0x4949, 0x92, 0xa5, 0xe0, 0x84, 0xf2, 0xf4, 0xb4, 0x4e); + +/*! \struct _XENBUS_CACHE_INTERFACE_V1 + \brief CACHE interface version 1 + \ingroup interfaces +*/ +struct _XENBUS_CACHE_INTERFACE_V1 { + INTERFACE Interface; + XENBUS_CACHE_ACQUIRE CacheAcquire; + XENBUS_CACHE_RELEASE CacheRelease; + XENBUS_CACHE_CREATE CacheCreate; + XENBUS_CACHE_GET CacheGet; + XENBUS_CACHE_PUT CachePut; + XENBUS_CACHE_DESTROY CacheDestroy; +}; + +typedef struct _XENBUS_CACHE_INTERFACE_V1 XENBUS_CACHE_INTERFACE, *PXENBUS_CACHE_INTERFACE; + +/*! \def XENBUS_CACHE + \brief Macro at assist in method invocation +*/ +#define XENBUS_CACHE(_Method, _Interface, ...) \ + (_Interface)->Cache ## _Method((PINTERFACE)(_Interface), __VA_ARGS__) + +#endif // _WINDLL + +#define XENBUS_CACHE_INTERFACE_VERSION_MIN 1 +#define XENBUS_CACHE_INTERFACE_VERSION_MAX 1 + +#endif // _XENBUS_CACHE_INTERFACE_H diff --git a/include/evtchn_interface.h b/include/evtchn_interface.h new file mode 100755 index 0000000..068a697 --- /dev/null +++ b/include/evtchn_interface.h @@ -0,0 +1,357 @@ +/* Copyright (c) Citrix Systems Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, + * with or without modification, are permitted provided + * that the following conditions are met: + * + * * Redistributions of source code must retain the above + * copyright notice, this list of conditions and the + * following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the + * following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND + * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/*! \file evtchn_interface.h + \brief XENBUS EVTCHN Interface + + This interface provides access to hypervisor event channels +*/ + +#ifndef _XENBUS_EVTCHN_INTERFACE_H +#define _XENBUS_EVTCHN_INTERFACE_H + +#ifndef _WINDLL + +/*! \enum _XENBUS_EVTCHN_TYPE + \brief Event channel type to be opened +*/ +typedef enum _XENBUS_EVTCHN_TYPE { + XENBUS_EVTCHN_TYPE_INVALID = 0, + XENBUS_EVTCHN_TYPE_FIXED, /*!< Fixed */ + XENBUS_EVTCHN_TYPE_UNBOUND, /*!< Unbound */ + XENBUS_EVTCHN_TYPE_INTER_DOMAIN, /*!< Interdomain */ + XENBUS_EVTCHN_TYPE_VIRQ /*!< VIRQ */ +} XENBUS_EVTCHN_TYPE, *PXENBUS_EVTCHN_TYPE; + +/*! \typedef XENBUS_EVTCHN_CHANNEL + \brief Event channel handle +*/ +typedef struct _XENBUS_EVTCHN_CHANNEL XENBUS_EVTCHN_CHANNEL, *PXENBUS_EVTCHN_CHANNEL; + +/*! \typedef XENBUS_EVTCHN_ACQUIRE + \brief Acquire a reference to the EVTCHN interface + + \param Interface The interface header +*/ +typedef NTSTATUS +(*XENBUS_EVTCHN_ACQUIRE)( + IN PINTERFACE Interface + ); + +/*! \typedef XENBUS_EVTCHN_RELEASE + \brief Release a reference to the EVTCHN interface + + \param Interface The interface header +*/ +typedef VOID +(*XENBUS_EVTCHN_RELEASE)( + IN PINTERFACE Interface + ); + +/*! \typedef XENBUS_EVTCHN_OPEN + \brief Open an event channel + + \param Interface The interface header + \param Type The type of event channel to open + \param Function The callback function + \param Argument An optional context argument passed to the callback + \param ... Additional parameters required by \a Type + + \b Fixed: + \param LocalPort The local port number of the (already bound) channel + \param Mask Set to TRUE if the channel should be automatically masked before invoking the callback + + \b Unbound: + \param RemoteDomain The domid of the remote domain which will bind the channel + \param Mask Set to TRUE if the channel should be automatically masked before invoking the callback + + \b Interdomain: + \param RemoteDomain The domid of the remote domain which has already bound the channel + \param RemotePort The port number bound to the channel in the remote domain + \param Mask Set to TRUE if the channel should be automatically masked before invoking the callback + + \b VIRQ: + \param Index The index number of the VIRQ + + \return Event channel handle +*/ +typedef PXENBUS_EVTCHN_CHANNEL +(*XENBUS_EVTCHN_OPEN)( + IN PINTERFACE Interface, + IN XENBUS_EVTCHN_TYPE Type, + IN PKSERVICE_ROUTINE Function, + IN PVOID Argument OPTIONAL, + ... + ); + +/*! \typedef XENBUS_EVTCHN_BIND + \brief Bind an event channel to a specific CPU + + \param Interface The interface header + \param Channel The channel handle + \param Group The group number of the CPU that should handle events + \param Number The relative number of the CPU that should handle events +*/ +typedef NTSTATUS +(*XENBUS_EVTCHN_BIND)( + IN PINTERFACE Interface, + IN PXENBUS_EVTCHN_CHANNEL Channel, + IN USHORT Group, + IN UCHAR Number + ); + +typedef VOID +(*XENBUS_EVTCHN_UNMASK_V4)( + IN PINTERFACE Interface, + IN PXENBUS_EVTCHN_CHANNEL Channel, + IN BOOLEAN InCallback + ); + +/*! \typedef XENBUS_EVTCHN_UNMASK + \brief Unmask an event channel + + \param Interface The interface header + \param Channel The channel handle + \param InCallback Set to TRUE if this method is invoked in context of the channel callback + \param Force Set to TRUE if the unmask must succeed, otherwise set to FALSE and the function will return FALSE if the unmask did not complete. +*/ +typedef BOOLEAN +(*XENBUS_EVTCHN_UNMASK)( + IN PINTERFACE Interface, + IN PXENBUS_EVTCHN_CHANNEL Channel, + IN BOOLEAN InCallback, + IN BOOLEAN Force + ); + +typedef VOID +(*XENBUS_EVTCHN_SEND_V1)( + IN PINTERFACE Interface, + IN PXENBUS_EVTCHN_CHANNEL Channel + ); + +/*! \typedef XENBUS_EVTCHN_SEND + \brief Send an event to the remote end of the channel + + It is assumed that the domain cannot suspend during this call so + IRQL must be >= DISPATCH_LEVEL. + + \param Interface The interface header + \param Channel The channel handle +*/ +typedef VOID +(*XENBUS_EVTCHN_SEND)( + IN PINTERFACE Interface, + IN PXENBUS_EVTCHN_CHANNEL Channel + ); + +/*! \typedef XENBUS_EVTCHN_TRIGGER + \brief Send an event to the local end of the channel + + \param Interface The interface header + \param Channel The channel handle +*/ +typedef VOID +(*XENBUS_EVTCHN_TRIGGER)( + IN PINTERFACE Interface, + IN PXENBUS_EVTCHN_CHANNEL Channel + ); + +/*! \typedef XENBUS_EVTCHN_GET_COUNT + \brief Get the number of events received by the channel since it was opened + + \param Interface The interface header + \param Channel The channel handle + \return The number of events +*/ +typedef ULONG +(*XENBUS_EVTCHN_GET_COUNT)( + IN PINTERFACE Interface, + IN PXENBUS_EVTCHN_CHANNEL Channel + ); + +typedef NTSTATUS +(*XENBUS_EVTCHN_WAIT_V5)( + IN PINTERFACE Interface, + IN PXENBUS_EVTCHN_CHANNEL Channel, + IN PLARGE_INTEGER Timeout OPTIONAL + ); + +/*! \typedef XENBUS_EVTCHN_WAIT + \brief Wait for events to the local end of the channel + + \param Interface The interface header + \param Channel The channel handle + \param Count The event count to wait for + \param Timeout An optional timeout value (similar to KeWaitForSingleObject(), but non-zero values are allowed at DISPATCH_LEVEL). +*/ +typedef NTSTATUS +(*XENBUS_EVTCHN_WAIT)( + IN PINTERFACE Interface, + IN PXENBUS_EVTCHN_CHANNEL Channel, + IN ULONG Count, + IN PLARGE_INTEGER Timeout OPTIONAL + ); + +/*! \typedef XENBUS_EVTCHN_GET_PORT + \brief Get the local port number bound to the channel + + \param Interface The interface header + \param Channel The channel handle + \return The port number +*/ +typedef ULONG +(*XENBUS_EVTCHN_GET_PORT)( + IN PINTERFACE Interface, + IN PXENBUS_EVTCHN_CHANNEL Channel + ); + +/*! \typedef XENBUS_EVTCHN_CLOSE + \brief Close an event channel + + \param Interface The interface header + \param Channel The channel handle +*/ +typedef VOID +(*XENBUS_EVTCHN_CLOSE)( + IN PINTERFACE Interface, + IN PXENBUS_EVTCHN_CHANNEL Channel + ); + +// {BE2440AC-1098-4150-AF4D-452FADCEF923} +DEFINE_GUID(GUID_XENBUS_EVTCHN_INTERFACE, +0xbe2440ac, 0x1098, 0x4150, 0xaf, 0x4d, 0x45, 0x2f, 0xad, 0xce, 0xf9, 0x23); + +/*! \struct _XENBUS_EVTCHN_INTERFACE_V4 + \brief EVTCHN interface version 4 + \ingroup interfaces +*/ +struct _XENBUS_EVTCHN_INTERFACE_V4 { + INTERFACE Interface; + XENBUS_EVTCHN_ACQUIRE EvtchnAcquire; + XENBUS_EVTCHN_RELEASE EvtchnRelease; + XENBUS_EVTCHN_OPEN EvtchnOpen; + XENBUS_EVTCHN_BIND EvtchnBind; + XENBUS_EVTCHN_UNMASK_V4 EvtchnUnmaskVersion4; + XENBUS_EVTCHN_SEND_V1 EvtchnSendVersion1; + XENBUS_EVTCHN_TRIGGER EvtchnTrigger; + XENBUS_EVTCHN_GET_PORT EvtchnGetPort; + XENBUS_EVTCHN_CLOSE EvtchnClose; +}; + +/*! \struct _XENBUS_EVTCHN_INTERFACE_V5 + \brief EVTCHN interface version 5 + \ingroup interfaces +*/ +struct _XENBUS_EVTCHN_INTERFACE_V5 { + INTERFACE Interface; + XENBUS_EVTCHN_ACQUIRE EvtchnAcquire; + XENBUS_EVTCHN_RELEASE EvtchnRelease; + XENBUS_EVTCHN_OPEN EvtchnOpen; + XENBUS_EVTCHN_BIND EvtchnBind; + XENBUS_EVTCHN_UNMASK_V4 EvtchnUnmaskVersion4; + XENBUS_EVTCHN_SEND_V1 EvtchnSendVersion1; + XENBUS_EVTCHN_TRIGGER EvtchnTrigger; + XENBUS_EVTCHN_WAIT_V5 EvtchnWaitVersion5; + XENBUS_EVTCHN_GET_PORT EvtchnGetPort; + XENBUS_EVTCHN_CLOSE EvtchnClose; +}; + +/*! \struct _XENBUS_EVTCHN_INTERFACE_V6 + \brief EVTCHN interface version 6 + \ingroup interfaces +*/ +struct _XENBUS_EVTCHN_INTERFACE_V6 { + INTERFACE Interface; + XENBUS_EVTCHN_ACQUIRE EvtchnAcquire; + XENBUS_EVTCHN_RELEASE EvtchnRelease; + XENBUS_EVTCHN_OPEN EvtchnOpen; + XENBUS_EVTCHN_BIND EvtchnBind; + XENBUS_EVTCHN_UNMASK_V4 EvtchnUnmaskVersion4; + XENBUS_EVTCHN_SEND EvtchnSend; + XENBUS_EVTCHN_TRIGGER EvtchnTrigger; + XENBUS_EVTCHN_WAIT_V5 EvtchnWaitVersion5; + XENBUS_EVTCHN_GET_PORT EvtchnGetPort; + XENBUS_EVTCHN_CLOSE EvtchnClose; +}; + +/*! \struct _XENBUS_EVTCHN_INTERFACE_V7 + \brief EVTCHN interface version 7 + \ingroup interfaces +*/ +struct _XENBUS_EVTCHN_INTERFACE_V7 { + INTERFACE Interface; + XENBUS_EVTCHN_ACQUIRE EvtchnAcquire; + XENBUS_EVTCHN_RELEASE EvtchnRelease; + XENBUS_EVTCHN_OPEN EvtchnOpen; + XENBUS_EVTCHN_BIND EvtchnBind; + XENBUS_EVTCHN_UNMASK_V4 EvtchnUnmaskVersion4; + XENBUS_EVTCHN_SEND EvtchnSend; + XENBUS_EVTCHN_TRIGGER EvtchnTrigger; + XENBUS_EVTCHN_GET_COUNT EvtchnGetCount; + XENBUS_EVTCHN_WAIT EvtchnWait; + XENBUS_EVTCHN_GET_PORT EvtchnGetPort; + XENBUS_EVTCHN_CLOSE EvtchnClose; +}; + +/*! \struct _XENBUS_EVTCHN_INTERFACE_V8 + \brief EVTCHN interface version 8 + \ingroup interfaces +*/ +struct _XENBUS_EVTCHN_INTERFACE_V8 { + INTERFACE Interface; + XENBUS_EVTCHN_ACQUIRE EvtchnAcquire; + XENBUS_EVTCHN_RELEASE EvtchnRelease; + XENBUS_EVTCHN_OPEN EvtchnOpen; + XENBUS_EVTCHN_BIND EvtchnBind; + XENBUS_EVTCHN_UNMASK EvtchnUnmask; + XENBUS_EVTCHN_SEND EvtchnSend; + XENBUS_EVTCHN_TRIGGER EvtchnTrigger; + XENBUS_EVTCHN_GET_COUNT EvtchnGetCount; + XENBUS_EVTCHN_WAIT EvtchnWait; + XENBUS_EVTCHN_GET_PORT EvtchnGetPort; + XENBUS_EVTCHN_CLOSE EvtchnClose; +}; + +typedef struct _XENBUS_EVTCHN_INTERFACE_V8 XENBUS_EVTCHN_INTERFACE, *PXENBUS_EVTCHN_INTERFACE; + +/*! \def XENBUS_EVTCHN + \brief Macro at assist in method invocation +*/ +#define XENBUS_EVTCHN(_Method, _Interface, ...) \ + (_Interface)->Evtchn ## _Method((PINTERFACE)(_Interface), __VA_ARGS__) + +#endif // _WINDLL + +#define XENBUS_EVTCHN_INTERFACE_VERSION_MIN 4 +#define XENBUS_EVTCHN_INTERFACE_VERSION_MAX 8 + +#endif // _XENBUS_EVTCHN_INTERFACE_H + diff --git a/include/gnttab_interface.h b/include/gnttab_interface.h new file mode 100755 index 0000000..61272ab --- /dev/null +++ b/include/gnttab_interface.h @@ -0,0 +1,287 @@ +/* Copyright (c) Citrix Systems Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, + * with or without modification, are permitted provided + * that the following conditions are met: + * + * * Redistributions of source code must retain the above + * copyright notice, this list of conditions and the + * following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the + * following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND + * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/*! \file gnttab_interface.h + \brief XENBUS GNTTAB Interface + + This interface provides access to the hypervisor grant table +*/ + +#ifndef _XENBUS_GNTTAB_INTERFACE_H +#define _XENBUS_GNTTAB_INTERFACE_H + +#include <cache_interface.h> + +#ifndef _WINDLL + +/*! \typedef XENBUS_GNTTAB_ENTRY + \brief Grant table entry handle +*/ +typedef struct _XENBUS_GNTTAB_ENTRY XENBUS_GNTTAB_ENTRY, *PXENBUS_GNTTAB_ENTRY; + +/*! \typedef XENBUS_GNTTAB_CACHE + \brief Grant table cache handle +*/ +typedef struct _XENBUS_GNTTAB_CACHE XENBUS_GNTTAB_CACHE, *PXENBUS_GNTTAB_CACHE; + +/*! \typedef XENBUS_GNTTAB_ACQUIRE + \brief Acquire a reference to the GNTTAB interface + + \param Interface The interface header +*/ +typedef NTSTATUS +(*XENBUS_GNTTAB_ACQUIRE)( + IN PINTERFACE Interface + ); + +/*! \typedef XENBUS_GNTTAB_RELEASE + \brief Release a reference to the GNTTAB interface + + \param Interface The interface header +*/ +typedef VOID +(*XENBUS_GNTTAB_RELEASE)( + IN PINTERFACE Interface + ); + +/*! \typedef XENBUS_GNTTAB_CREATE_CACHE + \brief Create a cache of grant table entries + + \param Interface The interface header + \param Name A name for the cache which will be used in debug output + \param Reservation The target minimum population of the cache + \param AcquireLock A callback invoked to acquire a spinlock + \param ReleaseLock A callback invoked to release the spinlock + \param Argument An optional context argument passed to the callbacks + \param Cache A pointer to a grant table cache handle to be initialized +*/ +typedef NTSTATUS +(*XENBUS_GNTTAB_CREATE_CACHE)( + IN PINTERFACE Interface, + IN const CHAR *Name, + IN ULONG Reservation, + IN XENBUS_CACHE_ACQUIRE_LOCK AcquireLock, + IN XENBUS_CACHE_RELEASE_LOCK ReleaseLock, + IN PVOID Argument OPTIONAL, + OUT PXENBUS_GNTTAB_CACHE *Cache + ); + +/*! \typedef XENBUS_GNTTAB_PERMIT_FOREIGN_ACCESS + \brief Get a table entry from the \a Cache permitting access to a given \a Pfn + + \param Interface The interface header + \param Cache The grant table cache handle + \param Locked If mutually exclusive access to the cache is already + guaranteed then set this to TRUE + \param Domain The domid of the domain being granted access + \param Pfn The frame number of the page that we are granting access to + \param ReadOnly Set to TRUE if the foreign domain is only being granted + read access + \param Entry A pointer to a grant table entry handle to be initialized +*/ +typedef NTSTATUS +(*XENBUS_GNTTAB_PERMIT_FOREIGN_ACCESS)( + IN PINTERFACE Interface, + IN PXENBUS_GNTTAB_CACHE Cache, + IN BOOLEAN Locked, + IN USHORT Domain, + IN PFN_NUMBER Pfn, + IN BOOLEAN ReadOnly, + OUT PXENBUS_GNTTAB_ENTRY *Entry + ); + +/*! \typedef XENBUS_GNTTAB_REVOKE_FOREIGN_ACCESS + \brief Revoke foreign access and return the \a Entry to the \a Cache + + \param Interface The interface header + \param Cache The grant table cache handle + \param Locked If mutually exclusive access to the cache is already + guaranteed then set this to TRUE + \param Entry The grant table entry handle +*/ +typedef NTSTATUS +(*XENBUS_GNTTAB_REVOKE_FOREIGN_ACCESS)( + IN PINTERFACE Interface, + IN PXENBUS_GNTTAB_CACHE Cache, + IN BOOLEAN Locked, + IN PXENBUS_GNTTAB_ENTRY Entry + ); + +/*! \typedef XENBUS_GNTTAB_GET_REFERENCE + \brief Get the reference number of the entry + + \param Interface The interface header + \param Entry The grant table entry handle + \return The reference number +*/ +typedef ULONG +(*XENBUS_GNTTAB_GET_REFERENCE)( + IN PINTERFACE Interface, + IN PXENBUS_GNTTAB_ENTRY Entry + ); + +/*! \typedef XENBUS_GNTTAB_QUERY_REFERENCE + \brief Get the reference number of the entry + + \param Interface The interface header + \param Reference The reference number + \param Pfn An optional pointer to receive the value of the reference frame number + \param ReadOnly An optional pointer to receive the boolean value of the read-only flag +*/ +typedef NTSTATUS +(*XENBUS_GNTTAB_QUERY_REFERENCE)( + IN PINTERFACE Interface, + IN ULONG Reference, + OUT PPFN_NUMBER Pfn OPTIONAL, + OUT PBOOLEAN ReadOnly OPTIONAL + ); + +#define XENBUS_GNTTAB_CONSOLE_REFERENCE 0 +#define XENBUS_GNTTAB_STORE_REFERENCE 1 + + +/*! \typedef XENBUS_GNTTAB_DESTROY_CACHE + \brief Destroy a cache of grant table entries + + \param Interface The interface header + \param Cache The grant table cache handle + + All grant table entries must have been revoked prior to destruction + of the cache +*/ +typedef VOID +(*XENBUS_GNTTAB_DESTROY_CACHE)( + IN PINTERFACE Interface, + IN PXENBUS_GNTTAB_CACHE Cache + ); + +/*! \typedef XENBUS_GNTTAB_MAP_FOREIGN_PAGES + \brief Map foreign memory pages into the system address space + + \param Interface The interface header + \param Domain The domid of the foreign domain that granted the pages + \param NumberPages Number of pages to map + \param References Array of grant reference numbers shared by the foreign domain + \param ReadOnly If TRUE, pages are mapped with read-only access + \param Address The physical address that the foreign pages are mapped under +*/ + +typedef NTSTATUS +(*XENBUS_GNTTAB_MAP_FOREIGN_PAGES)( + IN PINTERFACE Interface, + IN USHORT Domain, + IN ULONG NumberPages, + IN PULONG References, + IN BOOLEAN ReadOnly, + OUT PHYSICAL_ADDRESS *Address + ); + +/*! \typedef XENBUS_GNTTAB_UNMAP_FOREIGN_PAGES + \brief Unmap foreign memory pages from the system address space + + \param Interface The interface header + \param Address The physical address that the foreign pages are mapped under +*/ +typedef NTSTATUS +(*XENBUS_GNTTAB_UNMAP_FOREIGN_PAGES)( + IN PINTERFACE Interface, + IN PHYSICAL_ADDRESS Address + ); + +// {763679C5-E5C2-4A6D-8B88-6BB02EC42D8E} +DEFINE_GUID(GUID_XENBUS_GNTTAB_INTERFACE, +0x763679c5, 0xe5c2, 0x4a6d, 0x8b, 0x88, 0x6b, 0xb0, 0x2e, 0xc4, 0x2d, 0x8e); + +/*! \struct _XENBUS_GNTTAB_INTERFACE_V1 + \brief GNTTAB interface version 1 + \ingroup interfaces +*/ +struct _XENBUS_GNTTAB_INTERFACE_V1 { + INTERFACE Interface; + XENBUS_GNTTAB_ACQUIRE GnttabAcquire; + XENBUS_GNTTAB_RELEASE GnttabRelease; + XENBUS_GNTTAB_CREATE_CACHE GnttabCreateCache; + XENBUS_GNTTAB_PERMIT_FOREIGN_ACCESS GnttabPermitForeignAccess; + XENBUS_GNTTAB_REVOKE_FOREIGN_ACCESS GnttabRevokeForeignAccess; + XENBUS_GNTTAB_GET_REFERENCE GnttabGetReference; + XENBUS_GNTTAB_DESTROY_CACHE GnttabDestroyCache; +}; + +/*! \struct _XENBUS_GNTTAB_INTERFACE_V2 + \brief GNTTAB interface version 2 + \ingroup interfaces +*/ +struct _XENBUS_GNTTAB_INTERFACE_V2 { + INTERFACE Interface; + XENBUS_GNTTAB_ACQUIRE GnttabAcquire; + XENBUS_GNTTAB_RELEASE GnttabRelease; + XENBUS_GNTTAB_CREATE_CACHE GnttabCreateCache; + XENBUS_GNTTAB_PERMIT_FOREIGN_ACCESS GnttabPermitForeignAccess; + XENBUS_GNTTAB_REVOKE_FOREIGN_ACCESS GnttabRevokeForeignAccess; + XENBUS_GNTTAB_GET_REFERENCE GnttabGetReference; + XENBUS_GNTTAB_DESTROY_CACHE GnttabDestroyCache; + XENBUS_GNTTAB_MAP_FOREIGN_PAGES GnttabMapForeignPages; + XENBUS_GNTTAB_UNMAP_FOREIGN_PAGES GnttabUnmapForeignPages; +}; + +/*! \struct _XENBUS_GNTTAB_INTERFACE_V3 + \brief GNTTAB interface version 3 + \ingroup interfaces +*/ +struct _XENBUS_GNTTAB_INTERFACE_V3 { + INTERFACE Interface; + XENBUS_GNTTAB_ACQUIRE GnttabAcquire; + XENBUS_GNTTAB_RELEASE GnttabRelease; + XENBUS_GNTTAB_CREATE_CACHE GnttabCreateCache; + XENBUS_GNTTAB_PERMIT_FOREIGN_ACCESS GnttabPermitForeignAccess; + XENBUS_GNTTAB_REVOKE_FOREIGN_ACCESS GnttabRevokeForeignAccess; + XENBUS_GNTTAB_GET_REFERENCE GnttabGetReference; + XENBUS_GNTTAB_QUERY_REFERENCE GnttabQueryReference; + XENBUS_GNTTAB_DESTROY_CACHE GnttabDestroyCache; + XENBUS_GNTTAB_MAP_FOREIGN_PAGES GnttabMapForeignPages; + XENBUS_GNTTAB_UNMAP_FOREIGN_PAGES GnttabUnmapForeignPages; +}; + +typedef struct _XENBUS_GNTTAB_INTERFACE_V3 XENBUS_GNTTAB_INTERFACE, *PXENBUS_GNTTAB_INTERFACE; + +/*! \def XENBUS_GNTTAB + \brief Macro at assist in method invocation +*/ +#define XENBUS_GNTTAB(_Method, _Interface, ...) \ + (_Interface)->Gnttab ## _Method((PINTERFACE)(_Interface), __VA_ARGS__) + +#endif // _WINDLL + +#define XENBUS_GNTTAB_INTERFACE_VERSION_MIN 1 +#define XENBUS_GNTTAB_INTERFACE_VERSION_MAX 3 + +#endif // _XENBUS_GNTTAB_INTERFACE_H + diff --git a/src/xencons/fdo.c b/src/xencons/fdo.c index e28355c..4b6558a 100644 --- a/src/xencons/fdo.c +++ b/src/xencons/fdo.c @@ -41,6 +41,8 @@ #include <suspend_interface.h> #include <store_interface.h> #include <console_interface.h> +#include <evtchn_interface.h> +#include <gnttab_interface.h> #include <version.h> #include "driver.h" @@ -97,6 +99,8 @@ struct _XENCONS_FDO { XENBUS_SUSPEND_INTERFACE SuspendInterface; XENBUS_STORE_INTERFACE StoreInterface; XENBUS_CONSOLE_INTERFACE ConsoleInterface; + XENBUS_EVTCHN_INTERFACE EvtchnInterface; + XENBUS_GNTTAB_INTERFACE GnttabInterface; PXENBUS_SUSPEND_CALLBACK SuspendCallbackLate; }; @@ -2938,6 +2942,8 @@ DEFINE_FDO_GET_INTERFACE(Debug, PXENBUS_DEBUG_INTERFACE) DEFINE_FDO_GET_INTERFACE(Suspend, PXENBUS_SUSPEND_INTERFACE) DEFINE_FDO_GET_INTERFACE(Store, PXENBUS_STORE_INTERFACE) DEFINE_FDO_GET_INTERFACE(Console, PXENBUS_CONSOLE_INTERFACE) +DEFINE_FDO_GET_INTERFACE(Evtchn, PXENBUS_EVTCHN_INTERFACE) +DEFINE_FDO_GET_INTERFACE(Gnttab, PXENBUS_GNTTAB_INTERFACE) NTSTATUS FdoCreate( @@ -3040,6 +3046,24 @@ FdoCreate( if (!NT_SUCCESS(status)) goto fail11; + status = FDO_QUERY_INTERFACE(Fdo, + XENBUS, + EVTCHN, + (PINTERFACE)&Fdo->EvtchnInterface, + sizeof(Fdo->EvtchnInterface), + FALSE); + if (!NT_SUCCESS(status)) + goto fail12; + + status = FDO_QUERY_INTERFACE(Fdo, + XENBUS, + GNTTAB, + (PINTERFACE)&Fdo->GnttabInterface, + sizeof(Fdo->GnttabInterface), + FALSE); + if (!NT_SUCCESS(status)) + goto fail13; + Dx->Fdo = Fdo; InitializeMutex(&Fdo->Mutex); @@ -3052,13 +3076,13 @@ FdoCreate( status = PdoCreate(Fdo, NULL); if (!NT_SUCCESS(status)) - goto fail12; + goto fail14; FunctionDeviceObject->Flags &= ~DO_DEVICE_INITIALIZING; return STATUS_SUCCESS; -fail12: - Error("fail12\n"); +fail14: + Error("fail14\n"); Dx->Fdo = Fdo; @@ -3066,6 +3090,18 @@ fail12: RtlZeroMemory(&Dx->ListEntry, sizeof(LIST_ENTRY)); Fdo->References = 0; + RtlZeroMemory(&Fdo->GnttabInterface, + sizeof(XENBUS_GNTTAB_INTERFACE)); + +fail13: + Error("fail13\n"); + + RtlZeroMemory(&Fdo->EvtchnInterface, + sizeof(XENBUS_EVTCHN_INTERFACE)); + +fail12: + Error("fail12\n"); + RtlZeroMemory(&Fdo->ConsoleInterface, sizeof(XENBUS_CONSOLE_INTERFACE)); @@ -3157,6 +3193,12 @@ FdoDestroy( Dx->Fdo = NULL; + RtlZeroMemory(&Fdo->GnttabInterface, + sizeof(XENBUS_GNTTAB_INTERFACE)); + + RtlZeroMemory(&Fdo->EvtchnInterface, + sizeof(XENBUS_EVTCHN_INTERFACE)); + RtlZeroMemory(&Fdo->ConsoleInterface, sizeof (XENBUS_CONSOLE_INTERFACE)); diff --git a/src/xencons/fdo.h b/src/xencons/fdo.h index f8ebaf3..7fe07de 100644 --- a/src/xencons/fdo.h +++ b/src/xencons/fdo.h @@ -37,6 +37,8 @@ #include <suspend_interface.h> #include <store_interface.h> #include <console_interface.h> +#include <evtchn_interface.h> +#include <gnttab_interface.h> #include "driver.h" @@ -100,6 +102,8 @@ DECLARE_FDO_GET_INTERFACE(Debug, PXENBUS_DEBUG_INTERFACE) DECLARE_FDO_GET_INTERFACE(Suspend, PXENBUS_SUSPEND_INTERFACE) DECLARE_FDO_GET_INTERFACE(Store, PXENBUS_STORE_INTERFACE) DECLARE_FDO_GET_INTERFACE(Console, PXENBUS_CONSOLE_INTERFACE) +DECLARE_FDO_GET_INTERFACE(Evtchn, PXENBUS_EVTCHN_INTERFACE) +DECLARE_FDO_GET_INTERFACE(Gnttab, PXENBUS_GNTTAB_INTERFACE) extern NTSTATUS FdoCreate( -- 2.8.3 _______________________________________________ win-pv-devel mailing list win-pv-devel@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/mailman/listinfo/win-pv-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |