win-pvdrivers

changeset 168:91ee03f3559a

Added some files I forgot
author James Harper <james.harper@bendigoit.com.au>
date Mon Feb 04 10:00:51 2008 +1100 (2008-02-04)
parents e21fa8b6df5b
children 30daf47ba4b4
files xenstub/sources xenstub/xenstub.c xenstub/xenstub.h xenstub/xenstub.inx
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/xenstub/sources	Mon Feb 04 10:00:51 2008 +1100
     1.3 @@ -0,0 +1,6 @@
     1.4 +!INCLUDE ..\common.inc
     1.5 +TARGETNAME=xenstub
     1.6 +TARGETTYPE=DRIVER
     1.7 +INF_NAME=$(TARGETNAME)
     1.8 +MISCFILES=..\Target\$(DDK_TARGET_OS)\$(INF_NAME).inf
     1.9 +SOURCES=xenstub.c
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/xenstub/xenstub.c	Mon Feb 04 10:00:51 2008 +1100
     2.3 @@ -0,0 +1,159 @@
     2.4 +/*
     2.5 +PV Drivers for Windows Xen HVM Domains
     2.6 +Copyright (C) 2007 James Harper
     2.7 +
     2.8 +This program is free software; you can redistribute it and/or
     2.9 +modify it under the terms of the GNU General Public License
    2.10 +as published by the Free Software Foundation; either version 2
    2.11 +of the License, or (at your option) any later version.
    2.12 +
    2.13 +This program is distributed in the hope that it will be useful,
    2.14 +but WITHOUT ANY WARRANTY; without even the implied warranty of
    2.15 +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    2.16 +GNU General Public License for more details.
    2.17 +
    2.18 +You should have received a copy of the GNU General Public License
    2.19 +along with this program; if not, write to the Free Software
    2.20 +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
    2.21 +*/
    2.22 +
    2.23 +#include "XenStub.h"
    2.24 +#include <stdlib.h>
    2.25 +
    2.26 +DRIVER_INITIALIZE DriverEntry;
    2.27 +static NTSTATUS
    2.28 +XenStub_AddDevice(WDFDRIVER Driver, PWDFDEVICE_INIT DeviceInit);
    2.29 +static NTSTATUS
    2.30 +XenStub_PrepareHardware(WDFDEVICE hDevice, WDFCMRESLIST Resources, WDFCMRESLIST ResourcesTranslated);
    2.31 +static NTSTATUS
    2.32 +XenStub_ReleaseHardware(WDFDEVICE Device, WDFCMRESLIST ResourcesTranslated);
    2.33 +static NTSTATUS
    2.34 +XenStub_D0Entry(WDFDEVICE Device, WDF_POWER_DEVICE_STATE PreviousState);
    2.35 +static NTSTATUS
    2.36 +XenStub_D0Exit(WDFDEVICE Device, WDF_POWER_DEVICE_STATE TargetState);
    2.37 +
    2.38 +#ifdef ALLOC_PRAGMA
    2.39 +#pragma alloc_text (INIT, DriverEntry)
    2.40 +#pragma alloc_text (PAGE, XenStub_AddDevice)
    2.41 +#endif
    2.42 +
    2.43 +#pragma warning(disable : 4200) // zero-sized array
    2.44 +
    2.45 +NTSTATUS
    2.46 +DriverEntry(PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath)
    2.47 +{
    2.48 +  WDF_DRIVER_CONFIG config;
    2.49 +  NTSTATUS status;
    2.50 +
    2.51 +  KdPrint((__DRIVER_NAME " --> DriverEntry\n"));
    2.52 +
    2.53 +  WDF_DRIVER_CONFIG_INIT(&config, XenStub_AddDevice);
    2.54 +  status = WdfDriverCreate(
    2.55 +    DriverObject,
    2.56 +    RegistryPath,
    2.57 +    WDF_NO_OBJECT_ATTRIBUTES,
    2.58 +    &config,
    2.59 +    WDF_NO_HANDLE);
    2.60 +  if(!NT_SUCCESS(status))
    2.61 +  {
    2.62 +    KdPrint((__DRIVER_NAME " WdfDriverCreate failed with status 0x%08x\n", status));
    2.63 +  }
    2.64 +
    2.65 +  KdPrint((__DRIVER_NAME " <-- DriverEntry\n"));
    2.66 +
    2.67 +  return status;
    2.68 +}
    2.69 +
    2.70 +static NTSTATUS
    2.71 +XenStub_AddDevice(
    2.72 +    IN WDFDRIVER Driver,
    2.73 +    IN PWDFDEVICE_INIT DeviceInit
    2.74 +    )
    2.75 +{
    2.76 +  NTSTATUS Status;
    2.77 +  WDF_OBJECT_ATTRIBUTES attributes;
    2.78 +  WDF_PNPPOWER_EVENT_CALLBACKS pnpPowerCallbacks;
    2.79 +  WDFDEVICE Device;
    2.80 +
    2.81 +  UNREFERENCED_PARAMETER(Driver);
    2.82 +
    2.83 +  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
    2.84 +
    2.85 +  WDF_PNPPOWER_EVENT_CALLBACKS_INIT(&pnpPowerCallbacks);
    2.86 +  pnpPowerCallbacks.EvtDevicePrepareHardware = XenStub_PrepareHardware;
    2.87 +  pnpPowerCallbacks.EvtDeviceReleaseHardware = XenStub_ReleaseHardware;
    2.88 +  pnpPowerCallbacks.EvtDeviceD0Entry = XenStub_D0Entry;
    2.89 +  pnpPowerCallbacks.EvtDeviceD0Exit = XenStub_D0Exit;
    2.90 +  WdfDeviceInitSetPnpPowerEventCallbacks(DeviceInit, &pnpPowerCallbacks);
    2.91 +
    2.92 +  WDF_OBJECT_ATTRIBUTES_INIT(&attributes);
    2.93 +
    2.94 +  Status = WdfDeviceCreate(&DeviceInit, &attributes, &Device);  
    2.95 +  if(!NT_SUCCESS(Status))
    2.96 +  {
    2.97 +    KdPrint((__DRIVER_NAME "     WdfDeviceCreate failed with Status 0x%08x\n", Status));
    2.98 +    return Status;
    2.99 +  }
   2.100 +
   2.101 +  KdPrint((__DRIVER_NAME " <-- DeviceAdd\n"));
   2.102 +  return Status;
   2.103 +}
   2.104 +
   2.105 +static NTSTATUS
   2.106 +XenStub_PrepareHardware(
   2.107 +  WDFDEVICE Device,
   2.108 +  WDFCMRESLIST ResourceList,
   2.109 +  WDFCMRESLIST ResourceListTranslated)
   2.110 +{
   2.111 +  UNREFERENCED_PARAMETER(Device);
   2.112 +  UNREFERENCED_PARAMETER(ResourceList);
   2.113 +  UNREFERENCED_PARAMETER(ResourceListTranslated);
   2.114 +
   2.115 +  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
   2.116 +
   2.117 +  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
   2.118 +
   2.119 +  return STATUS_SUCCESS;
   2.120 +}
   2.121 +
   2.122 +static NTSTATUS
   2.123 +XenStub_ReleaseHardware(WDFDEVICE Device, WDFCMRESLIST ResourcesTranslated)
   2.124 +{
   2.125 +  UNREFERENCED_PARAMETER(Device);
   2.126 +  UNREFERENCED_PARAMETER(ResourcesTranslated);
   2.127 +
   2.128 +  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
   2.129 +
   2.130 +  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
   2.131 +
   2.132 +  return STATUS_SUCCESS;
   2.133 +}
   2.134 +
   2.135 +static NTSTATUS
   2.136 +XenStub_D0Entry(
   2.137 +  WDFDEVICE Device,
   2.138 +  WDF_POWER_DEVICE_STATE PreviousState
   2.139 +  )
   2.140 +{
   2.141 +  UNREFERENCED_PARAMETER(Device);
   2.142 +  UNREFERENCED_PARAMETER(PreviousState);
   2.143 +
   2.144 +  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
   2.145 +
   2.146 +  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
   2.147 +
   2.148 +  return STATUS_SUCCESS;
   2.149 +}
   2.150 +
   2.151 +static NTSTATUS
   2.152 +XenStub_D0Exit(WDFDEVICE Device, WDF_POWER_DEVICE_STATE TargetState)
   2.153 +{
   2.154 +  UNREFERENCED_PARAMETER(Device);
   2.155 +  UNREFERENCED_PARAMETER(TargetState);
   2.156 +
   2.157 +  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
   2.158 +
   2.159 +  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
   2.160 +
   2.161 +  return STATUS_SUCCESS;
   2.162 +}
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/xenstub/xenstub.h	Mon Feb 04 10:00:51 2008 +1100
     3.3 @@ -0,0 +1,35 @@
     3.4 +/*
     3.5 +PV Drivers for Windows Xen HVM Domains
     3.6 +Copyright (C) 2007 James Harper
     3.7 +
     3.8 +This program is free software; you can redistribute it and/or
     3.9 +modify it under the terms of the GNU General Public License
    3.10 +as published by the Free Software Foundation; either version 2
    3.11 +of the License, or (at your option) any later version.
    3.12 +
    3.13 +This program is distributed in the hope that it will be useful,
    3.14 +but WITHOUT ANY WARRANTY; without even the implied warranty of
    3.15 +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    3.16 +GNU General Public License for more details.
    3.17 +
    3.18 +You should have received a copy of the GNU General Public License
    3.19 +along with this program; if not, write to the Free Software
    3.20 +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
    3.21 +*/
    3.22 +
    3.23 +#if !defined(_XENSTUB_H_)
    3.24 +#define _XENSTUB_H_
    3.25 +
    3.26 +#include <ntddk.h>
    3.27 +#include <wdm.h>
    3.28 +#include <wdf.h>
    3.29 +#include <initguid.h>
    3.30 +#include <wdmguid.h>
    3.31 +#include <errno.h>
    3.32 +#define NTSTRSAFE_LIB
    3.33 +#include <ntstrsafe.h>
    3.34 +#define __DRIVER_NAME "XenStub"
    3.35 +#include <xen_windows.h>
    3.36 +//#include <xen_public.h>
    3.37 +
    3.38 +#endif
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/xenstub/xenstub.inx	Mon Feb 04 10:00:51 2008 +1100
     4.3 @@ -0,0 +1,82 @@
     4.4 +[Version]
     4.5 +Signature="$WINDOWS NT$"
     4.6 +Class=System
     4.7 +ClassGuid={4D36E97D-E325-11CE-BFC1-08002BE10318}
     4.8 +Provider=%XenGplPv%
     4.9 +
    4.10 +[DestinationDirs]
    4.11 +DefaultDestDir = 12
    4.12 +ClassInstall32_CopyFiles=11
    4.13 +CoInstaller_CopyFiles = 11
    4.14 +
    4.15 +[ControlFlags]
    4.16 +ExcludeFromSelect=*
    4.17 +
    4.18 +[Manufacturer]
    4.19 +%XenGplPv%=XenGplPv,NTx86
    4.20 +%XenGplPv%=XenGplPv,NTamd64
    4.21 +
    4.22 +[XenGplPv.NTx86]
    4.23 +%XenStub.DRVDESC%=XenStub_Inst, XEN\CONSOLE
    4.24 +%XenStub.DRVDESC%=XenStub_Inst, XEN\VFB
    4.25 +
    4.26 +[XenGplPv.NTamd64]
    4.27 +%XenStub.DRVDESC%=XenStub_Inst, XEN\CONSOLE
    4.28 +%XenStub.DRVDESC%=XenStub_Inst, XEN\VFB
    4.29 +
    4.30 +[XenStub_Inst.NT]
    4.31 +CopyFiles=XenStub.CopyFiles
    4.32 +
    4.33 +[XenStub.CopyFiles]
    4.34 +XenStub.sys
    4.35 +
    4.36 +[SourceDisksFiles]
    4.37 +XenStub.sys=1
    4.38 +WdfCoinstaller01005.dll=1,,
    4.39 +
    4.40 +[SourceDisksNames.x86]
    4.41 +1 = %DISK_NAME%,,,\i386
    4.42 +
    4.43 +[SourceDisksNames.amd64]
    4.44 +1 = %DISK_NAME%,,,\amd64
    4.45 +
    4.46 +[XenStub_Inst.Services]
    4.47 +AddService=XenStub,2,XenStub_Service 
    4.48 +
    4.49 +[XenStub_Inst.NT.Services]
    4.50 +AddService=XenStub,2,XenStub_Service 
    4.51 +
    4.52 +[XenStub_Service]
    4.53 +DisplayName    = %XenStub.SVCDESC%                            
    4.54 +ServiceType    = 1
    4.55 +StartType      = 0
    4.56 +ErrorControl   = 1
    4.57 +LoadOrderGroup = WdfLoadGroup
    4.58 +ServiceBinary  = %12%\xenstub.sys                            
    4.59 +AddReg = XenStub_Service_AddReg
    4.60 +
    4.61 +[XenStub_Service_AddReg]
    4.62 +HKR,"Parameters\PnpInterface", "0", 0x00010001, 0x00000001
    4.63 +
    4.64 +[XenStub_Inst.NT.CoInstallers]
    4.65 +AddReg=CoInstaller_AddReg
    4.66 +CopyFiles=CoInstaller_CopyFiles
    4.67 +
    4.68 +[CoInstaller_CopyFiles]
    4.69 +WdfCoinstaller01005.dll,,,2
    4.70 +
    4.71 +[CoInstaller_AddReg]
    4.72 +HKR,,CoInstallers32,0x00010000, "WdfCoinstaller01005.dll,WdfCoInstaller"
    4.73 +
    4.74 +[XenStub_Inst.NT.Wdf]
    4.75 +KmdfService = XenStub, XenStub_wdfsect
    4.76 +
    4.77 +[XenStub_wdfsect]
    4.78 +KmdfLibraryVersion = 1.0
    4.79 +
    4.80 +[Strings]
    4.81 +XenGplPv = "Xen GPL PV Driver Developers"
    4.82 +ClassName = "Network Adapters"
    4.83 +XenStub.SVCDESC = "Xen Stub Device Driver"
    4.84 +XenStub.DRVDESC = "Xen Stub Device Driver"
    4.85 +DISK_NAME = "Xen Net Device Driver Install Disk"