| #pragma once |
| |
| #include <array> |
| #include <cstddef> |
| #include <cstdint> |
| #include <cstring> |
| #include <tuple> |
| |
| namespace uefi |
| { |
| // https://uefi.org/specs/UEFI/2.10/Apx_A_GUID_and_Time_Formats.html?highlight=guid#guid-and-time-formats |
| typedef struct __attribute__((packed)) Guid |
| { |
| uint32_t timeLow; |
| uint16_t timeMid; |
| uint16_t timeHiAndVersion; |
| std::array<uint8_t, 8> bytes; |
| |
| constexpr Guid() |
| {} |
| |
| constexpr Guid(const uint32_t timeLowIn, const uint16_t timeMidIn, |
| const uint16_t timeHiAndVersionIn, |
| const std::array<uint8_t, 8> bytesIn) : |
| timeLow(timeLowIn), timeMid(timeMidIn), |
| timeHiAndVersion(timeHiAndVersionIn), bytes(bytesIn) |
| {} |
| |
| constexpr bool operator==(const Guid& rhs) const |
| { |
| return std::tie(timeLow, timeMid, timeHiAndVersion, bytes) == |
| std::tie(rhs.timeLow, rhs.timeMid, rhs.timeHiAndVersion, |
| rhs.bytes); |
| } |
| } guid_t; |
| |
| // Ensure the compiler packs the Guid correctly. |
| static_assert(offsetof(Guid, timeLow) == 0, "Incorrect timeLow offset"); |
| static_assert(offsetof(Guid, timeMid) == 4, "Incorrect timeMid offset"); |
| static_assert(offsetof(Guid, timeHiAndVersion) == 6, |
| "Incorrect timeHiAndVersion offset"); |
| static_assert(offsetof(Guid, bytes) == 8, "Incorrect bytes offset"); |
| } // namespace uefi |