[VMX_SVGA]: Begin implementation of VMWARE SVGA-II Video Card Driver.
authorSir Richard <sir_richard@svn.reactos.org>
Wed, 3 Feb 2010 17:47:41 +0000 (17:47 +0000)
committerSir Richard <sir_richard@svn.reactos.org>
Wed, 3 Feb 2010 17:47:41 +0000 (17:47 +0000)
svn path=/trunk/; revision=45396

reactos/drivers/video/miniport/directory.rbuild
reactos/drivers/video/miniport/vmx_svga/precomp.h [new file with mode: 0644]
reactos/drivers/video/miniport/vmx_svga/vmx_regs.h [new file with mode: 0644]
reactos/drivers/video/miniport/vmx_svga/vmx_svga.c [new file with mode: 0644]
reactos/drivers/video/miniport/vmx_svga/vmx_svga.rbuild [new file with mode: 0644]
reactos/drivers/video/miniport/vmx_svga/vmx_svga.rc [new file with mode: 0644]

index 9b4eb01..2575e1a 100644 (file)
@@ -7,6 +7,9 @@
        <directory name="vga">
                <xi:include href="vga/vgamp.rbuild" />
        </directory>
+       <directory name="vmx_svga">
+               <xi:include href="vmx_svga/vmx_svga.rbuild" />
+       </directory>
        <directory name="xboxvmp">
                <xi:include href="xboxvmp/xboxvmp.rbuild" />
        </directory>
diff --git a/reactos/drivers/video/miniport/vmx_svga/precomp.h b/reactos/drivers/video/miniport/vmx_svga/precomp.h
new file mode 100644 (file)
index 0000000..245d901
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * PROJECT:         ReactOS Boot Loader
+ * LICENSE:         BSD - See COPYING.ARM in the top level directory
+ * FILE:            drivers/video/miniport/vmx_svga/precomp.h
+ * PURPOSE:         VMWARE SVGA-II Driver Header
+ * PROGRAMMERS:     ReactOS Portable Systems Group
+ */
+#include <ntddk.h>
+#include <dderror.h>
+#include <miniport.h>
+#include <ntddvdeo.h>
+#include <video.h>
+#include "vmx_regs.h"
+
+typedef struct _HW_DEVICE_EXTENSION
+{
+    USHORT Version;
+    PHYSICAL_ADDRESS FrameBuffer;
+    LARGE_INTEGER VramSize;
+    PHYSICAL_ADDRESS VramBase;
+    ULONG MemSize;
+    ULONG IndexPort;
+    ULONG ValuePort;
+    PVOID FrameBufferBase;
+    PVOID Fifo;
+    ULONG InterruptPort;
+    ULONG InterruptState;
+    PKEVENT SyncEvent;
+    VIDEO_MODE_INFORMATION CurrentMode;
+    ULONG VideoModeCount;
+    ULONG Capabilities;
+    USHORT Flags;
+    USHORT DisplayIndex;
+    ULONG YOrigin;
+    ULONG XOrigin;
+} HW_DEVICE_EXTENSION, *PHW_DEVICE_EXTENSION;
diff --git a/reactos/drivers/video/miniport/vmx_svga/vmx_regs.h b/reactos/drivers/video/miniport/vmx_svga/vmx_regs.h
new file mode 100644 (file)
index 0000000..9fb2bd4
--- /dev/null
@@ -0,0 +1,130 @@
+/*
+ * PROJECT:         ReactOS Boot Loader
+ * LICENSE:         BSD - See COPYING.ARM in the top level directory
+ * FILE:            drivers/video/miniport/vmx_svga/vmware.h
+ * PURPOSE:         VMWARE SVGA-II Card Registers and Definitions
+ * PROGRAMMERS:     ReactOS Portable Systems Group
+ */
+
+//
+// IT'S OVER 9000 THOUSAND!!!!!!!!!!
+//
+#define SVGA_MAGIC                  0x900000
+
+//
+// Known VMWARE SVGA Versions
+//
+#define SVGA_VERSION_2              2
+#define SVGA_VERSION_1              1
+#define SVGA_VERSION_0              0
+
+//
+// Known VMWARE SVGA IDs
+//
+#define SVGA_MAKE_ID(x)             (SVGA_MAGIC << 8 | (x))
+#define SVGA_ID_2                   SVGA_MAKE_ID(SVGA_VERSION_2)
+#define SVGA_ID_1                   SVGA_MAKE_ID(SVGA_VERSION_1)
+#define SVGA_ID_0                   SVGA_MAKE_ID(SVGA_VERSION_0)
+#define SVGA_ID_INVALID             0xFFFFFFFF
+
+//
+// Card Capabilities
+//
+#define SVGA_CAP_NONE               0x00000000
+#define SVGA_CAP_RECT_FILL             0x00000001
+#define SVGA_CAP_RECT_COPY             0x00000002
+#define SVGA_CAP_RECT_PAT_FILL      0x00000004
+#define SVGA_CAP_LEGACY_OFFSCREEN   0x00000008
+#define SVGA_CAP_RASTER_OP             0x00000010
+#define SVGA_CAP_CURSOR                        0x00000020
+#define SVGA_CAP_CURSOR_BYPASS     0x00000040
+#define SVGA_CAP_CURSOR_BYPASS_2    0x00000080
+#define SVGA_CAP_8BIT_EMULATION     0x00000100
+#define SVGA_CAP_ALPHA_CURSOR       0x00000200
+#define SVGA_CAP_GLYPH              0x00000400
+#define SVGA_CAP_GLYPH_CLIPPING     0x00000800
+#define SVGA_CAP_OFFSCREEN_1        0x00001000
+#define SVGA_CAP_ALPHA_BLEND        0x00002000
+#define SVGA_CAP_3D                 0x00004000
+#define SVGA_CAP_EXTENDED_FIFO      0x00008000
+#define SVGA_CAP_MULTIMON           0x00010000
+#define SVGA_CAP_PITCHLOCK          0x00020000
+#define SVGA_CAP_IRQMASK            0x00040000
+#define SVGA_CAP_DISPLAY_TOPOLOGY   0x00080000
+
+//
+// Port Offsets and Base in PCI Space
+//
+#define SVGA_LEGACY_BASE_PORT      0x4560
+#define SVGA_INDEX_PORT                        0x0
+#define SVGA_VALUE_PORT                        0x1
+#define SVGA_BIOS_PORT                 0x2
+#define SVGA_NUM_PORTS                 0x3
+#define SVGA_IRQSTATUS_PORT            0x8
+
+//
+// Invalid display ID
+//
+#define SVGA_INVALID_DISPLAY_ID     0xFFFFFFFF
+
+//
+// Global Maximums
+//
+#define SVGA_MAX_BITS_PER_PIXEL            32
+#define SVGA_MAX_DEPTH              24
+#define SVGA_MAX_DISPLAYS           10
+#define SVGA_MAX_PSEUDOCOLOR_DEPTH     8
+#define SVGA_MAX_PSEUDOCOLORS          (1 << SVGA_MAX_PSEUDOCOLOR_DEPTH)
+#define SVGA_NUM_PALETTE_REGS       (3 * SVGA_MAX_PSEUDOCOLORS)
+#define SVGA_FB_MAX_SIZE                                                    \
+   ((((SVGA_MAX_WIDTH * SVGA_MAX_HEIGHT *                                   \
+       SVGA_MAX_BITS_PER_PIXEL / 8) >> PAGE_SHIFT) + 1) << PAGE_SHIFT)
+
+//
+// Card Registers
+//
+typedef enum _VMX_SVGA_REGISTERS
+{
+    SVGA_REG_ID,
+    SVGA_REG_ENABLE,
+    SVGA_REG_WIDTH,
+    SVGA_REG_HEIGHT,
+    SVGA_REG_MAX_WIDTH,
+    SVGA_REG_MAX_HEIGHT,
+    SVGA_REG_DEPTH,
+    SVGA_REG_BITS_PER_PIXEL,
+    SVGA_REG_PSEUDOCOLOR,
+    SVGA_REG_RED_MASK,
+    SVGA_REG_GREEN_MASK,
+    SVGA_REG_BLUE_MASK,
+    SVGA_REG_BYTES_PER_LINE,
+    SVGA_REG_FB_START,
+    SVGA_REG_FB_OFFSET,
+    SVGA_REG_VRAM_SIZE,
+    SVGA_REG_FB_SIZE,
+    SVGA_REG_CAPABILITIES,
+    SVGA_REG_MEM_START,
+    SVGA_REG_MEM_SIZE,
+    SVGA_REG_CONFIG_DONE,
+    SVGA_REG_SYNC,
+    SVGA_REG_BUSY,
+    SVGA_REG_GUEST_ID,
+    SVGA_REG_CURSOR_ID,
+    SVGA_REG_CURSOR_X,
+    SVGA_REG_CURSOR_Y,
+    SVGA_REG_CURSOR_ON,
+    SVGA_REG_HOST_BITS_PER_PIXEL,
+    SVGA_REG_SCRATCH_SIZE,
+    SVGA_REG_MEM_REGS,
+    SVGA_REG_NUM_DISPLAYS,
+    SVGA_REG_PITCHLOCK,
+    SVGA_REG_IRQMASK,
+    SVGA_REG_NUM_GUEST_DISPLAYS,
+    SVGA_REG_DISPLAY_ID,
+    SVGA_REG_DISPLAY_IS_PRIMARY,
+    SVGA_REG_DISPLAY_POSITION_X,
+    SVGA_REG_DISPLAY_POSITION_Y,
+    SVGA_REG_DISPLAY_WIDTH,
+    SVGA_REG_DISPLAY_HEIGHT,
+    SVGA_REG_TOP,
+} VMX_SVGA_REGISTERS;
diff --git a/reactos/drivers/video/miniport/vmx_svga/vmx_svga.c b/reactos/drivers/video/miniport/vmx_svga/vmx_svga.c
new file mode 100644 (file)
index 0000000..ca5cab4
--- /dev/null
@@ -0,0 +1,117 @@
+/*
+ * PROJECT:         ReactOS Boot Loader
+ * LICENSE:         BSD - See COPYING.ARM in the top level directory
+ * FILE:            drivers/video/miniport/vmx_svga/vmx_svga.c
+ * PURPOSE:         VMWARE SVGA-II Card Main Driver File
+ * PROGRAMMERS:     ReactOS Portable Systems Group
+ */
+
+/* INCLUDES *******************************************************************/
+
+#include "precomp.h"
+
+/* GLOBALS ********************************************************************/
+
+PHW_DEVICE_EXTENSION VmxDeviceExtensionArray[SVGA_MAX_DISPLAYS];
+
+/* FUNCTIONS ******************************************************************/
+
+VP_STATUS
+NTAPI
+VmxFindAdapter(IN PVOID HwDeviceExtension,
+               IN PVOID HwContext,
+               IN PWSTR ArgumentString,
+               IN OUT PVIDEO_PORT_CONFIG_INFO ConfigInfo,
+               OUT PUCHAR Again)
+{
+    return NO_ERROR;
+}
+
+BOOLEAN
+NTAPI
+VmxInitialize(IN PVOID HwDeviceExtension)
+{
+    return TRUE;
+}
+
+BOOLEAN
+NTAPI
+VmxStartIO(IN PVOID HwDeviceExtension,
+           IN PVIDEO_REQUEST_PACKET RequestPacket)
+{
+    return TRUE;
+}
+
+BOOLEAN
+NTAPI
+VmxResetHw(IN PVOID DeviceExtension,
+           IN ULONG Columns,
+           IN ULONG Rows)
+{
+    return FALSE;
+}
+
+VP_STATUS
+NTAPI
+VmxGetPowerState(IN PVOID HwDeviceExtension,
+                 IN ULONG HwId,
+                 IN PVIDEO_POWER_MANAGEMENT VideoPowerControl)
+{
+    return NO_ERROR;
+}
+
+VP_STATUS
+NTAPI
+VmxSetPowerState(IN PVOID HwDeviceExtension,
+                 IN ULONG HwId,
+                 IN PVIDEO_POWER_MANAGEMENT VideoPowerControl)
+{
+
+   return NO_ERROR;
+}
+
+BOOLEAN
+NTAPI
+VmxInterrupt(IN PVOID HwDeviceExtension)
+{
+    return TRUE;
+}
+
+VP_STATUS
+NTAPI
+VmxGetVideoChildDescriptor(IN PVOID HwDeviceExtension,
+                           IN PVIDEO_CHILD_ENUM_INFO ChildEnumInfo,
+                           OUT PVIDEO_CHILD_TYPE VideoChildType,
+                           OUT PUCHAR pChildDescriptor,
+                           OUT PULONG UId,
+                           OUT PULONG pUnused)
+{
+    return NO_ERROR;
+}
+
+VP_STATUS
+NTAPI
+DriverEntry(IN PVOID Context1,
+            IN PVOID Context2)
+{
+    VIDEO_HW_INITIALIZATION_DATA InitData;
+
+    /* Zero initialization structure and array of extensions, one per screen */
+    VideoPortZeroMemory(VmxDeviceExtensionArray, sizeof(VmxDeviceExtensionArray));
+    VideoPortZeroMemory(&InitData, sizeof(InitData));
+    
+    /* Setup the initialization structure with VideoPort */
+    InitData.HwInitDataSize = sizeof(VIDEO_HW_INITIALIZATION_DATA);
+    InitData.HwFindAdapter = VmxFindAdapter;
+    InitData.HwInitialize = VmxInitialize;
+    InitData.HwInterrupt = VmxInterrupt;
+    InitData.HwStartIO = VmxStartIO;
+    InitData.HwResetHw = VmxResetHw;
+    InitData.HwGetPowerState = VmxGetPowerState;
+    InitData.HwSetPowerState = VmxSetPowerState;
+    InitData.HwGetVideoChildDescriptor = VmxGetVideoChildDescriptor;
+    InitData.AdapterInterfaceType = PCIBus;
+    InitData.HwInitDataSize = sizeof(VIDEO_HW_INITIALIZATION_DATA);
+    InitData.HwDeviceExtensionSize = sizeof(HW_DEVICE_EXTENSION);
+    return VideoPortInitialize(Context1, Context2, &InitData, NULL);
+}
diff --git a/reactos/drivers/video/miniport/vmx_svga/vmx_svga.rbuild b/reactos/drivers/video/miniport/vmx_svga/vmx_svga.rbuild
new file mode 100644 (file)
index 0000000..2c03c8e
--- /dev/null
@@ -0,0 +1,9 @@
+<?xml version="1.0"?>
+<!DOCTYPE module SYSTEM "../../../../tools/rbuild/project.dtd">
+<module name="vmx_svga" type="kernelmodedriver" installbase="system32/drivers" installname="vmx_svga.sys">
+       <include base="vmx_svga">.</include>
+       <library>videoprt</library>
+       <file>vmx_svga.c</file>
+       <file>vmx_svga.rc</file>
+       <pch>precomp.h</pch>
+</module>
diff --git a/reactos/drivers/video/miniport/vmx_svga/vmx_svga.rc b/reactos/drivers/video/miniport/vmx_svga/vmx_svga.rc
new file mode 100644 (file)
index 0000000..b474b39
--- /dev/null
@@ -0,0 +1,5 @@
+#define REACTOS_VERSION_DLL
+#define REACTOS_STR_FILE_DESCRIPTION   "VMWARE SVGA-II Miniport Device Driver\0"
+#define REACTOS_STR_INTERNAL_NAME          "vmx_svga\0"
+#define REACTOS_STR_ORIGINAL_FILENAME  "vmx_svga.sys\0"
+#include <reactos/version.rc>