From d855c0a219a180497c2e50f9bc19bfce69b937a6 Mon Sep 17 00:00:00 2001 From: Ada Christine Date: Thu, 23 Jan 2025 00:24:57 +0000 Subject: it printfs with the efi interface --- boot/efi/status.h | 110 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 boot/efi/status.h (limited to 'boot/efi/status.h') diff --git a/boot/efi/status.h b/boot/efi/status.h new file mode 100644 index 0000000..bcb6b96 --- /dev/null +++ b/boot/efi/status.h @@ -0,0 +1,110 @@ +#pragma once + +#include +#include +#include + +namespace Efi +{ + class Status + { + using size_t = std::size_t; + using ssize_t = std::make_signed_t; + + size_t m_Value; + + constexpr Status(size_t value) + : m_Value(value) + { + } + + constexpr bool IsError() const + { + return static_cast(m_Value) < 0; + } + + constexpr bool IsWarning() const + { + return m_Value > 0; + } + + constexpr bool IsSuccess() const + { + return m_Value == 0; + } + + constexpr static Status ErrorStatus(size_t code) + { + auto errorBit = std::numeric_limits::min(); + return Status(static_cast(errorBit) | code); + } + + constexpr static Status WarningStatus(size_t code) + { + return Status(code); + } + + public: + + operator size_t() const + { + return m_Value; + } + + static const Status Success; + + class Warning + { + public: + + static const Status UnknownGlyph; + static const Status DeleteFailure; + static const Status WriteFailure; + static const Status BufferTooSmall; + static const Status StaleData; + static const Status FileSystem; + static const Status ResetRequired; + }; + + class Error + { + public: + + static const Status LoadError; + static const Status InvalidParameter; + static const Status Unsupported; + static const Status BadBufferSize; + static const Status BufferTooSmall; + static const Status NotReady; + static const Status DeviceError; + static const Status WriteProtected; + static const Status OutOfResources; + static const Status VolumeCorrupted; + static const Status VolumeFull; + static const Status NoMedia; + static const Status MediaChanged; + static const Status NotFound; + static const Status AccessDenied; + static const Status NoResponse; + static const Status NoMapping; + static const Status Timeout; + static const Status NotStarted; + static const Status AlreadyStarted; + static const Status Aborted; + static const Status IcmpError; + static const Status TftpError; + static const Status ProtocolError; + static const Status IncompatibleVersion; + static const Status SecurityViolation; + static const Status CrcError; + static const Status EndOfMedia; + static const Status EndOfFile; + static const Status InvalidLanguage; + static const Status CompromisedData; + static const Status IpAddressConflict; + static const Status HttpError; + }; + + }; +} + -- cgit v1.3.1-1-g115d