23 uintptr_t physical_address{0};
30 bool is_secure{
false};
39 bool executable{
false};
42 bool user_accessible{
false};
47 [[nodiscard]]
constexpr bool is_valid() const noexcept {
return readable || writable || executable; }
92 std::enable_if_t<std::is_void_v<typename Traits::context_type>,
int> = 0>
98 template <
typename Tag,
typename Context,
typename Traits = address_translator_traits<Tag>,
99 std::enable_if_t<!std::is_
void_v<
typename Traits::context_type> &&
100 std::is_convertible_v<const Context *, const
typename Traits::context_type *>,
103 const Context &ctx RELOCO_LIFETIMEBOUND RELOCO_LIFETIME_CAPTURE_BY_THIS) noexcept
104 : ctx_(&ctx), vtbl_(&s_vtbl<Tag>) {}
106 template <
typename Tag,
typename Context, std::enable_if_t<!std::is_lvalue_reference_v<Context>,
int> = 0>
109 template <
typename Tag,
typename Traits = address_translator_traits<Tag>,
110 std::enable_if_t<std::is_
void_v<
typename Traits::context_type>,
int> = 0>
115 template <
typename Tag,
typename Context,
typename Traits = address_translator_traits<Tag>,
116 std::enable_if_t<!std::is_
void_v<
typename Traits::context_type>,
int> = 0>
121 template <
typename Tag,
typename Context, std::enable_if_t<!std::is_lvalue_reference_v<Context>,
int> = 0>
133 if (vtbl_ ==
nullptr || vtbl_->translate ==
nullptr)
135 return vtbl_->translate(ctx_.get(), virt_addr, out_attrs);
138 [[nodiscard]]
constexpr explicit operator bool() const noexcept {
return vtbl_ !=
nullptr; }
141 template <
typename Tag>
142 static bool translate_entry(
const void *context, uintptr_t address,
translation_attributes &attributes)
noexcept {
144 if constexpr (std::is_void_v<context_type>) {
147 const auto &typed_context = *
static_cast<const context_type *
>(context);
148 return address_translator_traits<Tag>::translate(value_ref<const context_type>(typed_context), address,
153 template <
typename Tag>
static constexpr vtable s_vtbl{&translate_entry<Tag>};
155 value_ptr<const void> ctx_{};
156 const vtable *vtbl_{
nullptr};
159template <typename Tag, bool Stateless = std::is_void_v<typename address_translator_traits<Tag>::context_type>>
169 [[nodiscard]]
constexpr value_ref<context_type>
context() &
noexcept RELOCO_LIFETIMEBOUND {
170 return value_ref<context_type>(context_);
173 [[nodiscard]]
constexpr value_ref<const context_type>
context() const & noexcept RELOCO_LIFETIMEBOUND {
174 return value_ref<const context_type>(context_);
181 value_ref<context_type>
context() && =
delete;
182 value_ref<const context_type>
context() const && = delete;
Type-erased remote address-space access and remote string/object views.
typename traits_type::context_type context_type
Definition address_translator.hpp:165
value_ref< context_type > context() &&=delete
constexpr address_translator(context_type context) noexcept
Definition address_translator.hpp:167
constexpr value_ref< const context_type > context() const &noexcept RELOCO_LIFETIMEBOUND
Definition address_translator.hpp:173
value_ref< const context_type > context() const &&=delete
constexpr value_ref< context_type > context() &noexcept RELOCO_LIFETIMEBOUND
Definition address_translator.hpp:169
constexpr address_translator_ref ref() const &noexcept RELOCO_LIFETIMEBOUND
Definition address_translator.hpp:177
static constexpr address_translator_ref ref() noexcept
Definition address_translator.hpp:191
Type-erased, two-word handle for virtual-to-physical address translation.
Definition address_translator.hpp:64
bool translate(uintptr_t virt_addr, translation_attributes &out_attrs) const noexcept
Translates a virtual address to physical address and populates attributes.
Definition address_translator.hpp:132
constexpr address_translator_ref(Tag, Context &&)=delete
static address_translator_ref make(Context &&)=delete
static constexpr address_translator_ref make() noexcept
Definition address_translator.hpp:111
constexpr address_translator_ref() noexcept=default
Constructs an empty (invalid) handle.
static constexpr address_translator_ref make(const Context &ctx RELOCO_LIFETIMEBOUND) noexcept
Definition address_translator.hpp:117
constexpr address_translator_ref(Tag, const Context &ctx RELOCO_LIFETIMEBOUND RELOCO_LIFETIME_CAPTURE_BY_THIS) noexcept
Constructs a handle for a stateful translator tag.
Definition address_translator.hpp:102
Definition address_translator.hpp:160
#define MICROFMT_API_CLASS
Definition compat.hpp:181
Virtual table of address translation operations.
Definition address_translator.hpp:69
Static customization point describing a virtual-to-physical translator backend.
Definition address_translator.hpp:55
Attributes and physical mapping details resolved for a virtual address.
Definition address_translator.hpp:21
constexpr bool is_valid() const noexcept
Reports whether the attribute record represents a valid translation.
Definition address_translator.hpp:47