From b6574bd635172c36ecdc70f92b724364928b26cc Mon Sep 17 00:00:00 2001 From: Alexandro Sanchez Bach Date: Fri, 29 Oct 2021 22:06:56 +0200 Subject: [PATCH] common: Separate OffsetRange structure into its own header --- src/orbital/hardware/aeolia/aeolia_pcie.cpp | 16 +------------ src/orbital/offset_range.h | 26 +++++++++++++++++++++ 2 files changed, 27 insertions(+), 15 deletions(-) create mode 100644 src/orbital/offset_range.h diff --git a/src/orbital/hardware/aeolia/aeolia_pcie.cpp b/src/orbital/hardware/aeolia/aeolia_pcie.cpp index c15ed25..7f27c7f 100644 --- a/src/orbital/hardware/aeolia/aeolia_pcie.cpp +++ b/src/orbital/hardware/aeolia/aeolia_pcie.cpp @@ -11,21 +11,7 @@ #include "aeolia_pcie.h" #include "aeolia_mem.h" #include "uart/aeolia_uart.h" - -struct OffsetRange { - uint64_t base; - uint64_t size; - - constexpr OffsetRange(uint64_t base, uint64_t size) - : base(base), size(size) { - } - constexpr bool contains(uint64_t off) const noexcept { - return (base <= off) && (off < base + size); - } - constexpr bool contains_strict(uint64_t off, uint64_t len) const noexcept { - return contains(off) && (off + len <= base + size); - } -}; +#include constexpr auto range_wdt = OffsetRange(0x081000, 0x1000); constexpr auto range_unk1 = OffsetRange(0x084000, 0x1000); // ??? diff --git a/src/orbital/offset_range.h b/src/orbital/offset_range.h new file mode 100644 index 0000000..3dca1f7 --- /dev/null +++ b/src/orbital/offset_range.h @@ -0,0 +1,26 @@ +/** + * Offset range helper. + * + * Copyright 2017-2021. Orbital project. + * Released under MIT license. Read LICENSE for more details. + * + * Authors: + * - Alexandro Sanchez Bach + */ + +#pragma once + +struct OffsetRange { + uint64_t base; + uint64_t size; + + constexpr OffsetRange(uint64_t base, uint64_t size) + : base(base), size(size) { + } + constexpr bool contains(uint64_t off) const noexcept { + return (base <= off) && (off < base + size); + } + constexpr bool contains_strict(uint64_t off, uint64_t len) const noexcept { + return contains(off) && (off + len <= base + size); + } +};