[STORORT] Allocate the miniport device extension and use it the calls to HwFindAdapter and HwInitialize.

CORE-13866
This commit is contained in:
Eric Kohl 2017-10-15 00:06:22 +02:00
parent dc8bfeabcf
commit 42cb5353b8
3 changed files with 48 additions and 9 deletions

View file

@ -38,9 +38,14 @@ PortFdoStartMiniport(
return STATUS_NO_SUCH_DEVICE; return STATUS_NO_SUCH_DEVICE;
/* Initialize the miniport */ /* Initialize the miniport */
MiniportInitialize(&DeviceExtension->Miniport, Status = MiniportInitialize(&DeviceExtension->Miniport,
DeviceExtension, DeviceExtension,
InitData); InitData);
if (!NT_SUCCESS(Status))
{
DPRINT1("MiniportInitialize() failed (Status 0x%08lx)\n", Status);
return Status;
}
/* Call the miniports FindAdapter function */ /* Call the miniports FindAdapter function */
Status = MiniportFindAdapter(&DeviceExtension->Miniport); Status = MiniportFindAdapter(&DeviceExtension->Miniport);

View file

@ -15,14 +15,38 @@
/* FUNCTIONS ******************************************************************/ /* FUNCTIONS ******************************************************************/
VOID NTSTATUS
MiniportInitialize( MiniportInitialize(
_In_ PMINIPORT Miniport, _In_ PMINIPORT Miniport,
_In_ PFDO_DEVICE_EXTENSION DeviceExtension, _In_ PFDO_DEVICE_EXTENSION DeviceExtension,
_In_ PHW_INITIALIZATION_DATA InitData) _In_ PHW_INITIALIZATION_DATA InitData)
{ {
PMINIPORT_DEVICE_EXTENSION MiniportExtension;
ULONG Size;
DPRINT1("MiniportInitialize(%p %p %p)\n",
Miniport, DeviceExtension, InitData);
Miniport->DeviceExtension = DeviceExtension; Miniport->DeviceExtension = DeviceExtension;
Miniport->InitData = InitData; Miniport->InitData = InitData;
/* Calculate the miniport device extension size */
Size = sizeof(MINIPORT_DEVICE_EXTENSION) +
Miniport->InitData->DeviceExtensionSize;
/* Allocate and initialize the miniport device extension */
MiniportExtension = ExAllocatePoolWithTag(NonPagedPool,
Size,
TAG_MINIPORT_DATA);
if (MiniportExtension == NULL)
return STATUS_NO_MEMORY;
RtlZeroMemory(MiniportExtension, Size);
MiniportExtension->Miniport = Miniport;
Miniport->MiniportExtension = MiniportExtension;
return STATUS_SUCCESS;
} }
@ -36,7 +60,8 @@ MiniportFindAdapter(
DPRINT1("MiniportFindAdapter(%p)\n", Miniport); DPRINT1("MiniportFindAdapter(%p)\n", Miniport);
Result = Miniport->InitData->HwFindAdapter(NULL, /* Call the miniport HwFindAdapter routine */
Result = Miniport->InitData->HwFindAdapter(&Miniport->MiniportExtension->HwDeviceExtension,
NULL, NULL,
NULL, NULL,
NULL, NULL,
@ -84,7 +109,8 @@ MiniportHwInitialize(
DPRINT1("MiniportHwInitialize(%p)\n", Miniport); DPRINT1("MiniportHwInitialize(%p)\n", Miniport);
Status = Miniport->InitData->HwInitialize(NULL); /* Call the miniport HwInitialize routine */
Status = Miniport->InitData->HwInitialize(&Miniport->MiniportExtension->HwDeviceExtension);
DPRINT1("HwInitialize() returned 0x%08lx\n", Status); DPRINT1("HwInitialize() returned 0x%08lx\n", Status);
return Status; return Status;

View file

@ -23,8 +23,9 @@
#include <wdmguid.h> #include <wdmguid.h>
/* Memory Tags */ /* Memory Tags */
#define TAG_GLOBAL_DATA 'DGtS' #define TAG_GLOBAL_DATA 'DGtS'
#define TAG_INIT_DATA 'DItS' #define TAG_INIT_DATA 'DItS'
#define TAG_MINIPORT_DATA 'DMtS'
typedef enum typedef enum
{ {
@ -61,10 +62,17 @@ typedef struct _DRIVER_OBJECT_EXTENSION
LIST_ENTRY InitDataListHead; LIST_ENTRY InitDataListHead;
} DRIVER_OBJECT_EXTENSION, *PDRIVER_OBJECT_EXTENSION; } DRIVER_OBJECT_EXTENSION, *PDRIVER_OBJECT_EXTENSION;
typedef struct _MINIPORT_DEVICE_EXTENSION
{
struct _MINIPORT *Miniport;
UCHAR HwDeviceExtension[0];
} MINIPORT_DEVICE_EXTENSION, *PMINIPORT_DEVICE_EXTENSION;
typedef struct _MINIPORT typedef struct _MINIPORT
{ {
struct _FDO_DEVICE_EXTENSION *DeviceExtension; struct _FDO_DEVICE_EXTENSION *DeviceExtension;
PHW_INITIALIZATION_DATA InitData; PHW_INITIALIZATION_DATA InitData;
PMINIPORT_DEVICE_EXTENSION MiniportExtension;
} MINIPORT, *PMINIPORT; } MINIPORT, *PMINIPORT;
typedef struct _FDO_DEVICE_EXTENSION typedef struct _FDO_DEVICE_EXTENSION
@ -107,7 +115,7 @@ PortFdoPnp(
/* miniport.c */ /* miniport.c */
VOID NTSTATUS
MiniportInitialize( MiniportInitialize(
_In_ PMINIPORT Miniport, _In_ PMINIPORT Miniport,
_In_ PFDO_DEVICE_EXTENSION DeviceExtension, _In_ PFDO_DEVICE_EXTENSION DeviceExtension,