1 |
|
|
/*************************************************************************** |
2 |
|
|
* Copyright (c) 2024 Microsoft Corporation |
3 |
|
|
* Copyright (c) 2026-present Eclipse ThreadX contributors |
4 |
|
|
* |
5 |
|
|
* This program and the accompanying materials are made available under the |
6 |
|
|
* terms of the MIT License which is available at |
7 |
|
|
* https://opensource.org/licenses/MIT. |
8 |
|
|
* |
9 |
|
|
* SPDX-License-Identifier: MIT |
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 |
|
|
/**************************************************************************/ |
34 |
|
|
/* */ |
35 |
|
|
/* FUNCTION RELEASE */ |
36 |
|
|
/* */ |
37 |
|
|
/* _ux_host_class_storage_unit_ready_test PORTABLE C */ |
38 |
|
|
/* 6.1.10 */ |
39 |
|
|
/* AUTHOR */ |
40 |
|
|
/* */ |
41 |
|
|
/* Chaoqiong Xiao, Microsoft Corporation */ |
42 |
|
|
/* */ |
43 |
|
|
/* DESCRIPTION */ |
44 |
|
|
/* */ |
45 |
|
|
/* This function will verify that a SCSI unit is ready for data */ |
46 |
|
|
/* transfer. This command is used when the device does not mount */ |
47 |
|
|
/* when power is supplied. */ |
48 |
|
|
/* */ |
49 |
|
|
/* INPUT */ |
50 |
|
|
/* */ |
51 |
|
|
/* storage Pointer to storage class */ |
52 |
|
|
/* */ |
53 |
|
|
/* OUTPUT */ |
54 |
|
|
/* */ |
55 |
|
|
/* Completion Status */ |
56 |
|
|
/* */ |
57 |
|
|
/* CALLS */ |
58 |
|
|
/* */ |
59 |
|
|
/* _ux_host_class_storage_cbw_initialize Initialize the CBW */ |
60 |
|
|
/* _ux_host_class_storage_transport Send transport layer command */ |
61 |
|
|
/* */ |
62 |
|
|
/* CALLED BY */ |
63 |
|
|
/* */ |
64 |
|
|
/* Storage Class */ |
65 |
|
|
/* */ |
66 |
|
|
/**************************************************************************/ |
67 |
|
380 |
UINT _ux_host_class_storage_unit_ready_test(UX_HOST_CLASS_STORAGE *storage) |
68 |
|
|
{ |
69 |
|
|
|
70 |
|
|
UINT status; |
71 |
|
|
UCHAR *cbw; |
72 |
|
|
UINT command_length; |
73 |
|
|
|
74 |
|
|
/* If trace is enabled, insert this event into the trace buffer. */ |
75 |
|
|
UX_TRACE_IN_LINE_INSERT(UX_TRACE_HOST_CLASS_STORAGE_UNIT_READY_TEST, storage, 0, 0, 0, UX_TRACE_HOST_CLASS_EVENTS, 0, 0) |
76 |
|
|
|
77 |
|
|
/* Use a pointer for the CBW, easier to manipulate. */ |
78 |
|
380 |
cbw = (UCHAR *) storage -> ux_host_class_storage_cbw; |
79 |
|
|
|
80 |
|
|
/* Get the Unit Ready Test Command Length. */ |
81 |
|
|
#ifdef UX_HOST_CLASS_STORAGE_INCLUDE_LEGACY_PROTOCOL_SUPPORT |
82 |
|
|
if (storage -> ux_host_class_storage_interface -> ux_interface_descriptor.bInterfaceSubClass == UX_HOST_CLASS_STORAGE_SUBCLASS_UFI) |
83 |
|
|
command_length = UX_HOST_CLASS_STORAGE_TEST_READY_COMMAND_LENGTH_UFI; |
84 |
|
|
else |
85 |
|
|
command_length = UX_HOST_CLASS_STORAGE_TEST_READY_COMMAND_LENGTH_SBC; |
86 |
|
|
#else |
87 |
|
380 |
command_length = UX_HOST_CLASS_STORAGE_TEST_READY_COMMAND_LENGTH_SBC; |
88 |
|
|
#endif |
89 |
|
|
|
90 |
|
|
/* Initialize the CBW for this command. */ |
91 |
|
380 |
_ux_host_class_storage_cbw_initialize(storage, 0, 0, command_length); |
92 |
|
|
|
93 |
|
|
/* Prepare the TEST UNIT READY command block. */ |
94 |
|
380 |
*(cbw + UX_HOST_CLASS_STORAGE_CBW_CB + UX_HOST_CLASS_STORAGE_TEST_READY_OPERATION) = UX_HOST_CLASS_STORAGE_SCSI_TEST_READY; |
95 |
|
|
|
96 |
|
|
#if defined(UX_HOST_STANDALONE) |
97 |
|
|
|
98 |
|
|
/* Prepare states. */ |
99 |
|
|
UX_HOST_CLASS_STORAGE_TRANS_STATE_RESET(storage); |
100 |
|
|
storage -> ux_host_class_storage_state_state = UX_HOST_CLASS_STORAGE_STATE_TRANSPORT; |
101 |
|
|
storage -> ux_host_class_storage_state_next = UX_HOST_CLASS_STORAGE_STATE_TEST_CHECK; |
102 |
|
|
status = UX_SUCCESS; |
103 |
|
|
#else |
104 |
|
|
|
105 |
|
|
/* Send the command to transport layer. */ |
106 |
|
380 |
status = _ux_host_class_storage_transport(storage, UX_NULL); |
107 |
|
|
#endif |
108 |
|
|
|
109 |
|
|
/* Return completion status. */ |
110 |
|
380 |
return(status); |
111 |
|
|
} |