mirror of
https://github.com/yuzu-emu/yuzu-android.git
synced 2025-06-17 16:37:57 -05:00
SMMU: Implement physical memory mirroring
This commit is contained in:
@ -16,8 +16,8 @@
|
||||
namespace Service::Nvidia::NvCore {
|
||||
|
||||
struct ContainerImpl {
|
||||
explicit ContainerImpl(Tegra::Host1x::Host1x& host1x_)
|
||||
: host1x{host1x_}, file{host1x_}, manager{host1x_}, device_file_data{} {}
|
||||
explicit ContainerImpl(Container& core, Tegra::Host1x::Host1x& host1x_)
|
||||
: host1x{host1x_}, file{core, host1x_}, manager{host1x_}, device_file_data{} {}
|
||||
Tegra::Host1x::Host1x& host1x;
|
||||
NvMap file;
|
||||
SyncpointManager manager;
|
||||
@ -29,7 +29,7 @@ struct ContainerImpl {
|
||||
};
|
||||
|
||||
Container::Container(Tegra::Host1x::Host1x& host1x_) {
|
||||
impl = std::make_unique<ContainerImpl>(host1x_);
|
||||
impl = std::make_unique<ContainerImpl>(*this, host1x_);
|
||||
}
|
||||
|
||||
Container::~Container() = default;
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include "common/alignment.h"
|
||||
#include "common/assert.h"
|
||||
#include "common/logging/log.h"
|
||||
#include "core/hle/service/nvdrv/core/container.h"
|
||||
#include "core/hle/service/nvdrv/core/nvmap.h"
|
||||
#include "core/memory.h"
|
||||
#include "video_core/host1x/host1x.h"
|
||||
@ -64,7 +65,7 @@ NvResult NvMap::Handle::Duplicate(bool internal_session) {
|
||||
return NvResult::Success;
|
||||
}
|
||||
|
||||
NvMap::NvMap(Tegra::Host1x::Host1x& host1x_) : host1x{host1x_} {}
|
||||
NvMap::NvMap(Container& core_, Tegra::Host1x::Host1x& host1x_) : host1x{host1x_}, core{core_} {}
|
||||
|
||||
void NvMap::AddHandle(std::shared_ptr<Handle> handle_description) {
|
||||
std::scoped_lock lock(handles_lock);
|
||||
@ -160,6 +161,8 @@ DAddr NvMap::PinHandle(NvMap::Handle::Id handle, size_t session_id, bool low_are
|
||||
// If not then allocate some space and map it
|
||||
DAddr address{};
|
||||
auto& smmu = host1x.MemoryManager();
|
||||
auto* session = core.GetSession(session_id);
|
||||
|
||||
auto allocate = std::bind(&Tegra::MaxwellDeviceMemoryManager::Allocate, &smmu, _1);
|
||||
//: std::bind(&Tegra::MaxwellDeviceMemoryManager::Allocate, &smmu, _1);
|
||||
while ((address = allocate(static_cast<size_t>(handle_description->aligned_size))) == 0) {
|
||||
@ -179,7 +182,7 @@ DAddr NvMap::PinHandle(NvMap::Handle::Id handle, size_t session_id, bool low_are
|
||||
handle_description->d_address = address;
|
||||
|
||||
smmu.Map(address, handle_description->address, handle_description->aligned_size,
|
||||
session_id);
|
||||
session->smmu_id);
|
||||
}
|
||||
|
||||
handle_description->pins++;
|
||||
|
@ -25,6 +25,8 @@ class Host1x;
|
||||
} // namespace Tegra
|
||||
|
||||
namespace Service::Nvidia::NvCore {
|
||||
|
||||
class Container;
|
||||
/**
|
||||
* @brief The nvmap core class holds the global state for nvmap and provides methods to manage
|
||||
* handles
|
||||
@ -109,7 +111,7 @@ public:
|
||||
bool can_unlock; //!< If the address region is ready to be unlocked
|
||||
};
|
||||
|
||||
explicit NvMap(Tegra::Host1x::Host1x& host1x);
|
||||
explicit NvMap(Container& core, Tegra::Host1x::Host1x& host1x);
|
||||
|
||||
/**
|
||||
* @brief Creates an unallocated handle of the given size
|
||||
@ -173,5 +175,7 @@ private:
|
||||
* @return If the handle was removed from the map
|
||||
*/
|
||||
bool TryRemoveHandle(const Handle& handle_description);
|
||||
|
||||
Container& core;
|
||||
};
|
||||
} // namespace Service::Nvidia::NvCore
|
||||
|
Reference in New Issue
Block a user