win-pvdrivers

annotate xenpci/xenpci_pdo.c @ 259:161a8a26f3db

Enumeration now working, but no useful info passed to child devices yet.
author James Harper <james.harper@bendigoit.com.au>
date Sun May 04 16:40:30 2008 +1000 (2008-05-04)
parents
children 952b8aa9c44c
rev   line source
james@259 1 /*
james@259 2 PV Drivers for Windows Xen HVM Domains
james@259 3 Copyright (C) 2007 James Harper
james@259 4
james@259 5 This program is free software; you can redistribute it and/or
james@259 6 modify it under the terms of the GNU General Public License
james@259 7 as published by the Free Software Foundation; either version 2
james@259 8 of the License, or (at your option) any later version.
james@259 9
james@259 10 This program is distributed in the hope that it will be useful,
james@259 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
james@259 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
james@259 13 GNU General Public License for more details.
james@259 14
james@259 15 You should have received a copy of the GNU General Public License
james@259 16 along with this program; if not, write to the Free Software
james@259 17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
james@259 18 */
james@259 19
james@259 20 #include "xenpci.h"
james@259 21 #include <stdlib.h>
james@259 22
james@259 23 #pragma warning(disable : 4200) // zero-sized array
james@259 24
james@259 25 NTSTATUS
james@259 26 XenPci_Power_Pdo(PDEVICE_OBJECT device_object, PIRP irp)
james@259 27 {
james@259 28 UNREFERENCED_PARAMETER(device_object);
james@259 29
james@259 30 KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
james@259 31
james@259 32 irp->IoStatus.Status = STATUS_NOT_SUPPORTED;
james@259 33 IoCompleteRequest(irp, IO_NO_INCREMENT);
james@259 34
james@259 35 KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
james@259 36
james@259 37 return irp->IoStatus.Status;
james@259 38 }
james@259 39
james@259 40 NTSTATUS
james@259 41 XenPci_Pnp_Pdo(PDEVICE_OBJECT device_object, PIRP irp)
james@259 42 {
james@259 43 NTSTATUS status;
james@259 44 PIO_STACK_LOCATION stack;
james@259 45 PXENPCI_PDO_DEVICE_DATA xppdd = (PXENPCI_PDO_DEVICE_DATA)device_object->DeviceExtension;
james@259 46 LPWSTR buffer;
james@259 47 WCHAR widebuf[256];
james@259 48 unsigned int i;
james@259 49
james@259 50 KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
james@259 51
james@259 52 stack = IoGetCurrentIrpStackLocation(irp);
james@259 53
james@259 54 switch (stack->MinorFunction)
james@259 55 {
james@259 56 case IRP_MN_START_DEVICE:
james@259 57 KdPrint((__DRIVER_NAME " IRP_MN_START_DEVICE\n"));
james@259 58 status = STATUS_SUCCESS;
james@259 59 break;
james@259 60
james@259 61 case IRP_MN_QUERY_STOP_DEVICE:
james@259 62 KdPrint((__DRIVER_NAME " IRP_MN_QUERY_STOP_DEVICE\n"));
james@259 63 status = STATUS_SUCCESS;
james@259 64 break;
james@259 65
james@259 66 case IRP_MN_STOP_DEVICE:
james@259 67 KdPrint((__DRIVER_NAME " IRP_MN_STOP_DEVICE\n"));
james@259 68 status = STATUS_SUCCESS;
james@259 69 break;
james@259 70
james@259 71 case IRP_MN_CANCEL_STOP_DEVICE:
james@259 72 KdPrint((__DRIVER_NAME " IRP_MN_CANCEL_STOP_DEVICE\n"));
james@259 73 status = STATUS_SUCCESS;
james@259 74 break;
james@259 75
james@259 76 case IRP_MN_QUERY_REMOVE_DEVICE:
james@259 77 KdPrint((__DRIVER_NAME " IRP_MN_QUERY_REMOVE_DEVICE\n"));
james@259 78 status = STATUS_SUCCESS;
james@259 79 break;
james@259 80
james@259 81 case IRP_MN_REMOVE_DEVICE:
james@259 82 KdPrint((__DRIVER_NAME " IRP_MN_REMOVE_DEVICE\n"));
james@259 83 status = STATUS_SUCCESS;
james@259 84 break;
james@259 85
james@259 86 case IRP_MN_CANCEL_REMOVE_DEVICE:
james@259 87 KdPrint((__DRIVER_NAME " IRP_MN_CANCEL_REMOVE_DEVICE\n"));
james@259 88 status = STATUS_SUCCESS;
james@259 89 break;
james@259 90
james@259 91 case IRP_MN_SURPRISE_REMOVAL:
james@259 92 KdPrint((__DRIVER_NAME " IRP_MN_SURPRISE_REMOVAL\n"));
james@259 93 status = STATUS_SUCCESS;
james@259 94 break;
james@259 95
james@259 96 case IRP_MN_DEVICE_USAGE_NOTIFICATION:
james@259 97 KdPrint((__DRIVER_NAME " IRP_MN_DEVICE_USAGE_NOTIFICATION\n"));
james@259 98 status = STATUS_SUCCESS;
james@259 99 break;
james@259 100
james@259 101 case IRP_MN_QUERY_DEVICE_RELATIONS:
james@259 102 KdPrint((__DRIVER_NAME " IRP_MN_QUERY_DEVICE_RELATIONS\n"));
james@259 103 status = STATUS_NOT_SUPPORTED;
james@259 104 break;
james@259 105
james@259 106 case IRP_MN_QUERY_ID:
james@259 107 KdPrint((__DRIVER_NAME " IRP_MN_QUERY_ID\n"));
james@259 108 switch (stack->Parameters.QueryId.IdType)
james@259 109 {
james@259 110 case BusQueryDeviceID: /* REG_SZ */
james@259 111 KdPrint((__DRIVER_NAME " BusQueryDeviceID\n"));
james@259 112 buffer = ExAllocatePoolWithTag(PagedPool, 512, XENPCI_POOL_TAG);
james@259 113 for (i = 0; i < strlen(xppdd->path); i++)
james@259 114 widebuf[i] = xppdd->path[i];
james@259 115 widebuf[i] = 0;
james@259 116 RtlStringCbPrintfW(buffer, 512, L"Xen\\%ws\0", widebuf);
james@259 117 KdPrint((__DRIVER_NAME " %ls\n", buffer));
james@259 118 irp->IoStatus.Information = (ULONG_PTR)buffer;
james@259 119 status = STATUS_SUCCESS;
james@259 120 break;
james@259 121 case BusQueryHardwareIDs: /* REG_MULTI_SZ */
james@259 122 KdPrint((__DRIVER_NAME " BusQueryHardwareIDs\n"));
james@259 123 buffer = ExAllocatePoolWithTag(PagedPool, 512, XENPCI_POOL_TAG);
james@259 124 for (i = 0; i < strlen(xppdd->path); i++)
james@259 125 widebuf[i] = xppdd->path[i];
james@259 126 widebuf[i] = 0;
james@259 127 RtlStringCbPrintfW(buffer, 512, L"Xen\\%ws\0", widebuf);
james@259 128 KdPrint((__DRIVER_NAME " %ls\n", buffer));
james@259 129 irp->IoStatus.Information = (ULONG_PTR)buffer;
james@259 130 status = STATUS_SUCCESS;
james@259 131 break;
james@259 132 case BusQueryCompatibleIDs: /* REG_MULTI_SZ */
james@259 133 KdPrint((__DRIVER_NAME " BusQueryCompatibleIDs\n"));
james@259 134 buffer = ExAllocatePoolWithTag(PagedPool, 512, XENPCI_POOL_TAG);
james@259 135 for (i = 0; i < strlen(xppdd->path); i++)
james@259 136 widebuf[i] = xppdd->path[i];
james@259 137 widebuf[i] = 0;
james@259 138 RtlStringCbPrintfW(buffer, 512, L"Xen\\%ws\0", widebuf);
james@259 139 KdPrint((__DRIVER_NAME " %ls\n", buffer));
james@259 140 irp->IoStatus.Information = (ULONG_PTR)buffer;
james@259 141 status = STATUS_SUCCESS;
james@259 142 break;
james@259 143 case BusQueryInstanceID: /* REG_SZ */
james@259 144 KdPrint((__DRIVER_NAME " BusQueryInstanceID\n"));
james@259 145 buffer = ExAllocatePoolWithTag(PagedPool, 512, XENPCI_POOL_TAG);
james@259 146 RtlStringCbPrintfW(buffer, 512, L"%02d", xppdd->index);
james@259 147 KdPrint((__DRIVER_NAME " %ls\n", buffer));
james@259 148 irp->IoStatus.Information = (ULONG_PTR)buffer;
james@259 149 status = STATUS_SUCCESS;
james@259 150 break;
james@259 151 default:
james@259 152 KdPrint((__DRIVER_NAME " Unhandled IdType = %d\n", stack->Parameters.QueryId.IdType));
james@259 153 irp->IoStatus.Information = 0;
james@259 154 status = STATUS_NOT_SUPPORTED;
james@259 155 break;
james@259 156 }
james@259 157 break;
james@259 158
james@259 159 case IRP_MN_QUERY_DEVICE_TEXT:
james@259 160 KdPrint((__DRIVER_NAME " IRP_MN_QUERY_DEVICE_TEXT\n"));
james@259 161 switch (stack->Parameters.QueryDeviceText.DeviceTextType)
james@259 162 {
james@259 163 case DeviceTextDescription:
james@259 164 KdPrint((__DRIVER_NAME " DeviceTextDescription\n"));
james@259 165 buffer = ExAllocatePoolWithTag(NonPagedPool, 512, XENPCI_POOL_TAG);
james@259 166 for (i = 0; i < strlen(xppdd->path); i++)
james@259 167 widebuf[i] = xppdd->path[i];
james@259 168 widebuf[i] = 0;
james@259 169 RtlStringCbPrintfW(buffer, 512, L"Xen %ws device #%d", widebuf, xppdd->index);
james@259 170 KdPrint((__DRIVER_NAME " %ls\n", buffer));
james@259 171 irp->IoStatus.Information = (ULONG_PTR)buffer;
james@259 172 status = STATUS_SUCCESS;
james@259 173 break;
james@259 174 case DeviceTextLocationInformation:
james@259 175 KdPrint((__DRIVER_NAME " DeviceTextLocationInformation\n"));
james@259 176 buffer = ExAllocatePoolWithTag(NonPagedPool, 512, XENPCI_POOL_TAG);
james@259 177 RtlStringCbPrintfW(buffer, 512, L"Xen Bus");
james@259 178 KdPrint((__DRIVER_NAME " %ls\n", buffer));
james@259 179 irp->IoStatus.Information = (ULONG_PTR)buffer;
james@259 180 status = STATUS_SUCCESS;
james@259 181 break;
james@259 182 default:
james@259 183 KdPrint((__DRIVER_NAME " Unhandled IdType = %d\n", stack->Parameters.QueryDeviceText.DeviceTextType));
james@259 184 irp->IoStatus.Information = 0;
james@259 185 status = STATUS_NOT_SUPPORTED;
james@259 186 break;
james@259 187 }
james@259 188 break;
james@259 189
james@259 190 default:
james@259 191 KdPrint((__DRIVER_NAME " Unhandled Minor = %d\n", stack->MinorFunction));
james@259 192 status = STATUS_NOT_SUPPORTED;
james@259 193 break;
james@259 194 }
james@259 195
james@259 196 irp->IoStatus.Status = status;
james@259 197 IoCompleteRequest(irp, IO_NO_INCREMENT);
james@259 198
james@259 199 KdPrint((__DRIVER_NAME " <-- " __FUNCTION__"\n"));
james@259 200
james@259 201 return status;
james@259 202 }