|
1 | 1 | /*************************************************************************** |
2 | | - * Copyright (c) 2024 Microsoft Corporation |
3 | | - * |
| 2 | + * Copyright (c) 2024 Microsoft Corporation |
| 3 | + * |
4 | 4 | * This program and the accompanying materials are made available under the |
5 | 5 | * terms of the MIT License which is available at |
6 | 6 | * https://opensource.org/licenses/MIT. |
7 | | - * |
| 7 | + * |
8 | 8 | * SPDX-License-Identifier: MIT |
9 | 9 | **************************************************************************/ |
10 | 10 |
|
|
67 | 67 | #ifndef UX_DEVICE_CLASS_STORAGE_H |
68 | 68 | #define UX_DEVICE_CLASS_STORAGE_H |
69 | 69 |
|
70 | | -/* Determine if a C++ compiler is being used. If so, ensure that standard |
71 | | - C is used to process the API information. */ |
| 70 | +/* Determine if a C++ compiler is being used. If so, ensure that standard |
| 71 | + C is used to process the API information. */ |
72 | 72 |
|
73 | | -#ifdef __cplusplus |
| 73 | +#ifdef __cplusplus |
74 | 74 |
|
75 | | -/* Yes, C++ compiler is present. Use standard C. */ |
76 | | -extern "C" { |
| 75 | +/* Yes, C++ compiler is present. Use standard C. */ |
| 76 | +extern "C" { |
77 | 77 |
|
78 | | -#endif |
| 78 | +#endif |
79 | 79 |
|
80 | 80 |
|
81 | 81 | /* Internal option: enable the basic USBX error checking. This define is typically used |
@@ -112,7 +112,10 @@ extern "C" { |
112 | 112 | #define UX_SLAVE_CLASS_STORAGE_MEDIA_OPTICAL_DISK 7 |
113 | 113 | #define UX_SLAVE_CLASS_STORAGE_MEDIA_IOMEGA_CLICK 0x55 |
114 | 114 |
|
| 115 | +/* Define Storage Class USB medium removable type. */ |
115 | 116 |
|
| 117 | +#define UX_SLAVE_CLASS_STORAGE_MEDIA_IS_NOT_REMOVABLE 0x00 |
| 118 | +#define UX_SLAVE_CLASS_STORAGE_MEDIA_IS_REMOVABLE (1u<<8) |
116 | 119 |
|
117 | 120 | /* Define Storage Class SCSI command constants. */ |
118 | 121 |
|
@@ -321,6 +324,10 @@ extern "C" { |
321 | 324 | #define UX_SLAVE_CLASS_STORAGE_SENSE_KEY_VOLUME_OVERFLOW 0x0d |
322 | 325 | #define UX_SLAVE_CLASS_STORAGE_SENSE_KEY_MISCOMPARE 0x0e |
323 | 326 |
|
| 327 | +#define UX_SLAVE_CLASS_STORAGE_SENSE_CODE_NOT_READY 0x04 |
| 328 | +#define UX_SLAVE_CLASS_STORAGE_SENSE_CODE_WRITE_PROTECTED 0x27 |
| 329 | +#define UX_SLAVE_CLASS_STORAGE_SENSE_CODE_NOT_READY_TO_READY 0x28 |
| 330 | +#define UX_SLAVE_CLASS_STORAGE_SENSE_CODE_NOT_PRESENT 0x3A |
324 | 331 |
|
325 | 332 | /* Define Storage Class SCSI sense key definition constants. */ |
326 | 333 |
|
@@ -361,6 +368,23 @@ extern "C" { |
361 | 368 | #define UX_SLAVE_CLASS_STORAGE_READ_DISK_INFORMATION_ALLOCATION_LENGTH 7 |
362 | 369 | #define UX_SLAVE_CLASS_STORAGE_READ_DISK_INFORMATION_LENGTH 10 |
363 | 370 |
|
| 371 | +/* Define Storage Class (SBC-4) POWER CONDITION constants. */ |
| 372 | + |
| 373 | +#define UX_SLAVE_CLASS_STORAGE_POWER_CONDITION_START_VALID 0x00 |
| 374 | +#define UX_SLAVE_CLASS_STORAGE_POWER_CONDITION_ACTIVE 0x01 |
| 375 | +#define UX_SLAVE_CLASS_STORAGE_POWER_CONDITION_IDLE 0x02 |
| 376 | +#define UX_SLAVE_CLASS_STORAGE_POWER_CONDITION_STANDBY 0x03 |
| 377 | +#define UX_SLAVE_CLASS_STORAGE_POWER_CONDITION_LU_CONTROL 0x07 |
| 378 | +#define UX_SLAVE_CLASS_STORAGE_POWER_CONDITION_FORCE_IDLE_0 0x0A |
| 379 | +#define UX_SLAVE_CLASS_STORAGE_POWER_CONDITION_FORCE_STANDBY_0 0x0B |
| 380 | + |
| 381 | +/* Define Storage Class (SBC-4) PREVENT constants. */ |
| 382 | + |
| 383 | +#define UX_SLAVE_CLASS_STORAGE_MEDIUM_REMOVAL_IS_ALLOWED 0x00 |
| 384 | +#define UX_SLAVE_CLASS_STORAGE_MEDIUM_REMOVAL_SHALL_BE_PREVENTED 0x01 |
| 385 | +#define UX_SLAVE_CLASS_STORAGE_MEDIUM_PREVENT_OBSOLETE_2 0x02 |
| 386 | +#define UX_SLAVE_CLASS_STORAGE_MEDIUM_PREVENT_OBSOLETE_3 0x03 |
| 387 | + |
364 | 388 | /* Define Storage Class Feature Descriptor generic format. */ |
365 | 389 |
|
366 | 390 | #define USBX_DEVICE_CLASS_STORAGE_FEATURE_DESCRIPTOR_FEATURE_CODE 0 |
@@ -504,12 +528,17 @@ typedef struct UX_SLAVE_CLASS_STORAGE_LUN_STRUCT |
504 | 528 | ULONG ux_slave_class_storage_request_sense_status; |
505 | 529 | ULONG ux_slave_class_storage_disk_status; |
506 | 530 | ULONG ux_slave_class_storage_last_session_state; |
| 531 | + ULONG ux_slave_class_storage_prevent_medium_removal; |
| 532 | + ULONG ux_slave_class_storage_medium_loaded_status; |
507 | 533 |
|
508 | 534 | UINT (*ux_slave_class_storage_media_read)(VOID *storage, ULONG lun, UCHAR *data_pointer, ULONG number_blocks, ULONG lba, ULONG *media_status); |
509 | 535 | UINT (*ux_slave_class_storage_media_write)(VOID *storage, ULONG lun, UCHAR *data_pointer, ULONG number_blocks, ULONG lba, ULONG *media_status); |
510 | 536 | UINT (*ux_slave_class_storage_media_flush)(VOID *storage, ULONG lun, ULONG number_blocks, ULONG lba, ULONG *media_status); |
511 | 537 | UINT (*ux_slave_class_storage_media_status)(VOID *storage, ULONG lun, ULONG media_id, ULONG *media_status); |
512 | 538 | UINT (*ux_slave_class_storage_media_notification)(VOID *storage, ULONG lun, ULONG media_id, ULONG notification_class, UCHAR **media_notification, ULONG *media_notification_length); |
| 539 | + |
| 540 | + /* Optional callback invoked when load/eject media is requested. */ |
| 541 | + UINT (*ux_slave_class_storage_media_start_stop)(VOID *storage, ULONG lun, ULONG power_condition, ULONG start, ULONG load_eject); |
513 | 542 | } UX_SLAVE_CLASS_STORAGE_LUN; |
514 | 543 |
|
515 | 544 | /* Sense status value (key at bit0-7, code at bit8-15 and qualifier at bit16-23). */ |
@@ -674,10 +703,10 @@ UINT _uxe_device_class_storage_initialize(UX_SLAVE_CLASS_COMMAND *command); |
674 | 703 |
|
675 | 704 | #define ux_device_class_storage_entry _ux_device_class_storage_entry |
676 | 705 |
|
677 | | -/* Determine if a C++ compiler is being used. If so, complete the standard |
678 | | - C conditional started above. */ |
| 706 | +/* Determine if a C++ compiler is being used. If so, complete the standard |
| 707 | + C conditional started above. */ |
679 | 708 | #ifdef __cplusplus |
680 | | -} |
681 | | -#endif |
| 709 | +} |
| 710 | +#endif |
682 | 711 |
|
683 | 712 | #endif |
0 commit comments