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 /**   Host Sierra Wireless AR module class                                */
18 /**                                                                       */
19 /**************************************************************************/
20 /**************************************************************************/
21 
22 
23 /**************************************************************************/
24 /*                                                                        */
25 /*  COMPONENT DEFINITION                                   RELEASE        */
26 /*                                                                        */
27 /*    ux_host_class_swar.h                                PORTABLE C      */
28 /*                                                           6.1.8        */
29 /*  AUTHOR                                                                */
30 /*                                                                        */
31 /*    Chaoqiong Xiao, Microsoft Corporation                               */
32 /*                                                                        */
33 /*  DESCRIPTION                                                           */
34 /*                                                                        */
35 /*    This file contains all the header and extern functions used by the  */
36 /*    USBX Sierra Wireless AR Class.                                      */
37 /*                                                                        */
38 /*  RELEASE HISTORY                                                       */
39 /*                                                                        */
40 /*    DATE              NAME                      DESCRIPTION             */
41 /*                                                                        */
42 /*  05-19-2020     Chaoqiong Xiao           Initial Version 6.0           */
43 /*  09-30-2020     Chaoqiong Xiao           Modified comment(s),          */
44 /*                                            used UX prefix to refer to  */
45 /*                                            TX symbols instead of using */
46 /*                                            them directly,              */
47 /*                                            resulting in version 6.1    */
48 /*  08-02-2021     Wen Wang                 Modified comment(s),          */
49 /*                                            added extern "C" keyword    */
50 /*                                            for compatibility with C++, */
51 /*                                            resulting in version 6.1.8  */
52 /*                                                                        */
53 /**************************************************************************/
54 
55 #ifndef UX_HOST_CLASS_SWAR_H
56 #define UX_HOST_CLASS_SWAR_H
57 
58 /* Determine if a C++ compiler is being used.  If so, ensure that standard
59    C is used to process the API information.  */
60 
61 #ifdef   __cplusplus
62 
63 /* Yes, C++ compiler is present.  Use standard C.  */
64 extern   "C" {
65 
66 #endif
67 
68 
69 /* Internal option: enable the basic USBX error checking. This define is typically used
70    while debugging application.  */
71 #if defined(UX_ENABLE_ERROR_CHECKING) && !defined(UX_HOST_CLASS_SWAR_ENABLE_ERROR_CHECKING)
72 #define UX_HOST_CLASS_SWAR_ENABLE_ERROR_CHECKING
73 #endif
74 
75 
76 /* Define Sierra Wireless AR Class constants.  */
77 
78 #define UX_HOST_CLASS_SWAR_CLASS_TRANSFER_TIMEOUT               300000
79 #ifndef UX_HOST_CLASS_SWAR_VENDOR_ID
80 #define UX_HOST_CLASS_SWAR_VENDOR_ID                            0X1199
81 #define UX_HOST_CLASS_SWAR_PRODUCT_ID                           0X68A3
82 #endif
83 
84 /* Define Sierra Wireless AR Class packet equivalences.  */
85 #define UX_HOST_CLASS_SWAR_PACKET_SIZE                          128
86 
87 /* Define Sierra Wireless AR Class data interface.  */
88 #define UX_HOST_CLASS_SWAR_DATA_INTERFACE                       3
89 
90 /* Define Sierra Wireless AR IOCTL functions.  */
91 #define UX_HOST_CLASS_SWAR_IOCTL_ABORT_IN_PIPE                  1
92 #define UX_HOST_CLASS_SWAR_IOCTL_ABORT_OUT_PIPE                 2
93 
94 /* Define CDC ACM Reception States. */
95 
96 #define UX_HOST_CLASS_SWAR_RECEPTION_STATE_STOPPED              0
97 #define UX_HOST_CLASS_SWAR_RECEPTION_STATE_STARTED              1
98 #define UX_HOST_CLASS_SWAR_RECEPTION_STATE_IN_TRANSFER          2
99 
100 
101 /* Define Sierra Wireless Airprime Class instance structure.  */
102 
103 typedef struct UX_HOST_CLASS_SWAR_STRUCT
104 {
105 
106     struct UX_HOST_CLASS_SWAR_STRUCT
107                     *ux_host_class_swar_next_instance;
108     UX_HOST_CLASS   *ux_host_class_swar_class;
109     UX_DEVICE       *ux_host_class_swar_device;
110     UX_INTERFACE    *ux_host_class_swar_interface;
111     UX_ENDPOINT     *ux_host_class_swar_bulk_out_endpoint;
112     UX_ENDPOINT     *ux_host_class_swar_bulk_in_endpoint;
113     UINT            ux_host_class_swar_state;
114     UX_SEMAPHORE    ux_host_class_swar_semaphore;
115 
116     struct UX_HOST_CLASS_SWAR_RECEPTION_STRUCT
117                     *ux_host_class_swar_reception;
118     ULONG           ux_host_class_swar_notification_count;
119 } UX_HOST_CLASS_SWAR;
120 
121 /* Define Sierra Wireless reception structure. */
122 
123 typedef struct UX_HOST_CLASS_SWAR_RECEPTION_STRUCT
124 {
125 
126     ULONG           ux_host_class_swar_reception_state;
127     ULONG           ux_host_class_swar_reception_block_size;
128     UCHAR           *ux_host_class_swar_reception_data_buffer;
129     ULONG           ux_host_class_swar_reception_data_buffer_size;
130     UCHAR           *ux_host_class_swar_reception_data_head;
131     UCHAR           *ux_host_class_swar_reception_data_tail;
132     VOID            (*ux_host_class_swar_reception_callback)(struct UX_HOST_CLASS_SWAR_STRUCT *swar,
133                                                                 UINT  status,
134                                                                 UCHAR *reception_buffer,
135                                                                 ULONG reception_size);
136 
137 } UX_HOST_CLASS_SWAR_RECEPTION;
138 
139 /* Define  Sierra Wireless Airprime Classfunction prototypes.  */
140 
141 UINT    _ux_host_class_swar_activate(UX_HOST_CLASS_COMMAND *command);
142 UINT    _ux_host_class_swar_configure(UX_HOST_CLASS_SWAR *swar);
143 UINT    _ux_host_class_swar_deactivate(UX_HOST_CLASS_COMMAND *command);
144 UINT    _ux_host_class_swar_endpoints_get(UX_HOST_CLASS_SWAR *swar);
145 UINT    _ux_host_class_swar_entry(UX_HOST_CLASS_COMMAND *command);
146 UINT    _ux_host_class_swar_read (UX_HOST_CLASS_SWAR *swar, UCHAR *data_pointer,
147                                     ULONG requested_length, ULONG *actual_length);
148 UINT    _ux_host_class_swar_write(UX_HOST_CLASS_SWAR *swar, UCHAR *data_pointer,
149                                     ULONG requested_length, ULONG *actual_length);
150 UINT    _ux_host_class_swar_ioctl(UX_HOST_CLASS_SWAR *swar, ULONG ioctl_function,
151                                     VOID *parameter);
152 VOID    _ux_host_class_swar_reception_callback (UX_TRANSFER *transfer_request);
153 UINT    _ux_host_class_swar_reception_stop (UX_HOST_CLASS_SWAR *swar,
154                                     UX_HOST_CLASS_SWAR_RECEPTION *swar_reception);
155 UINT    _ux_host_class_swar_reception_start (UX_HOST_CLASS_SWAR *swar,
156                                     UX_HOST_CLASS_SWAR_RECEPTION *swar_reception);
157 
158 
159 UINT    _uxe_host_class_swar_read (UX_HOST_CLASS_SWAR *swar, UCHAR *data_pointer,
160                                     ULONG requested_length, ULONG *actual_length);
161 UINT    _uxe_host_class_swar_write(UX_HOST_CLASS_SWAR *swar, UCHAR *data_pointer,
162                                     ULONG requested_length, ULONG *actual_length);
163 UINT    _uxe_host_class_swar_ioctl(UX_HOST_CLASS_SWAR *swar, ULONG ioctl_function,
164                                     VOID *parameter);
165 UINT    _uxe_host_class_swar_reception_stop (UX_HOST_CLASS_SWAR *swar,
166                                     UX_HOST_CLASS_SWAR_RECEPTION *swar_reception);
167 UINT    _uxe_host_class_swar_reception_start (UX_HOST_CLASS_SWAR *swar,
168                                     UX_HOST_CLASS_SWAR_RECEPTION *swar_reception);
169 
170 /* Define SWAR Class API prototypes.  */
171 
172 #define  ux_host_class_swar_entry                           _ux_host_class_swar_entry
173 #define  ux_host_class_swar_setup                           _ux_host_class_swar_setup
174 
175 #if defined(UX_HOST_CLASS_SWAR_ENABLE_ERROR_CHECKING)
176 
177 #define  ux_host_class_swar_read                            _uxe_host_class_swar_read
178 #define  ux_host_class_swar_write                           _uxe_host_class_swar_write
179 #define  ux_host_class_swar_ioctl                           _uxe_host_class_swar_ioctl
180 #define  ux_host_class_swar_reception_stop                  _uxe_host_class_swar_reception_stop
181 #define  ux_host_class_swar_reception_start                 _uxe_host_class_swar_reception_start
182 
183 #else
184 
185 #define  ux_host_class_swar_read                            _ux_host_class_swar_read
186 #define  ux_host_class_swar_write                           _ux_host_class_swar_write
187 #define  ux_host_class_swar_ioctl                           _ux_host_class_swar_ioctl
188 #define  ux_host_class_swar_reception_stop                  _ux_host_class_swar_reception_stop
189 #define  ux_host_class_swar_reception_start                 _ux_host_class_swar_reception_start
190 
191 #endif
192 
193 /* Determine if a C++ compiler is being used.  If so, complete the standard
194    C conditional started above.  */
195 #ifdef __cplusplus
196 }
197 #endif
198 
199 #endif
200