blob: 30bd5e650616696f7574ff4ec218b50b1c6b3bad (
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
|
/***************************************************************************
* 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"
/**************************************************************************/
/* */
/* FUNCTION RELEASE */
/* */
/* _ux_host_class_storage_cbw_initialize PORTABLE C */
/* 6.1.3 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
/* */
/* DESCRIPTION */
/* */
/* This function will initialize the Command Block Wrapper (CBW) that */
/* encapsulate the SCSI request to be sent to the storage device. */
/* The CBW is normally used only for the BO protocol. */
/* */
/* INPUT */
/* */
/* storage Pointer to storage class */
/* flags Flags for transfer */
/* data_transfer_length Length of data transfer */
/* command_length Length of command */
/* */
/* OUTPUT */
/* */
/* None */
/* */
/* CALLS */
/* */
/* _ux_utility_long_put Write a 32-bit value */
/* _ux_utility_memory_set Set memory to a value */
/* */
/* CALLED BY */
/* */
/* Storage Class */
/* */
/**************************************************************************/
VOID _ux_host_class_storage_cbw_initialize(UX_HOST_CLASS_STORAGE *storage, UINT flags,
ULONG data_transfer_length, UINT command_length)
{
UCHAR *cbw;
/* Use a pointer for the cbw, easier to manipulate. */
cbw = (UCHAR *) storage -> ux_host_class_storage_cbw;
/* Store the signature of the CBW. */
_ux_utility_long_put(cbw, UX_HOST_CLASS_STORAGE_CBW_SIGNATURE_MASK);
/* Set the Tag, this value is simply an arbitrary number that is echoed by
the device in the CSW. */
_ux_utility_long_put(cbw + UX_HOST_CLASS_STORAGE_CBW_TAG, UX_HOST_CLASS_STORAGE_CBW_TAG_MASK);
/* Store the Data Transfer Length expected for the data payload. */
_ux_utility_long_put(cbw + UX_HOST_CLASS_STORAGE_CBW_DATA_LENGTH, data_transfer_length);
/* Store the CBW Flag field that contains the transfer flags. */
*(cbw + UX_HOST_CLASS_STORAGE_CBW_FLAGS) = (UCHAR)flags;
/* Store the LUN value. */
*(cbw + UX_HOST_CLASS_STORAGE_CBW_LUN) = (UCHAR)storage -> ux_host_class_storage_lun;
/* Store the size of the SCSI command block that follows. */
*(cbw + UX_HOST_CLASS_STORAGE_CBW_CB_LENGTH) = (UCHAR)command_length;
/* Reset the SCSI command block. */
_ux_utility_memory_set(cbw + UX_HOST_CLASS_STORAGE_CBW_CB, 0, (ULONG) command_length); /* Use case of memset is verified. */
/* Return to caller. */
return;
}
|