common: Separate OffsetRange structure into its own header

This commit is contained in:
Alexandro Sanchez Bach 2021-10-29 22:06:56 +02:00
parent 3fb3afc1ea
commit b6574bd635
2 changed files with 27 additions and 15 deletions

View file

@ -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 <orbital/offset_range.h>
constexpr auto range_wdt = OffsetRange(0x081000, 0x1000);
constexpr auto range_unk1 = OffsetRange(0x084000, 0x1000); // ???

View file

@ -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 <alexandro@phi.nz>
*/
#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);
}
};