mirror of
https://github.com/wiiu-env/MemoryMappingModule.git
synced 2024-11-25 03:06:54 +01:00
Revert "Replace the Spinlock with a Mutex, flush the heap header"
This reverts commit 60d000a277
.
This commit is contained in:
parent
b981a93848
commit
e11cf31b05
@ -11,11 +11,9 @@
|
|||||||
#include "CThread.h"
|
#include "CThread.h"
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <coreinit/debug.h>
|
#include <coreinit/debug.h>
|
||||||
#include <coreinit/mutex.h>
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
|
||||||
OSMutex allocFreeMutex;
|
OSSpinLock allocFreeSpinlock;
|
||||||
|
|
||||||
|
|
||||||
// #define DEBUG_FUNCTION_LINE(x,...)
|
// #define DEBUG_FUNCTION_LINE(x,...)
|
||||||
|
|
||||||
@ -384,11 +382,10 @@ void MemoryMapping_setupMemoryMapping() {
|
|||||||
//readTestValuesFromMemory();
|
//readTestValuesFromMemory();
|
||||||
|
|
||||||
//runOnAllCores(writeSegmentRegister,&srTableCpy);
|
//runOnAllCores(writeSegmentRegister,&srTableCpy);
|
||||||
OSInitMutex(&allocFreeMutex);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void *MemoryMapping_allocEx(uint32_t size, int32_t align, bool videoOnly) {
|
void *MemoryMapping_allocEx(uint32_t size, int32_t align, bool videoOnly) {
|
||||||
OSLockMutex(&allocFreeMutex);
|
OSUninterruptibleSpinLock_Acquire(&allocFreeSpinlock);
|
||||||
void *res = nullptr;
|
void *res = nullptr;
|
||||||
for (int32_t i = 0; /* waiting for a break */; i++) {
|
for (int32_t i = 0; /* waiting for a break */; i++) {
|
||||||
if (mem_mapping[i].physical_addresses == nullptr) {
|
if (mem_mapping[i].physical_addresses == nullptr) {
|
||||||
@ -403,8 +400,6 @@ void *MemoryMapping_allocEx(uint32_t size, int32_t align, bool videoOnly) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
DCFlushRange(heap, sizeof(MEMExpHeap));
|
|
||||||
|
|
||||||
res = MEMAllocFromExpHeapEx(heapHandle, size, align);
|
res = MEMAllocFromExpHeapEx(heapHandle, size, align);
|
||||||
auto cur = heap->usedList.head;
|
auto cur = heap->usedList.head;
|
||||||
while (cur != nullptr) {
|
while (cur != nullptr) {
|
||||||
@ -420,7 +415,7 @@ void *MemoryMapping_allocEx(uint32_t size, int32_t align, bool videoOnly) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
OSUnlockMutex(&allocFreeMutex);
|
OSUninterruptibleSpinLock_Release(&allocFreeSpinlock);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -436,7 +431,7 @@ void MemoryMapping_free(void *ptr) {
|
|||||||
if (ptr == nullptr) {
|
if (ptr == nullptr) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
OSLockMutex(&allocFreeMutex);
|
OSUninterruptibleSpinLock_Acquire(&allocFreeSpinlock);
|
||||||
auto ptr_val = (uint32_t) ptr;
|
auto ptr_val = (uint32_t) ptr;
|
||||||
for (int32_t i = 0; /* waiting for a break */; i++) {
|
for (int32_t i = 0; /* waiting for a break */; i++) {
|
||||||
if (mem_mapping[i].physical_addresses == nullptr) {
|
if (mem_mapping[i].physical_addresses == nullptr) {
|
||||||
@ -447,7 +442,6 @@ void MemoryMapping_free(void *ptr) {
|
|||||||
auto *heap = (MEMExpHeap *) heapHandle;
|
auto *heap = (MEMExpHeap *) heapHandle;
|
||||||
|
|
||||||
MEMFreeToExpHeap((MEMHeapHandle) mem_mapping[i].effective_start_address, ptr);
|
MEMFreeToExpHeap((MEMHeapHandle) mem_mapping[i].effective_start_address, ptr);
|
||||||
DCFlushRange(heap, sizeof(MEMExpHeap));
|
|
||||||
auto cur = heap->usedList.head;
|
auto cur = heap->usedList.head;
|
||||||
while (cur != nullptr) {
|
while (cur != nullptr) {
|
||||||
DCFlushRange(cur, sizeof(MEMExpHeapBlock));
|
DCFlushRange(cur, sizeof(MEMExpHeapBlock));
|
||||||
@ -461,7 +455,7 @@ void MemoryMapping_free(void *ptr) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
OSUnlockMutex(&allocFreeMutex);
|
OSUninterruptibleSpinLock_Release(&allocFreeSpinlock);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t MemoryMapping_MEMGetAllocatableSize() {
|
uint32_t MemoryMapping_MEMGetAllocatableSize() {
|
||||||
|
Loading…
Reference in New Issue
Block a user