win-pvdrivers

view xenstub/xenstub.c @ 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
children 874c3640830e
line source
1 /*
2 PV Drivers for Windows Xen HVM Domains
3 Copyright (C) 2007 James Harper
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License
7 as published by the Free Software Foundation; either version 2
8 of the License, or (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 */
20 #include "XenStub.h"
21 #include <stdlib.h>
23 DRIVER_INITIALIZE DriverEntry;
24 static NTSTATUS
25 XenStub_AddDevice(WDFDRIVER Driver, PWDFDEVICE_INIT DeviceInit);
26 static NTSTATUS
27 XenStub_PrepareHardware(WDFDEVICE hDevice, WDFCMRESLIST Resources, WDFCMRESLIST ResourcesTranslated);
28 static NTSTATUS
29 XenStub_ReleaseHardware(WDFDEVICE Device, WDFCMRESLIST ResourcesTranslated);
30 static NTSTATUS
31 XenStub_D0Entry(WDFDEVICE Device, WDF_POWER_DEVICE_STATE PreviousState);
32 static NTSTATUS
33 XenStub_D0Exit(WDFDEVICE Device, WDF_POWER_DEVICE_STATE TargetState);
35 #ifdef ALLOC_PRAGMA
36 #pragma alloc_text (INIT, DriverEntry)
37 #pragma alloc_text (PAGE, XenStub_AddDevice)
38 #endif
40 #pragma warning(disable : 4200) // zero-sized array
42 NTSTATUS
43 DriverEntry(PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath)
44 {
45 WDF_DRIVER_CONFIG config;
46 NTSTATUS status;
48 KdPrint((__DRIVER_NAME " --> DriverEntry\n"));
50 WDF_DRIVER_CONFIG_INIT(&config, XenStub_AddDevice);
51 status = WdfDriverCreate(
52 DriverObject,
53 RegistryPath,
54 WDF_NO_OBJECT_ATTRIBUTES,
55 &config,
56 WDF_NO_HANDLE);
57 if(!NT_SUCCESS(status))
58 {
59 KdPrint((__DRIVER_NAME " WdfDriverCreate failed with status 0x%08x\n", status));
60 }
62 KdPrint((__DRIVER_NAME " <-- DriverEntry\n"));
64 return status;
65 }
67 static NTSTATUS
68 XenStub_AddDevice(
69 IN WDFDRIVER Driver,
70 IN PWDFDEVICE_INIT DeviceInit
71 )
72 {
73 NTSTATUS Status;
74 WDF_OBJECT_ATTRIBUTES attributes;
75 WDF_PNPPOWER_EVENT_CALLBACKS pnpPowerCallbacks;
76 WDFDEVICE Device;
78 UNREFERENCED_PARAMETER(Driver);
80 KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
82 WDF_PNPPOWER_EVENT_CALLBACKS_INIT(&pnpPowerCallbacks);
83 pnpPowerCallbacks.EvtDevicePrepareHardware = XenStub_PrepareHardware;
84 pnpPowerCallbacks.EvtDeviceReleaseHardware = XenStub_ReleaseHardware;
85 pnpPowerCallbacks.EvtDeviceD0Entry = XenStub_D0Entry;
86 pnpPowerCallbacks.EvtDeviceD0Exit = XenStub_D0Exit;
87 WdfDeviceInitSetPnpPowerEventCallbacks(DeviceInit, &pnpPowerCallbacks);
89 WDF_OBJECT_ATTRIBUTES_INIT(&attributes);
91 Status = WdfDeviceCreate(&DeviceInit, &attributes, &Device);
92 if(!NT_SUCCESS(Status))
93 {
94 KdPrint((__DRIVER_NAME " WdfDeviceCreate failed with Status 0x%08x\n", Status));
95 return Status;
96 }
98 KdPrint((__DRIVER_NAME " <-- DeviceAdd\n"));
99 return Status;
100 }
102 static NTSTATUS
103 XenStub_PrepareHardware(
104 WDFDEVICE Device,
105 WDFCMRESLIST ResourceList,
106 WDFCMRESLIST ResourceListTranslated)
107 {
108 UNREFERENCED_PARAMETER(Device);
109 UNREFERENCED_PARAMETER(ResourceList);
110 UNREFERENCED_PARAMETER(ResourceListTranslated);
112 KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
114 KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
116 return STATUS_SUCCESS;
117 }
119 static NTSTATUS
120 XenStub_ReleaseHardware(WDFDEVICE Device, WDFCMRESLIST ResourcesTranslated)
121 {
122 UNREFERENCED_PARAMETER(Device);
123 UNREFERENCED_PARAMETER(ResourcesTranslated);
125 KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
127 KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
129 return STATUS_SUCCESS;
130 }
132 static NTSTATUS
133 XenStub_D0Entry(
134 WDFDEVICE Device,
135 WDF_POWER_DEVICE_STATE PreviousState
136 )
137 {
138 UNREFERENCED_PARAMETER(Device);
139 UNREFERENCED_PARAMETER(PreviousState);
141 KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
143 KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
145 return STATUS_SUCCESS;
146 }
148 static NTSTATUS
149 XenStub_D0Exit(WDFDEVICE Device, WDF_POWER_DEVICE_STATE TargetState)
150 {
151 UNREFERENCED_PARAMETER(Device);
152 UNREFERENCED_PARAMETER(TargetState);
154 KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
156 KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
158 return STATUS_SUCCESS;
159 }