[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH RFC 13/18] OvmfPkg/XenbusDxe: Add Xenstore function into the Xenbus protocol
Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Anthony PERARD <anthony.perard@xxxxxxxxxx> --- OvmfPkg/Include/Protocol/Xenbus.h | 105 +++++++++++++++++++++++++ OvmfPkg/XenbusDxe/Xenstore.c | 159 ++++++++++++++++++++++++++++++++++++++ OvmfPkg/XenbusDxe/Xenstore.h | 86 +++++++++++++++++++++ 3 files changed, 350 insertions(+) diff --git a/OvmfPkg/Include/Protocol/Xenbus.h b/OvmfPkg/Include/Protocol/Xenbus.h index 1e0d01d..ef4d0c2 100644 --- a/OvmfPkg/Include/Protocol/Xenbus.h +++ b/OvmfPkg/Include/Protocol/Xenbus.h @@ -56,6 +56,62 @@ typedef enum { /// Function prototypes /// +/* + * Return error from xs_read + * Return value of the node ${This->Node}/${node} + */ +typedef +XENSTORE_STATUS +(EFIAPI *XENBUS_XS_READ)( + IN XENBUS_PROTOCOL *This, + IN XENSTORE_TRANSACTION Transaction, + IN CONST CHAR8 *Node, + OUT VOID **Result + ); + +typedef +XENSTORE_STATUS +(EFIAPI *XENBUS_XS_BACKEND_READ)( + IN XENBUS_PROTOCOL *This, + IN XENSTORE_TRANSACTION Transaction, + IN CONST CHAR8 *Node, + OUT VOID **Result + ); + +typedef +XENSTORE_STATUS +(EFIAPI *XENBUS_XS_PRINTF) ( + IN XENBUS_PROTOCOL *This, + IN XENSTORE_TRANSACTION Transaction, + IN CONST CHAR8 *Directory, + IN CONST CHAR8 *Node, + IN CONST CHAR8 *Format, + ... + ); + +typedef +XENSTORE_STATUS +(EFIAPI *XENBUS_XS_REMOVE) ( + IN XENBUS_PROTOCOL *This, + IN XENSTORE_TRANSACTION Transaction, + IN CONST CHAR8 *Node + ); + +typedef +XENSTORE_STATUS +(EFIAPI *XENBUS_XS_TRANSACTION_START)( + IN XENBUS_PROTOCOL *This, + OUT XENSTORE_TRANSACTION *Transaction + ); + +typedef +XENSTORE_STATUS +(EFIAPI *XENBUS_XS_TRANSACTION_END) ( + IN XENBUS_PROTOCOL *This, + IN XENSTORE_TRANSACTION Transaction, + IN BOOLEAN Abort + ); + typedef EFI_STATUS (EFIAPI *XENBUS_GRANT_ACCESS)( @@ -73,16 +129,65 @@ EFI_STATUS IN grant_ref_t Ref ); +typedef +XENSTORE_STATUS +(EFIAPI *XENBUS_REGISTER_WATCH) ( + IN XENBUS_PROTOCOL *This, + IN CONST CHAR8 *Node, + // XENSTORE_WATCH ? + OUT VOID **Token + ); + +typedef +XENSTORE_STATUS +(EFIAPI *XENBUS_REGISTER_WATCH_BACKEND) ( + IN XENBUS_PROTOCOL *This, + IN CONST CHAR8 *Node, + OUT VOID **Token + ); + +typedef +VOID +(EFIAPI *XENBUS_UNREGISTER_WATCH) ( + IN XENBUS_PROTOCOL *This, + IN VOID *Token + ); + +typedef +VOID +(EFIAPI *XENBUS_WAIT_FOR_WATCH) ( + IN XENBUS_PROTOCOL *This, + IN VOID *Token + ); + /// /// Protocol structure /// struct _XENBUS_PROTOCOL { + XENBUS_XS_READ XsRead; + XENBUS_XS_BACKEND_READ XsBackendRead; + XENBUS_XS_PRINTF XsPrintf; + XENBUS_XS_REMOVE XsRemove; + XENBUS_XS_TRANSACTION_START XsTransactionStart; + XENBUS_XS_TRANSACTION_END XsTransactionEnd; + XENBUS_GRANT_ACCESS GrantAccess; XENBUS_GRANT_END_ACCESS GrantEndAccess; + + XENBUS_REGISTER_WATCH RegisterWatch; + XENBUS_REGISTER_WATCH_BACKEND RegisterWatchBackend; + XENBUS_UNREGISTER_WATCH UnregisterWatch; + XENBUS_WAIT_FOR_WATCH WaitForWatch; // // Place protocol data fields here // + CONST CHAR8 *Type; + // helper, since the value is in Node, avoid calculating twice, + // in XenbusDxe and in XenPvBlkDxe + UINT16 DeviceId; + CONST CHAR8 *Node; + CONST CHAR8 *Backend; }; extern EFI_GUID gXenbusProtocolGuid; diff --git a/OvmfPkg/XenbusDxe/Xenstore.c b/OvmfPkg/XenbusDxe/Xenstore.c index 2252c4f..6d92fc4 100644 --- a/OvmfPkg/XenbusDxe/Xenstore.c +++ b/OvmfPkg/XenbusDxe/Xenstore.c @@ -946,6 +946,42 @@ XenstoreUnwatch ( return XenstoreTalkv (XST_NIL, XS_UNWATCH, WriteRequest, 2, NULL, NULL); } +STATIC +VOID +XenstoreWaitWatch ( + VOID *Token + ) +{ + XENSTORE_MESSAGE *Message; + LIST_ENTRY *Entry = NULL; + LIST_ENTRY *Last = NULL; + + while (TRUE) { + EfiAcquireLock (&xs.WatchEventsLock); + if (IsListEmpty (&xs.WatchEvents) || + Last == GetFirstNode (&xs.WatchEvents)) { + EfiReleaseLock (&xs.WatchEventsLock); + XenstoreProcessMessage (); + continue; + } + + for (Entry = GetFirstNode (&xs.WatchEvents); + Entry != Last && !IsNull (&xs.WatchEvents, Entry); + Entry = GetNextNode (&xs.WatchEvents, Entry)) { + Message = XENSTORE_MESSAGE_FROM_LINK (Entry); + if (Message->u.Watch.Handle == Token) { + RemoveEntryList (Entry); + EfiReleaseLock (&xs.WatchEventsLock); + FreePool(Message->u.Watch.Vector); + FreePool(Message); + return; + } + } + Last = GetFirstNode (&xs.WatchEvents); + EfiReleaseLock (&xs.WatchEventsLock); + } +} + VOID EFIAPI NotifyEventChannelCheckForEvent ( @@ -1311,3 +1347,126 @@ XenstoreUnregisterWatch ( FreePool (Watch->Node); FreePool (Watch); } + + +/* + * XENBUS + */ +VOID +EFIAPI +XenbusWaitForWatch ( + IN XENBUS_PROTOCOL *This, + IN VOID *Token + ) +{ + XenstoreWaitWatch (Token); +} + +XENSTORE_STATUS +EFIAPI +XenbusXenstoreRead ( + IN XENBUS_PROTOCOL *This, + IN XENSTORE_TRANSACTION Transaction, + IN CONST CHAR8 *Node, + OUT VOID **Value + ) +{ + return XenstoreRead (Transaction, This->Node, Node, NULL, Value); +} + +XENSTORE_STATUS +EFIAPI +XenbusXenstoreBackendRead ( + IN XENBUS_PROTOCOL *This, + IN XENSTORE_TRANSACTION Transaction, + IN CONST CHAR8 *Node, + OUT VOID **Value + ) +{ + return XenstoreRead (Transaction, This->Backend, Node, NULL, Value); +} + +XENSTORE_STATUS +EFIAPI +XenbusXenstoreRemove ( + IN XENBUS_PROTOCOL *This, + IN XENSTORE_TRANSACTION Transaction, + IN const char *Node + ) +{ + return XenstoreRemove (Transaction, This->Node, Node); +} + +XENSTORE_STATUS +EFIAPI +XenbusXenstoreTransactionStart ( + IN XENBUS_PROTOCOL *This, + OUT XENSTORE_TRANSACTION *Transaction + ) +{ + return XenstoreTransactionStart (Transaction); +} + +XENSTORE_STATUS +EFIAPI +XenbusXenstoreTransactionEnd ( + IN XENBUS_PROTOCOL *This, + IN XENSTORE_TRANSACTION Transaction, + IN BOOLEAN Abort + ) +{ + return XenstoreTransactionEnd (Transaction, Abort); +} + +XENSTORE_STATUS +EFIAPI +XenbusXenstoreSPrint ( + IN XENBUS_PROTOCOL *This, + IN XENSTORE_TRANSACTION Transaction, + IN CONST CHAR8 *DirectoryPath, + IN CONST CHAR8 *Node, + IN CONST CHAR8 *FormatString, + ... + ) +{ + VA_LIST Marker; + XENSTORE_STATUS Status; + + VA_START (Marker, FormatString); + Status = XenstoreVSPrint (Transaction, DirectoryPath, Node, FormatString, Marker); + VA_END (Marker); + + return Status; +} + +XENSTORE_STATUS +EFIAPI +XenbusRegisterWatch ( + IN XENBUS_PROTOCOL *This, + IN CONST CHAR8 *Node, + OUT VOID **Token + ) +{ + return XenstoreRegisterWatch (This->Node, Node, (XENSTORE_WATCH **) Token); +} + +XENSTORE_STATUS +EFIAPI +XenbusRegisterWatchBackend ( + IN XENBUS_PROTOCOL *This, + IN CONST CHAR8 *Node, + OUT VOID **Token + ) +{ + return XenstoreRegisterWatch (This->Backend, Node, (XENSTORE_WATCH **) Token); +} + +VOID +EFIAPI +XenbusUnregisterWatch ( + IN XENBUS_PROTOCOL *This, + IN VOID *Token + ) +{ + XenstoreUnregisterWatch ((XENSTORE_WATCH *) Token); +} diff --git a/OvmfPkg/XenbusDxe/Xenstore.h b/OvmfPkg/XenbusDxe/Xenstore.h index 3a056c0..276ad7a 100644 --- a/OvmfPkg/XenbusDxe/Xenstore.h +++ b/OvmfPkg/XenbusDxe/Xenstore.h @@ -278,4 +278,90 @@ XenstoreInit ( XENBUS_DEVICE *Dev ); +/* + * XENBUS + */ + +VOID +EFIAPI +XenbusWaitForWatch ( + IN XENBUS_PROTOCOL *This, + IN VOID *Token + ); + +XENSTORE_STATUS +EFIAPI +XenbusXenstoreRead ( + IN XENBUS_PROTOCOL *This, + IN XENSTORE_TRANSACTION Transaction, + IN CONST CHAR8 *Node, + OUT VOID **Value + ); + +XENSTORE_STATUS +EFIAPI +XenbusXenstoreBackendRead ( + IN XENBUS_PROTOCOL *This, + IN XENSTORE_TRANSACTION Transaction, + IN CONST CHAR8 *Node, + OUT VOID **Value + ); + +XENSTORE_STATUS +EFIAPI +XenbusXenstoreRemove ( + IN XENBUS_PROTOCOL *This, + IN XENSTORE_TRANSACTION Transaction, + IN CONST CHAR8 *Node + ); + +XENSTORE_STATUS +EFIAPI +XenbusXenstoreTransactionStart ( + IN XENBUS_PROTOCOL *This, + OUT XENSTORE_TRANSACTION *Transaction + ); + +XENSTORE_STATUS +EFIAPI +XenbusXenstoreTransactionEnd ( + IN XENBUS_PROTOCOL *This, + IN XENSTORE_TRANSACTION Transaction, + IN BOOLEAN Abort + ); + +XENSTORE_STATUS +EFIAPI +XenbusXenstoreSPrint ( + IN XENBUS_PROTOCOL *This, + IN XENSTORE_TRANSACTION Transaction, + IN CONST CHAR8 *DirectoryPath, + IN CONST CHAR8 *Node, + IN CONST CHAR8 *FormatString, + ... + ); + +XENSTORE_STATUS +EFIAPI +XenbusRegisterWatch ( + IN XENBUS_PROTOCOL *This, + IN CONST CHAR8 *Node, + OUT VOID **Token + ); + +XENSTORE_STATUS +EFIAPI +XenbusRegisterWatchBackend ( + IN XENBUS_PROTOCOL *This, + IN CONST CHAR8 *Node, + OUT VOID **Token + ); + +VOID +EFIAPI +XenbusUnregisterWatch ( + IN XENBUS_PROTOCOL *This, + IN VOID *Token + ); + #endif /* _XEN_XENSTORE_XENSTOREVAR_H */ -- Anthony PERARD _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |