mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-04-17 19:21:30 +12:00
[Kernel/Memory] Implement datetime a bit more nicely
This commit is contained in:
parent
4da023c236
commit
c4cb20f846
4 changed files with 17 additions and 5 deletions
|
@ -155,6 +155,11 @@ public:
|
||||||
return env.totalTicks;
|
return env.totalTicks;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get reference to tick count. Memory needs access to this
|
||||||
|
u64& getTicksRef() {
|
||||||
|
return env.totalTicks;
|
||||||
|
}
|
||||||
|
|
||||||
void runFrame() {
|
void runFrame() {
|
||||||
env.ticksLeft = 268111856 / 60;
|
env.ticksLeft = 268111856 / 60;
|
||||||
const auto exitReason = jit->Run();
|
const auto exitReason = jit->Run();
|
||||||
|
|
|
@ -30,7 +30,7 @@ class Emulator {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Emulator() : window(sf::VideoMode(width, height), "Alber", sf::Style::Default, sf::ContextSettings(0, 0, 0, 4, 3)),
|
Emulator() : window(sf::VideoMode(width, height), "Alber", sf::Style::Default, sf::ContextSettings(0, 0, 0, 4, 3)),
|
||||||
kernel(cpu, memory, gpu), cpu(memory, kernel), gpu(memory) {
|
kernel(cpu, memory, gpu), cpu(memory, kernel), gpu(memory), memory(cpu.getTicksRef()) {
|
||||||
reset();
|
reset();
|
||||||
window.setActive(true);
|
window.setActive(true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,6 +72,7 @@ namespace KernelMemoryTypes {
|
||||||
|
|
||||||
class Memory {
|
class Memory {
|
||||||
u8* fcram;
|
u8* fcram;
|
||||||
|
u64& cpuTicks; // Reference to the CPU tick counter
|
||||||
|
|
||||||
// Our dynarmic core uses page tables for reads and writes with 4096 byte pages
|
// Our dynarmic core uses page tables for reads and writes with 4096 byte pages
|
||||||
std::vector<uintptr_t> readTable, writeTable;
|
std::vector<uintptr_t> readTable, writeTable;
|
||||||
|
@ -93,13 +94,14 @@ class Memory {
|
||||||
|
|
||||||
std::bitset<FCRAM_PAGE_COUNT> usedFCRAMPages;
|
std::bitset<FCRAM_PAGE_COUNT> usedFCRAMPages;
|
||||||
std::optional<u32> findPaddr(u32 size);
|
std::optional<u32> findPaddr(u32 size);
|
||||||
|
u64 timeSince3DSEpoch();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
u16 kernelVersion = 0;
|
u16 kernelVersion = 0;
|
||||||
u32 usedUserMemory = 0;
|
u32 usedUserMemory = 0;
|
||||||
std::optional<int> gspMemIndex; // Index of GSP shared mem in lockedMemoryInfo or nullopt if it's already reserved
|
std::optional<int> gspMemIndex; // Index of GSP shared mem in lockedMemoryInfo or nullopt if it's already reserved
|
||||||
|
|
||||||
Memory();
|
Memory(u64& cpuTicks);
|
||||||
void reset();
|
void reset();
|
||||||
void* getReadPointer(u32 address);
|
void* getReadPointer(u32 address);
|
||||||
void* getWritePointer(u32 address);
|
void* getWritePointer(u32 address);
|
||||||
|
@ -118,7 +120,6 @@ public:
|
||||||
|
|
||||||
u32 getLinearHeapVaddr();
|
u32 getLinearHeapVaddr();
|
||||||
u8* getFCRAM() { return fcram; }
|
u8* getFCRAM() { return fcram; }
|
||||||
u64 timeSince3DSEpoch();
|
|
||||||
|
|
||||||
// Returns whether "addr" is aligned to a page (4096 byte) boundary
|
// Returns whether "addr" is aligned to a page (4096 byte) boundary
|
||||||
static constexpr bool isAligned(u32 addr) {
|
static constexpr bool isAligned(u32 addr) {
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
using namespace KernelMemoryTypes;
|
using namespace KernelMemoryTypes;
|
||||||
|
|
||||||
Memory::Memory() {
|
Memory::Memory(u64& cpuTicks) : cpuTicks(cpuTicks) {
|
||||||
fcram = new uint8_t[FCRAM_SIZE]();
|
fcram = new uint8_t[FCRAM_SIZE]();
|
||||||
readTable.resize(totalPageCount, 0);
|
readTable.resize(totalPageCount, 0);
|
||||||
writeTable.resize(totalPageCount, 0);
|
writeTable.resize(totalPageCount, 0);
|
||||||
|
@ -88,6 +88,12 @@ u32 Memory::read32(u32 vaddr) {
|
||||||
switch (vaddr) {
|
switch (vaddr) {
|
||||||
case ConfigMem::Datetime0: return u32(timeSince3DSEpoch()); // ms elapsed since Jan 1 1900, bottom 32 bits
|
case ConfigMem::Datetime0: return u32(timeSince3DSEpoch()); // ms elapsed since Jan 1 1900, bottom 32 bits
|
||||||
case ConfigMem::Datetime0 + 4: return u32(timeSince3DSEpoch() >> 32); // top 32 bits
|
case ConfigMem::Datetime0 + 4: return u32(timeSince3DSEpoch() >> 32); // top 32 bits
|
||||||
|
// Ticks since time was last updated. For now we return the current tick count
|
||||||
|
case ConfigMem::Datetime0 + 8: return u32(cpuTicks);
|
||||||
|
case ConfigMem::Datetime0 + 12: return u32(cpuTicks >> 32);
|
||||||
|
case ConfigMem::Datetime0 + 16: return 0xFFB0FF0; // Unknown, set by PTM
|
||||||
|
case ConfigMem::Datetime0 + 20: case ConfigMem::Datetime0 + 24: case ConfigMem::Datetime0 + 28:
|
||||||
|
return 0; // Set to 0 by PTM
|
||||||
|
|
||||||
case ConfigMem::AppMemAlloc: return appResourceLimits.maxCommit;
|
case ConfigMem::AppMemAlloc: return appResourceLimits.maxCommit;
|
||||||
case 0x1FF81000: return 0; // TODO: Figure out what this config mem address does
|
case 0x1FF81000: return 0; // TODO: Figure out what this config mem address does
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue