3 modified files
reactos/drivers/video/videoprt
diff -u -r1.1.2.6 -r1.1.2.7
--- dispatch.c 15 Mar 2004 20:21:50 -0000 1.1.2.6
+++ dispatch.c 16 Mar 2004 20:36:54 -0000 1.1.2.7
@@ -18,7 +18,7 @@
* If not, write to the Free Software Foundation,
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
- * $Id: dispatch.c,v 1.1.2.6 2004/03/15 20:21:50 navaraf Exp $
+ * $Id: dispatch.c,v 1.1.2.7 2004/03/16 20:36:54 navaraf Exp $
*/
#include "videoprt.h"
@@ -138,6 +138,17 @@
ConfigInfo.AdapterInterfaceType =
DriverExtension->InitializationData.AdapterInterfaceType;
+ if (PhysicalDeviceObject != NULL)
+ {
+ Size = sizeof(ULONG);
+ IoGetDeviceProperty(
+ PhysicalDeviceObject,
+ DevicePropertyLegacyBusType,
+ Size,
+ &ConfigInfo.AdapterInterfaceType,
+ &Size);
+ }
+
if (ConfigInfo.AdapterInterfaceType == PCIBus)
ConfigInfo.InterruptMode = LevelSensitive;
else
@@ -147,13 +158,16 @@
ConfigInfo.VideoPortGetProcAddress = VideoPortGetProcAddress;
/* Get bus number from the upper level bus driver. */
- Size = sizeof(ULONG);
- IoGetDeviceProperty(
- PhysicalDeviceObject,
- DevicePropertyBusNumber,
- Size,
- &ConfigInfo.SystemIoBusNumber,
- &Size);
+ if (PhysicalDeviceObject != NULL)
+ {
+ Size = sizeof(ULONG);
+ IoGetDeviceProperty(
+ PhysicalDeviceObject,
+ DevicePropertyBusNumber,
+ Size,
+ &ConfigInfo.SystemIoBusNumber,
+ &Size);
+ }
Size = sizeof(SystemBasicInfo);
Status = ZwQuerySystemInformation(
@@ -211,17 +225,19 @@
DeviceExtension->PhysicalDeviceObject = PhysicalDeviceObject;
DeviceExtension->FunctionalDeviceObject = DeviceObject;
DeviceExtension->SystemIoBusNumber = ConfigInfo.SystemIoBusNumber;
- DeviceExtension->AdapterInterfaceType =
- DriverExtension->InitializationData.AdapterInterfaceType;
+ DeviceExtension->AdapterInterfaceType = ConfigInfo.AdapterInterfaceType;
/* Get bus device address from the upper level bus driver. */
- Size = sizeof(ULONG);
- IoGetDeviceProperty(
- PhysicalDeviceObject,
- DevicePropertyAddress,
- Size,
- &DeviceExtension->SystemIoSlotNumber,
- &Size);
+ if (PhysicalDeviceObject != NULL)
+ {
+ Size = sizeof(ULONG);
+ IoGetDeviceProperty(
+ PhysicalDeviceObject,
+ DevicePropertyAddress,
+ Size,
+ &DeviceExtension->SystemIoSlotNumber,
+ &Size);
+ }
InitializeListHead(&DeviceExtension->AddressMappingListHead);
KeInitializeDpc(
@@ -244,13 +260,56 @@
* particular device is present.
*/
- /* FIXME: Need to figure out what string to pass as param 3. */
- Status = DriverExtension->InitializationData.HwFindAdapter(
- &DeviceExtension->MiniPortDeviceExtension,
- DriverExtension->HwContext,
- NULL,
- &ConfigInfo,
- &Again);
+ if (PhysicalDeviceObject == NULL)
+ {
+ /*
+ * Legacy detection method: Try all available buses.
+ */
+
+ ULONG BusNumber, MaxBuses;
+
+ MaxBuses = DeviceExtension->AdapterInterfaceType == PCIBus ? 8 : 1;
+
+ for (BusNumber = 0; BusNumber < MaxBuses; BusNumber++)
+ {
+ DeviceExtension->SystemIoBusNumber =
+ ConfigInfo.SystemIoBusNumber = BusNumber;
+
+ /* FIXME: Need to figure out what string to pass as param 3. */
+ Status = DriverExtension->InitializationData.HwFindAdapter(
+ &DeviceExtension->MiniPortDeviceExtension,
+ DriverExtension->HwContext,
+ NULL,
+ &ConfigInfo,
+ &Again);
+
+ if (Status == ERROR_DEV_NOT_EXIST)
+ {
+ continue;
+ }
+ else if (Status == NO_ERROR)
+ {
+ break;
+ }
+ else
+ {
+ DPRINT("HwFindAdapter call failed with error %X\n", Status);
+ IoDeleteDevice(DeviceObject);
+
+ return Status;
+ }
+ }
+ }
+ else
+ {
+ /* FIXME: Need to figure out what string to pass as param 3. */
+ Status = DriverExtension->InitializationData.HwFindAdapter(
+ &DeviceExtension->MiniPortDeviceExtension,
+ DriverExtension->HwContext,
+ NULL,
+ &ConfigInfo,
+ &Again);
+ }
if (Status != NO_ERROR)
{
@@ -358,7 +417,8 @@
}
}
- IoAttachDeviceToDeviceStack(DeviceObject, PhysicalDeviceObject);
+ if (PhysicalDeviceObject != NULL)
+ IoAttachDeviceToDeviceStack(DeviceObject, PhysicalDeviceObject);
return STATUS_SUCCESS;
}
reactos/drivers/video/videoprt
diff -u -r1.1.2.2 -r1.1.2.3
--- resource.c 15 Mar 2004 17:02:14 -0000 1.1.2.2
+++ resource.c 16 Mar 2004 20:36:54 -0000 1.1.2.3
@@ -18,7 +18,7 @@
* If not, write to the Free Software Foundation,
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
- * $Id: resource.c,v 1.1.2.2 2004/03/15 17:02:14 navaraf Exp $
+ * $Id: resource.c,v 1.1.2.3 2004/03/16 20:36:54 navaraf Exp $
*/
#include "videoprt.h"
@@ -314,7 +314,10 @@
{
VendorIdToFind = VendorId != NULL ? *(PUSHORT)VendorId : 0;
DeviceIdToFind = DeviceId != NULL ? *(PUSHORT)DeviceId : 0;
- SlotIdToFind = Slot != NULL ? *Slot : DeviceExtension->SystemIoSlotNumber;
+ if (DeviceExtension->PhysicalDeviceObject != NULL)
+ SlotIdToFind = DeviceExtension->SystemIoSlotNumber;
+ else
+ SlotIdToFind = Slot != NULL ? *Slot : 0;
DPRINT("Looking for VendorId 0x%04x DeviceId 0x%04x SlotId 0x%04x\n",
VendorIdToFind, DeviceIdToFind, SlotIdToFind);
@@ -567,3 +570,73 @@
/* Should store the ranges in the device extension for use by ntvdm. */
return NO_ERROR;
}
+
+/*
+ * @implemented
+ */
+
+ULONG STDCALL
+VideoPortGetBusData(
+ IN PVOID HwDeviceExtension,
+ IN BUS_DATA_TYPE BusDataType,
+ IN ULONG SlotNumber,
+ OUT PVOID Buffer,
+ IN ULONG Offset,
+ IN ULONG Length)
+{
+ PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
+
+ DPRINT("VideoPortGetBusData\n");
+
+ DeviceExtension = VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension);
+
+ if (BusDataType != Cmos)
+ {
+ /* Legacy vs. PnP behaviour */
+ if (DeviceExtension->PhysicalDeviceObject != NULL)
+ SlotNumber = DeviceExtension->SystemIoSlotNumber;
+ }
+
+ return HalGetBusDataByOffset(
+ BusDataType,
+ DeviceExtension->SystemIoBusNumber,
+ SlotNumber,
+ Buffer,
+ Offset,
+ Length);
+}
+
+/*
+ * @implemented
+ */
+
+ULONG STDCALL
+VideoPortSetBusData(
+ IN PVOID HwDeviceExtension,
+ IN BUS_DATA_TYPE BusDataType,
+ IN ULONG SlotNumber,
+ IN PVOID Buffer,
+ IN ULONG Offset,
+ IN ULONG Length)
+{
+ PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
+
+ DPRINT("VideoPortSetBusData\n");
+
+ DeviceExtension = VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension);
+
+ if (BusDataType != Cmos)
+ {
+ /* Legacy vs. PnP behaviour */
+ if (DeviceExtension->PhysicalDeviceObject != NULL)
+ SlotNumber = DeviceExtension->SystemIoSlotNumber;
+ }
+
+ return HalSetBusDataByOffset(
+ BusDataType,
+ DeviceExtension->SystemIoBusNumber,
+ SlotNumber,
+ Buffer,
+ Offset,
+ Length);
+}
reactos/drivers/video/videoprt
diff -u -r1.21.2.2 -r1.21.2.3
--- videoprt.c 15 Mar 2004 17:02:14 -0000 1.21.2.2
+++ videoprt.c 16 Mar 2004 20:36:54 -0000 1.21.2.3
@@ -18,7 +18,7 @@
* If not, write to the Free Software Foundation,
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
- * $Id: videoprt.c,v 1.21.2.2 2004/03/15 17:02:14 navaraf Exp $
+ * $Id: videoprt.c,v 1.21.2.3 2004/03/16 20:36:54 navaraf Exp $
*/
#include "videoprt.h"
@@ -166,32 +166,37 @@
PUNICODE_STRING RegistryPath = Context2;
NTSTATUS Status;
PVIDEO_PORT_DRIVER_EXTENSION DriverExtension;
+ BOOL LegacyDetection = FALSE;
DPRINT("VideoPortInitialize\n");
+ /*
+ * NOTE:
+ * The driver extension can be already allocated in case that we were
+ * called by legacy driver and failed detecting device. Some miniport
+ * drivers in that case adjust parameters and calls VideoPortInitialize
+ * again.
+ */
+
DriverExtension = IoGetDriverObjectExtension(DriverObject, DriverObject);
- if (DriverExtension != NULL)
+ if (DriverExtension == NULL)
{
- DPRINT1(
- "Oops, we were called twice to initialize the driver. This propably\n"
- "means that we were loaded by legacy driver, so we have to fallback\n"
- "to the old driver detection paradigm. Unfortunetly this case isn't\n"
- "implemented yet.");
-
- return STATUS_UNSUCCESSFUL;
- }
-
- Status = IoAllocateDriverObjectExtension(
- DriverObject,
- DriverObject,
- sizeof(VIDEO_PORT_DRIVER_EXTENSION),
- (PVOID *)&DriverExtension);
+ Status = IoAllocateDriverObjectExtension(
+ DriverObject,
+ DriverObject,
+ sizeof(VIDEO_PORT_DRIVER_EXTENSION),
+ (PVOID *)&DriverExtension);
- if (!NT_SUCCESS(Status))
- {
- return Status;
+ if (!NT_SUCCESS(Status))
+ {
+ return Status;
+ }
}
+ /*
+ * Copy the correct miniport initializtation data to the device extension.
+ */
+
RtlCopyMemory(
&DriverExtension->InitializationData,
HwInitializationData,
@@ -200,29 +205,53 @@
RtlCopyMemory(&DriverExtension->RegistryPath, RegistryPath, sizeof(UNICODE_STRING));
-#ifndef NDEBUG
switch (HwInitializationData->HwInitDataSize)
{
+ /*
+ * NT4 drivers are special case, because we must use legacy method
+ * of detection instead of the Plug & Play one.
+ */
+
case SIZE_OF_NT4_VIDEO_HW_INITIALIZATION_DATA:
- DPRINT("We were loaded by a Windows NT miniport driver.\n"); break;
+ DPRINT("We were loaded by a Windows NT miniport driver.\n");
+ LegacyDetection = TRUE;
+ break;
+
case SIZE_OF_W2K_VIDEO_HW_INITIALIZATION_DATA:
- DPRINT("We were loaded by a Windows 2000 miniport driver.\n"); break;
+ DPRINT("We were loaded by a Windows 2000 miniport driver.\n");
+ break;
+
case sizeof(VIDEO_HW_INITIALIZATION_DATA):
- DPRINT("We were loaded by a Windows XP or later miniport driver.\n"); break;
+ DPRINT("We were loaded by a Windows XP or later miniport driver.\n");
+ break;
+
default:
- DPRINT("Invalid HwInitializationData size.\n"); break;
+ DPRINT("Invalid HwInitializationData size.\n");
+ return STATUS_UNSUCCESSFUL;
}
-#endif
- DriverObject->DriverExtension->AddDevice = VideoPortAddDevice;
DriverObject->MajorFunction[IRP_MJ_CREATE] = VideoPortDispatchOpen;
DriverObject->MajorFunction[IRP_MJ_CLOSE] = VideoPortDispatchClose;
DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = VideoPortDispatchDeviceControl;
- DriverObject->MajorFunction[IRP_MJ_PNP] = VideoPortDispatchPnp;
- DriverObject->MajorFunction[IRP_MJ_POWER] = VideoPortDispatchPower;
DriverObject->DriverUnload = VideoPortUnload;
- return STATUS_SUCCESS;
+ /*
+ * Plug & Play drivers registers the device in AddDevice routine. For
+ * legacy drivers we must do it now.
+ */
+
+ if (LegacyDetection)
+ {
+ return VideoPortAddDevice(DriverObject, NULL);
+ }
+ else
+ {
+ DriverObject->DriverExtension->AddDevice = VideoPortAddDevice;
+ DriverObject->MajorFunction[IRP_MJ_PNP] = VideoPortDispatchPnp;
+ DriverObject->MajorFunction[IRP_MJ_POWER] = VideoPortDispatchPower;
+
+ return STATUS_SUCCESS;
+ }
}
/*
@@ -267,55 +296,6 @@
* @implemented
*/
-ULONG STDCALL
-VideoPortGetBusData(
- IN PVOID HwDeviceExtension,
- IN BUS_DATA_TYPE BusDataType,
- IN ULONG SlotNumber,
- OUT PVOID Buffer,
- IN ULONG Offset,
- IN ULONG Length)
-{
- DPRINT("VideoPortGetBusData\n");
-
- return HalGetBusDataByOffset(
- BusDataType,
- VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension)->SystemIoBusNumber,
- BusDataType == Cmos ? SlotNumber :
- VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension)->SystemIoSlotNumber,
- Buffer,
- Offset,
- Length);
-}
-
-/*
- * @implemented
- */
-
-ULONG STDCALL
-VideoPortSetBusData(
- IN PVOID HwDeviceExtension,
- IN BUS_DATA_TYPE BusDataType,
- IN ULONG SlotNumber,
- IN PVOID Buffer,
- IN ULONG Offset,
- IN ULONG Length)
-{
- DPRINT("VideoPortSetBusData\n");
- return HalSetBusDataByOffset(
- BusDataType,
- VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension)->SystemIoBusNumber,
- BusDataType == Cmos ? SlotNumber :
- VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension)->SystemIoSlotNumber,
- Buffer,
- Offset,
- Length);
-}
-
-/*
- * @implemented
- */
-
UCHAR STDCALL
VideoPortGetCurrentIrql(VOID)
{
CVSspam 0.2.8