mirror of
https://github.com/yuzu-emu/yuzu-android.git
synced 2024-12-24 00:55:30 +00:00
core: device_memory: Templatize GetPointer(..).
This commit is contained in:
parent
cb073f95dc
commit
47b8160666
|
@ -31,12 +31,14 @@ public:
|
|||
DramMemoryMap::Base;
|
||||
}
|
||||
|
||||
u8* GetPointer(PAddr addr) {
|
||||
return buffer.BackingBasePointer() + (addr - DramMemoryMap::Base);
|
||||
template <typename T>
|
||||
T* GetPointer(PAddr addr) {
|
||||
return reinterpret_cast<T*>(buffer.BackingBasePointer() + (addr - DramMemoryMap::Base));
|
||||
}
|
||||
|
||||
const u8* GetPointer(PAddr addr) const {
|
||||
return buffer.BackingBasePointer() + (addr - DramMemoryMap::Base);
|
||||
template <typename T>
|
||||
const T* GetPointer(PAddr addr) const {
|
||||
return reinterpret_cast<T*>(buffer.BackingBasePointer() + (addr - DramMemoryMap::Base));
|
||||
}
|
||||
|
||||
Common::HostMemory buffer;
|
||||
|
|
|
@ -94,8 +94,8 @@ VAddr InitializeSlabHeap(Core::System& system, KMemoryLayout& memory_layout, VAd
|
|||
// TODO(bunnei): Fix this once we support the kernel virtual memory layout.
|
||||
|
||||
if (size > 0) {
|
||||
void* backing_kernel_memory{
|
||||
system.DeviceMemory().GetPointer(TranslateSlabAddrToPhysical(memory_layout, start))};
|
||||
void* backing_kernel_memory{system.DeviceMemory().GetPointer<void>(
|
||||
TranslateSlabAddrToPhysical(memory_layout, start))};
|
||||
|
||||
const KMemoryRegion* region = memory_layout.FindVirtual(start + size - 1);
|
||||
ASSERT(region != nullptr);
|
||||
|
@ -181,7 +181,7 @@ void InitializeKPageBufferSlabHeap(Core::System& system) {
|
|||
ASSERT(slab_address != 0);
|
||||
|
||||
// Initialize the slabheap.
|
||||
KPageBuffer::InitializeSlabHeap(kernel, system.DeviceMemory().GetPointer(slab_address),
|
||||
KPageBuffer::InitializeSlabHeap(kernel, system.DeviceMemory().GetPointer<void>(slab_address),
|
||||
slab_size);
|
||||
}
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ Result KCodeMemory::Initialize(Core::DeviceMemory& device_memory, VAddr addr, si
|
|||
|
||||
// Clear the memory.
|
||||
for (const auto& block : m_page_group.Nodes()) {
|
||||
std::memset(device_memory.GetPointer(block.GetAddress()), 0xFF, block.GetSize());
|
||||
std::memset(device_memory.GetPointer<void>(block.GetAddress()), 0xFF, block.GetSize());
|
||||
}
|
||||
|
||||
// Set remaining tracking members.
|
||||
|
|
|
@ -331,7 +331,7 @@ Result KMemoryManager::AllocateAndOpenForProcess(KPageGroup* out, size_t num_pag
|
|||
|
||||
// Set all the allocated memory.
|
||||
for (const auto& block : out->Nodes()) {
|
||||
std::memset(system.DeviceMemory().GetPointer(block.GetAddress()), fill_pattern,
|
||||
std::memset(system.DeviceMemory().GetPointer<void>(block.GetAddress()), fill_pattern,
|
||||
block.GetSize());
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace Kernel {
|
|||
|
||||
KPageBuffer* KPageBuffer::FromPhysicalAddress(Core::System& system, PAddr phys_addr) {
|
||||
ASSERT(Common::IsAligned(phys_addr, PageSize));
|
||||
return reinterpret_cast<KPageBuffer*>(system.DeviceMemory().GetPointer(phys_addr));
|
||||
return system.DeviceMemory().GetPointer<KPageBuffer>(phys_addr);
|
||||
}
|
||||
|
||||
} // namespace Kernel
|
||||
|
|
|
@ -1648,7 +1648,7 @@ Result KPageTable::SetHeapSize(VAddr* out, std::size_t size) {
|
|||
|
||||
// Clear all the newly allocated pages.
|
||||
for (const auto& it : pg.Nodes()) {
|
||||
std::memset(system.DeviceMemory().GetPointer(it.GetAddress()), heap_fill_value,
|
||||
std::memset(system.DeviceMemory().GetPointer<void>(it.GetAddress()), heap_fill_value,
|
||||
it.GetSize());
|
||||
}
|
||||
|
||||
|
@ -1805,9 +1805,9 @@ bool KPageTable::IsRegionMapped(VAddr address, u64 size) {
|
|||
}
|
||||
|
||||
bool KPageTable::IsRegionContiguous(VAddr addr, u64 size) const {
|
||||
auto start_ptr = system.Memory().GetPointer(addr);
|
||||
auto start_ptr = system.DeviceMemory().GetPointer<u8>(addr);
|
||||
for (u64 offset{}; offset < size; offset += PageSize) {
|
||||
if (start_ptr != system.Memory().GetPointer(addr + offset)) {
|
||||
if (start_ptr != system.DeviceMemory().GetPointer<u8>(addr + offset)) {
|
||||
return false;
|
||||
}
|
||||
start_ptr += PageSize;
|
||||
|
|
|
@ -50,7 +50,7 @@ Result KSharedMemory::Initialize(Core::DeviceMemory& device_memory_, KProcess* o
|
|||
is_initialized = true;
|
||||
|
||||
// Clear all pages in the memory.
|
||||
std::memset(device_memory_.GetPointer(physical_address_), 0, size_);
|
||||
std::memset(device_memory_.GetPointer<void>(physical_address_), 0, size_);
|
||||
|
||||
return ResultSuccess;
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ public:
|
|||
* @return A pointer to the shared memory block from the specified offset
|
||||
*/
|
||||
u8* GetPointer(std::size_t offset = 0) {
|
||||
return device_memory->GetPointer(physical_address + offset);
|
||||
return device_memory->GetPointer<u8>(physical_address + offset);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -63,7 +63,7 @@ public:
|
|||
* @return A pointer to the shared memory block from the specified offset
|
||||
*/
|
||||
const u8* GetPointer(std::size_t offset = 0) const {
|
||||
return device_memory->GetPointer(physical_address + offset);
|
||||
return device_memory->GetPointer<u8>(physical_address + offset);
|
||||
}
|
||||
|
||||
void Finalize() override;
|
||||
|
|
|
@ -65,7 +65,7 @@ struct Memory::Impl {
|
|||
return {};
|
||||
}
|
||||
|
||||
return system.DeviceMemory().GetPointer(paddr) + vaddr;
|
||||
return system.DeviceMemory().GetPointer<u8>(paddr) + vaddr;
|
||||
}
|
||||
|
||||
[[nodiscard]] u8* GetPointerFromDebugMemory(VAddr vaddr) const {
|
||||
|
@ -75,7 +75,7 @@ struct Memory::Impl {
|
|||
return {};
|
||||
}
|
||||
|
||||
return system.DeviceMemory().GetPointer(paddr) + vaddr;
|
||||
return system.DeviceMemory().GetPointer<u8>(paddr) + vaddr;
|
||||
}
|
||||
|
||||
u8 Read8(const VAddr addr) {
|
||||
|
@ -499,7 +499,7 @@ struct Memory::Impl {
|
|||
} else {
|
||||
while (base != end) {
|
||||
page_table.pointers[base].Store(
|
||||
system.DeviceMemory().GetPointer(target) - (base << YUZU_PAGEBITS), type);
|
||||
system.DeviceMemory().GetPointer<u8>(target) - (base << YUZU_PAGEBITS), type);
|
||||
page_table.backing_addr[base] = target - (base << YUZU_PAGEBITS);
|
||||
|
||||
ASSERT_MSG(page_table.pointers[base].Pointer(),
|
||||
|
|
Loading…
Reference in a new issue