mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 19:27:45 +00:00
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
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<>
|
template<>
|
||||||
struct AK::Formatter<Kernel::SBI::Base::SpecificationVersion> : Formatter<FormatString> {
|
struct AK::Formatter<Kernel::SBI::Base::SpecificationVersion> : Formatter<FormatString> {
|
||||||
ErrorOr<void> format(FormatBuilder& builder, Kernel::SBI::Base::SpecificationVersion const& version)
|
ErrorOr<void> format(FormatBuilder& builder, Kernel::SBI::Base::SpecificationVersion const& version)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue