changeset 3:2f7db4d23d13

Publishing the source code under the MIT license.
author Michal Necasek <mnecasek@yahoo.com>
date Mon, 28 Jul 2014 13:27:42 +0200
parents 1ac5a9d19fc6
children 18e52516e7e8
files boxv.c boxv.h boxv_io.h readme.txt videomp.c videomp.h vidmpdat.c
diffstat 7 files changed, 179 insertions(+), 24 deletions(-) [+]
line wrap: on
line diff
--- a/boxv.c	Tue Jul 22 00:06:03 2014 +0200
+++ b/boxv.c	Mon Jul 28 13:27:42 2014 +0200
@@ -1,3 +1,27 @@
+/*****************************************************************************
+
+Copyright (c) 2012  Michal Necasek
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+
+*****************************************************************************/
+
 #include "boxv.h"
 #include "boxv_io.h"
 
@@ -109,7 +133,7 @@
     v_byte          seq[5];         /* Sequencer registers. */
     v_byte          crtc[25];       /* CRTC registers. */
     v_byte          gctl[9];        /* Graphics controller registers. */
-    v_byte          atr[21];        /* Attribute registers. */        
+    v_byte          atr[21];        /* Attribute registers. */
 } v_vgaregs;
 
 /* A structure fully describing a graphics or text mode. */
@@ -119,7 +143,7 @@
     int             yres;           /* Vertical (Y) resolution. */
     int             bpp;            /* Bits per pixel. */
     int             ext;            /* Non-zero for extended modes. */
-    v_vgaregs      *vgaregs;       /* Contents of VGA registers. */ 
+    v_vgaregs      *vgaregs;       /* Contents of VGA registers. */
 } v_mode;
 
 v_vgaregs       vga_regs_ext = {
@@ -182,7 +206,7 @@
     NULL
 };
 
-/* Write a single value to an indexed register at a specified 
+/* Write a single value to an indexed register at a specified
  * index. Suitable for the CRTC or graphics controller.
  */
 static void vid_wridx( void *cx, int idx_reg, int idx, v_byte data )
@@ -201,7 +225,7 @@
         vid_wridx( cx, idx_reg, idx, data[idx] );   /* Write index/data. */
 }
 
-/* Program a sequence of bytes into the attribute controller, starting 
+/* Program a sequence of bytes into the attribute controller, starting
  * at index 0. Note: This function may not be interrupted by code which
  * also accesses the attribute controller.
  */
@@ -301,12 +325,12 @@
     vid_wridx( cx, VGA_SEQUENCER, VGA_SR_RESET, VGA_SR0_NORESET );
 
     /* Re-enable palette. */
-    vid_outb( cx, VGA_ATTR_W, 0x20 );               
+    vid_outb( cx, VGA_ATTR_W, 0x20 );
 
     return( 0 );
 }
 
-/* Set the requested mode (text or graphics). 
+/* Set the requested mode (text or graphics).
  * Returns non-zero value on failure.
  */
 int BOXV_mode_set( void *cx, int mode_no )
--- a/boxv.h	Tue Jul 22 00:06:03 2014 +0200
+++ b/boxv.h	Mon Jul 28 13:27:42 2014 +0200
@@ -1,3 +1,27 @@
+/*****************************************************************************
+
+Copyright (c) 2012  Michal Necasek
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+
+*****************************************************************************/
+
 /*
  * Public interface to the boxv library.
  */
--- a/boxv_io.h	Tue Jul 22 00:06:03 2014 +0200
+++ b/boxv_io.h	Mon Jul 28 13:27:42 2014 +0200
@@ -1,3 +1,26 @@
+/*****************************************************************************
+
+Copyright (c) 2012  Michal Necasek
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+
+*****************************************************************************/
 
 #include <miniport.h>
 #include <ntddvdeo.h>
@@ -11,14 +34,14 @@
 static void vid_outb( void *cx, unsigned port, unsigned val )
 {
     PHW_DEV_EXT     pExt = cx;
-    
+
     VideoPortWritePortUchar( pExt->IOAddrVGA + port, val );
 }
 
 static void vid_outw( void *cx, unsigned port, unsigned val )
 {
     PHW_DEV_EXT     pExt = cx;
-    
+
     VideoPortWritePortUshort( (PUSHORT)(pExt->IOAddrVGA + port), val );
 }
 
--- a/readme.txt	Tue Jul 22 00:06:03 2014 +0200
+++ b/readme.txt	Mon Jul 28 13:27:42 2014 +0200
@@ -37,3 +37,15 @@
 installation media is required and should be copied to the directory which
 contains the INF file. For Windows NT 4.0 and later, framebuf.dll
 is already preinstalled on the system.
+
+
+ Building
+
+ The miniport is designed to be built with Open Watcom C/C++ 1.9 or later.
+Windows has been tested as a build host, but it is likely that other host
+platforms can be used with minor changes.
+
+
+ Licensing
+
+ The source code is published under the MIT license.
--- a/videomp.c	Tue Jul 22 00:06:03 2014 +0200
+++ b/videomp.c	Mon Jul 28 13:27:42 2014 +0200
@@ -1,4 +1,28 @@
-/* 
+/*****************************************************************************
+
+Copyright (c) 2012  Michal Necasek
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+
+*****************************************************************************/
+
+/*
  * Windows NT Video Miniport for the VirtualBox/bochs/qemu SVGA adapter.
  * This miniport programs the hardware directly and does not use or require
  * the video BIOS or VBE.
@@ -89,7 +113,7 @@
         /* Horizontal resolution should be divisible by 8. */
         if( Mode->HorzRes % 8)
             break;
-        
+
         /* Validate memory requirements. */
         ulModeMem = vmpPitchByBpp( Mode->HorzRes, Mode->Bpp ) * Mode->VertRes;
         if( ulModeMem > FramebufLen )
@@ -100,7 +124,7 @@
     } while( 0 );
 }
 
-/* Determine whether the supported adapter is present. Note that this 
+/* Determine whether the supported adapter is present. Note that this
  * function is not allowed to change the state of the adapter!
  */
 VP_STATUS HwVidFindAdapter( PVOID HwDevExt, PVOID HwContext, PWSTR ArgumentString,
@@ -137,8 +161,8 @@
     }
 
     /* Sadly, VideoPortGetAccessRanges was not present in NT 3.1. There is no
-     * reasonably simple way to dynamically import port driver routines on 
-     * newer versions, so we'll just do without. 
+     * reasonably simple way to dynamically import port driver routines on
+     * newer versions, so we'll just do without.
      */
 #ifdef USE_GETACCESSRANGES
     /* If PCI is supported, query the bus for resource mappings. */
@@ -158,8 +182,8 @@
             accessRanges[1].RangeLength = pciAccessRanges[0].RangeLength;
         } else {
             /* On NT versions without PCI support, we won't even attempt this.
-             * So if we tried to query the PCI device and failed to find it, 
-             * it really isn't there and we have to give up. 
+             * So if we tried to query the PCI device and failed to find it,
+             * it really isn't there and we have to give up.
              */
             VideoDebugPrint( (1, "videomp: PCI adapter not found\n") );
             return( ERROR_DEV_NOT_EXIST );
@@ -174,7 +198,7 @@
      */
     if( PortVersion < VP_VER_W2K )
         accessRanges[0].RangeStart = RtlConvertUlongToLargeInteger( 0x1CC );
- 
+
     /* Check for a conflict in case someone else claimed our resources. */
     status = VideoPortVerifyAccessRanges( HwDevExt, NUM_ACCESS_RANGES, accessRanges );
     if( status != NO_ERROR ) {
@@ -205,7 +229,7 @@
 
     /* Attempt to claim and map the memory and I/O address ranges. */
     for( i = 0; i < NUM_ACCESS_RANGES; ++i, ++pVirtAddr ) {
-        *pVirtAddr = VideoPortGetDeviceBase( pExt, 
+        *pVirtAddr = VideoPortGetDeviceBase( pExt,
                                              accessRanges[i].RangeStart,
                                              accessRanges[i].RangeLength,
                                              accessRanges[i].RangeInIoSpace );
@@ -225,7 +249,7 @@
         return( ERROR_DEV_NOT_EXIST );
     }
 
-    /* We need to access VGA and other I/O ports. Fortunately the HAL doesn't 
+    /* We need to access VGA and other I/O ports. Fortunately the HAL doesn't
      * care at all how the I/O ports are or aren't mapped on x86 platforms.
      */
     pExt->IOAddrVGA = NULL;
@@ -385,7 +409,7 @@
     {
         PVIDEO_NUM_MODES        numModes;
 
-        VideoDebugPrint( (2, "QUERY_NUM_AVAIL_MODES\n") );        
+        VideoDebugPrint( (2, "QUERY_NUM_AVAIL_MODES\n") );
         if( ReqPkt->OutputBufferLength < sizeof( VIDEO_NUM_MODES ) ) {
             status = ERROR_INSUFFICIENT_BUFFER;
         } else {
@@ -424,7 +448,7 @@
         } else {
             ReqPkt->StatusBlock->Information = sizeof( VIDEO_MODE_INFORMATION );
             modeInfo  = ReqPkt->OutputBuffer;
-            vmpFillModeInfo( modeInfo, 
+            vmpFillModeInfo( modeInfo,
                              VideoModes[pExt->CurrentModeNumber].HorzRes,
                              VideoModes[pExt->CurrentModeNumber].VertRes,
                              VideoModes[pExt->CurrentModeNumber].Bpp );
@@ -444,7 +468,7 @@
             break;
         }
 
-        BOXV_ext_mode_set( pExt, VideoModes[modeNumber].HorzRes, 
+        BOXV_ext_mode_set( pExt, VideoModes[modeNumber].HorzRes,
                            VideoModes[modeNumber].VertRes, VideoModes[modeNumber].Bpp,
                            VideoModes[modeNumber].HorzRes, VideoModes[modeNumber].VertRes );
 
@@ -723,7 +747,7 @@
     /* Later NT versions support PCI; recent versions ignore this entirely */
     hwInitData.AdapterInterfaceType = PCIBus;
 
-    /* The PsGetVersion function was not available in NT 3.x. We therefore 
+    /* The PsGetVersion function was not available in NT 3.x. We therefore
      * implement a poor man's version detection by successively reducing the
      * HwInitDataSize until the video miniport (we hope) accepts it.
      */
--- a/videomp.h	Tue Jul 22 00:06:03 2014 +0200
+++ b/videomp.h	Mon Jul 28 13:27:42 2014 +0200
@@ -1,3 +1,27 @@
+/*****************************************************************************
+
+Copyright (c) 2012  Michal Necasek
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+
+*****************************************************************************/
+
 /*
  * Internal video miniport interfaces.
  */
--- a/vidmpdat.c	Tue Jul 22 00:06:03 2014 +0200
+++ b/vidmpdat.c	Mon Jul 28 13:27:42 2014 +0200
@@ -1,3 +1,27 @@
+/*****************************************************************************
+
+Copyright (c) 2012  Michal Necasek
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+
+*****************************************************************************/
+
 /*
  * Video miniport static data.
  */
@@ -36,8 +60,8 @@
 
 
 /* Table of supported modes. Note that the resolutions we can set are
- * quite arbitrary, but there's no point in reporting a massive list. 
- * All modes start out as unsupported and must be validated. 
+ * quite arbitrary, but there's no point in reporting a massive list.
+ * All modes start out as unsupported and must be validated.
  */
 VIDEOMP_MODE    VideoModes[] = {
     MODE_RES(  640,  480 ),