]> git.proxmox.com Git - mirror_edk2.git/blobdiff - OvmfPkg/Include/Protocol/XenBus.h
OvmfPkg/XenBusDxe: Add XenStore function into the XenBus protocol
[mirror_edk2.git] / OvmfPkg / Include / Protocol / XenBus.h
index 565d491db697a9831879b157f88e7132899ca73d..5693b3f28436846664093dc045a5bf8dbce4a6b6 100644 (file)
@@ -68,6 +68,136 @@ typedef enum {
 /// Function prototypes\r
 ///\r
 \r
+/**\r
+  Get the contents of the node Node of the PV device. Returns the contents in\r
+  *Result which should be freed after use.\r
+\r
+  @param This           A pointer to XENBUS_PROTOCOL instance.\r
+  @param Transaction    The XenStore transaction covering this request.\r
+  @param Node           The basename of the file to read.\r
+  @param Result         The returned contents from this file.\r
+\r
+  @return  On success, XENSTORE_STATUS_SUCCESS. Otherwise an errno value\r
+           indicating the type of failure.\r
+\r
+  @note The results buffer is malloced and should be free'd by the\r
+        caller.\r
+**/\r
+typedef\r
+XENSTORE_STATUS\r
+(EFIAPI *XENBUS_XS_READ)(\r
+  IN  XENBUS_PROTOCOL       *This,\r
+  IN  XENSTORE_TRANSACTION  Transaction,\r
+  IN  CONST CHAR8           *Node,\r
+  OUT VOID                  **Result\r
+  );\r
+\r
+/**\r
+  Get the contents of the node Node of the PV device's backend. Returns the\r
+  contents in *Result which should be freed after use.\r
+\r
+  @param This           A pointer to XENBUS_PROTOCOL instance.\r
+  @param Transaction    The XenStore transaction covering this request.\r
+  @param Node           The basename of the file to read.\r
+  @param Result         The returned contents from this file.\r
+\r
+  @return  On success, XENSTORE_STATUS_SUCCESS. Otherwise an errno value\r
+           indicating the type of failure.\r
+\r
+  @note The results buffer is malloced and should be free'd by the\r
+        caller.\r
+**/\r
+typedef\r
+XENSTORE_STATUS\r
+(EFIAPI *XENBUS_XS_BACKEND_READ)(\r
+  IN  XENBUS_PROTOCOL       *This,\r
+  IN  XENSTORE_TRANSACTION  Transaction,\r
+  IN  CONST CHAR8           *Node,\r
+  OUT VOID                  **Result\r
+  );\r
+\r
+/**\r
+  Print formatted write to a XenStore node.\r
+\r
+  @param This             A pointer to XENBUS_PROTOCOL instance.\r
+  @param Transaction      The XenStore transaction covering this request.\r
+  @param Directory        The dirname of the path to read.\r
+  @param Node             The basename of the path to read.\r
+  @param Format           AsciiSPrint format string followed by a variable number\r
+                          of arguments.\r
+\r
+  @return  On success, XENSTORE_STATUS_SUCCESS. Otherwise an errno value\r
+           indicating the type of write failure.\r
+**/\r
+typedef\r
+XENSTORE_STATUS\r
+(EFIAPI *XENBUS_XS_PRINTF) (\r
+  IN XENBUS_PROTOCOL        *This,\r
+  IN XENSTORE_TRANSACTION   Transaction,\r
+  IN CONST CHAR8            *Directory,\r
+  IN CONST CHAR8            *Node,\r
+  IN CONST CHAR8            *Format,\r
+  ...\r
+  );\r
+\r
+/**\r
+  Remove a node or directory (directories must be empty) of the PV driver's\r
+  subdirectory.\r
+\r
+  @param This           A pointer to XENBUS_PROTOCOL instance.\r
+  @param Transaction    The XenStore transaction covering this request.\r
+  @param Node           The basename of the node to remove.\r
+\r
+  @return  On success, XENSTORE_STATUS_SUCCESS. Otherwise an errno value\r
+           indicating the type of failure.\r
+**/\r
+typedef\r
+XENSTORE_STATUS\r
+(EFIAPI *XENBUS_XS_REMOVE) (\r
+  IN XENBUS_PROTOCOL        *This,\r
+  IN XENSTORE_TRANSACTION   Transaction,\r
+  IN CONST CHAR8            *Node\r
+  );\r
+\r
+/**\r
+  Start a transaction.\r
+\r
+  Changes by others will not be seen during the lifetime of this\r
+  transaction, and changes will not be visible to others until it\r
+  is committed (XsTransactionEnd).\r
+\r
+  @param This         A pointer to XENBUS_PROTOCOL instance.\r
+  @param Transaction  The returned transaction.\r
+\r
+  @return  On success, XENSTORE_STATUS_SUCCESS. Otherwise an errno value\r
+           indicating the type of failure.\r
+**/\r
+typedef\r
+XENSTORE_STATUS\r
+(EFIAPI *XENBUS_XS_TRANSACTION_START)(\r
+  IN  XENBUS_PROTOCOL       *This,\r
+  OUT XENSTORE_TRANSACTION  *Transaction\r
+  );\r
+\r
+/**\r
+  End a transaction.\r
+\r
+  @param This         A pointer to XENBUS_PROTOCOL instance.\r
+  @param Transaction  The transaction to end/commit.\r
+  @param Abort        If TRUE, the transaction is discarded\r
+                      instead of committed.\r
+\r
+  @return  On success, XENSTORE_STATUS_SUCCESS. Otherwise an errno value\r
+           indicating the type of failure.\r
+**/\r
+typedef\r
+XENSTORE_STATUS\r
+(EFIAPI *XENBUS_XS_TRANSACTION_END) (\r
+  IN XENBUS_PROTOCOL        *This,\r
+  IN XENSTORE_TRANSACTION   Transaction,\r
+  IN BOOLEAN                Abort\r
+  );\r
+\r
 /**\r
   Grant access to the page Frame to the domain DomainId.\r
 \r
@@ -101,6 +231,83 @@ EFI_STATUS
   IN grant_ref_t      Ref\r
   );\r
 \r
+/**\r
+  Register a XenStore watch.\r
+\r
+  XenStore watches allow a client to wait for changes to an object in the\r
+  XenStore.\r
+\r
+  @param This       A pointer to the XENBUS_PROTOCOL.\r
+  @param Node       The basename of the path to watch.\r
+  @param Token      A token.\r
+\r
+  @return  On success, XENSTORE_STATUS_SUCCESS. Otherwise an errno value\r
+           indicating the type of write failure.  EEXIST errors from the\r
+           XenStore are supressed, allowing multiple, physically different,\r
+           xenbus_watch objects, to watch the same path in the XenStore.\r
+**/\r
+typedef\r
+XENSTORE_STATUS\r
+(EFIAPI *XENBUS_REGISTER_WATCH) (\r
+  IN  XENBUS_PROTOCOL *This,\r
+  IN  CONST CHAR8     *Node,\r
+  OUT VOID            **Token\r
+  );\r
+\r
+/**\r
+  Register a XenStore watch on a backend's node.\r
+\r
+  XenStore watches allow a client to wait for changes to an object in the\r
+  XenStore.\r
+\r
+  @param This       A pointer to the XENBUS_PROTOCOL.\r
+  @param Node       The basename of the path to watch.\r
+  @param Token      A token.\r
+\r
+  @return  On success, XENSTORE_STATUS_SUCCESS. Otherwise an errno value\r
+           indicating the type of write failure.  EEXIST errors from the\r
+           XenStore are supressed, allowing multiple, physically different,\r
+           xenbus_watch objects, to watch the same path in the XenStore.\r
+**/\r
+typedef\r
+XENSTORE_STATUS\r
+(EFIAPI *XENBUS_REGISTER_WATCH_BACKEND) (\r
+  IN  XENBUS_PROTOCOL *This,\r
+  IN  CONST CHAR8     *Node,\r
+  OUT VOID            **Token\r
+  );\r
+\r
+/**\r
+  Unregister a XenStore watch.\r
+\r
+  @param This   A pointer to the XENBUS_PROTOCOL.\r
+  @param Token  An token previously returned by a successful\r
+                call to RegisterWatch ().\r
+**/\r
+typedef\r
+VOID\r
+(EFIAPI *XENBUS_UNREGISTER_WATCH) (\r
+  IN XENBUS_PROTOCOL  *This,\r
+  IN VOID             *Token\r
+  );\r
+\r
+/**\r
+  Block until the node watch by Token change.\r
+\r
+  @param This   A pointer to the XENBUS_PROTOCOL.\r
+  @param Token  An token previously returned by a successful\r
+                call to RegisterWatch or RegisterWatchBackend.\r
+\r
+  @return  On success, XENSTORE_STATUS_SUCCESS. Otherwise an errno value\r
+           indicating the type of failure.\r
+**/\r
+typedef\r
+XENSTORE_STATUS\r
+(EFIAPI *XENBUS_WAIT_FOR_WATCH) (\r
+  IN XENBUS_PROTOCOL  *This,\r
+  IN VOID             *Token\r
+  );\r
+\r
 \r
 ///\r
 /// Protocol structure\r
@@ -109,11 +316,27 @@ EFI_STATUS
 /// should not be used outside of the EDK II tree.\r
 ///\r
 struct _XENBUS_PROTOCOL {\r
+  XENBUS_XS_READ                XsRead;\r
+  XENBUS_XS_BACKEND_READ        XsBackendRead;\r
+  XENBUS_XS_PRINTF              XsPrintf;\r
+  XENBUS_XS_REMOVE              XsRemove;\r
+  XENBUS_XS_TRANSACTION_START   XsTransactionStart;\r
+  XENBUS_XS_TRANSACTION_END     XsTransactionEnd;\r
+\r
   XENBUS_GRANT_ACCESS           GrantAccess;\r
   XENBUS_GRANT_END_ACCESS       GrantEndAccess;\r
+\r
+  XENBUS_REGISTER_WATCH         RegisterWatch;\r
+  XENBUS_REGISTER_WATCH_BACKEND RegisterWatchBackend;\r
+  XENBUS_UNREGISTER_WATCH       UnregisterWatch;\r
+  XENBUS_WAIT_FOR_WATCH         WaitForWatch;\r
   //\r
   // Protocol data fields\r
   //\r
+  CONST CHAR8                   *Type;\r
+  UINT16                        DeviceId;\r
+  CONST CHAR8                   *Node;\r
+  CONST CHAR8                   *Backend;\r
 };\r
 \r
 extern EFI_GUID gXenBusProtocolGuid;\r