summaryrefslogtreecommitdiff
path: root/src/core/hle/kernel
diff options
context:
space:
mode:
authorGravatar bunnei2016-01-30 19:03:33 -0500
committerGravatar bunnei2016-01-30 19:03:33 -0500
commitcd0b31fd7334d574477a3c92bcbd392e8c3eb5e1 (patch)
tree865c931cb344cc4addb0d50e6533ff5ce9c150d8 /src/core/hle/kernel
parentMerge pull request #1379 from lioncash/color (diff)
parentMemory: Implement MMIO (diff)
downloadyuzu-cd0b31fd7334d574477a3c92bcbd392e8c3eb5e1.tar.gz
yuzu-cd0b31fd7334d574477a3c92bcbd392e8c3eb5e1.tar.xz
yuzu-cd0b31fd7334d574477a3c92bcbd392e8c3eb5e1.zip
Merge pull request #1377 from MerryMage/mmio
Memory: Implemented MMIO
Diffstat (limited to 'src/core/hle/kernel')
-rw-r--r--src/core/hle/kernel/vm_manager.cpp7
-rw-r--r--src/core/hle/kernel/vm_manager.h5
2 files changed, 8 insertions, 4 deletions
diff --git a/src/core/hle/kernel/vm_manager.cpp b/src/core/hle/kernel/vm_manager.cpp
index 2610acf76..1e289f38a 100644
--- a/src/core/hle/kernel/vm_manager.cpp
+++ b/src/core/hle/kernel/vm_manager.cpp
@@ -8,6 +8,7 @@
8 8
9#include "core/hle/kernel/vm_manager.h" 9#include "core/hle/kernel/vm_manager.h"
10#include "core/memory_setup.h" 10#include "core/memory_setup.h"
11#include "core/mmio.h"
11 12
12namespace Kernel { 13namespace Kernel {
13 14
@@ -104,7 +105,7 @@ ResultVal<VMManager::VMAHandle> VMManager::MapBackingMemory(VAddr target, u8 * m
104 return MakeResult<VMAHandle>(MergeAdjacent(vma_handle)); 105 return MakeResult<VMAHandle>(MergeAdjacent(vma_handle));
105} 106}
106 107
107ResultVal<VMManager::VMAHandle> VMManager::MapMMIO(VAddr target, PAddr paddr, u32 size, MemoryState state) { 108ResultVal<VMManager::VMAHandle> VMManager::MapMMIO(VAddr target, PAddr paddr, u32 size, MemoryState state, Memory::MMIORegionPointer mmio_handler) {
108 // This is the appropriately sized VMA that will turn into our allocation. 109 // This is the appropriately sized VMA that will turn into our allocation.
109 CASCADE_RESULT(VMAIter vma_handle, CarveVMA(target, size)); 110 CASCADE_RESULT(VMAIter vma_handle, CarveVMA(target, size));
110 VirtualMemoryArea& final_vma = vma_handle->second; 111 VirtualMemoryArea& final_vma = vma_handle->second;
@@ -114,6 +115,7 @@ ResultVal<VMManager::VMAHandle> VMManager::MapMMIO(VAddr target, PAddr paddr, u3
114 final_vma.permissions = VMAPermission::ReadWrite; 115 final_vma.permissions = VMAPermission::ReadWrite;
115 final_vma.meminfo_state = state; 116 final_vma.meminfo_state = state;
116 final_vma.paddr = paddr; 117 final_vma.paddr = paddr;
118 final_vma.mmio_handler = mmio_handler;
117 UpdatePageTableForVMA(final_vma); 119 UpdatePageTableForVMA(final_vma);
118 120
119 return MakeResult<VMAHandle>(MergeAdjacent(vma_handle)); 121 return MakeResult<VMAHandle>(MergeAdjacent(vma_handle));
@@ -330,8 +332,7 @@ void VMManager::UpdatePageTableForVMA(const VirtualMemoryArea& vma) {
330 Memory::MapMemoryRegion(vma.base, vma.size, vma.backing_memory); 332 Memory::MapMemoryRegion(vma.base, vma.size, vma.backing_memory);
331 break; 333 break;
332 case VMAType::MMIO: 334 case VMAType::MMIO:
333 // TODO(yuriks): Add support for MMIO handlers. 335 Memory::MapIoRegion(vma.base, vma.size, vma.mmio_handler);
334 Memory::MapIoRegion(vma.base, vma.size);
335 break; 336 break;
336 } 337 }
337} 338}
diff --git a/src/core/hle/kernel/vm_manager.h b/src/core/hle/kernel/vm_manager.h
index 4e95f1f0c..91d40655b 100644
--- a/src/core/hle/kernel/vm_manager.h
+++ b/src/core/hle/kernel/vm_manager.h
@@ -11,6 +11,7 @@
11#include "common/common_types.h" 11#include "common/common_types.h"
12 12
13#include "core/hle/result.h" 13#include "core/hle/result.h"
14#include "core/mmio.h"
14 15
15namespace Kernel { 16namespace Kernel {
16 17
@@ -92,6 +93,7 @@ struct VirtualMemoryArea {
92 // Settings for type = MMIO 93 // Settings for type = MMIO
93 /// Physical address of the register area this VMA maps to. 94 /// Physical address of the register area this VMA maps to.
94 PAddr paddr = 0; 95 PAddr paddr = 0;
96 Memory::MMIORegionPointer mmio_handler = nullptr;
95 97
96 /// Tests if this area can be merged to the right with `next`. 98 /// Tests if this area can be merged to the right with `next`.
97 bool CanBeMergedWith(const VirtualMemoryArea& next) const; 99 bool CanBeMergedWith(const VirtualMemoryArea& next) const;
@@ -168,8 +170,9 @@ public:
168 * @param paddr The physical address where the registers are present. 170 * @param paddr The physical address where the registers are present.
169 * @param size Size of the mapping. 171 * @param size Size of the mapping.
170 * @param state MemoryState tag to attach to the VMA. 172 * @param state MemoryState tag to attach to the VMA.
173 * @param mmio_handler The handler that will implement read and write for this MMIO region.
171 */ 174 */
172 ResultVal<VMAHandle> MapMMIO(VAddr target, PAddr paddr, u32 size, MemoryState state); 175 ResultVal<VMAHandle> MapMMIO(VAddr target, PAddr paddr, u32 size, MemoryState state, Memory::MMIORegionPointer mmio_handler);
173 176
174 /// Unmaps a range of addresses, splitting VMAs as necessary. 177 /// Unmaps a range of addresses, splitting VMAs as necessary.
175 ResultCode UnmapRange(VAddr target, u32 size); 178 ResultCode UnmapRange(VAddr target, u32 size);