mirror of
https://github.com/reactos/reactos.git
synced 2024-12-27 01:24:38 +00:00
- Make WrapperConfigurationContext a pointer to a WRAPPER_CONTEXT structure.
- Use correct bus number in NtImmediateReadPciSlotInformation, NdisImmediateWritePciSlotInformation, NdisReadPciSlotInformation and NdisWritePciSlotInformation. svn path=/trunk/; revision=11676
This commit is contained in:
parent
1d44f8fade
commit
43d65f019d
4 changed files with 51 additions and 29 deletions
|
@ -10,6 +10,12 @@
|
|||
|
||||
#include <ndissys.h>
|
||||
|
||||
/* WrapperConfigurationContext is a pointer to this structure */
|
||||
typedef struct _WRAPPER_CONTEXT {
|
||||
PDEVICE_OBJECT DeviceObject;
|
||||
ULONG BusNumber;
|
||||
HANDLE DeviceKeyHandle;
|
||||
} WRAPPER_CONTEXT, *PWRAPPER_CONTEXT;
|
||||
|
||||
typedef struct _HARDWARE_ADDRESS {
|
||||
union {
|
||||
|
|
|
@ -171,11 +171,11 @@ NdisOpenConfiguration(
|
|||
{
|
||||
HANDLE KeyHandle;
|
||||
PMINIPORT_CONFIGURATION_CONTEXT ConfigurationContext;
|
||||
HANDLE RootKeyHandle = (HANDLE)WrapperConfigurationContext;
|
||||
PWRAPPER_CONTEXT WrapperContext = (PWRAPPER_CONTEXT)WrapperConfigurationContext;
|
||||
|
||||
NDIS_DbgPrint(MAX_TRACE, ("Called\n"));
|
||||
|
||||
*Status = ZwDuplicateObject(NtCurrentProcess(), RootKeyHandle,
|
||||
*Status = ZwDuplicateObject(NtCurrentProcess(), WrapperContext->DeviceKeyHandle,
|
||||
NtCurrentProcess(), &KeyHandle, 0, FALSE,
|
||||
DUPLICATE_SAME_ACCESS);
|
||||
if(!NT_SUCCESS(*Status))
|
||||
|
|
|
@ -9,9 +9,6 @@
|
|||
* CSH 01/08-2000 Created
|
||||
* 25 Aug 2003 Vizzini - NDIS4/5 and PnP additions
|
||||
* 3 Oct 2003 Vizzini - formatting and minor bugfixes
|
||||
*
|
||||
* TODO:
|
||||
* - Fix HalGetBusDataByOffset() param 2 in most calls below
|
||||
*/
|
||||
|
||||
#include <roscfg.h>
|
||||
|
@ -30,7 +27,9 @@ NdisImmediateReadPciSlotInformation(
|
|||
IN PVOID Buffer,
|
||||
IN ULONG Length)
|
||||
{
|
||||
return HalGetBusDataByOffset (PCIConfiguration, 0, SlotNumber, Buffer, Offset, Length);
|
||||
PWRAPPER_CONTEXT WrapperContext = (PWRAPPER_CONTEXT)WrapperConfigurationContext;
|
||||
return HalGetBusDataByOffset(PCIConfiguration, WrapperContext->BusNumber,
|
||||
SlotNumber, Buffer, Offset, Length);
|
||||
}
|
||||
|
||||
|
||||
|
@ -46,7 +45,9 @@ NdisImmediateWritePciSlotInformation(
|
|||
IN PVOID Buffer,
|
||||
IN ULONG Length)
|
||||
{
|
||||
return HalSetBusDataByOffset (PCIConfiguration, 0, SlotNumber, Buffer, Offset, Length);
|
||||
PWRAPPER_CONTEXT WrapperContext = (PWRAPPER_CONTEXT)WrapperConfigurationContext;
|
||||
return HalSetBusDataByOffset(PCIConfiguration, WrapperContext->BusNumber,
|
||||
SlotNumber, Buffer, Offset, Length);
|
||||
}
|
||||
|
||||
|
||||
|
@ -89,16 +90,6 @@ NdisMPciAssignResources(
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
VOID
|
||||
EXPORT
|
||||
NdisMQueryAdapterResources(
|
||||
OUT PNDIS_STATUS Status,
|
||||
IN NDIS_HANDLE WrapperConfigurationContext,
|
||||
OUT PNDIS_RESOURCE_LIST ResourceList,
|
||||
IN OUT PUINT BufferSize)
|
||||
/*
|
||||
* FUNCTION: returns a nic's hardware resources
|
||||
* ARGUMENTS:
|
||||
|
@ -111,7 +102,16 @@ NdisMQueryAdapterResources(
|
|||
* - Must be called at IRQL = PASSIVE_LEVEL;
|
||||
* BUGS:
|
||||
* - Needs an implementation; for now i think we are waiting on pnp
|
||||
*
|
||||
* @unimplemented
|
||||
*/
|
||||
VOID
|
||||
EXPORT
|
||||
NdisMQueryAdapterResources(
|
||||
OUT PNDIS_STATUS Status,
|
||||
IN NDIS_HANDLE WrapperConfigurationContext,
|
||||
OUT PNDIS_RESOURCE_LIST ResourceList,
|
||||
IN OUT PUINT BufferSize)
|
||||
{
|
||||
PAGED_CODE();
|
||||
ASSERT(Status && ResourceList);
|
||||
|
@ -147,7 +147,7 @@ VOID
|
|||
EXPORT
|
||||
NdisReadEisaSlotInformation(
|
||||
OUT PNDIS_STATUS Status,
|
||||
IN NDIS_HANDLE WrapperConfigurationContext,
|
||||
IN NDIS_HANDLE WrapperConfigurationContext,
|
||||
OUT PUINT SlotNumber,
|
||||
OUT PNDIS_EISA_FUNCTION_INFORMATION EisaData)
|
||||
{
|
||||
|
@ -186,8 +186,8 @@ NdisReadPciSlotInformation(
|
|||
PLOGICAL_ADAPTER AdapterObject = (PLOGICAL_ADAPTER)NdisAdapterHandle;
|
||||
/* Slot number is ignored since W2K for all NDIS drivers. */
|
||||
NDIS_DbgPrint(MAX_TRACE, ("Slot: %d\n", AdapterObject->SlotNumber));
|
||||
return HalGetBusDataByOffset (PCIConfiguration, 0, AdapterObject->SlotNumber,
|
||||
Buffer, Offset, Length);
|
||||
return HalGetBusDataByOffset(PCIConfiguration, AdapterObject->BusNumber,
|
||||
AdapterObject->SlotNumber, Buffer, Offset, Length);
|
||||
}
|
||||
|
||||
|
||||
|
@ -206,8 +206,8 @@ NdisWritePciSlotInformation(
|
|||
PLOGICAL_ADAPTER AdapterObject = (PLOGICAL_ADAPTER)NdisAdapterHandle;
|
||||
/* Slot number is ignored since W2K for all NDIS drivers. */
|
||||
NDIS_DbgPrint(MAX_TRACE, ("Slot: %d\n", AdapterObject->SlotNumber));
|
||||
return HalSetBusDataByOffset (PCIConfiguration, 0, AdapterObject->SlotNumber,
|
||||
Buffer, Offset, Length);
|
||||
return HalSetBusDataByOffset(PCIConfiguration, AdapterObject->BusNumber,
|
||||
AdapterObject->SlotNumber, Buffer, Offset, Length);
|
||||
}
|
||||
|
||||
/* EOF */
|
||||
|
|
|
@ -1340,7 +1340,6 @@ NdisIStartAdapter(
|
|||
* - break up this 250-line function
|
||||
*/
|
||||
{
|
||||
HANDLE RegKeyHandle;
|
||||
NDIS_STATUS NdisStatus;
|
||||
NDIS_STATUS OpenErrorStatus;
|
||||
NTSTATUS Status;
|
||||
|
@ -1350,19 +1349,20 @@ NdisIStartAdapter(
|
|||
BOOLEAN MemError = FALSE;
|
||||
KIRQL OldIrql;
|
||||
ULONG Size;
|
||||
PWRAPPER_CONTEXT WrapperContext;
|
||||
|
||||
Adapter = ExAllocatePool(NonPagedPool, sizeof(LOGICAL_ADAPTER));
|
||||
if (!Adapter)
|
||||
if (!Adapter)
|
||||
{
|
||||
NDIS_DbgPrint(MIN_TRACE, ("Insufficient resources.\n"));
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
/* This is very important */
|
||||
RtlZeroMemory(Adapter, sizeof(LOGICAL_ADAPTER));
|
||||
|
||||
Adapter->DeviceName.Buffer = ExAllocatePool(NonPagedPool, DeviceName->Length);
|
||||
if(!Adapter->DeviceName.Buffer)
|
||||
if (!Adapter->DeviceName.Buffer)
|
||||
{
|
||||
NDIS_DbgPrint(MIN_TRACE,("Insufficient memory\n"));
|
||||
ExFreePool(Adapter);
|
||||
|
@ -1371,6 +1371,16 @@ NdisIStartAdapter(
|
|||
Adapter->DeviceName.MaximumLength = DeviceName->Length;
|
||||
RtlCopyUnicodeString(&Adapter->DeviceName, DeviceName);
|
||||
|
||||
WrapperContext = ExAllocatePool(NonPagedPool, sizeof(WRAPPER_CONTEXT));
|
||||
if (!WrapperContext)
|
||||
{
|
||||
NDIS_DbgPrint(MIN_TRACE,("Insufficient memory\n"));
|
||||
ExFreePool(Adapter->DeviceName.Buffer);
|
||||
ExFreePool(Adapter);
|
||||
return;
|
||||
}
|
||||
WrapperContext->DeviceObject = PhysicalDeviceObject;
|
||||
|
||||
NDIS_DbgPrint(MAX_TRACE, ("creating device %wZ\n", DeviceName));
|
||||
|
||||
Status = IoCreateDevice(Miniport->DriverObject, 0, &Adapter->DeviceName, FILE_DEVICE_PHYSICAL_NETCARD,
|
||||
|
@ -1378,15 +1388,19 @@ NdisIStartAdapter(
|
|||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
NDIS_DbgPrint(MIN_TRACE, ("Could not create device object.\n"));
|
||||
ExFreePool(WrapperContext);
|
||||
ExFreePool(Adapter->DeviceName.Buffer);
|
||||
ExFreePool(Adapter);
|
||||
return;
|
||||
}
|
||||
|
||||
Status = IoOpenDeviceRegistryKey(PhysicalDeviceObject, PLUGPLAY_REGKEY_DRIVER,
|
||||
KEY_ALL_ACCESS, &RegKeyHandle);
|
||||
KEY_ALL_ACCESS, &WrapperContext->DeviceKeyHandle);
|
||||
if(Status != STATUS_SUCCESS)
|
||||
{
|
||||
NDIS_DbgPrint(MIN_TRACE,("failed to open adapter-specific reg key\n"));
|
||||
ExFreePool(WrapperContext);
|
||||
ExFreePool(Adapter->DeviceName.Buffer);
|
||||
ExFreePool(Adapter);
|
||||
return;
|
||||
}
|
||||
|
@ -1407,6 +1421,7 @@ NdisIStartAdapter(
|
|||
Size, &Adapter->BusNumber, &Size);
|
||||
IoGetDeviceProperty(PhysicalDeviceObject, DevicePropertyAddress,
|
||||
Size, &Adapter->SlotNumber, &Size);
|
||||
WrapperContext->BusNumber = Adapter->BusNumber;
|
||||
|
||||
/* Set handlers (some NDIS macros require these) */
|
||||
|
||||
|
@ -1429,9 +1444,10 @@ NdisIStartAdapter(
|
|||
/* Call MiniportInitialize */
|
||||
NDIS_DbgPrint(MID_TRACE, ("calling MiniportInitialize\n"));
|
||||
NdisStatus = (*Miniport->Chars.InitializeHandler)( &OpenErrorStatus, &SelectedMediumIndex, &MediaArray[0],
|
||||
MEDIA_ARRAY_SIZE, Adapter, RegKeyHandle);
|
||||
MEDIA_ARRAY_SIZE, Adapter, WrapperContext);
|
||||
|
||||
ZwClose(RegKeyHandle);
|
||||
ZwClose(WrapperContext->DeviceKeyHandle);
|
||||
ExFreePool(WrapperContext);
|
||||
|
||||
if ((NdisStatus == NDIS_STATUS_SUCCESS) && (SelectedMediumIndex < MEDIA_ARRAY_SIZE))
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue