]> xenbits.xensource.com Git - people/pauldu/xeniface.git/commitdiff
Add SharedInfo IOCTL interface
authorOwen Smith <owen.smith@citrix.com>
Mon, 27 Jun 2016 10:24:44 +0000 (11:24 +0100)
committerPaul Durrant <paul.durrant@citrix.com>
Tue, 5 Jul 2016 16:55:16 +0000 (17:55 +0100)
Adds
* GetTime - returns Xen wallclock time

Signed-off-by: Owen Smith <owen.smith@citrix.com>
include/xeniface_ioctls.h
src/xeniface/ioctl_sharedinfo.c [new file with mode: 0644]
src/xeniface/ioctls.c
src/xeniface/ioctls.h
vs2012/xeniface/xeniface.vcxproj
vs2013/xeniface/xeniface.vcxproj

index 4f22bd6b0dcaef639de69a396c5a95741812cda0..857bf49f61b48fa3279775af6e721d83fdbb6660 100644 (file)
@@ -360,4 +360,13 @@ typedef struct _XENIFACE_SUSPEND_REGISTER_OUT {
 #define IOCTL_XENIFACE_SUSPEND_DEREGISTER \
     CTL_CODE(FILE_DEVICE_UNKNOWN, 0x832, METHOD_BUFFERED, FILE_ANY_ACCESS)
 
+/*! \brief Gets the current time.
+
+    Input: None
+
+    Output: LARGE_INTEGER
+*/
+#define IOCTL_XENIFACE_SHAREDINFO_GET_TIME \
+    CTL_CODE(FILE_DEVICE_UNKNOWN, 0x840, METHOD_BUFFERED, FILE_ANY_ACCESS)
+
 #endif // _XENIFACE_IOCTLS_H_
diff --git a/src/xeniface/ioctl_sharedinfo.c b/src/xeniface/ioctl_sharedinfo.c
new file mode 100644 (file)
index 0000000..c9dfe65
--- /dev/null
@@ -0,0 +1,68 @@
+/* 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.
+ */
+
+#include "driver.h"
+#include "ioctls.h"
+#include "xeniface_ioctls.h"
+#include "log.h"
+
+DECLSPEC_NOINLINE
+NTSTATUS
+IoctlSharedInfoGetTime(
+    __in  PXENIFACE_FDO     Fdo,
+    __in  PCHAR             Buffer,
+    __in  ULONG             InLen,
+    __in  ULONG             OutLen,
+    __out PULONG_PTR        Info
+    )
+{
+    NTSTATUS        status;
+    PLARGE_INTEGER  Value;
+
+    status = STATUS_INVALID_BUFFER_SIZE;
+    if (InLen != 0)
+        goto fail1;
+
+    if (OutLen != sizeof(LARGE_INTEGER))
+        goto fail2;
+
+    Value = (PLARGE_INTEGER)Buffer;
+    *Value = XENBUS_SHARED_INFO(GetTime, &Fdo->SharedInfoInterface); 
+    *Info = (ULONG_PTR)sizeof(LARGE_INTEGER);
+
+    return STATUS_SUCCESS;
+
+fail2:
+    XenIfaceDebugPrint(ERROR, "Fail2\n");
+fail1:
+    XenIfaceDebugPrint(ERROR, "Fail1 (%08x)\n", status);
+    return status;
+}
index 2df299cb596a96bc94cb126e3f7c5195b050437b..7092a56566cf39762089370987ffcaee5a7f5088 100644 (file)
@@ -257,6 +257,12 @@ XenIfaceIoctl(
         status = IoctlSuspendDeregister(Fdo, Buffer, InLen, OutLen, Stack->FileObject);
         break;
 
+        // sharedinfo
+    case IOCTL_XENIFACE_SHAREDINFO_GET_TIME:
+        status = IoctlSharedInfoGetTime(Fdo, Buffer, InLen, OutLen, &Irp->IoStatus.Information);
+        break;
+
+
     default:
         status = STATUS_INVALID_DEVICE_REQUEST;
         break;
index 7dd34ee02ceaf210772e95f9e8a124cc6fdfdba6..d06f6b524b229489e7945fcf6a335ac0685f1b9b 100644 (file)
@@ -409,5 +409,14 @@ SuspendFreeEvent(
     __inout  PXENIFACE_SUSPEND_CONTEXT Context
     );
 
+NTSTATUS
+IoctlSharedInfoGetTime(
+    __in  PXENIFACE_FDO     Fdo,
+    __in  PCHAR             Buffer,
+    __in  ULONG             InLen,
+    __in  ULONG             OutLen,
+    __out PULONG_PTR        Info
+    );
+
 #endif // _IOCTLS_H_
 
index ff70eb0d770301668c34f04d3c3391c5aa98d39b..bb344e4e3105f41f8c386cc56be096fb069a9c50 100644 (file)
@@ -79,6 +79,7 @@
                <ClCompile Include="..\..\src\xeniface\fdo.c" />
                <ClCompile Include="..\..\src\xeniface\registry.c" />
                <ClCompile Include="..\..\src\xeniface\thread.c" />
+               <ClCompile Include="..\..\src\xeniface\ioctl_sharedinfo.c" />
                <ClCompile Include="..\..\src\xeniface\ioctl_suspend.c" />
                <ClCompile Include="..\..\src\xeniface\ioctl_evtchn.c" />
                <ClCompile Include="..\..\src\xeniface\ioctl_gnttab.c" />
index 3a3a937e84f142f62cd90230f290e3d31463d753..c6232e412c1ac5eac4d397f6c6d6a5ad8d5d8f5c 100644 (file)
     <ClCompile Include="..\..\src\xeniface\fdo.c" />
     <ClCompile Include="..\..\src\xeniface\registry.c" />
     <ClCompile Include="..\..\src\xeniface\thread.c" />
+    <ClCompile Include="..\..\src\xeniface\ioctl_sharedinfo.c" />
     <ClCompile Include="..\..\src\xeniface\ioctl_suspend.c" />
     <ClCompile Include="..\..\src\xeniface\ioctl_evtchn.c" />
     <ClCompile Include="..\..\src\xeniface\ioctl_gnttab.c" />