summaryrefslogtreecommitdiff
path: root/network/wlan/WIFICX/drivercode/device.cpp
blob: 0fc17ea43320773abecaa5f4ee6ddb695210d364 (plain)
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
// 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);

    WX_RETURN_NTSTATUS_IF_NOT_NT_SUCCESS_MSG(
        WifiHAL::_Create(device),
        "WifiHAL::_Create failed");

    WFCInfo("Device=0x%p", device);
    return STATUS_SUCCESS;
}

_Use_decl_annotations_
NTSTATUS EvtDeviceReleaseHardware(WDFDEVICE device, WDFCMRESLIST resourcesTranslated)
{
    UNREFERENCED_PARAMETER(resourcesTranslated);

    WFCInfo("Device=0x%p", device);

    return STATUS_SUCCESS;
}

_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{};
    WX_RETURN_NTSTATUS_IF_NOT_NT_SUCCESS_MSG(
        NetAdapterCreate(AdapterInit, &adapterAttributes, &netAdapter), "Failed to create NetAdapter");

    WX_RETURN_NTSTATUS_IF_NOT_NT_SUCCESS_MSG(
        WifiAdapterInitialize(netAdapter), "Failed to initialize WifiAdapter");

    WX_RETURN_NTSTATUS_IF_NOT_NT_SUCCESS_MSG(
        WifiIhvInitAdapterContext(Device, netAdapter), "Failed to initialize WifiAdapterContext");
    
    WX_RETURN_NTSTATUS_IF_NOT_NT_SUCCESS_MSG(
        WifiIhvAdapterStart(netAdapter), "Failed to start WifiIhvAdapter");

    return STATUS_SUCCESS;
}

_Use_decl_annotations_
NTSTATUS EvtWifiDeviceCreateWifiDirectDevice(WDFDEVICE, WIFIDIRECT_DEVICE_INIT*)
{
    NTSTATUS status = STATUS_SUCCESS;
    TraceEntry();
    TraceExit(status);
    return status;
}

_Use_decl_annotations_
void EvtAdapterCleanup(_In_ WDFOBJECT NetAdapter)
{
    UNREFERENCED_PARAMETER(NetAdapter);
    TraceEntry();
    TraceExit(STATUS_SUCCESS);
}