1 |
|
|
/*************************************************************************** |
2 |
|
|
* Copyright (c) 2024 Microsoft Corporation |
3 |
|
|
* |
4 |
|
|
* This program and the accompanying materials are made available under the |
5 |
|
|
* terms of the MIT License which is available at |
6 |
|
|
* https://opensource.org/licenses/MIT. |
7 |
|
|
* |
8 |
|
|
* SPDX-License-Identifier: MIT |
9 |
|
|
**************************************************************************/ |
10 |
|
|
|
11 |
|
|
|
12 |
|
|
/**************************************************************************/ |
13 |
|
|
/**************************************************************************/ |
14 |
|
|
/** */ |
15 |
|
|
/** USBX Component */ |
16 |
|
|
/** */ |
17 |
|
|
/** HUB Class */ |
18 |
|
|
/** */ |
19 |
|
|
/**************************************************************************/ |
20 |
|
|
/**************************************************************************/ |
21 |
|
|
|
22 |
|
|
|
23 |
|
|
/* Include necessary system files. */ |
24 |
|
|
|
25 |
|
|
#define UX_SOURCE_CODE |
26 |
|
|
|
27 |
|
|
#include "ux_api.h" |
28 |
|
|
#include "ux_host_class_hub.h" |
29 |
|
|
#include "ux_host_stack.h" |
30 |
|
|
|
31 |
|
|
|
32 |
|
|
/**************************************************************************/ |
33 |
|
|
/* */ |
34 |
|
|
/* FUNCTION RELEASE */ |
35 |
|
|
/* */ |
36 |
|
|
/* _ux_host_class_hub_port_change_process PORTABLE C */ |
37 |
|
|
/* 6.1 */ |
38 |
|
|
/* AUTHOR */ |
39 |
|
|
/* */ |
40 |
|
|
/* Chaoqiong Xiao, Microsoft Corporation */ |
41 |
|
|
/* */ |
42 |
|
|
/* DESCRIPTION */ |
43 |
|
|
/* */ |
44 |
|
|
/* This function will process a port change indication. */ |
45 |
|
|
/* */ |
46 |
|
|
/* INPUT */ |
47 |
|
|
/* */ |
48 |
|
|
/* hub Pointer to HUB class */ |
49 |
|
|
/* port Port number */ |
50 |
|
|
/* */ |
51 |
|
|
/* OUTPUT */ |
52 |
|
|
/* */ |
53 |
|
|
/* Completion Status */ |
54 |
|
|
/* */ |
55 |
|
|
/* CALLS */ |
56 |
|
|
/* */ |
57 |
|
|
/* _ux_host_class_hub_port_change_connection_process */ |
58 |
|
|
/* Process connection */ |
59 |
|
|
/* _ux_host_class_hub_port_change_enable_process */ |
60 |
|
|
/* Enable process */ |
61 |
|
|
/* _ux_host_class_hub_port_change_over_current_process */ |
62 |
|
|
/* Change over current process */ |
63 |
|
|
/* _ux_host_class_hub_port_change_reset_process */ |
64 |
|
|
/* Reset process */ |
65 |
|
|
/* _ux_host_class_hub_port_change_suspend_process */ |
66 |
|
|
/* Suspend process */ |
67 |
|
|
/* _ux_host_class_hub_status_get Get HUB status */ |
68 |
|
|
/* */ |
69 |
|
|
/* CALLED BY */ |
70 |
|
|
/* */ |
71 |
|
|
/* HUB Class */ |
72 |
|
|
/* */ |
73 |
|
|
/* RELEASE HISTORY */ |
74 |
|
|
/* */ |
75 |
|
|
/* DATE NAME DESCRIPTION */ |
76 |
|
|
/* */ |
77 |
|
|
/* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ |
78 |
|
|
/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ |
79 |
|
|
/* resulting in version 6.1 */ |
80 |
|
|
/* */ |
81 |
|
|
/**************************************************************************/ |
82 |
|
27 |
UINT _ux_host_class_hub_port_change_process(UX_HOST_CLASS_HUB *hub, UINT port) |
83 |
|
|
{ |
84 |
|
|
|
85 |
|
|
USHORT port_status; |
86 |
|
|
USHORT port_change; |
87 |
|
|
UINT status; |
88 |
|
|
|
89 |
|
|
|
90 |
|
|
/* First step is to retrieve the status on the port with a GET_STATUS. */ |
91 |
|
27 |
status = _ux_host_class_hub_status_get(hub, port, &port_status, &port_change); |
92 |
✓✓ |
27 |
if (status != UX_SUCCESS) |
93 |
|
2 |
return(status); |
94 |
|
|
|
95 |
|
|
/* On return of the GET_STATUS, the port change field has been updated |
96 |
|
|
check for each of the bits it may contain. */ |
97 |
✓✓ |
25 |
if (port_change & UX_HOST_CLASS_HUB_PORT_CHANGE_CONNECTION) |
98 |
|
21 |
_ux_host_class_hub_port_change_connection_process(hub, port, port_status); |
99 |
|
|
|
100 |
✓✓ |
25 |
if (port_change & UX_HOST_CLASS_HUB_PORT_CHANGE_ENABLE) |
101 |
|
1 |
_ux_host_class_hub_port_change_enable_process(hub, port, port_status); |
102 |
|
|
|
103 |
✓✓ |
25 |
if (port_change & UX_HOST_CLASS_HUB_PORT_CHANGE_SUSPEND) |
104 |
|
1 |
_ux_host_class_hub_port_change_suspend_process(hub, port, port_status); |
105 |
|
|
|
106 |
✓✓ |
25 |
if (port_change & UX_HOST_CLASS_HUB_PORT_CHANGE_OVER_CURRENT) |
107 |
|
1 |
_ux_host_class_hub_port_change_over_current_process(hub, port, port_status); |
108 |
|
|
|
109 |
✓✓ |
25 |
if (port_change & UX_HOST_CLASS_HUB_PORT_CHANGE_RESET) |
110 |
|
1 |
_ux_host_class_hub_port_change_reset_process(hub, port, port_status); |
111 |
|
|
|
112 |
|
|
/* Return successful completion. */ |
113 |
|
25 |
return(UX_SUCCESS); |
114 |
|
|
} |
115 |
|
|
|