Stub GPU DMA, fix up some FS stuff. horribly wrong savedata implementation

This commit is contained in:
wheremyfoodat 2022-10-15 13:28:29 +03:00
parent b6a1da21a9
commit 5d15efe72c
13 changed files with 169 additions and 35 deletions

View file

@ -9,7 +9,7 @@ namespace PathType {
Empty = 1,
Binary = 2,
ASCII = 3,
UTF8 = 4,
UTF16 = 4,
};
}
@ -68,7 +68,6 @@ struct ArchiveSession {
class ArchiveBase {
protected:
using Result = u32;
using Handle = u32;
Memory& mem;

View file

@ -12,4 +12,10 @@ public:
bool openFile(const FSPath& path) override;
ArchiveBase* openArchive(const FSPath& path) override;
std::optional<u32> readFile(FileSession* file, u64 offset, u32 size, u32 dataPointer) override;
// Returns whether the cart has a RomFS
bool hasRomFS() {
auto cxi = mem.getCXI();
return (cxi != nullptr && cxi->hasRomFS());
}
};

View file

@ -12,4 +12,10 @@ public:
bool openFile(const FSPath& path) override;
ArchiveBase* openArchive(const FSPath& path) override;
std::optional<u32> readFile(FileSession* file, u64 offset, u32 size, u32 dataPointer) override;
// Returns whether the cart has save data or not
bool cartHasSaveData() {
auto cxi = mem.getCXI();
return (cxi != nullptr && cxi->hasSaveData()); // We need to have a CXI file with more than 0 bytes of save data
}
};

View file

@ -39,25 +39,6 @@ class Kernel {
// Top 8 bits are the major version, bottom 8 are the minor version
u16 kernelVersion = 0;
// Get pointer to the object with the specified handle
KernelObject* getObject(Handle handle) {
// Accessing an object that has not been created
if (handle >= objects.size()) [[unlikely]] {
return nullptr;
}
return &objects[handle];
}
// Get pointer to the object with the specified handle and type
KernelObject* getObject(Handle handle, KernelObjectType type) {
if (handle >= objects.size() || objects[handle].type != type) [[unlikely]] {
return nullptr;
}
return &objects[handle];
}
Handle makeArbiter();
Handle makeEvent(ResetType resetType);
Handle makeProcess(u32 id);
@ -148,5 +129,24 @@ public:
return objects;
}
// Get pointer to the object with the specified handle
KernelObject* getObject(Handle handle) {
// Accessing an object that has not been created
if (handle >= objects.size()) [[unlikely]] {
return nullptr;
}
return &objects[handle];
}
// Get pointer to the object with the specified handle and type
KernelObject* getObject(Handle handle, KernelObjectType type) {
if (handle >= objects.size() || objects[handle].type != type) [[unlikely]] {
return nullptr;
}
return &objects[handle];
}
void sendGPUInterrupt(GPUInterrupt type) { serviceManager.requestGPUInterrupt(type); }
};

View file

@ -47,6 +47,8 @@ struct NCCH {
// Contents of the .code file in the ExeFS
std::vector<u8> codeFile;
// Contains of the cart's save data
std::vector<u8> saveData;
// Header: 0x200 + 0x800 byte NCCH header + exheadr
// Returns true on success, false on failure
@ -57,6 +59,7 @@ struct NCCH {
bool hasExeFS() { return exeFS.size != 0; }
bool hasRomFS() { return romFS.size != 0; }
bool hasCode() { return codeFile.size() != 0; }
bool hasSaveData() { return saveData.size() != 0; }
private:
std::array<u8, 16> primaryKey = {}; // For exheader, ExeFS header and icons

View file

@ -36,6 +36,8 @@ namespace VirtualAddrs {
TLSBase = 0xFF400000,
TLSSize = 0x1000,
VramStart = 0x1F000000,
VramSize = 0x00600000,
DSPMemStart = 0x1FF00000
};
}

View file

@ -27,8 +27,10 @@ class FSService {
std::optional<Handle> openFileHandle(ArchiveBase* archive, const FSPath& path);
// Service commands
void closeArchive(u32 messagePointer);
void initialize(u32 messagePointer);
void openArchive(u32 messagePointer);
void openFile(u32 messagePointer);
void openFileDirectly(u32 messagePointer);
public:

View file

@ -44,6 +44,7 @@ class GPUService {
void processCommandList(u32* cmd);
void memoryFill(u32* cmd);
void triggerDisplayTransfer(u32* cmd);
void triggerDMARequest(u32* cmd);
void flushCacheRegions(u32* cmd);
public: