Kernel/riscv64: Add AK::Formatter for SBI errors
This allows us to print errors returned to us via the SBI. The error messages are taken from the SBI spec.
This commit is contained in:
parent
27087318bc
commit
21b2d1de65
Notes:
sideshowbarker
2024-07-17 02:55:44 +09:00
Author: https://github.com/spholz Commit: https://github.com/SerenityOS/serenity/commit/21b2d1de65 Pull-request: https://github.com/SerenityOS/serenity/pull/22586
1 changed files with 44 additions and 0 deletions
|
@ -203,6 +203,50 @@ void initialize();
|
|||
|
||||
}
|
||||
|
||||
template<>
|
||||
struct AK::Formatter<Kernel::SBI::SBIError> : Formatter<StringView> {
|
||||
ErrorOr<void> format(FormatBuilder& builder, Kernel::SBI::SBIError error)
|
||||
{
|
||||
auto string = "Unknown error"sv;
|
||||
|
||||
using enum Kernel::SBI::SBIError;
|
||||
switch (error) {
|
||||
case Success:
|
||||
string = "Completed successfully"sv;
|
||||
break;
|
||||
case Failed:
|
||||
string = "Failed"sv;
|
||||
break;
|
||||
case NotSupported:
|
||||
string = "Not supported"sv;
|
||||
break;
|
||||
case InvalidParam:
|
||||
string = "Invalid parameter(s)"sv;
|
||||
break;
|
||||
case Denied:
|
||||
string = "Denied or not allowed"sv;
|
||||
break;
|
||||
case InvalidAddress:
|
||||
string = "Invalid address(s)"sv;
|
||||
break;
|
||||
case AlreadyAvailable:
|
||||
string = "Already available"sv;
|
||||
break;
|
||||
case AlreadyStarted:
|
||||
string = "Already started"sv;
|
||||
break;
|
||||
case AlreadyStopped:
|
||||
string = "Already stopped"sv;
|
||||
break;
|
||||
case NoSHMEM:
|
||||
string = "Shared memory not available"sv;
|
||||
break;
|
||||
}
|
||||
|
||||
return builder.put_string(string);
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct AK::Formatter<Kernel::SBI::Base::SpecificationVersion> : Formatter<FormatString> {
|
||||
ErrorOr<void> format(FormatBuilder& builder, Kernel::SBI::Base::SpecificationVersion const& version)
|
||||
|
|
Loading…
Add table
Reference in a new issue