[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[win-pv-devel] [PATCH 02/20] Add SHAREDINFO interface IOCTL



* GetTime : returns the Xen wallclock time

Signed-off-by: Owen Smith <owen.smith@xxxxxxxxxx>
---
 include/xeniface_ioctls.h        |  9 ++++++
 src/xeniface/ioctl_sharedinfo.c  | 70 ++++++++++++++++++++++++++++++++++++++++
 src/xeniface/ioctls.c            |  5 +++
 src/xeniface/ioctls.h            |  9 ++++++
 vs2012/xeniface/xeniface.vcxproj |  1 +
 vs2013/xeniface/xeniface.vcxproj |  1 +
 6 files changed, 95 insertions(+)
 create mode 100644 src/xeniface/ioctl_sharedinfo.c

diff --git a/include/xeniface_ioctls.h b/include/xeniface_ioctls.h
index dc53e6b..b2631f6 100644
--- a/include/xeniface_ioctls.h
+++ b/include/xeniface_ioctls.h
@@ -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
index 0000000..12452b2
--- /dev/null
+++ b/src/xeniface/ioctl_sharedinfo.c
@@ -0,0 +1,70 @@
+/* Copyright (c) Citrix Systems Inc.
+ * Copyright (c) Rafal Wojdyla <omeg@xxxxxxxxxxxxxxxxxxxxxx>
+ * 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);
+    status = STATUS_SUCCESS;
+
+    return status;
+
+fail2:
+    XenIfaceDebugPrint(ERROR, "Fail2\n");
+fail1:
+    XenIfaceDebugPrint(ERROR, "Fail1 (%08x)\n", status);
+    return status;
+}
diff --git a/src/xeniface/ioctls.c b/src/xeniface/ioctls.c
index c6d471d..928c2be 100644
--- a/src/xeniface/ioctls.c
+++ b/src/xeniface/ioctls.c
@@ -257,6 +257,11 @@ 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;
diff --git a/src/xeniface/ioctls.h b/src/xeniface/ioctls.h
index 005aea5..c1d7c0f 100644
--- a/src/xeniface/ioctls.h
+++ b/src/xeniface/ioctls.h
@@ -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_
 
diff --git a/vs2012/xeniface/xeniface.vcxproj b/vs2012/xeniface/xeniface.vcxproj
index aec3533..4010d82 100644
--- a/vs2012/xeniface/xeniface.vcxproj
+++ b/vs2012/xeniface/xeniface.vcxproj
@@ -83,6 +83,7 @@
                <ClCompile Include="..\..\src\xeniface\ioctl_gnttab.c" />
                <ClCompile Include="..\..\src\xeniface\ioctl_store.c" />
                <ClCompile Include="..\..\src\xeniface\ioctl_suspend.c" />
+               <ClCompile Include="..\..\src\xeniface\ioctl_sharedinfo.c" />
                <ClCompile Include="..\..\src\xeniface\irp_queue.c" />
        </ItemGroup>
         <ItemGroup>
diff --git a/vs2013/xeniface/xeniface.vcxproj b/vs2013/xeniface/xeniface.vcxproj
index b324d9c..9731a3b 100644
--- a/vs2013/xeniface/xeniface.vcxproj
+++ b/vs2013/xeniface/xeniface.vcxproj
@@ -135,6 +135,7 @@
     <ClCompile Include="..\..\src\xeniface\ioctl_gnttab.c" />
     <ClCompile Include="..\..\src\xeniface\ioctl_store.c" />
     <ClCompile Include="..\..\src\xeniface\ioctl_suspend.c" />
+    <ClCompile Include="..\..\src\xeniface\ioctl_sharedinfo.c" />
     <ClCompile Include="..\..\src\xeniface\irp_queue.c" />
   </ItemGroup>
   <ItemGroup>
-- 
1.9.4.msysgit.1


_______________________________________________
win-pv-devel mailing list
win-pv-devel@xxxxxxxxxxxxxxxxxxxx
http://lists.xenproject.org/cgi-bin/mailman/listinfo/win-pv-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.