1 // Copyright 2019 The Android Open Source Project 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 #pragma once 15 16 #include <unordered_map> 17 18 #include "aemu/base/export.h" 19 #include "aemu/base/files/Stream.h" 20 21 struct QAndroidVmOperations; 22 23 namespace android { 24 namespace emulation { 25 26 AEMU_EXPORT void goldfish_address_space_set_vm_operations(const QAndroidVmOperations* vmops); 27 AEMU_EXPORT const QAndroidVmOperations* goldfish_address_space_get_vm_operations(); 28 29 int goldfish_address_space_memory_state_load(android::base::Stream *stream); 30 int goldfish_address_space_memory_state_save(android::base::Stream *stream); 31 32 // Resources which can not be directly reloaded by ASG. 33 struct AddressSpaceDeviceLoadResources { 34 // ASGs may use memory backed by an external memory allocation (e.g. a 35 // Virtio GPU blob resource with a host shmem allocation). These external 36 // memory allocations can not be directly saved and loaded via 37 // `android::base::Stream` and may not have the same `void*` across save 38 // and load. 39 struct ExternalMemory { 40 void* externalAddress = nullptr; 41 uint64_t externalAddressSize = 0; 42 }; 43 // Maps ASG handle to the dedicated external memory. 44 std::unordered_map<uint32_t, ExternalMemory> contextExternalMemoryMap; 45 }; 46 47 // Sets the resources that can be used during a load which can not be loaded 48 // directly from by ASG. 49 int goldfish_address_space_memory_state_set_load_resources( 50 AddressSpaceDeviceLoadResources resources); 51 52 } // namespace emulation 53 } // namespace android 54