Repostiory containing DAPLink source code with Reset Pin workaround for HANI_IOT board.
Upstream: https://github.com/ARMmbed/DAPLink
source/usb/usb_msc.h@0:01f31e923fe2, 2020-04-07 (annotated)
- Committer:
- Pawel Zarembski
- Date:
- Tue Apr 07 12:55:42 2020 +0200
- Revision:
- 0:01f31e923fe2
hani: DAPLink with reset workaround
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Pawel Zarembski |
0:01f31e923fe2 | 1 | /** |
Pawel Zarembski |
0:01f31e923fe2 | 2 | * @file usb_msc.h |
Pawel Zarembski |
0:01f31e923fe2 | 3 | * @brief USB mass storage header |
Pawel Zarembski |
0:01f31e923fe2 | 4 | * |
Pawel Zarembski |
0:01f31e923fe2 | 5 | * DAPLink Interface Firmware |
Pawel Zarembski |
0:01f31e923fe2 | 6 | * Copyright (c) 2009-2016, ARM Limited, All Rights Reserved |
Pawel Zarembski |
0:01f31e923fe2 | 7 | * SPDX-License-Identifier: Apache-2.0 |
Pawel Zarembski |
0:01f31e923fe2 | 8 | * |
Pawel Zarembski |
0:01f31e923fe2 | 9 | * Licensed under the Apache License, Version 2.0 (the "License"); you may |
Pawel Zarembski |
0:01f31e923fe2 | 10 | * not use this file except in compliance with the License. |
Pawel Zarembski |
0:01f31e923fe2 | 11 | * You may obtain a copy of the License at |
Pawel Zarembski |
0:01f31e923fe2 | 12 | * |
Pawel Zarembski |
0:01f31e923fe2 | 13 | * http://www.apache.org/licenses/LICENSE-2.0 |
Pawel Zarembski |
0:01f31e923fe2 | 14 | * |
Pawel Zarembski |
0:01f31e923fe2 | 15 | * Unless required by applicable law or agreed to in writing, software |
Pawel Zarembski |
0:01f31e923fe2 | 16 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
Pawel Zarembski |
0:01f31e923fe2 | 17 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
Pawel Zarembski |
0:01f31e923fe2 | 18 | * See the License for the specific language governing permissions and |
Pawel Zarembski |
0:01f31e923fe2 | 19 | * limitations under the License. |
Pawel Zarembski |
0:01f31e923fe2 | 20 | */ |
Pawel Zarembski |
0:01f31e923fe2 | 21 | |
Pawel Zarembski |
0:01f31e923fe2 | 22 | #ifndef __USB_MSC_H__ |
Pawel Zarembski |
0:01f31e923fe2 | 23 | #define __USB_MSC_H__ |
Pawel Zarembski |
0:01f31e923fe2 | 24 | |
Pawel Zarembski |
0:01f31e923fe2 | 25 | |
Pawel Zarembski |
0:01f31e923fe2 | 26 | /* MSC Subclass Codes */ |
Pawel Zarembski |
0:01f31e923fe2 | 27 | #define MSC_SUBCLASS_RBC 0x01 |
Pawel Zarembski |
0:01f31e923fe2 | 28 | #define MSC_SUBCLASS_SFF8020I_MMC2 0x02 |
Pawel Zarembski |
0:01f31e923fe2 | 29 | #define MSC_SUBCLASS_QIC157 0x03 |
Pawel Zarembski |
0:01f31e923fe2 | 30 | #define MSC_SUBCLASS_UFI 0x04 |
Pawel Zarembski |
0:01f31e923fe2 | 31 | #define MSC_SUBCLASS_SFF8070I 0x05 |
Pawel Zarembski |
0:01f31e923fe2 | 32 | #define MSC_SUBCLASS_SCSI 0x06 |
Pawel Zarembski |
0:01f31e923fe2 | 33 | |
Pawel Zarembski |
0:01f31e923fe2 | 34 | /* MSC Protocol Codes */ |
Pawel Zarembski |
0:01f31e923fe2 | 35 | #define MSC_PROTOCOL_CBI_INT 0x00 |
Pawel Zarembski |
0:01f31e923fe2 | 36 | #define MSC_PROTOCOL_CBI_NOINT 0x01 |
Pawel Zarembski |
0:01f31e923fe2 | 37 | #define MSC_PROTOCOL_BULK_ONLY 0x50 |
Pawel Zarembski |
0:01f31e923fe2 | 38 | |
Pawel Zarembski |
0:01f31e923fe2 | 39 | |
Pawel Zarembski |
0:01f31e923fe2 | 40 | /* MSC Request Codes */ |
Pawel Zarembski |
0:01f31e923fe2 | 41 | #define MSC_REQUEST_RESET 0xFF |
Pawel Zarembski |
0:01f31e923fe2 | 42 | #define MSC_REQUEST_GET_MAX_LUN 0xFE |
Pawel Zarembski |
0:01f31e923fe2 | 43 | |
Pawel Zarembski |
0:01f31e923fe2 | 44 | |
Pawel Zarembski |
0:01f31e923fe2 | 45 | /* MSC Bulk-only Stage */ |
Pawel Zarembski |
0:01f31e923fe2 | 46 | #define MSC_BS_CBW 0 /* Command Block Wrapper */ |
Pawel Zarembski |
0:01f31e923fe2 | 47 | #define MSC_BS_DATA_OUT 1 /* Data Out Phase */ |
Pawel Zarembski |
0:01f31e923fe2 | 48 | #define MSC_BS_DATA_IN 2 /* Data In Phase */ |
Pawel Zarembski |
0:01f31e923fe2 | 49 | #define MSC_BS_DATA_IN_LAST 3 /* Data In Last Phase */ |
Pawel Zarembski |
0:01f31e923fe2 | 50 | #define MSC_BS_DATA_IN_LAST_STALL 4 /* Data In Last Phase with Stall */ |
Pawel Zarembski |
0:01f31e923fe2 | 51 | #define MSC_BS_CSW 5 /* Command Status Wrapper */ |
Pawel Zarembski |
0:01f31e923fe2 | 52 | #define MSC_BS_ERROR 6 /* Error */ |
Pawel Zarembski |
0:01f31e923fe2 | 53 | #define MSC_BS_RESET 7 /* Bulk-Only Mass Storage Reset */ |
Pawel Zarembski |
0:01f31e923fe2 | 54 | |
Pawel Zarembski |
0:01f31e923fe2 | 55 | |
Pawel Zarembski |
0:01f31e923fe2 | 56 | /* Bulk-only Command Block Wrapper */ |
Pawel Zarembski |
0:01f31e923fe2 | 57 | typedef __packed struct _MSC_CBW { |
Pawel Zarembski |
0:01f31e923fe2 | 58 | U32 dSignature; |
Pawel Zarembski |
0:01f31e923fe2 | 59 | U32 dTag; |
Pawel Zarembski |
0:01f31e923fe2 | 60 | U32 dDataLength; |
Pawel Zarembski |
0:01f31e923fe2 | 61 | U8 bmFlags; |
Pawel Zarembski |
0:01f31e923fe2 | 62 | U8 bLUN; |
Pawel Zarembski |
0:01f31e923fe2 | 63 | U8 bCBLength; |
Pawel Zarembski |
0:01f31e923fe2 | 64 | U8 CB[16]; |
Pawel Zarembski |
0:01f31e923fe2 | 65 | } MSC_CBW; |
Pawel Zarembski |
0:01f31e923fe2 | 66 | |
Pawel Zarembski |
0:01f31e923fe2 | 67 | /* Bulk-only Command Status Wrapper */ |
Pawel Zarembski |
0:01f31e923fe2 | 68 | typedef __packed struct _MSC_CSW { |
Pawel Zarembski |
0:01f31e923fe2 | 69 | U32 dSignature; |
Pawel Zarembski |
0:01f31e923fe2 | 70 | U32 dTag; |
Pawel Zarembski |
0:01f31e923fe2 | 71 | U32 dDataResidue; |
Pawel Zarembski |
0:01f31e923fe2 | 72 | U8 bStatus; |
Pawel Zarembski |
0:01f31e923fe2 | 73 | } MSC_CSW; |
Pawel Zarembski |
0:01f31e923fe2 | 74 | |
Pawel Zarembski |
0:01f31e923fe2 | 75 | #define MSC_CBW_Signature 0x43425355 |
Pawel Zarembski |
0:01f31e923fe2 | 76 | #define MSC_CSW_Signature 0x53425355 |
Pawel Zarembski |
0:01f31e923fe2 | 77 | |
Pawel Zarembski |
0:01f31e923fe2 | 78 | |
Pawel Zarembski |
0:01f31e923fe2 | 79 | /* CSW Status Definitions */ |
Pawel Zarembski |
0:01f31e923fe2 | 80 | #define CSW_CMD_PASSED 0x00 |
Pawel Zarembski |
0:01f31e923fe2 | 81 | #define CSW_CMD_FAILED 0x01 |
Pawel Zarembski |
0:01f31e923fe2 | 82 | #define CSW_PHASE_ERROR 0x02 |
Pawel Zarembski |
0:01f31e923fe2 | 83 | |
Pawel Zarembski |
0:01f31e923fe2 | 84 | |
Pawel Zarembski |
0:01f31e923fe2 | 85 | /* SCSI Commands */ |
Pawel Zarembski |
0:01f31e923fe2 | 86 | #define SCSI_TEST_UNIT_READY 0x00 |
Pawel Zarembski |
0:01f31e923fe2 | 87 | #define SCSI_REQUEST_SENSE 0x03 |
Pawel Zarembski |
0:01f31e923fe2 | 88 | #define SCSI_FORMAT_UNIT 0x04 |
Pawel Zarembski |
0:01f31e923fe2 | 89 | #define SCSI_INQUIRY 0x12 |
Pawel Zarembski |
0:01f31e923fe2 | 90 | #define SCSI_MODE_SELECT6 0x15 |
Pawel Zarembski |
0:01f31e923fe2 | 91 | #define SCSI_MODE_SENSE6 0x1A |
Pawel Zarembski |
0:01f31e923fe2 | 92 | #define SCSI_START_STOP_UNIT 0x1B |
Pawel Zarembski |
0:01f31e923fe2 | 93 | #define SCSI_MEDIA_REMOVAL 0x1E |
Pawel Zarembski |
0:01f31e923fe2 | 94 | #define SCSI_READ_FORMAT_CAPACITIES 0x23 |
Pawel Zarembski |
0:01f31e923fe2 | 95 | #define SCSI_READ_CAPACITY 0x25 |
Pawel Zarembski |
0:01f31e923fe2 | 96 | #define SCSI_READ10 0x28 |
Pawel Zarembski |
0:01f31e923fe2 | 97 | #define SCSI_WRITE10 0x2A |
Pawel Zarembski |
0:01f31e923fe2 | 98 | #define SCSI_VERIFY10 0x2F |
Pawel Zarembski |
0:01f31e923fe2 | 99 | #define SCSI_SYNC_CACHE10 0x35 |
Pawel Zarembski |
0:01f31e923fe2 | 100 | #define SCSI_READ12 0xA8 |
Pawel Zarembski |
0:01f31e923fe2 | 101 | #define SCSI_WRITE12 0xAA |
Pawel Zarembski |
0:01f31e923fe2 | 102 | #define SCSI_MODE_SELECT10 0x55 |
Pawel Zarembski |
0:01f31e923fe2 | 103 | #define SCSI_MODE_SENSE10 0x5A |
Pawel Zarembski |
0:01f31e923fe2 | 104 | #define SCSI_SYNC_CACHE16 0x91 |
Pawel Zarembski |
0:01f31e923fe2 | 105 | #define SCSI_ATA_COMMAND_PASS_THROUGH12 0xA1 |
Pawel Zarembski |
0:01f31e923fe2 | 106 | #define SCSI_ATA_COMMAND_PASS_THROUGH16 0x85 |
Pawel Zarembski |
0:01f31e923fe2 | 107 | #define SCSI_SERVICE_ACTION_IN12 0xAB |
Pawel Zarembski |
0:01f31e923fe2 | 108 | #define SCSI_SERVICE_ACTION_IN16 0x9E |
Pawel Zarembski |
0:01f31e923fe2 | 109 | #define SCSI_SERVICE_ACTION_OUT12 0xA9 |
Pawel Zarembski |
0:01f31e923fe2 | 110 | #define SCSI_SERVICE_ACTION_OUT16 0x9F |
Pawel Zarembski |
0:01f31e923fe2 | 111 | #define SCSI_REPORT_ID_INFO 0xA3 |
Pawel Zarembski |
0:01f31e923fe2 | 112 | |
Pawel Zarembski |
0:01f31e923fe2 | 113 | #endif /* __USB_MSC_H__ */ |