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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
161
167
168
169
171
172
173
174
175
176
177
178
179
180
181
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
220
221
222
223
224
225
...
...
...
#define UX_SOURCE_CODE
#include "ux_api.h"
#include "ux_host_class_storage.h"
#include "ux_host_stack.h"
#if !defined(UX_HOST_CLASS_STORAGE_NO_FILEX) && !defined(UX_HOST_STANDALONE)...
...
VOID _ux_host_class_storage_driver_entry(FX_MEDIA *media)
{
UINT status;
UX_HOST_CLASS_STORAGE *storage;
UX_HOST_CLASS_STORAGE_MEDIA *storage_media;
storage = (UX_HOST_CLASS_STORAGE *) media -> fx_media_driver_info;
storage_media = (UX_HOST_CLASS_STORAGE_MEDIA *) media -> fx_media_reserved_for_user;
if ((storage -> ux_host_class_storage_state != UX_HOST_CLASS_INSTANCE_LIVE) &&
(storage -> ux_host_class_storage_state != UX_HOST_CLASS_INSTANCE_MOUNTING))
{
media -> fx_media_driver_status = FX_PTR_ERROR;
return;
}if ((storage -> ux_host_class_storage_state != UX_HOST_CLASS_INSTANCE_LIVE) && (storage -> ux_host_class_storage_state != UX_HOST_CLASS_INSTANCE_MOUNTING)) { ... }
status = _ux_host_semaphore_get(&storage -> ux_host_class_storage_semaphore, UX_WAIT_FOREVER);
storage -> ux_host_class_storage_lun = storage_media -> ux_host_class_storage_media_lun;
storage -> ux_host_class_storage_sector_size = storage_media -> ux_host_class_storage_media_sector_size;
switch (media -> fx_media_driver_request)
{
case FX_DRIVER_READ:
status = _ux_host_class_storage_media_read(storage, media -> fx_media_driver_logical_sector +
storage_media -> ux_host_class_storage_media_partition_start,
media -> fx_media_driver_sectors, media -> fx_media_driver_buffer);
if (status == UX_SUCCESS)
media -> fx_media_driver_status = FX_SUCCESS;
else
media -> fx_media_driver_status = _ux_host_class_storage_sense_code_translate(storage, status);
break;
case FX_DRIVER_READ:
case FX_DRIVER_WRITE:
status = _ux_host_class_storage_media_write(storage, media -> fx_media_driver_logical_sector +
storage_media -> ux_host_class_storage_media_partition_start,
media -> fx_media_driver_sectors, media -> fx_media_driver_buffer);
if (status == UX_SUCCESS)
media -> fx_media_driver_status = FX_SUCCESS;
else
media -> fx_media_driver_status = _ux_host_class_storage_sense_code_translate(storage,status);
break;
case FX_DRIVER_WRITE:
case FX_DRIVER_FLUSH:
media -> fx_media_driver_status = FX_SUCCESS;
break;
case FX_DRIVER_FLUSH:
case FX_DRIVER_ABORT:
media -> fx_media_driver_status = FX_SUCCESS;
break;
case FX_DRIVER_ABORT:
case FX_DRIVER_INIT:
/* ... */
if (storage -> ux_host_class_storage_write_protected_media == UX_TRUE)
media -> fx_media_driver_write_protect = UX_TRUE;
media -> fx_media_driver_status = FX_SUCCESS;
break;
case FX_DRIVER_INIT:
case FX_DRIVER_UNINIT:
media -> fx_media_driver_status = FX_SUCCESS;
break;
case FX_DRIVER_UNINIT:
case FX_DRIVER_BOOT_READ:
status = _ux_host_class_storage_media_read(storage, storage_media -> ux_host_class_storage_media_partition_start, 1,
media -> fx_media_driver_buffer);
if (status == UX_SUCCESS)
media -> fx_media_driver_status = FX_SUCCESS;
else
media -> fx_media_driver_status = _ux_host_class_storage_sense_code_translate(storage,status);
break;
case FX_DRIVER_BOOT_READ:
case FX_DRIVER_BOOT_WRITE:
status = _ux_host_class_storage_media_write(storage, storage_media -> ux_host_class_storage_media_partition_start, 1,
media -> fx_media_driver_buffer);
if (status == UX_SUCCESS)
media -> fx_media_driver_status = FX_SUCCESS;
else
media -> fx_media_driver_status = _ux_host_class_storage_sense_code_translate(storage, status);
break;
case FX_DRIVER_BOOT_WRITE:
default:
media -> fx_media_driver_status = FX_IO_ERROR;
break;default
}switch (media -> fx_media_driver_request) { ... }
_ux_host_semaphore_put(&storage -> ux_host_class_storage_semaphore);
}{ ... }
#endif... /* ... */