1 /**************************************************************************/
2 /* */
3 /* Copyright (c) Microsoft Corporation. All rights reserved. */
4 /* */
5 /* This software is licensed under the Microsoft Software License */
6 /* Terms for Microsoft Azure RTOS. Full text of the license can be */
7 /* found in the LICENSE file at https://aka.ms/AzureRTOS_EULA */
8 /* and in the root directory of this software. */
9 /* */
10 /**************************************************************************/
11
12
13 /**************************************************************************/
14 /**************************************************************************/
15 /** */
16 /** USBX Component */
17 /** */
18 /** Storage Class */
19 /** */
20 /**************************************************************************/
21 /**************************************************************************/
22
23
24 /* Include necessary system files. */
25
26 #define UX_SOURCE_CODE
27
28 #include "ux_api.h"
29 #include "ux_host_class_storage.h"
30 #include "ux_host_stack.h"
31
32
33 #if defined(UX_HOST_STANDALONE)
34 /**************************************************************************/
35 /* */
36 /* FUNCTION RELEASE */
37 /* */
38 /* _ux_host_class_storage_media_check PORTABLE C */
39 /* 6.1.10 */
40 /* AUTHOR */
41 /* */
42 /* Chaoqiong Xiao, Microsoft Corporation */
43 /* */
44 /* DESCRIPTION */
45 /* */
46 /* This function runs state machine to check and mount/unmount storage */
47 /* media for current selected logic unit number (LUN). */
48 /* */
49 /* It's valid only in standalone mode. */
50 /* It's blocking. */
51 /* */
52 /* INPUT */
53 /* */
54 /* storage Pointer to storage class */
55 /* sector_start Starting sector */
56 /* sector_count Number of sectors to read */
57 /* data_pointer Pointer to data to read */
58 /* */
59 /* OUTPUT */
60 /* */
61 /* Completion Status */
62 /* */
63 /* CALLS */
64 /* */
65 /* _ux_host_class_storage_check_run Runs check state machine */
66 /* */
67 /* CALLED BY */
68 /* */
69 /* Storage Class */
70 /* */
71 /* RELEASE HISTORY */
72 /* */
73 /* DATE NAME DESCRIPTION */
74 /* */
75 /* 05-19-2020 Chaoqiong Xiao Initial Version 6.1.10 */
76 /* */
77 /**************************************************************************/
_ux_host_class_storage_media_check(UX_HOST_CLASS_STORAGE * storage)78 UINT _ux_host_class_storage_media_check(UX_HOST_CLASS_STORAGE *storage)
79 {
80 UINT status;
81 do {
82 status = _ux_host_class_storage_check_run(storage);
83 } while(status == UX_STATE_WAIT);
84 return(storage -> ux_host_class_storage_status);
85 }
86
87
88 /**************************************************************************/
89 /* */
90 /* FUNCTION RELEASE */
91 /* */
92 /* _uxe_host_class_storage_media_check PORTABLE C */
93 /* 6.3.0 */
94 /* AUTHOR */
95 /* */
96 /* Chaoqiong Xiao, Microsoft Corporation */
97 /* */
98 /* DESCRIPTION */
99 /* */
100 /* This function checks errors in storage media check function call. */
101 /* */
102 /* INPUT */
103 /* */
104 /* storage Pointer to storage class */
105 /* */
106 /* OUTPUT */
107 /* */
108 /* Status */
109 /* */
110 /* CALLS */
111 /* */
112 /* _ux_host_class_storage_media_check Check storage media */
113 /* */
114 /* CALLED BY */
115 /* */
116 /* Application */
117 /* */
118 /* RELEASE HISTORY */
119 /* */
120 /* DATE NAME DESCRIPTION */
121 /* */
122 /* 10-31-2023 Chaoqiong Xiao Initial Version 6.3.0 */
123 /* */
124 /**************************************************************************/
_uxe_host_class_storage_media_check(UX_HOST_CLASS_STORAGE * storage)125 UINT _uxe_host_class_storage_media_check(UX_HOST_CLASS_STORAGE *storage)
126 {
127
128 /* Sanity check. */
129 if (storage == UX_NULL)
130 return(UX_INVALID_PARAMETER);
131
132 /* Invoke storage media check function. */
133 return(_ux_host_class_storage_media_check(storage));
134 }
135 #endif
136