-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Kernel/USBMS: Add a basic UAS driver
For now we only support USB <3.0 devices, as we don't lissten for ERDY transaction packets. We also don't leverage the benefits of UAS, as we pretend to have a queue depth of 1, ie are single threaded. To test this driver, you can use the following command: ``` SERENITY_BOOT_DRIVE=usb-uas Meta/serenity.sh run x86_64 Clang ```
- Loading branch information
1 parent
7f9d791
commit 1c466ec
Showing
12 changed files
with
1,126 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* | ||
* Copyright (c) 2024, Leon Albrecht <[email protected]> | ||
* | ||
* SPDX-License-Identifier: BSD-2-Clause | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <AK/Format.h> | ||
#include <AK/StringView.h> | ||
#include <AK/Types.h> | ||
|
||
namespace Kernel::SCSI { | ||
|
||
// SAM 4: 5.3.1 Status codes | ||
enum class StatusCode : u8 { | ||
Good = 0x00, | ||
CheckCondition = 0x02, | ||
ConditionMet = 0x04, | ||
Busy = 0x08, | ||
// Obsolete = 0x10, | ||
// Obsolete = 0x14, | ||
ReservationConflict = 0x18, | ||
// Obsolete = 0x22, was Command Terminated | ||
TaskSetFull = 0x28, | ||
ACAActive = 0x30, | ||
TaskAborted = 0x40, | ||
}; | ||
constexpr StringView to_string(StatusCode status) | ||
{ | ||
using enum StatusCode; | ||
switch (status) { | ||
case Good: | ||
return "Good"sv; | ||
case CheckCondition: | ||
return "Check Condition"sv; | ||
case ConditionMet: | ||
return "Condition Met"sv; | ||
case Busy: | ||
return "Busy"sv; | ||
case ReservationConflict: | ||
return "Reservation Conflict"sv; | ||
case TaskSetFull: | ||
return "Task Set Full"sv; | ||
case ACAActive: | ||
return "ACA Active"sv; | ||
case TaskAborted: | ||
return "Task Aborted"sv; | ||
default: | ||
return "Unknown"sv; | ||
} | ||
} | ||
|
||
} | ||
|
||
namespace AK { | ||
|
||
template<> | ||
struct Formatter<Kernel::SCSI::StatusCode> : Formatter<FormatString> { | ||
ErrorOr<void> format(FormatBuilder& builder, Kernel::SCSI::StatusCode value) | ||
{ | ||
return Formatter<FormatString>::format(builder, "{:02x}({})"sv, to_underlying(value), Kernel::SCSI::to_string(value)); | ||
} | ||
}; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* | ||
* Copyright (c) 2024, Leon Albrecht <[email protected]> | ||
* | ||
* SPDX-License-Identifier: BSD-2-Clause | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <AK/Types.h> | ||
|
||
namespace Kernel::USB { | ||
|
||
enum class SCSIDataDirection { | ||
DataToTarget, | ||
DataToInitiator, | ||
NoData | ||
}; | ||
|
||
} |
Oops, something went wrong.