summaryrefslogtreecommitdiff
path: root/serial/VirtualSerial2/device.h
blob: e271884149c940a01fc1f9c1a19a4238fd2aa479 (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
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
118
119
120
121
122
/*++

Copyright (C) Microsoft Corporation, All Rights Reserved

Module Name:

    Device.h

Abstract:

    This module contains the type definitions for the VirtualSerial sample
    driver's device callback class.

Environment:

    Windows Driver Framework

--*/

#pragma once

#define SYMBOLIC_LINK_NAME_LENGTH   32
#define SYMBOLIC_LINK_NAME_PREFIX   L"\\DosDevices\\Global\\"
#define REG_PATH_DEVICEMAP          L"HARDWARE\\DEVICEMAP"
#define SERIAL_DEVICE_MAP           L"SERIALCOMM"
#define REG_VALUENAME_PORTNAME      L"PortName"
#define REG_PATH_SERIALCOMM         REG_PATH_DEVICEMAP L"\\" SERIAL_DEVICE_MAP

typedef struct _DEVICE_CONTEXT
{
    WDFDEVICE       Device;

    ULONG           BaudRate;

    ULONG           ModemControlRegister;

    ULONG           FifoControlRegister;

    ULONG           LineControlRegister;

    UCHAR           ValidDataMask;

    SERIAL_TIMEOUTS Timeouts;

    BOOLEAN         CreatedLegacyHardwareKey;

    PWSTR           PdoName;

} DEVICE_CONTEXT, *PDEVICE_CONTEXT;

WDF_DECLARE_CONTEXT_TYPE_WITH_NAME(DEVICE_CONTEXT, GetDeviceContext);


NTSTATUS
DeviceCreate(
    _In_  WDFDRIVER         Driver,
    _In_  PWDFDEVICE_INIT   DeviceInit,
    _Out_ PDEVICE_CONTEXT   *DeviceContext
    );

NTSTATUS
DeviceConfigure(
    _In_  PDEVICE_CONTEXT   DeviceContext
    );

NTSTATUS
DeviceGetPdoName(
    _In_  PDEVICE_CONTEXT   DeviceContext
    );

NTSTATUS
DeviceWriteLegacyHardwareKey(
    _In_  PWSTR             PdoName,
    _In_  PWSTR             ComPort,
    _In_  WDFDEVICE         Device
    );

EVT_WDF_DEVICE_CONTEXT_CLEANUP  EvtDeviceCleanup;

ULONG
GetBaudRate(
    _In_  PDEVICE_CONTEXT   DeviceContext
    );

VOID
SetBaudRate(
    _In_  PDEVICE_CONTEXT   DeviceContext,
    _In_  ULONG             BaudRate
    );

ULONG *
GetModemControlRegisterPtr(
    _In_  PDEVICE_CONTEXT   DeviceContext
    );

ULONG *
GetFifoControlRegisterPtr(
    _In_  PDEVICE_CONTEXT   DeviceContext
    );

ULONG *
GetLineControlRegisterPtr(
    _In_  PDEVICE_CONTEXT   DeviceContext
    );

VOID
SetValidDataMask(
    _In_  PDEVICE_CONTEXT   DeviceContext,
    _In_  UCHAR             Mask
    );

VOID
SetTimeouts(
    _In_  PDEVICE_CONTEXT   DeviceContext,
    _In_  SERIAL_TIMEOUTS   Timeouts
    );

VOID
GetTimeouts(
    _In_  PDEVICE_CONTEXT   DeviceContext,
    _Out_ SERIAL_TIMEOUTS   *Timeouts
    );