* Copyright (C) 2002 - 2005 ReactOS Team
*
* This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
+ * modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
+ * version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
+ * Lesser General Public License for more details.
*
- * You should have received a copy of the GNU Library General Public
- * License along with this library; see the file COPYING.LIB.
- * If not, write to the Free Software Foundation,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
if (Status)
*Status = NO_ERROR;
- return (PVOID)TranslatedAddress.u.LowPart;
+ return (PVOID)(ULONG_PTR)TranslatedAddress.u.LowPart;
}
/* user space */
Status = ZwUnmapViewOfSection(NtCurrentProcess(), MappedAddress);
if (!NT_SUCCESS(Status))
{
- WARN_(VIDEOPRT, "Warning: Mapping for address 0x%x not found!\n", (ULONG)MappedAddress);
+ WARN_(VIDEOPRT, "Warning: Mapping for address 0x%p not found!\n", MappedAddress);
}
}
{
TRACE_(VIDEOPRT, "VideoPortMapBankedMemory\n");
UNIMPLEMENTED;
- return ERROR_CALL_NOT_IMPLEMENTED;
+ return ERROR_INVALID_FUNCTION;
}
IN PULONG Slot)
{
PCI_SLOT_NUMBER PciSlotNumber;
+ ULONG DeviceNumber;
ULONG FunctionNumber;
PCI_COMMON_CONFIG Config;
PCM_RESOURCE_LIST AllocatedResources;
USHORT DeviceIdToFind;
ULONG SlotIdToFind;
ULONG ReturnedLength;
+ BOOLEAN DeviceAndVendorFound = FALSE;
TRACE_(VIDEOPRT, "VideoPortGetAccessRanges\n");
if (ReturnedLength != sizeof(PCI_COMMON_CONFIG))
{
- return ERROR_NO_SYSTEM_RESOURCES;
+ return ERROR_NOT_ENOUGH_MEMORY;
}
}
else
/*
* Search for the device id and vendor id on this bus.
*/
-
- for (FunctionNumber = 0; FunctionNumber < 8; FunctionNumber++)
+ for (DeviceNumber = 0; DeviceNumber < PCI_MAX_DEVICES; DeviceNumber++)
{
- INFO_(VIDEOPRT, "- Function number: %d\n", FunctionNumber);
- PciSlotNumber.u.bits.FunctionNumber = FunctionNumber;
- ReturnedLength = HalGetBusData(
- PCIConfiguration,
- DeviceExtension->SystemIoBusNumber,
- PciSlotNumber.u.AsULONG,
- &Config,
- sizeof(PCI_COMMON_CONFIG));
- INFO_(VIDEOPRT, "- Length of data: %x\n", ReturnedLength);
- if (ReturnedLength == sizeof(PCI_COMMON_CONFIG))
+ PciSlotNumber.u.bits.DeviceNumber = DeviceNumber;
+ for (FunctionNumber = 0; FunctionNumber < 8; FunctionNumber++)
{
- INFO_(VIDEOPRT, "- Slot 0x%02x (Device %d Function %d) VendorId 0x%04x "
- "DeviceId 0x%04x\n",
- PciSlotNumber.u.AsULONG,
- PciSlotNumber.u.bits.DeviceNumber,
- PciSlotNumber.u.bits.FunctionNumber,
- Config.VendorID,
- Config.DeviceID);
-
- if ((VendorIdToFind == 0 || Config.VendorID == VendorIdToFind) &&
- (DeviceIdToFind == 0 || Config.DeviceID == DeviceIdToFind))
+ INFO_(VIDEOPRT, "- Function number: %d\n", FunctionNumber);
+ PciSlotNumber.u.bits.FunctionNumber = FunctionNumber;
+ ReturnedLength = HalGetBusData(
+ PCIConfiguration,
+ DeviceExtension->SystemIoBusNumber,
+ PciSlotNumber.u.AsULONG,
+ &Config,
+ sizeof(PCI_COMMON_CONFIG));
+ INFO_(VIDEOPRT, "- Length of data: %x\n", ReturnedLength);
+ if (ReturnedLength == sizeof(PCI_COMMON_CONFIG))
{
- break;
+ INFO_(VIDEOPRT, "- Slot 0x%02x (Device %d Function %d) VendorId 0x%04x "
+ "DeviceId 0x%04x\n",
+ PciSlotNumber.u.AsULONG,
+ PciSlotNumber.u.bits.DeviceNumber,
+ PciSlotNumber.u.bits.FunctionNumber,
+ Config.VendorID,
+ Config.DeviceID);
+
+ if ((VendorIdToFind == 0 || Config.VendorID == VendorIdToFind) &&
+ (DeviceIdToFind == 0 || Config.DeviceID == DeviceIdToFind))
+ {
+ DeviceAndVendorFound = TRUE;
+ break;
+ }
}
}
+ if (DeviceAndVendorFound) break;
}
-
if (FunctionNumber == 8)
{
WARN_(VIDEOPRT, "Didn't find device.\n");
}
Status = HalAssignSlotResources(
- NULL, NULL, NULL, NULL,
+ &DeviceExtension->RegistryPath,
+ NULL,
+ DeviceExtension->DriverObject,
+ DeviceExtension->DriverObject->DeviceObject,
DeviceExtension->AdapterInterfaceType,
DeviceExtension->SystemIoBusNumber,
PciSlotNumber.u.AsULONG,
if (!NT_SUCCESS(Status))
{
+ WARN_(VIDEOPRT, "HalAssignSlotResources failed with status %x.\n",Status);
return Status;
}
DeviceExtension->AllocatedResources = AllocatedResources;
}
if (AllocatedResources == NULL)
- return ERROR_NO_SYSTEM_RESOURCES;
-
+ return ERROR_NOT_ENOUGH_MEMORY;
AssignedCount = 0;
for (FullList = AllocatedResources->List;
FullList < AllocatedResources->List + AllocatedResources->Count;
FullList++)
{
- ASSERT(FullList->InterfaceType == PCIBus &&
- FullList->BusNumber == DeviceExtension->SystemIoBusNumber &&
- 1 == FullList->PartialResourceList.Version &&
- 1 == FullList->PartialResourceList.Revision);
- for (Descriptor = FullList->PartialResourceList.PartialDescriptors;
+ INFO_(VIDEOPRT, "InterfaceType %u BusNumber List %u Device BusNumber %u Version %u Revision %u\n",
+ FullList->InterfaceType, FullList->BusNumber, DeviceExtension->SystemIoBusNumber, FullList->PartialResourceList.Version, FullList->PartialResourceList.Revision);
+
+ ASSERT(FullList->InterfaceType == PCIBus);
+ ASSERT(FullList->BusNumber == DeviceExtension->SystemIoBusNumber);
+ ASSERT(1 == FullList->PartialResourceList.Version);
+ ASSERT(1 == FullList->PartialResourceList.Revision);
+ for (Descriptor = FullList->PartialResourceList.PartialDescriptors;
Descriptor < FullList->PartialResourceList.PartialDescriptors + FullList->PartialResourceList.Count;
Descriptor++)
{
AssignedCount >= NumAccessRanges)
{
WARN_(VIDEOPRT, "Too many access ranges found\n");
- return ERROR_NO_SYSTEM_RESOURCES;
+ return ERROR_NOT_ENOUGH_MEMORY;
}
if (Descriptor->Type == CmResourceTypeMemory)
{
if (NumAccessRanges <= AssignedCount)
{
WARN_(VIDEOPRT, "Too many access ranges found\n");
- return ERROR_NO_SYSTEM_RESOURCES;
+ return ERROR_NOT_ENOUGH_MEMORY;
}
INFO_(VIDEOPRT, "Memory range starting at 0x%08x length 0x%08x\n",
Descriptor->u.Memory.Start.u.LowPart, Descriptor->u.Memory.Length);
{
TRACE_(VIDEOPRT, "VideoPortGetDeviceData\n");
UNIMPLEMENTED;
- return ERROR_CALL_NOT_IMPLEMENTED;
+ return ERROR_INVALID_FUNCTION;
}
/*
}
/*
- * @unimplemented
+ * @implemented
*/
PVOID NTAPI
IN ULONG Length,
IN VP_LOCK_OPERATION Operation)
{
- UNIMPLEMENTED;
- return NULL;
+ PMDL Mdl;
+
+ Mdl = IoAllocateMdl(BaseAddress, Length, FALSE, FALSE, NULL);
+ if (!Mdl)
+ {
+ return NULL;
+ }
+ /* FIXME use seh */
+ MmProbeAndLockPages(Mdl, KernelMode,Operation);
+ return Mdl;
}
/*
IN PVOID HwDeviceExtension,
IN PVOID Mdl)
{
- UNIMPLEMENTED;
+ if (Mdl)
+ {
+ MmUnlockPages((PMDL)Mdl);
+ IoFreeMdl(Mdl);
+ }
}
/*