kvm-guest-drivers-windows

Форк
0
99 строк · 3.6 Кб
1
/*
2
 * Main driver file containing DriverEntry and driver related functions
3
 *
4
 * Copyright (c) 2016-2017 Red Hat, Inc.
5
 *
6
 * Redistribution and use in source and binary forms, with or without
7
 * modification, are permitted provided that the following conditions
8
 * are met :
9
 * 1. Redistributions of source code must retain the above copyright
10
 *    notice, this list of conditions and the following disclaimer.
11
 * 2. Redistributions in binary form must reproduce the above copyright
12
 *    notice, this list of conditions and the following disclaimer in the
13
 *    documentation and / or other materials provided with the distribution.
14
 * 3. Neither the names of the copyright holders nor the names of their contributors
15
 *    may be used to endorse or promote products derived from this software
16
 *    without specific prior written permission.
17
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND
18
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20
 * ARE DISCLAIMED.IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE
21
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27
 * SUCH DAMAGE.
28
 */
29

30
#include "precomp.h"
31
#include "vioinput.h"
32

33
#if defined(EVENT_TRACING)
34
#include "Driver.tmh"
35
#endif
36

37
DRIVER_INITIALIZE DriverEntry;
38

39
// Context cleanup callbacks generally run at IRQL <= DISPATCH_LEVEL but
40
// WDFDRIVER context cleanup is guaranteed to run at PASSIVE_LEVEL.
41
// Annotate the prototype to make static analysis happy.
42
EVT_WDF_OBJECT_CONTEXT_CLEANUP _IRQL_requires_(PASSIVE_LEVEL) VIOInputEvtDriverContextCleanup;
43

44
#ifdef ALLOC_PRAGMA
45
#pragma alloc_text (INIT, DriverEntry)
46
#pragma alloc_text (PAGE, VIOInputEvtDriverContextCleanup)
47
#endif
48

49
NTSTATUS
50
DriverEntry(
51
    IN PDRIVER_OBJECT  DriverObject,
52
    IN PUNICODE_STRING RegistryPath)
53
{
54
    NTSTATUS              status = STATUS_SUCCESS;
55
    WDF_DRIVER_CONFIG     config;
56
    WDF_OBJECT_ATTRIBUTES attributes;
57
    WDFDRIVER             driver;
58

59
    ExInitializeDriverRuntime(DrvRtPoolNxOptIn);
60

61
    InitializeDebugPrints(DriverObject, RegistryPath);
62

63
    TraceEvents(TRACE_LEVEL_INFORMATION, DBG_INIT,
64
        "Virtio-input driver started...built on %s %s\n", __DATE__, __TIME__);
65

66
    WDF_DRIVER_CONFIG_INIT(&config,VIOInputEvtDeviceAdd);
67
    config.DriverPoolTag  = VIOINPUT_DRIVER_MEMORY_TAG;
68

69
    WDF_OBJECT_ATTRIBUTES_INIT(&attributes);
70
    attributes.EvtCleanupCallback = VIOInputEvtDriverContextCleanup;
71

72
    status = WdfDriverCreate(DriverObject,
73
                             RegistryPath,
74
                             &attributes,
75
                             &config,
76
                             &driver);
77

78
    if (!NT_SUCCESS(status))
79
    {
80
        TraceEvents(TRACE_LEVEL_ERROR, DBG_INIT,
81
           "WdfDriverCreate failed - 0x%x\n", status);
82
        WPP_CLEANUP(DriverObject);
83
        return status;
84
    }
85

86
    TraceEvents(TRACE_LEVEL_INFORMATION, DBG_PNP, "<-- %s\n", __FUNCTION__);
87
    return status;
88
}
89

90
VOID
91
VIOInputEvtDriverContextCleanup(
92
    IN WDFOBJECT Driver)
93
{
94
    PAGED_CODE();
95

96
    TraceEvents(TRACE_LEVEL_INFORMATION, DBG_PNP, "<--> %s\n", __FUNCTION__);
97

98
    WPP_CLEANUP(WdfDriverWdmGetDriverObject((WDFDRIVER)Driver));
99
}
100

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.