summaryrefslogtreecommitdiff
path: root/common/core/inc/ux_device_class_dpump.h
blob: 87b11649d8d7bd0e57860d581154b7aaee7f7824 (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
/***************************************************************************
 * 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                                                        */
/**                                                                       */
/**   Device Data Pump Class                                              */
/**                                                                       */
/**************************************************************************/
/**************************************************************************/


/**************************************************************************/
/*                                                                        */
/*  COMPONENT DEFINITION                                   RELEASE        */
/*                                                                        */
/*    ux_device_class_dpump.h                             PORTABLE C      */
/*                                                           6.3.0        */
/*  AUTHOR                                                                */
/*                                                                        */
/*    Chaoqiong Xiao, Microsoft Corporation                               */
/*                                                                        */
/*  DESCRIPTION                                                           */
/*                                                                        */
/*    This file contains all the header and extern functions used by the  */
/*    USBX device dpump class.                                            */
/*                                                                        */
/**************************************************************************/

#ifndef UX_DEVICE_CLASS_DPUMP_H
#define UX_DEVICE_CLASS_DPUMP_H

/* Determine if a C++ compiler is being used.  If so, ensure that standard
   C is used to process the API information.  */

#ifdef   __cplusplus

/* Yes, C++ compiler is present.  Use standard C.  */
extern   "C" {

#endif


/* Bulk out endpoint / read buffer size, must be larger than max packet size in framework, and aligned in 4-bytes.  */
#define UX_DEVICE_CLASS_DPUMP_READ_BUFFER_SIZE                  UX_SLAVE_REQUEST_DATA_MAX_LENGTH

/* Bulk in endpoint / write buffer size, must be larger than max packet size in framework, and aligned in 4-bytes.  */
#define UX_DEVICE_CLASS_DPUMP_WRITE_BUFFER_SIZE                 UX_SLAVE_REQUEST_DATA_MAX_LENGTH


/* Define Storage Class USB Class constants.  */

#define UX_SLAVE_CLASS_DPUMP_CLASS                              0x99
#define UX_SLAVE_CLASS_DPUMP_SUBCLASS                           0x99
#define UX_SLAVE_CLASS_DPUMP_PROTOCOL                           0x99

/* Define Data Pump Class packet equivalences.  */
#define UX_DEVICE_CLASS_DPUMP_PACKET_SIZE                       128


/* Define Slave DPUMP Class Calling Parameter structure */

typedef struct UX_SLAVE_CLASS_DPUMP_PARAMETER_STRUCT
{
    VOID                    (*ux_slave_class_dpump_instance_activate)(VOID *);
    VOID                    (*ux_slave_class_dpump_instance_deactivate)(VOID *);

} UX_SLAVE_CLASS_DPUMP_PARAMETER;

/* Define Slave Data Pump Class structure.  */

typedef struct UX_SLAVE_CLASS_DPUMP_STRUCT
{
    UX_SLAVE_INTERFACE                  *ux_slave_class_dpump_interface;
    UX_SLAVE_CLASS_DPUMP_PARAMETER      ux_slave_class_dpump_parameter;
    UX_SLAVE_ENDPOINT                   *ux_slave_class_dpump_bulkin_endpoint;
    UX_SLAVE_ENDPOINT                   *ux_slave_class_dpump_bulkout_endpoint;
#if UX_DEVICE_ENDPOINT_BUFFER_OWNER == 1
    UCHAR                               *ux_device_class_dpump_endpoint_buffer;
#endif
    ULONG                               ux_slave_class_dpump_alternate_setting;
#if defined(UX_DEVICE_STANDALONE)
    UCHAR                               *ux_device_class_dpump_write_buffer;
    ULONG                               ux_device_class_dpump_write_requested_length;
    ULONG                               ux_device_class_dpump_write_transfer_length;
    ULONG                               ux_device_class_dpump_write_actual_length;
    UINT                                ux_device_class_dpump_write_state;
    UINT                                ux_device_class_dpump_write_status;
    UCHAR                               *ux_device_class_dpump_read_buffer;
    ULONG                               ux_device_class_dpump_read_requested_length;
    ULONG                               ux_device_class_dpump_read_transfer_length;
    ULONG                               ux_device_class_dpump_read_actual_length;
    UINT                                ux_device_class_dpump_read_state;
    UINT                                ux_device_class_dpump_read_status;
#endif
} UX_SLAVE_CLASS_DPUMP;

/* Defined for endpoint buffer settings (when DPUMP owns buffer).  */
#define UX_DEVICE_CLASS_DPUMP_ENDPOINT_BUFFER_SIZE_CALC_OVERFLOW                \
    (UX_OVERFLOW_CHECK_ADD_ULONG(UX_DEVICE_CLASS_DPUMP_READ_BUFFER_SIZE,        \
                                 UX_DEVICE_CLASS_DPUMP_WRITE_BUFFER_SIZE))
#define UX_DEVICE_CLASS_DPUMP_ENDPOINT_BUFFER_SIZE  (UX_DEVICE_CLASS_DPUMP_READ_BUFFER_SIZE + UX_DEVICE_CLASS_DPUMP_WRITE_BUFFER_SIZE)
#define UX_DEVICE_CLASS_DPUMP_READ_BUFFER(dpump)    ((dpump)->ux_device_class_dpump_endpoint_buffer)
#define UX_DEVICE_CLASS_DPUMP_WRITE_BUFFER(dpump)   (UX_DEVICE_CLASS_DPUMP_READ_BUFFER(dpump) + UX_DEVICE_CLASS_DPUMP_READ_BUFFER_SIZE)


/* Define Device Data Pump Class prototypes.  */

UINT    _ux_device_class_dpump_initialize(UX_SLAVE_CLASS_COMMAND *command);
UINT    _ux_device_class_dpump_activate(UX_SLAVE_CLASS_COMMAND *command);
UINT    _ux_device_class_dpump_deactivate(UX_SLAVE_CLASS_COMMAND *command);
UINT    _ux_device_class_dpump_entry(UX_SLAVE_CLASS_COMMAND *command);
UINT    _ux_device_class_dpump_read(UX_SLAVE_CLASS_DPUMP *dpump, UCHAR *buffer,
                                ULONG requested_length, ULONG *actual_length);
UINT    _ux_device_class_dpump_read_run(UX_SLAVE_CLASS_DPUMP *dpump, UCHAR *buffer,
                                ULONG requested_length, ULONG *actual_length);
UINT    _ux_device_class_dpump_write(UX_SLAVE_CLASS_DPUMP *dpump, UCHAR *buffer,
                                ULONG requested_length, ULONG *actual_length);
UINT    _ux_device_class_dpump_write_run(UX_SLAVE_CLASS_DPUMP *dpump, UCHAR *buffer,
                                ULONG requested_length, ULONG *actual_length);
UINT    _ux_device_class_dpump_change(UX_SLAVE_CLASS_COMMAND *command);

/* Define Device DPUMP Class API prototypes.  */

#define ux_device_class_dpump_entry                               _ux_device_class_dpump_entry
#define ux_device_class_dpump_read                                _ux_device_class_dpump_read
#define ux_device_class_dpump_read_run                            _ux_device_class_dpump_read_run
#define ux_device_class_dpump_write                               _ux_device_class_dpump_write
#define ux_device_class_dpump_write_run                           _ux_device_class_dpump_write_run

/* Determine if a C++ compiler is being used.  If so, complete the standard
   C conditional started above.  */
#ifdef __cplusplus
}
#endif

#endif