mirror of
https://github.com/AlexAltea/orbital.git
synced 2024-06-16 03:07:58 -04:00
common: Separate OffsetRange structure into its own header
This commit is contained in:
parent
3fb3afc1ea
commit
b6574bd635
|
@ -11,21 +11,7 @@
|
||||||
#include "aeolia_pcie.h"
|
#include "aeolia_pcie.h"
|
||||||
#include "aeolia_mem.h"
|
#include "aeolia_mem.h"
|
||||||
#include "uart/aeolia_uart.h"
|
#include "uart/aeolia_uart.h"
|
||||||
|
#include <orbital/offset_range.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);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
constexpr auto range_wdt = OffsetRange(0x081000, 0x1000);
|
constexpr auto range_wdt = OffsetRange(0x081000, 0x1000);
|
||||||
constexpr auto range_unk1 = OffsetRange(0x084000, 0x1000); // ???
|
constexpr auto range_unk1 = OffsetRange(0x084000, 0x1000); // ???
|
||||||
|
|
26
src/orbital/offset_range.h
Normal file
26
src/orbital/offset_range.h
Normal 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);
|
||||||
|
}
|
||||||
|
};
|
Loading…
Reference in a new issue