1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
|
// Copyright (c) Microsoft Corporation. All rights reserved.
#include "precomp.h"
#include "adapter.h"
#include "device.h"
#include "device.tmh"
_Use_decl_annotations_
NTSTATUS EvtDevicePrepareHardware(WDFDEVICE device, WDFCMRESLIST resourcesRaw, WDFCMRESLIST resourcesTranslated)
{
UNREFERENCED_PARAMETER(resourcesRaw);
UNREFERENCED_PARAMETER(resourcesTranslated);
UNREFERENCED_PARAMETER(device);
NTSTATUS status = STATUS_SUCCESS;
//status = WifiCxTestSetDeviceCapabilities(device);
if (!NT_SUCCESS(status))
{
WFCError("%!FUNC!: WifiCxTestSetDeviceCapabilities failed with %!STATUS!", status);
return status;
}
WFCInfo("Device=0x%p", device);
return status;
}
_Use_decl_annotations_
NTSTATUS EvtDeviceReleaseHardware(WDFDEVICE device, WDFCMRESLIST resourcesTranslated)
{
UNREFERENCED_PARAMETER(device);
UNREFERENCED_PARAMETER(resourcesTranslated);
WFCInfo("Device=0x%p", device);
return STATUS_SUCCESS;
}
_Use_decl_annotations_
void EvtDeviceSurpriseRemoval(WDFDEVICE device)
{
UNREFERENCED_PARAMETER(device);
WFCInfo("Device=0x%p is surprise removed", device);
}
static NTSTATUS WifiInitAdapterContext(_In_ WDFDEVICE Device, _In_ NETADAPTER NetAdapter)
{
PWIFI_IHV_DEVICE_CONTEXT deviceContext = WifiGetIhvDeviceContext(Device);
PWIFI_IHV_NETADAPTER_CONTEXT netAdapterContext = WifiGetIhvNetAdapterContext(NetAdapter);
NTSTATUS status = STATUS_SUCCESS;
if (deviceContext->primaryStaAdapter == WDF_NO_HANDLE)
{
deviceContext->primaryStaAdapter = NetAdapter;
}
netAdapterContext->WifiDeviceContext = deviceContext;
return status;
}
_Use_decl_annotations_
NTSTATUS EvtWifiDeviceCreateAdapter(WDFDEVICE Device, NETADAPTER_INIT* AdapterInit)
{
//NET_ADAPTER_DATAPATH_CALLBACKS datapathCallbacks;
//NET_ADAPTER_DATAPATH_CALLBACKS_INIT(&datapathCallbacks, EvtAdapterCreateTxQueue, EvtAdapterCreateRxQueue);
//NetAdapterInitSetDatapathCallbacks(AdapterInit, &datapathCallbacks);
WDF_OBJECT_ATTRIBUTES adapterAttributes;
WDF_OBJECT_ATTRIBUTES_INIT(&adapterAttributes);
WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&adapterAttributes, WIFI_IHV_NETADAPTER_CONTEXT);
adapterAttributes.EvtCleanupCallback = EvtAdapterCleanup;
NETADAPTER netAdapter;
NTSTATUS ntStatus = NetAdapterCreate(AdapterInit, &adapterAttributes, &netAdapter);
if (!NT_SUCCESS(ntStatus))
{
WFCError("%!FUNC!: NetAdapterCreate failed, status=0x%x", ntStatus);
return ntStatus;
}
ntStatus = WifiAdapterInitialize(netAdapter);
ASSERT(NT_SUCCESS(ntStatus));
if (!NT_SUCCESS(ntStatus))
{
WFCError("%!FUNC!: WifiAdapterInitialize failed with %!STATUS!", ntStatus);
return ntStatus;
}
ntStatus = WifiInitAdapterContext(Device, netAdapter);
ASSERT(NT_SUCCESS(ntStatus));
if (!NT_SUCCESS(ntStatus))
{
WFCError("%!FUNC!: WifiInitAdapterContext failed with %!STATUS!", ntStatus);
return ntStatus;
}
ntStatus = WifiCxTestAdapterStart(netAdapter);
ASSERT(NT_SUCCESS(ntStatus));
if (!NT_SUCCESS(ntStatus))
{
WFCError("%!FUNC!: WifiCxTestAdapterStart failed with %!STATUS!", ntStatus);
return ntStatus;
}
return ntStatus;
}
_Use_decl_annotations_
void EvtAdapterCleanup(_In_ WDFOBJECT NetAdapter)
{
UNREFERENCED_PARAMETER(NetAdapter);
TraceEntry();
TraceExit(STATUS_SUCCESS);
}
|