diff options
author | Gurchetan Singh <gurchetansingh@chromium.org> | 2023-03-28 20:10:15 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2023-03-28 20:10:15 +0000 |
commit | 351905ea872c58494c06e219849bfc6ffac7a91c (patch) | |
tree | 89c35d4708a1ca833f5900346923050fe32a68fc | |
parent | 2ca61a4a8fad46eb18e1baa1ef28badb6463487d (diff) | |
parent | 7363364e72fcb5eeaebdbe5c0eefd74981b1d3b9 (diff) | |
download | aemu-351905ea872c58494c06e219849bfc6ffac7a91c.tar.gz |
aemu: modify HostMemIdMapping interface am: 466cc58c69 am: 1809f5f3bd am: dfa64838ef am: 7363364e72
Original change: https://android-review.googlesource.com/c/platform/hardware/google/aemu/+/2510375
Change-Id: Ic9edbfaa7ce24ad33e7a68a74cf6c9c5ee1b0b9b
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r-- | host-common/HostmemIdMapping.cpp | 32 | ||||
-rw-r--r-- | host-common/include/host-common/HostmemIdMapping.h | 7 |
2 files changed, 25 insertions, 14 deletions
diff --git a/host-common/HostmemIdMapping.cpp b/host-common/HostmemIdMapping.cpp index 0800010..5d9efea 100644 --- a/host-common/HostmemIdMapping.cpp +++ b/host-common/HostmemIdMapping.cpp @@ -20,8 +20,10 @@ using android::base::ManagedDescriptor; namespace android { namespace emulation { +using Id = uint64_t; + // static -const HostmemIdMapping::Id HostmemIdMapping::kInvalidHostmemId = 0; +const Id HostmemIdMapping::kInvalidHostmemId = 0; static HostmemIdMapping* sMapping() { static HostmemIdMapping* s = new HostmemIdMapping; @@ -35,7 +37,7 @@ HostmemIdMapping* HostmemIdMapping::get() { // TODO: Add registerHostmemFixed version that takes a predetermined id, // for snapshots -HostmemIdMapping::Id HostmemIdMapping::add(const struct MemEntry *entry) { +Id HostmemIdMapping::add(const struct MemEntry *entry) { if (entry->hva == 0 || entry->size == 0) return kInvalidHostmemId; Id wantedId; @@ -56,14 +58,22 @@ HostmemIdMapping::Id HostmemIdMapping::add(const struct MemEntry *entry) { return wantedId; } -void HostmemIdMapping::remove(HostmemIdMapping::Id id) { +void HostmemIdMapping::remove(Id id) { mEntries.erase(id); } -HostmemIdMapping::Id HostmemIdMapping::addDescriptorInfo(ManagedDescriptor descriptor, - uint32_t handleType, uint32_t caching, - std::optional<VulkanInfo> vulkanInfoOpt) { - Id wantedId = mCurrentId++; +void HostmemIdMapping::addMapping(Id id, const struct MemEntry *entry) { + HostmemIdMapping::Entry hostmem_entry; + hostmem_entry.id = id; + hostmem_entry.hva = entry->hva; + hostmem_entry.size = entry->size; + hostmem_entry.caching = entry->caching; + mEntries.set(id, hostmem_entry); +} + +void HostmemIdMapping::addDescriptorInfo(Id id, ManagedDescriptor descriptor, + uint32_t handleType, uint32_t caching, + std::optional<VulkanInfo> vulkanInfoOpt) { struct ManagedDescriptorInfo info = { .descriptor = std::move(descriptor), @@ -72,11 +82,11 @@ HostmemIdMapping::Id HostmemIdMapping::addDescriptorInfo(ManagedDescriptor descr .vulkanInfoOpt = std::move(vulkanInfoOpt), }; - mDescriptorInfos.insert(std::make_pair(wantedId, std::move(info))); - return wantedId; + + mDescriptorInfos.insert(std::make_pair(id, std::move(info))); } -std::optional<ManagedDescriptorInfo> HostmemIdMapping::removeDescriptorInfo(HostmemIdMapping::Id id) { +std::optional<ManagedDescriptorInfo> HostmemIdMapping::removeDescriptorInfo(Id id) { auto found = mDescriptorInfos.find(id); if (found != mDescriptorInfos.end()) { std::optional<ManagedDescriptorInfo> ret = std::move(found->second); @@ -87,7 +97,7 @@ std::optional<ManagedDescriptorInfo> HostmemIdMapping::removeDescriptorInfo(Host return std::nullopt; } -HostmemIdMapping::Entry HostmemIdMapping::get(HostmemIdMapping::Id id) const { +HostmemIdMapping::Entry HostmemIdMapping::get(Id id) const { const HostmemIdMapping::Entry badEntry { kInvalidHostmemId, 0, 0, }; diff --git a/host-common/include/host-common/HostmemIdMapping.h b/host-common/include/host-common/HostmemIdMapping.h index 0ce6b07..6cb82b9 100644 --- a/host-common/include/host-common/HostmemIdMapping.h +++ b/host-common/include/host-common/HostmemIdMapping.h @@ -79,10 +79,11 @@ public: // is referenced. AEMU_EXPORT void remove(Id id); - Id addDescriptorInfo(ManagedDescriptor descriptor, uint32_t handleType, uint32_t caching, - std::optional<VulkanInfo> vulkanInfoOpt); + void addMapping(Id id, const struct MemEntry *entry); + void addDescriptorInfo(Id id, ManagedDescriptor descriptor, uint32_t handleType, + uint32_t caching, std::optional<VulkanInfo> vulkanInfoOpt); - std::optional<ManagedDescriptorInfo> removeDescriptorInfo(HostmemIdMapping::Id id); + std::optional<ManagedDescriptorInfo> removeDescriptorInfo(Id id); // If id == kInvalidHostmemId or not found in map, // returns entry with id == kInvalidHostmemId, |