mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Merge pull request #3262 from unknownbrackets/sysmem
Fix "grain will be off" by making it not actually off
This commit is contained in:
commit
c5de701ae3
2 changed files with 39 additions and 20 deletions
|
@ -15,9 +15,10 @@
|
||||||
// Official git repository and contact information can be found at
|
// Official git repository and contact information can be found at
|
||||||
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
|
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
|
||||||
|
|
||||||
#include "Log.h"
|
#include "Common/Log.h"
|
||||||
#include "BlockAllocator.h"
|
#include "Common/ChunkFile.h"
|
||||||
#include "ChunkFile.h"
|
#include "Core/Util/BlockAllocator.h"
|
||||||
|
#include "Core/Reporting.h"
|
||||||
|
|
||||||
// Slow freaking thing but works (eventually) :)
|
// Slow freaking thing but works (eventually) :)
|
||||||
|
|
||||||
|
@ -146,15 +147,23 @@ u32 BlockAllocator::AllocAt(u32 position, u32 size, const char *tag)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// upalign size to grain
|
// Downalign the position so we're allocating full blocks.
|
||||||
size = (size + grain_ - 1) & ~(grain_ - 1);
|
u32 alignedPosition = position;
|
||||||
|
u32 alignedSize = size;
|
||||||
// check that position is aligned
|
|
||||||
if (position & (grain_ - 1)) {
|
if (position & (grain_ - 1)) {
|
||||||
ERROR_LOG(HLE, "Position %08x does not align to grain. Grain will be off.", position);
|
DEBUG_LOG(HLE, "Position %08x does not align to grain.", position);
|
||||||
|
alignedPosition &= ~(grain_ - 1);
|
||||||
|
|
||||||
|
// Since the position was decreased, size must increase.
|
||||||
|
alignedSize += alignedPosition - position;
|
||||||
}
|
}
|
||||||
|
|
||||||
Block *bp = GetBlockFromAddress(position);
|
// Upalign size to grain.
|
||||||
|
alignedSize = (alignedSize + grain_ - 1) & ~(grain_ - 1);
|
||||||
|
// Tell the caller the allocated size from their requested starting position.
|
||||||
|
size = alignedSize - (alignedPosition - position);
|
||||||
|
|
||||||
|
Block *bp = GetBlockFromAddress(alignedPosition);
|
||||||
if (bp != NULL)
|
if (bp != NULL)
|
||||||
{
|
{
|
||||||
Block &b = *bp;
|
Block &b = *bp;
|
||||||
|
@ -166,24 +175,24 @@ u32 BlockAllocator::AllocAt(u32 position, u32 size, const char *tag)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//good to go
|
//good to go
|
||||||
if (b.start == position)
|
if (b.start == alignedPosition)
|
||||||
{
|
{
|
||||||
InsertFreeAfter(&b, b.start + size, b.size - size);
|
InsertFreeAfter(&b, b.start + alignedSize, b.size - alignedSize);
|
||||||
b.taken = true;
|
b.taken = true;
|
||||||
b.size = size;
|
b.size = alignedSize;
|
||||||
b.SetTag(tag);
|
b.SetTag(tag);
|
||||||
CheckBlocks();
|
CheckBlocks();
|
||||||
return position;
|
return position;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int size1 = position - b.start;
|
int size1 = alignedPosition - b.start;
|
||||||
InsertFreeBefore(&b, b.start, size1);
|
InsertFreeBefore(&b, b.start, size1);
|
||||||
if (b.start + b.size > position + size)
|
if (b.start + b.size > alignedPosition + alignedSize)
|
||||||
InsertFreeAfter(&b, position + size, b.size - (size + size1));
|
InsertFreeAfter(&b, alignedPosition + alignedSize, b.size - (alignedSize + size1));
|
||||||
b.taken = true;
|
b.taken = true;
|
||||||
b.start = position;
|
b.start = alignedPosition;
|
||||||
b.size = size;
|
b.size = alignedSize;
|
||||||
b.SetTag(tag);
|
b.SetTag(tag);
|
||||||
return position;
|
return position;
|
||||||
}
|
}
|
||||||
|
@ -197,7 +206,7 @@ u32 BlockAllocator::AllocAt(u32 position, u32 size, const char *tag)
|
||||||
|
|
||||||
//Out of memory :(
|
//Out of memory :(
|
||||||
ListBlocks();
|
ListBlocks();
|
||||||
ERROR_LOG(HLE, "Block Allocator failed to allocate %i bytes of contiguous memory", size);
|
ERROR_LOG(HLE, "Block Allocator failed to allocate %i bytes of contiguous memory", alignedSize);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -376,6 +385,8 @@ u32 BlockAllocator::GetLargestFreeBlockSize() const
|
||||||
maxFreeBlock = b.size;
|
maxFreeBlock = b.size;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (maxFreeBlock & (grain_ - 1))
|
||||||
|
WARN_LOG_REPORT(HLE, "GetLargestFreeBlockSize: free size %08x does not align to grain %08x.", maxFreeBlock, grain_);
|
||||||
return maxFreeBlock;
|
return maxFreeBlock;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -390,6 +401,8 @@ u32 BlockAllocator::GetTotalFreeBytes() const
|
||||||
sum += b.size;
|
sum += b.size;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (sum & (grain_ - 1))
|
||||||
|
WARN_LOG_REPORT(HLE, "GetTotalFreeBytes: free size %08x does not align to grain %08x.", sum, grain_);
|
||||||
return sum;
|
return sum;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -290,6 +290,12 @@ void PathBrowser::Navigate(const std::string &path) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static std::string GetMemCardDirectory() {
|
||||||
|
std::string memCardDirectory, ignore;
|
||||||
|
GetSysDirectories(memCardDirectory, ignore);
|
||||||
|
return memCardDirectory;
|
||||||
|
}
|
||||||
|
|
||||||
class GameBrowser : public UI::LinearLayout {
|
class GameBrowser : public UI::LinearLayout {
|
||||||
public:
|
public:
|
||||||
GameBrowser(std::string path, bool allowBrowsing, bool *gridStyle_, std::string lastText, std::string lastLink, UI::LayoutParams *layoutParams = 0);
|
GameBrowser(std::string path, bool allowBrowsing, bool *gridStyle_, std::string lastText, std::string lastLink, UI::LayoutParams *layoutParams = 0);
|
||||||
|
@ -333,7 +339,7 @@ UI::EventReturn GameBrowser::LastClick(UI::EventParams &e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
UI::EventReturn GameBrowser::HomeClick(UI::EventParams &e) {
|
UI::EventReturn GameBrowser::HomeClick(UI::EventParams &e) {
|
||||||
path_.SetPath(g_Config.memCardDirectory);
|
path_.SetPath(GetMemCardDirectory());
|
||||||
g_Config.currentDirectory = path_.GetPath();
|
g_Config.currentDirectory = path_.GetPath();
|
||||||
Refresh();
|
Refresh();
|
||||||
return UI::EVENT_DONE;
|
return UI::EVENT_DONE;
|
||||||
|
@ -472,7 +478,7 @@ void MainScreen::CreateViews() {
|
||||||
GameBrowser *tabAllGames = new GameBrowser(g_Config.currentDirectory, true, &g_Config.bGridView2,
|
GameBrowser *tabAllGames = new GameBrowser(g_Config.currentDirectory, true, &g_Config.bGridView2,
|
||||||
m->T("How to get games"), "http://www.ppsspp.org/faq.html",
|
m->T("How to get games"), "http://www.ppsspp.org/faq.html",
|
||||||
new LinearLayoutParams(FILL_PARENT, FILL_PARENT));
|
new LinearLayoutParams(FILL_PARENT, FILL_PARENT));
|
||||||
GameBrowser *tabHomebrew = new GameBrowser(g_Config.memCardDirectory + "PSP/GAME/", false, &g_Config.bGridView3,
|
GameBrowser *tabHomebrew = new GameBrowser(GetMemCardDirectory() + "PSP/GAME/", false, &g_Config.bGridView3,
|
||||||
"", "",
|
"", "",
|
||||||
new LinearLayoutParams(FILL_PARENT, FILL_PARENT));
|
new LinearLayoutParams(FILL_PARENT, FILL_PARENT));
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue