blob: a0790cfed3faf3a1e9f2d0dab147612de5bbba84 (
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
|
/***************************************************************************
* Copyright (c) 2024 Microsoft Corporation
* Copyright (c) 2026-present Eclipse ThreadX contributors
*
* This program and the accompanying materials are made available under the
* terms of the MIT License which is available at
* https://opensource.org/licenses/MIT.
*
* SPDX-License-Identifier: MIT
**************************************************************************/
/**************************************************************************/
/**************************************************************************/
/** */
/** USBX Component */
/** */
/** Host Stack */
/** */
/**************************************************************************/
/**************************************************************************/
/* Include necessary system files. */
#define UX_SOURCE_CODE
#include "ux_api.h"
#include "ux_host_stack.h"
#if !defined(UX_HOST_STACK_DEVICE_DRIVER_SCAN_DISABLE)
#if defined(UX_HOST_STACK_DEVICE_DRIVER_SCAN_VIDPID_DISABLE) && \
defined(UX_HOST_STACK_DEVICE_DRIVER_SCAN_DCSP_DISABLE)
#error When device driver scan is enabled at least one of scan method must be enabled in (VIDPID, DeviceClassSubclassProtocol)
#endif
#endif
/**************************************************************************/
/* */
/* FUNCTION RELEASE */
/* */
/* _ux_host_stack_class_device_scan PORTABLE C */
/* 6.1.10 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
/* */
/* DESCRIPTION */
/* */
/* This function will scan all registered classes with a device */
/* candidate. Priority is given to the PID/VID and then the */
/* Class/Subclass/Protocol. */
/* */
/* INPUT */
/* */
/* device Pointer to device */
/* */
/* OUTPUT */
/* */
/* Completion Status */
/* */
/* CALLS */
/* */
/* _ux_host_stack_class_call Call host stack class */
/* (ux_host_class_entry_function) Class entry function */
/* */
/* CALLED BY */
/* */
/* USBX Components */
/* */
/**************************************************************************/
UINT _ux_host_stack_class_device_scan(UX_DEVICE *device)
{
#if !defined(UX_HOST_STACK_DEVICE_DRIVER_SCAN_DISABLE)
UINT status;
UX_HOST_CLASS *class_inst = UX_NULL;
UX_HOST_CLASS_COMMAND class_command;
/* Perform the command initialization. */
class_command.ux_host_class_command_request = UX_HOST_CLASS_COMMAND_QUERY;
class_command.ux_host_class_command_container = (VOID *) device;
class_command.ux_host_class_command_vid = device -> ux_device_descriptor.idVendor;
class_command.ux_host_class_command_pid = device -> ux_device_descriptor.idProduct;
class_command.ux_host_class_command_class = device -> ux_device_descriptor.bDeviceClass;
class_command.ux_host_class_command_subclass = device -> ux_device_descriptor.bDeviceSubClass;
class_command.ux_host_class_command_protocol = device -> ux_device_descriptor.bDeviceProtocol;
class_command.ux_host_class_command_iad_class = 0;
class_command.ux_host_class_command_iad_subclass = 0;
class_command.ux_host_class_command_iad_protocol = 0;
#if !defined(UX_HOST_STACK_DEVICE_DRIVER_SCAN_VIDPID_DISABLE)
/* We start with the PID/VID for this device. */
class_command.ux_host_class_command_usage = UX_HOST_CLASS_COMMAND_USAGE_PIDVID;
class_inst = _ux_host_stack_class_call(&class_command);
#endif
#if !defined(UX_HOST_STACK_DEVICE_DRIVER_SCAN_DCSP_DISABLE)
/* On return, either we have found a class or the device is still an orphan. */
if (class_inst == UX_NULL)
{
/* It the PID/VID did not work, we continue looking for the Class\Subclass\Protocol match. */
class_command.ux_host_class_command_usage = UX_HOST_CLASS_COMMAND_USAGE_DCSP;
class_inst = _ux_host_stack_class_call(&class_command);
}
#endif
/* On return, either we have found a class or the device is still an orphan. */
if (class_inst != UX_NULL)
{
device -> ux_device_class = class_inst;
#if defined(UX_HOST_STANDALONE)
/* Activation may take time, run as state machine. */
status = UX_SUCCESS;
return(status);
#else
class_command.ux_host_class_command_class_ptr = class_inst;
class_command.ux_host_class_command_request = UX_HOST_CLASS_COMMAND_ACTIVATE;
status = device -> ux_device_class -> ux_host_class_entry_function(&class_command);
/* Return result of activation. */
return(status);
#endif
}
#endif
/* Return an error. */
return(UX_NO_CLASS_MATCH);
}
|