summaryrefslogtreecommitdiff
path: root/usb/ufxclientsample/ufxendpoint.h
blob: 7eb3a2830091b9993aed9e2f15ab5cf21c8bd1d0 (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
/*++

Copyright (c) 1990-2013 Microsoft Corporation. All rights reserved.

Module Name:

    ufxendpoint.h

Abstract:

    Defines the structures and functions needed for UFXENDPOINT object

Environment:

    Kernel mode

--*/

#pragma once

#include <ufxclient.h>
#include "transfer.h"

#define CONTROL_ENDPOINT(Endpoint) \
    ((UfxEndpointGetContext(Endpoint)->Descriptor.bmAttributes & USB_ENDPOINT_TYPE_MASK) == \
        USB_ENDPOINT_TYPE_CONTROL)

#define DIRECTION_IN(Endpoint) \
    (CONTROL_ENDPOINT(Endpoint) || \
     USB_ENDPOINT_DIRECTION_IN(UfxEndpointGetContext(Endpoint)->Descriptor.bEndpointAddress))

#define DIRECTION_OUT(Endpoint) \
    (CONTROL_ENDPOINT(Endpoint) || \
     USB_ENDPOINT_DIRECTION_OUT(UfxEndpointGetContext(Endpoint)->Descriptor.bEndpointAddress))
  
typedef struct _UFXENDPOINT_CONTEXT {
    WDFDEVICE WdfDevice;
    UFXDEVICE UfxDevice;
    USB_ENDPOINT_DESCRIPTOR Descriptor;
    ULONG PhysicalEndpoint;
    WDFREQUEST StallRequest;
    WDFREQUEST ClearRequest;
} UFXENDPOINT_CONTEXT, *PUFXENDPOINT_CONTEXT;

WDF_DECLARE_CONTEXT_TYPE_WITH_NAME(UFXENDPOINT_CONTEXT, UfxEndpointGetContext);

typedef struct _ENDPOINT_QUEUE_CONTEXT {
    UFXENDPOINT Endpoint;
} ENDPOINT_QUEUE_CONTEXT, *PENDPOINT_QUEUE_CONTEXT;

WDF_DECLARE_CONTEXT_TYPE_WITH_NAME(ENDPOINT_QUEUE_CONTEXT, EndpointQueueGetContext);

_Must_inspect_result_
_IRQL_requires_(PASSIVE_LEVEL)
NTSTATUS
UfxEndpointAdd (
    _In_ UFXDEVICE Device,
    _In_ PUSB_ENDPOINT_DESCRIPTOR Descriptor,
    _Inout_ PUFXENDPOINT_INIT EndpointInit
    );

_IRQL_requires_max_(DISPATCH_LEVEL)
VOID
UfxEndpointConfigure (
    _In_ UFXENDPOINT Endpoint
    );

_IRQL_requires_max_(DISPATCH_LEVEL)
VOID
UfxEndpointConfigureHardware (
    _In_ UFXENDPOINT Endpoint,
    _In_ BOOLEAN Modify
    );