blob: 36378cd503ea7e305efca1fee77f2d2aec926bf2 (
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
|
/***************************************************************************
* 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 */
/** */
/** ASIX Class */
/** */
/**************************************************************************/
/**************************************************************************/
/* Include necessary system files. */
#define UX_SOURCE_CODE
#include "ux_api.h"
#include "ux_host_class_asix.h"
#include "ux_host_stack.h"
/**************************************************************************/
/* */
/* FUNCTION RELEASE */
/* */
/* _ux_host_class_asix_interrupt_notification PORTABLE C */
/* 6.2.0 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
/* */
/* DESCRIPTION */
/* */
/* This function is called by the stack when an interrupt packet as */
/* been received. */
/* */
/* INPUT */
/* */
/* transfer_request Pointer to transfer request */
/* */
/* OUTPUT */
/* */
/* None */
/* */
/* CALLS */
/* */
/* _ux_host_semaphore_put Put semaphore */
/* _ux_host_stack_transfer_request Transfer request */
/* */
/* CALLED BY */
/* */
/* USBX stack */
/* */
/**************************************************************************/
VOID _ux_host_class_asix_interrupt_notification(UX_TRANSFER *transfer_request)
{
UX_HOST_CLASS_ASIX *asix;
/* Get the class instance for this transfer request. */
asix = (UX_HOST_CLASS_ASIX *) transfer_request -> ux_transfer_request_class_instance;
/* Check the state of the transfer. If there is an error, we do not proceed with this notification. */
if (transfer_request -> ux_transfer_request_completion_code != UX_SUCCESS)
/* We do not proceed. */
return;
/* Check if the class is in shutdown. */
if (asix -> ux_host_class_asix_state == UX_HOST_CLASS_INSTANCE_SHUTDOWN)
/* We do not proceed. */
return;
/* Increment the notification count. */
asix -> ux_host_class_asix_notification_count++;
/* Ensure the length of our interrupt pipe data is correct. */
if (transfer_request -> ux_transfer_request_actual_length ==
transfer_request -> ux_transfer_request_requested_length)
{
/* Check if the first byte is a interrupt packet signature. */
if (*(transfer_request -> ux_transfer_request_data_pointer + UX_HOST_CLASS_ASIX_INTERRUPT_SIGNATURE_OFFSET) ==
UX_HOST_CLASS_ASIX_INTERRUPT_SIGNATURE_VALUE)
{
/* Explore the content of the interrupt packet. We treat the link up/down flag here. */
if (*(transfer_request -> ux_transfer_request_data_pointer + UX_HOST_CLASS_ASIX_INTERRUPT_STATE_OFFSET) &
UX_HOST_CLASS_ASIX_INTERRUPT_STATE_PPLS)
{
/* Link is up. See if we know about that. */
if (asix -> ux_host_class_asix_link_state != UX_HOST_CLASS_ASIX_LINK_STATE_UP &&
asix -> ux_host_class_asix_link_state != UX_HOST_CLASS_ASIX_LINK_STATE_PENDING_UP)
{
/* Memorize the new link state. */
asix -> ux_host_class_asix_link_state = UX_HOST_CLASS_ASIX_LINK_STATE_PENDING_UP;
/* We need to inform the asix thread of this change. */
_ux_host_semaphore_put(&asix -> ux_host_class_asix_interrupt_notification_semaphore);
/* Reactivate interrupt pipe after link up handled. */
return;
}
}
else
{
/* Link is down. See if we know about that. */
if (asix -> ux_host_class_asix_link_state != UX_HOST_CLASS_ASIX_LINK_STATE_DOWN &&
asix -> ux_host_class_asix_link_state != UX_HOST_CLASS_ASIX_LINK_STATE_PENDING_DOWN)
{
/* Memorize the new link state. */
asix -> ux_host_class_asix_link_state = UX_HOST_CLASS_ASIX_LINK_STATE_PENDING_DOWN;
/* Abort possible pending bulk in requests. */
_ux_host_stack_endpoint_transfer_abort(asix -> ux_host_class_asix_bulk_in_endpoint);
/* We need to inform the asix thread of this change. */
_ux_host_semaphore_put(&asix -> ux_host_class_asix_interrupt_notification_semaphore);
/* Reactivate interrupt pipe after link down handled. */
return;
}
}
}
}
/* Reactivate the ASIX interrupt pipe. */
_ux_host_stack_transfer_request(transfer_request);
/* If trace is enabled, insert this event into the trace buffer. */
UX_TRACE_IN_LINE_INSERT(UX_TRACE_HOST_CLASS_ASIX_INTERRUPT_NOTIFICATION, asix, 0, 0, 0, UX_TRACE_HOST_CLASS_EVENTS, 0, 0)
/* Return to caller. */
return;
}
|