mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-06-09 04:21:38 +12:00
Memory: Rework FCRAM management entirely
Disables a lot of functionality... but I didn't want to commit too much to this commit Also reworks virtual memory management somewhat (but needs more work)
This commit is contained in:
parent
8e303d8d08
commit
f230384444
16 changed files with 411 additions and 251 deletions
47
include/kernel/fcram.hpp
Normal file
47
include/kernel/fcram.hpp
Normal file
|
@ -0,0 +1,47 @@
|
|||
#pragma once
|
||||
#include <list>
|
||||
#include <memory>
|
||||
#include "kernel_types.hpp"
|
||||
|
||||
class Memory;
|
||||
|
||||
typedef std::list<FcramBlock> FcramBlockList;
|
||||
|
||||
class KFcram {
|
||||
struct Region {
|
||||
struct Block {
|
||||
s32 pages;
|
||||
s32 pageOffs;
|
||||
bool used;
|
||||
|
||||
Block(s32 pages, u32 pageOffs) : pages(pages), pageOffs(pageOffs), used(false) {}
|
||||
};
|
||||
|
||||
std::list<Block> blocks;
|
||||
u32 start;
|
||||
s32 pages;
|
||||
s32 freePages;
|
||||
public:
|
||||
Region() : start(0), pages(0) {}
|
||||
void reset(u32 start, size_t size);
|
||||
void alloc(std::list<FcramBlock>& out, s32 pages, bool linear);
|
||||
|
||||
u32 getUsedCount();
|
||||
u32 getFreeCount();
|
||||
};
|
||||
|
||||
Memory& mem;
|
||||
|
||||
Region appRegion, sysRegion, baseRegion;
|
||||
uint8_t* fcram;
|
||||
std::unique_ptr<u32> refs;
|
||||
public:
|
||||
KFcram(Memory& memory);
|
||||
void reset(size_t ramSize, size_t appSize, size_t sysSize, size_t baseSize);
|
||||
void alloc(FcramBlockList& out, s32 pages, FcramRegion region, bool linear);
|
||||
|
||||
void incRef(FcramBlockList& list);
|
||||
void decRef(FcramBlockList& list);
|
||||
|
||||
u32 getUsedCount(FcramRegion region);
|
||||
};
|
|
@ -7,6 +7,7 @@
|
|||
#include <vector>
|
||||
|
||||
#include "config.hpp"
|
||||
#include "fcram.hpp"
|
||||
#include "helpers.hpp"
|
||||
#include "kernel_types.hpp"
|
||||
#include "logger.hpp"
|
||||
|
@ -21,6 +22,8 @@ class Kernel {
|
|||
CPU& cpu;
|
||||
Memory& mem;
|
||||
|
||||
KFcram fcramManager;
|
||||
|
||||
// The handle number for the next kernel object to be created
|
||||
u32 handleCounter;
|
||||
// A list of our OS threads, the max number of which depends on the resource limit (hardcoded 32 per process on retail it seems).
|
||||
|
@ -243,6 +246,7 @@ public:
|
|||
}
|
||||
|
||||
ServiceManager& getServiceManager() { return serviceManager; }
|
||||
KFcram& getFcramManager() { return fcramManager; }
|
||||
|
||||
void sendGPUInterrupt(GPUInterrupt type) { serviceManager.sendGPUInterrupt(type); }
|
||||
void clearInstructionCache();
|
||||
|
|
|
@ -44,6 +44,12 @@ enum class ProcessorID : s32 {
|
|||
New3DSExtra2 = 3
|
||||
};
|
||||
|
||||
enum class FcramRegion {
|
||||
App = 0x100,
|
||||
Sys = 0x200,
|
||||
Base = 0x300
|
||||
};
|
||||
|
||||
struct AddressArbiter {};
|
||||
|
||||
struct ResourceLimits {
|
||||
|
@ -242,4 +248,11 @@ struct KernelObject {
|
|||
Helpers::panic("Called GetWaitList on kernel object without a waitlist (Type: %s)", getTypeName());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
struct FcramBlock {
|
||||
u32 paddr;
|
||||
s32 pages;
|
||||
|
||||
FcramBlock(u32 paddr, s32 pages) : paddr(paddr), pages(pages) {}
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue