1
10
13
14
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
137
138
139
140
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
185
186
187
188
189
190
192
193
194
195
196
197
198
199
200
201
202
203
...
...
...
#define UX_SOURCE_CODE
#include "ux_api.h"
#include "ux_device_class_storage.h"
#include "ux_device_stack.h"
...
...
UINT _ux_device_class_storage_synchronize_cache(UX_SLAVE_CLASS_STORAGE *storage, ULONG lun,
UX_SLAVE_ENDPOINT *endpoint_in,
UX_SLAVE_ENDPOINT *endpoint_out, UCHAR *cbwcb, UCHAR scsi_command)
{
UINT status;
ULONG lba;
USHORT number_blocks;
ULONG media_status;
#if !defined(UX_DEVICE_STANDALONE)
UCHAR flags;
#endif
UX_PARAMETER_NOT_USED(endpoint_out);
UX_PARAMETER_NOT_USED(scsi_command);
storage -> ux_slave_class_storage_csw_status = UX_SLAVE_CLASS_STORAGE_CSW_PASSED;
if (storage -> ux_slave_class_storage_lun[lun].ux_slave_class_storage_media_flush == UX_NULL)
{
return(UX_SUCCESS);
}if (storage -> ux_slave_class_storage_lun[lun].ux_slave_class_storage_media_flush == UX_NULL) { ... }
lba = _ux_utility_long_get_big_endian(cbwcb + UX_SLAVE_CLASS_STORAGE_SYNCHRONIZE_CACHE_LBA);
number_blocks = (USHORT)_ux_utility_short_get_big_endian(cbwcb + UX_SLAVE_CLASS_STORAGE_SYNCHRONIZE_CACHE_NUMBER_OF_BLOCKS);
UX_TRACE_IN_LINE_INSERT(UX_TRACE_DEVICE_CLASS_STORAGE_SYNCHRONIZE_CACHE, storage, lun, lba, number_blocks, UX_TRACE_DEVICE_CLASS_EVENTS, 0, 0)
status = storage -> ux_slave_class_storage_lun[lun].ux_slave_class_storage_media_status(storage,
lun, storage -> ux_slave_class_storage_lun[lun].ux_slave_class_storage_media_id, &media_status);
storage -> ux_slave_class_storage_lun[lun].ux_slave_class_storage_request_sense_status = media_status;
if (status != UX_SUCCESS)
{
/* ... */
#if !defined(UX_DEVICE_STANDALONE)
_ux_device_stack_endpoint_stall(endpoint_in);
#else
UX_PARAMETER_NOT_USED(endpoint_in);
storage -> ux_device_class_storage_cmd_state = UX_DEVICE_CLASS_STORAGE_CMD_ERR;/* ... */
#endif
storage -> ux_slave_class_storage_csw_status = UX_SLAVE_CLASS_STORAGE_CSW_FAILED;
return(UX_ERROR);
}if (status != UX_SUCCESS) { ... }
#if defined(UX_DEVICE_STANDALONE)
storage -> ux_device_class_storage_state = UX_DEVICE_CLASS_STORAGE_STATE_DISK_WAIT;
storage -> ux_device_class_storage_disk_state = UX_DEVICE_CLASS_STORAGE_DISK_OP_START;
storage -> ux_device_class_storage_cmd_state = UX_DEVICE_CLASS_STORAGE_CMD_DISK_OP;
storage -> ux_device_class_storage_cmd_lba = lba;
storage -> ux_device_class_storage_cmd_n_lb = number_blocks;
/* ... */
#else
flags = *(cbwcb + UX_SLAVE_CLASS_STORAGE_SYNCHRONIZE_CACHE_FLAGS);
if ((flags & UX_SLAVE_CLASS_STORAGE_SYNCHRONIZE_CACHE_FLAGS_IMMED) != 0)
_ux_device_class_storage_csw_send(storage, lun, endpoint_in, UX_SLAVE_CLASS_STORAGE_CSW_PASSED);
status = storage -> ux_slave_class_storage_lun[lun].ux_slave_class_storage_media_flush(storage, lun, number_blocks, lba, &media_status);
storage -> ux_slave_class_storage_lun[lun].ux_slave_class_storage_request_sense_status = media_status;
if ((flags & UX_SLAVE_CLASS_STORAGE_SYNCHRONIZE_CACHE_FLAGS_IMMED) != 0)
{
UX_DEVICE_CLASS_STORAGE_CSW_SKIP(&storage -> ux_slave_class_storage_csw_status) = UX_TRUE;
return(status);
}if ((flags & UX_SLAVE_CLASS_STORAGE_SYNCHRONIZE_CACHE_FLAGS_IMMED) != 0) { ... }
if (status != UX_SUCCESS)
{
/* ... */
_ux_device_stack_endpoint_stall(endpoint_in);
storage -> ux_slave_class_storage_csw_status = UX_SLAVE_CLASS_STORAGE_CSW_FAILED;
return(UX_ERROR);
}if (status != UX_SUCCESS) { ... }
/* ... */#endif
return(status);
}{ ... }