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

[win-pv-devel] [PATCH 03/14] Add IOCTLs to get Instance, Name and Protocol



From: Owen Smith <owen.smith@xxxxxxxxxx>

Hard code these values for the default console, the values
should be read from xenstore

Signed-off-by: Owen Smith <owen.smith@xxxxxxxxxx>
---
 include/xencons_device.h | 17 ++++++++++
 src/xencons/fdo.c        | 82 ++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 99 insertions(+)

diff --git a/include/xencons_device.h b/include/xencons_device.h
index eaf57d8..52f2671 100644
--- a/include/xencons_device.h
+++ b/include/xencons_device.h
@@ -36,4 +36,21 @@
 DEFINE_GUID(GUID_XENCONS_DEVICE,
             0xd3edd21, 0x8ef9, 0x4dff, 0x85, 0x6c, 0x8c, 0x68, 0xbf, 0x4f, 
0xdc, 0xa3);
 
+#define __IOCTL_XENCONS_BEGIN       0x800
+
+#define IOCTL_XENCONS_GET_INSTANCE  CTL_CODE(FILE_DEVICE_UNKNOWN,       \
+                                            __IOCTL_XENCONS_BEGIN + 0,  \
+                                            METHOD_BUFFERED,            \
+                                            FILE_ANY_ACCESS)
+
+#define IOCTL_XENCONS_GET_NAME      CTL_CODE(FILE_DEVICE_UNKNOWN,       \
+                                            __IOCTL_XENCONS_BEGIN + 1,  \
+                                            METHOD_BUFFERED,            \
+                                            FILE_ANY_ACCESS)
+
+#define IOCTL_XENCONS_GET_PROTOCOL  CTL_CODE(FILE_DEVICE_UNKNOWN,       \
+                                            __IOCTL_XENCONS_BEGIN + 2,  \
+                                            METHOD_BUFFERED,            \
+                                            FILE_ANY_ACCESS)
+
 #endif  // _XENCONS_DEVICE_H
diff --git a/src/xencons/fdo.c b/src/xencons/fdo.c
index 6a7f70c..8e72dc6 100644
--- a/src/xencons/fdo.c
+++ b/src/xencons/fdo.c
@@ -2194,6 +2194,84 @@ fail1:
 }
 
 static DECLSPEC_NOINLINE NTSTATUS
+FdoDispatchControl(
+    IN  PXENCONS_FDO    Fdo,
+    IN  PIRP            Irp
+    )
+{
+    PIO_STACK_LOCATION  StackLocation;
+    ULONG               IoControlCode;
+    ULONG               InputBufferLength;
+    ULONG               OutputBufferLength;
+    PVOID               Buffer;
+    PCHAR               Value;
+    ULONG               Length;
+    NTSTATUS            status;
+
+    UNREFERENCED_PARAMETER(Fdo);
+
+    StackLocation = IoGetCurrentIrpStackLocation(Irp);
+    IoControlCode = StackLocation->Parameters.DeviceIoControl.IoControlCode;
+    InputBufferLength = 
StackLocation->Parameters.DeviceIoControl.InputBufferLength;
+    OutputBufferLength = 
StackLocation->Parameters.DeviceIoControl.OutputBufferLength;
+    Buffer = Irp->AssociatedIrp.SystemBuffer;
+
+    switch (IoControlCode) {
+    case IOCTL_XENCONS_GET_INSTANCE:
+        Value = "0";
+        break;
+    case IOCTL_XENCONS_GET_NAME:
+        Value = "default";
+        break;
+    case IOCTL_XENCONS_GET_PROTOCOL:
+        Value = "vt100";
+        break;
+    default:
+        status = STATUS_NOT_SUPPORTED;
+        goto fail1;
+    }
+    Length = (ULONG)strlen(Value);
+
+    status = STATUS_INVALID_PARAMETER;
+    if (InputBufferLength != 0)
+        goto fail2;
+
+    Irp->IoStatus.Information = Length;
+
+    status = STATUS_INVALID_BUFFER_SIZE;
+    if (OutputBufferLength == 0)
+        goto done;
+
+    RtlZeroMemory(Buffer, OutputBufferLength);
+
+    if (OutputBufferLength < Length)
+        goto fail3;
+
+    RtlCopyMemory(Buffer, Value, Length);
+    status = STATUS_SUCCESS;
+
+done:
+    Irp->IoStatus.Status = status;
+    IoCompleteRequest(Irp, IO_NO_INCREMENT);
+
+    return status;
+
+fail3:
+    Error("fail3\n");
+
+fail2:
+    Error("fail2\n");
+
+fail1:
+    Error("fail1 (%08x)\n", status);
+
+    Irp->IoStatus.Status = status;
+    IoCompleteRequest(Irp, IO_NO_INCREMENT);
+
+    return status;
+}
+
+static DECLSPEC_NOINLINE NTSTATUS
 FdoDispatchDefault(
     IN  PXENCONS_FDO    Fdo,
     IN  PIRP            Irp
@@ -2250,6 +2328,10 @@ FdoDispatch(
         status = FdoDispatchReadWrite(Fdo, Irp);
         break;
 
+    case IRP_MJ_DEVICE_CONTROL:
+        status = FdoDispatchControl(Fdo, Irp);
+        break;
+
     default:
         status = FdoDispatchDefault(Fdo, Irp);
         break;
-- 
2.8.3


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

 


Rackspace

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