#include <mapped_resource.h>
Definition at line 50 of file mapped_resource.h.
◆ MappedResource() [1/2]
dart_utils::MappedResource::MappedResource |
( |
| ) |
|
|
inline |
◆ MappedResource() [2/2]
Definition at line 53 of file mapped_resource.h.
54 : address_(other.address_), size_(other.size_) {
55 other.address_ = nullptr;
56 other.size_ = 0;
57 }
◆ ~MappedResource()
dart_utils::MappedResource::~MappedResource |
( |
| ) |
|
Definition at line 96 of file mapped_resource.cc.
96 {
97 if (address_ != nullptr) {
98 zx::vmar::root_self()->unmap(reinterpret_cast<uintptr_t>(address_), size_);
99 address_ = nullptr;
100 size_ = 0;
101 }
102}
◆ address()
const uint8_t * dart_utils::MappedResource::address |
( |
| ) |
const |
|
inline |
Definition at line 92 of file mapped_resource.h.
92 {
93 return reinterpret_cast<const uint8_t*>(address_);
94 }
◆ LoadFromDir()
static bool dart_utils::MappedResource::LoadFromDir |
( |
int |
dirfd, |
|
|
const std::string & |
path, |
|
|
MappedResource & |
resource, |
|
|
bool |
executable = false |
|
) |
| |
|
static |
◆ LoadFromNamespace()
bool dart_utils::MappedResource::LoadFromNamespace |
( |
fdio_ns_t * |
namespc, |
|
|
const std::string & |
path, |
|
|
MappedResource & |
resource, |
|
|
bool |
executable = false |
|
) |
| |
|
static |
Definition at line 62 of file mapped_resource.cc.
65 {
66 fuchsia::mem::Buffer resource_vmo;
67 return OpenVmo(&resource_vmo, namespc, path, executable) &&
68 LoadFromVmo(path, std::move(resource_vmo), resource, executable);
69}
static bool LoadFromVmo(const std::string &path, fuchsia::mem::Buffer resource_vmo, MappedResource &resource, bool executable=false)
static bool OpenVmo(fuchsia::mem::Buffer *resource_vmo, fdio_ns_t *namespc, const std::string &path, bool executable)
◆ LoadFromVmo()
bool dart_utils::MappedResource::LoadFromVmo |
( |
const std::string & |
path, |
|
|
fuchsia::mem::Buffer |
resource_vmo, |
|
|
MappedResource & |
resource, |
|
|
bool |
executable = false |
|
) |
| |
|
static |
Definition at line 71 of file mapped_resource.cc.
74 {
75 if (resource_vmo.size == 0) {
76 return true;
77 }
78
79 uint32_t
flags = ZX_VM_PERM_READ;
80 if (executable) {
81 flags |= ZX_VM_PERM_EXECUTE;
82 }
84 zx_status_t status = zx::vmar::root_self()->map(
flags, 0, resource_vmo.vmo, 0,
85 resource_vmo.size, &addr);
86 if (status != ZX_OK) {
87 FML_LOG(
ERROR) <<
"Failed to map: " << zx_status_get_string(status);
88 return false;
89 }
90
91 resource.address_ =
reinterpret_cast<void*
>(
addr);
92 resource.size_ = resource_vmo.size;
93 return true;
94}
FlutterSemanticsFlag flags
#define FML_LOG(severity)
◆ operator=()
Definition at line 58 of file mapped_resource.h.
58 {
59 address_ = other.address_;
60 size_ = other.size_;
61 other.address_ = nullptr;
62 other.size_ = 0;
63 return *this;
64 }
◆ size()
size_t dart_utils::MappedResource::size |
( |
| ) |
const |
|
inline |
The documentation for this class was generated from the following files: