mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-06-03 12:27:21 +12:00
[FS] Cleanup, stub SDMC, start implementing SaveData
This commit is contained in:
parent
8cf55162d0
commit
b6a1da21a9
13 changed files with 135 additions and 15 deletions
|
@ -56,6 +56,16 @@ struct FileSession {
|
|||
}
|
||||
};
|
||||
|
||||
struct ArchiveSession {
|
||||
ArchiveBase* archive = nullptr;
|
||||
FSPath path;
|
||||
bool isOpen;
|
||||
|
||||
ArchiveSession(ArchiveBase* archive, const FSPath& filePath, bool isOpen = true) : archive(archive), isOpen(isOpen) {
|
||||
path = filePath;
|
||||
}
|
||||
};
|
||||
|
||||
class ArchiveBase {
|
||||
protected:
|
||||
using Result = u32;
|
||||
|
@ -67,7 +77,7 @@ public:
|
|||
virtual u64 getFreeBytes() = 0;
|
||||
virtual bool openFile(const FSPath& path) = 0;
|
||||
|
||||
virtual ArchiveBase* openArchive(FSPath& path) = 0;
|
||||
virtual ArchiveBase* openArchive(const FSPath& path) = 0;
|
||||
|
||||
// Read size bytes from a file starting at offset "offset" into a certain buffer in memory
|
||||
// Returns the number of bytes read, or nullopt if the read failed
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
#pragma once
|
||||
#include "archive_base.hpp"
|
||||
|
||||
class SelfNCCHArchive : public ArchiveBase {
|
||||
|
@ -9,6 +10,6 @@ public:
|
|||
const char* name() override { return "SelfNCCH"; }
|
||||
|
||||
bool openFile(const FSPath& path) override;
|
||||
ArchiveBase* openArchive(FSPath& path) override;
|
||||
ArchiveBase* openArchive(const FSPath& path) override;
|
||||
std::optional<u32> readFile(FileSession* file, u64 offset, u32 size, u32 dataPointer) override;
|
||||
};
|
15
include/fs/archive_save_data.hpp
Normal file
15
include/fs/archive_save_data.hpp
Normal file
|
@ -0,0 +1,15 @@
|
|||
#pragma once
|
||||
#include "archive_base.hpp"
|
||||
|
||||
class SaveDataArchive : public ArchiveBase {
|
||||
|
||||
public:
|
||||
SaveDataArchive(Memory& mem) : ArchiveBase(mem) {}
|
||||
|
||||
u64 getFreeBytes() override { return 0; }
|
||||
const char* name() override { return "SaveData"; }
|
||||
|
||||
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;
|
||||
};
|
15
include/fs/archive_sdmc.hpp
Normal file
15
include/fs/archive_sdmc.hpp
Normal file
|
@ -0,0 +1,15 @@
|
|||
#pragma once
|
||||
#include "archive_base.hpp"
|
||||
|
||||
class SDMCArchive : public ArchiveBase {
|
||||
|
||||
public:
|
||||
SDMCArchive(Memory& mem) : ArchiveBase(mem) {}
|
||||
|
||||
u64 getFreeBytes() override { return 0; }
|
||||
const char* name() override { return "SDMC"; }
|
||||
|
||||
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;
|
||||
};
|
|
@ -19,12 +19,11 @@ namespace SVCResult {
|
|||
|
||||
BadThreadPriority = 0xE0E01BFD,
|
||||
PortNameTooLong = 0xE0E0181E,
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
enum class KernelObjectType : u8 {
|
||||
AddressArbiter, Event, File, Port, Process, ResourceLimit, Session, Thread, Dummy
|
||||
AddressArbiter, Archive, Event, File, Port, Process, ResourceLimit, Session, Thread, Dummy
|
||||
};
|
||||
|
||||
enum class ResourceLimitCategory : int {
|
||||
|
@ -49,9 +48,7 @@ enum class ArbitrationType {
|
|||
DecrementAndWaitIfLessTimeout = 4
|
||||
};
|
||||
|
||||
struct AddressArbiter {
|
||||
|
||||
};
|
||||
struct AddressArbiter {};
|
||||
|
||||
struct ResourceLimits {
|
||||
Handle handle;
|
||||
|
@ -132,6 +129,7 @@ struct Thread {
|
|||
static const char* kernelObjectTypeToString(KernelObjectType t) {
|
||||
switch (t) {
|
||||
case KernelObjectType::AddressArbiter: return "address arbiter";
|
||||
case KernelObjectType::Archive: return "archive";
|
||||
case KernelObjectType::Event: return "event";
|
||||
case KernelObjectType::File: return "file";
|
||||
case KernelObjectType::Port: return "port";
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
#pragma once
|
||||
#include "fs/archive_ncch.hpp"
|
||||
#include "fs/archive_save_data.hpp"
|
||||
#include "fs/archive_sdmc.hpp"
|
||||
#include "helpers.hpp"
|
||||
#include "kernel_types.hpp"
|
||||
#include "logger.hpp"
|
||||
|
@ -15,10 +17,14 @@ class FSService {
|
|||
|
||||
MAKE_LOG_FUNCTION(log, fsLogger)
|
||||
|
||||
// The different filesystem archives (Save data, RomFS+ExeFS, etc)
|
||||
SelfNCCHArchive selfNcch;
|
||||
SaveDataArchive saveData;
|
||||
SDMCArchive sdmc;
|
||||
|
||||
ArchiveBase* getArchiveFromID(u32 id);
|
||||
std::optional<Handle> openFile(ArchiveBase* archive, const FSPath& path);
|
||||
std::optional<Handle> openArchiveHandle(u32 archiveID, const FSPath& path);
|
||||
std::optional<Handle> openFileHandle(ArchiveBase* archive, const FSPath& path);
|
||||
|
||||
// Service commands
|
||||
void initialize(u32 messagePointer);
|
||||
|
@ -26,7 +32,7 @@ class FSService {
|
|||
void openFileDirectly(u32 messagePointer);
|
||||
|
||||
public:
|
||||
FSService(Memory& mem, Kernel& kernel) : mem(mem), selfNcch(mem), kernel(kernel) {}
|
||||
FSService(Memory& mem, Kernel& kernel) : mem(mem), saveData(mem), sdmc(mem), selfNcch(mem), kernel(kernel) {}
|
||||
void reset();
|
||||
void handleSyncRequest(u32 messagePointer);
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue