blob: bb7085a1764d70a328f13f520796143ec13500cd (
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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
|
/***************************************************************************
* 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 */
/** */
/** Storage Class */
/** */
/**************************************************************************/
/**************************************************************************/
/* Include necessary system files. */
#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)
/**************************************************************************/
/* */
/* FUNCTION RELEASE */
/* */
/* _ux_host_class_storage_media_get PORTABLE C */
/* 6.1.12 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
/* */
/* DESCRIPTION */
/* */
/* This function retrieves storage media from the storage device. */
/* */
/* INPUT */
/* */
/* storage Pointer to storage class */
/* media_lun Media logical unit No. (LUN) */
/* storage_media Holds returned storage media */
/* pointer */
/* */
/* OUTPUT */
/* */
/* Completion Status */
/* */
/* CALLS */
/* */
/* */
/* CALLED BY */
/* */
/* Storage Class */
/* */
/**************************************************************************/
UINT _ux_host_class_storage_media_get(UX_HOST_CLASS_STORAGE *storage,
ULONG media_lun,
UX_HOST_CLASS_STORAGE_MEDIA **storage_media)
{
#if !defined(UX_HOST_CLASS_STORAGE_NO_FILEX)
UX_PARAMETER_NOT_USED(storage);
UX_PARAMETER_NOT_USED(media_index);
UX_PARAMETER_NOT_USED(storage_media);
return(UX_FUNCTION_NOT_SUPPORTED);
#else
UX_HOST_CLASS_STORAGE_MEDIA *storage_medias;
UX_HOST_CLASS_STORAGE_MEDIA *storage_media_inst;
UX_HOST_CLASS *class_inst;
UINT scan_index;
/* If storage is not live, media is not ready. */
if (storage -> ux_host_class_storage_state != UX_HOST_CLASS_INSTANCE_LIVE)
return(UX_ERROR);
/* Get storage class instance. */
class_inst = storage -> ux_host_class_storage_class;
/* Get shared storage media array. */
storage_medias = (UX_HOST_CLASS_STORAGE_MEDIA *)class_inst -> ux_host_class_media;
/* Search media to find the right one. */
for(scan_index = 0; scan_index < UX_HOST_CLASS_STORAGE_MAX_MEDIA; scan_index ++)
{
storage_media_inst = &storage_medias[scan_index];
/* Skip storage media not used. */
if (storage_media_inst -> ux_host_class_storage_media_status != UX_USED)
continue;
/* Skip storage media not belong to the storage. */
if (storage_media_inst -> ux_host_class_storage_media_storage != storage)
continue;
/* Skip storage media with different LUN. */
if (storage_media_inst -> ux_host_class_storage_media_lun != media_lun)
continue;
/* Store the media instance. */
{
*storage_media = storage_media_inst;
return(UX_SUCCESS);
}
}
/* Media not found. */
return(UX_ERROR);
#endif
}
/**************************************************************************/
/* */
/* FUNCTION RELEASE */
/* */
/* _uxe_host_class_storage_media_get PORTABLE C */
/* 6.3.0 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
/* */
/* DESCRIPTION */
/* */
/* This function checks errors in storage media get function call. */
/* */
/* INPUT */
/* */
/* storage Pointer to storage class */
/* media_lun Media logical unit No. (LUN) */
/* storage_media Holds returned storage media */
/* */
/* OUTPUT */
/* */
/* Status */
/* */
/* CALLS */
/* */
/* _ux_host_class_storage_media_get Get storage media */
/* */
/* CALLED BY */
/* */
/* Application */
/* */
/**************************************************************************/
UINT _uxe_host_class_storage_media_get(UX_HOST_CLASS_STORAGE *storage,
ULONG media_lun,
UX_HOST_CLASS_STORAGE_MEDIA **storage_media)
{
/* Sanity check. */
if ((storage == UX_NULL) || (storage_media == UX_NULL))
return(UX_INVALID_PARAMETER);
/* Invoke storage media get function. */
return(_ux_host_class_storage_media_get(storage, media_lun, storage_media));
}
#endif
|