mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-05-03 02:34:48 +12:00
Merge branch 'master' of github.com:fleroviux/Panda3DS into pica-tev-emulation
This commit is contained in:
commit
f8a8abd2c6
73 changed files with 540 additions and 419 deletions
include
|
@ -10,6 +10,9 @@
|
|||
#include "helpers.hpp"
|
||||
#include "memory.hpp"
|
||||
#include "result.hpp"
|
||||
#include "result/result.hpp"
|
||||
|
||||
using Result::HorizonResult;
|
||||
|
||||
namespace PathType {
|
||||
enum : u32 {
|
||||
|
@ -97,7 +100,7 @@ struct FileSession {
|
|||
u32 priority = 0; // TODO: What does this even do
|
||||
bool isOpen;
|
||||
|
||||
FileSession(ArchiveBase* archive, const FSPath& filePath, const FSPath& archivePath, FILE* fd, bool isOpen = true) :
|
||||
FileSession(ArchiveBase* archive, const FSPath& filePath, const FSPath& archivePath, FILE* fd, bool isOpen = true) :
|
||||
archive(archive), path(filePath), archivePath(archivePath), fd(fd), isOpen(isOpen), priority(0) {}
|
||||
|
||||
// For cloning a file session
|
||||
|
@ -128,16 +131,6 @@ struct DirectorySession {
|
|||
// Otherwise the fd of the opened file is returned (or nullptr if the opened file doesn't require one)
|
||||
using FileDescriptor = std::optional<FILE*>;
|
||||
|
||||
enum class FSResult : u32 {
|
||||
Success = 0,
|
||||
AlreadyExists = 0x82044BE,
|
||||
FileTooLarge = 0x86044D2,
|
||||
FileNotFound = 0xC8804470,
|
||||
NotFoundInvalid = 0xC8A04478, // Also a not found error code used here and there in the FS module.
|
||||
NotFormatted = 0xC8A04554, // Trying to access an archive that needs formatting and has not been formatted
|
||||
UnexpectedFileOrDir = 0xE0C04702
|
||||
};
|
||||
|
||||
class ArchiveBase {
|
||||
public:
|
||||
struct FormatInfo {
|
||||
|
@ -149,7 +142,7 @@ public:
|
|||
|
||||
protected:
|
||||
using Handle = u32;
|
||||
|
||||
|
||||
static constexpr FileDescriptor NoFile = nullptr;
|
||||
static constexpr FileDescriptor FileError = std::nullopt;
|
||||
Memory& mem;
|
||||
|
@ -176,12 +169,12 @@ protected:
|
|||
// If the path string doesn't begin with / then that means it's accessing outside the FS root, which is invalid & unsafe
|
||||
if (pathString[0] != Char('/')) return false;
|
||||
|
||||
// Counts how many folders sans the root our file is nested under.
|
||||
// Counts how many folders sans the root our file is nested under.
|
||||
// If it's < 0 at any point of parsing, then the path is unsafe and tries to crawl outside our file sandbox.
|
||||
// If it's 0 then this is the FS root.
|
||||
// If it's > 0 then we're in a subdirectory of the root.
|
||||
int level = 0;
|
||||
|
||||
|
||||
// Split the string on / characters and see how many of the substrings are ".."
|
||||
size_t pos = 0;
|
||||
while ((pos = pathString.find(Char('/'))) != String::npos) {
|
||||
|
@ -202,27 +195,27 @@ protected:
|
|||
public:
|
||||
virtual std::string name() = 0;
|
||||
virtual u64 getFreeBytes() = 0;
|
||||
virtual FSResult createFile(const FSPath& path, u64 size) = 0;
|
||||
virtual FSResult deleteFile(const FSPath& path) = 0;
|
||||
virtual HorizonResult createFile(const FSPath& path, u64 size) = 0;
|
||||
virtual HorizonResult deleteFile(const FSPath& path) = 0;
|
||||
|
||||
virtual Rust::Result<FormatInfo, FSResult> getFormatInfo(const FSPath& path) {
|
||||
virtual Rust::Result<FormatInfo, HorizonResult> getFormatInfo(const FSPath& path) {
|
||||
Helpers::panic("Unimplemented GetFormatInfo for %s archive", name().c_str());
|
||||
// Return a dummy struct just to avoid the UB of not returning anything, even if we panic
|
||||
return Ok(FormatInfo{ .size = 0, .numOfDirectories = 0, .numOfFiles = 0, .duplicateData = false });
|
||||
}
|
||||
|
||||
virtual FSResult createDirectory(const FSPath& path) {
|
||||
virtual HorizonResult createDirectory(const FSPath& path) {
|
||||
Helpers::panic("Unimplemented CreateDirectory for %s archive", name().c_str());
|
||||
return FSResult::AlreadyExists;
|
||||
return Result::FS::AlreadyExists;
|
||||
}
|
||||
|
||||
// Returns nullopt if opening the file failed, otherwise returns a file descriptor to it (nullptr if none is needed)
|
||||
virtual FileDescriptor openFile(const FSPath& path, const FilePerms& perms) = 0;
|
||||
virtual Rust::Result<ArchiveBase*, FSResult> openArchive(const FSPath& path) = 0;
|
||||
virtual Rust::Result<ArchiveBase*, HorizonResult> openArchive(const FSPath& path) = 0;
|
||||
|
||||
virtual Rust::Result<DirectorySession, FSResult> openDirectory(const FSPath& path) {
|
||||
virtual Rust::Result<DirectorySession, HorizonResult> openDirectory(const FSPath& path) {
|
||||
Helpers::panic("Unimplemented OpenDirectory for %s archive", name().c_str());
|
||||
return Err(FSResult::FileNotFound);
|
||||
return Err(Result::FS::FileNotFoundAlt);
|
||||
}
|
||||
|
||||
virtual void format(const FSPath& path, const FormatInfo& info) {
|
||||
|
@ -232,6 +225,6 @@ public:
|
|||
// 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
|
||||
virtual std::optional<u32> readFile(FileSession* file, u64 offset, u32 size, u32 dataPointer) = 0;
|
||||
|
||||
|
||||
ArchiveBase(Memory& mem) : mem(mem) {}
|
||||
};
|
|
@ -9,11 +9,11 @@ public:
|
|||
u64 getFreeBytes() override { Helpers::panic("ExtSaveData::GetFreeBytes unimplemented"); return 0; }
|
||||
std::string name() override { return "ExtSaveData::" + backingFolder; }
|
||||
|
||||
FSResult createFile(const FSPath& path, u64 size) override;
|
||||
FSResult deleteFile(const FSPath& path) override;
|
||||
HorizonResult createFile(const FSPath& path, u64 size) override;
|
||||
HorizonResult deleteFile(const FSPath& path) override;
|
||||
|
||||
Rust::Result<ArchiveBase*, FSResult> openArchive(const FSPath& path) override;
|
||||
Rust::Result<DirectorySession, FSResult> openDirectory(const FSPath& path) override;
|
||||
Rust::Result<ArchiveBase*, HorizonResult> openArchive(const FSPath& path) override;
|
||||
Rust::Result<DirectorySession, HorizonResult> openDirectory(const FSPath& path) override;
|
||||
FileDescriptor openFile(const FSPath& path, const FilePerms& perms) override;
|
||||
std::optional<u32> readFile(FileSession* file, u64 offset, u32 size, u32 dataPointer) override;
|
||||
|
||||
|
|
|
@ -8,10 +8,10 @@ public:
|
|||
u64 getFreeBytes() override { Helpers::panic("NCCH::GetFreeBytes unimplemented"); return 0; }
|
||||
std::string name() override { return "NCCH"; }
|
||||
|
||||
FSResult createFile(const FSPath& path, u64 size) override;
|
||||
FSResult deleteFile(const FSPath& path) override;
|
||||
HorizonResult createFile(const FSPath& path, u64 size) override;
|
||||
HorizonResult deleteFile(const FSPath& path) override;
|
||||
|
||||
Rust::Result<ArchiveBase*, FSResult> openArchive(const FSPath& path) override;
|
||||
Rust::Result<ArchiveBase*, HorizonResult> openArchive(const FSPath& path) override;
|
||||
FileDescriptor openFile(const FSPath& path, const FilePerms& perms) override;
|
||||
std::optional<u32> readFile(FileSession* file, u64 offset, u32 size, u32 dataPointer) override;
|
||||
|
||||
|
|
|
@ -8,17 +8,17 @@ public:
|
|||
u64 getFreeBytes() override { Helpers::panic("SaveData::GetFreeBytes unimplemented"); return 0; }
|
||||
std::string name() override { return "SaveData"; }
|
||||
|
||||
FSResult createDirectory(const FSPath& path) override;
|
||||
FSResult createFile(const FSPath& path, u64 size) override;
|
||||
FSResult deleteFile(const FSPath& path) override;
|
||||
HorizonResult createDirectory(const FSPath& path) override;
|
||||
HorizonResult createFile(const FSPath& path, u64 size) override;
|
||||
HorizonResult deleteFile(const FSPath& path) override;
|
||||
|
||||
Rust::Result<ArchiveBase*, FSResult> openArchive(const FSPath& path) override;
|
||||
Rust::Result<DirectorySession, FSResult> openDirectory(const FSPath& path) override;
|
||||
Rust::Result<ArchiveBase*, HorizonResult> openArchive(const FSPath& path) override;
|
||||
Rust::Result<DirectorySession, HorizonResult> openDirectory(const FSPath& path) override;
|
||||
FileDescriptor openFile(const FSPath& path, const FilePerms& perms) override;
|
||||
std::optional<u32> readFile(FileSession* file, u64 offset, u32 size, u32 dataPointer) override;
|
||||
|
||||
void format(const FSPath& path, const FormatInfo& info) override;
|
||||
Rust::Result<FormatInfo, FSResult> getFormatInfo(const FSPath& path) override;
|
||||
Rust::Result<FormatInfo, HorizonResult> getFormatInfo(const FSPath& path) override;
|
||||
|
||||
std::filesystem::path getFormatInfoPath() {
|
||||
return IOFile::getAppData() / "FormatInfo" / "SaveData.format";
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
#pragma once
|
||||
#include "archive_base.hpp"
|
||||
#include "result/result.hpp"
|
||||
|
||||
using Result::HorizonResult;
|
||||
|
||||
class SDMCArchive : public ArchiveBase {
|
||||
public:
|
||||
|
@ -8,10 +11,10 @@ public:
|
|||
u64 getFreeBytes() override { Helpers::panic("SDMC::GetFreeBytes unimplemented"); return 0; }
|
||||
std::string name() override { return "SDMC"; }
|
||||
|
||||
FSResult createFile(const FSPath& path, u64 size) override;
|
||||
FSResult deleteFile(const FSPath& path) override;
|
||||
HorizonResult createFile(const FSPath& path, u64 size) override;
|
||||
HorizonResult deleteFile(const FSPath& path) override;
|
||||
|
||||
Rust::Result<ArchiveBase*, FSResult> openArchive(const FSPath& path) override;
|
||||
Rust::Result<ArchiveBase*, HorizonResult> openArchive(const FSPath& path) override;
|
||||
FileDescriptor openFile(const FSPath& path, const FilePerms& perms) override;
|
||||
std::optional<u32> readFile(FileSession* file, u64 offset, u32 size, u32 dataPointer) override;
|
||||
};
|
|
@ -8,10 +8,10 @@ public:
|
|||
u64 getFreeBytes() override { return 0; }
|
||||
std::string name() override { return "SelfNCCH"; }
|
||||
|
||||
FSResult createFile(const FSPath& path, u64 size) override;
|
||||
FSResult deleteFile(const FSPath& path) override;
|
||||
HorizonResult createFile(const FSPath& path, u64 size) override;
|
||||
HorizonResult deleteFile(const FSPath& path) override;
|
||||
|
||||
Rust::Result<ArchiveBase*, FSResult> openArchive(const FSPath& path) override;
|
||||
Rust::Result<ArchiveBase*, HorizonResult> openArchive(const FSPath& path) override;
|
||||
FileDescriptor openFile(const FSPath& path, const FilePerms& perms) override;
|
||||
std::optional<u32> readFile(FileSession* file, u64 offset, u32 size, u32 dataPointer) override;
|
||||
|
||||
|
|
|
@ -4,33 +4,7 @@
|
|||
#include "fs/archive_base.hpp"
|
||||
#include "handles.hpp"
|
||||
#include "helpers.hpp"
|
||||
|
||||
namespace SVCResult {
|
||||
enum : u32 {
|
||||
Success = 0,
|
||||
Failure = 0xFFFFFFFF,
|
||||
ObjectNotFound = 0xD88007FA,
|
||||
|
||||
// Different calls return a different value for these ones
|
||||
InvalidEnumValue = 0xD8E007ED,
|
||||
InvalidEnumValueAlt = 0xD8E093ED,
|
||||
BadHandle = 0xD8E007F7,
|
||||
BadHandleAlt = 0xD9001BF7,
|
||||
|
||||
InvalidCombination = 0xE0E01BEE, // Used for invalid memory permission combinations
|
||||
UnalignedAddr = 0xE0E01BF1,
|
||||
UnalignedSize = 0xE0E01BF2,
|
||||
|
||||
BadThreadPriority = 0xE0E01BFD,
|
||||
PortNameTooLong = 0xE0E0181E,
|
||||
|
||||
// Returned when a thread stops waiting due to timing out
|
||||
Timeout = 0x9401BFE,
|
||||
|
||||
// Returned when a thread releases a mutex it does not own
|
||||
InvalidMutexRelease = 0xD8E0041F
|
||||
};
|
||||
}
|
||||
#include "result/result.hpp"
|
||||
|
||||
enum class KernelObjectType : u8 {
|
||||
AddressArbiter, Archive, Directory, File, MemoryBlock, Process, ResourceLimit, Session, Dummy,
|
||||
|
@ -125,7 +99,7 @@ struct Thread {
|
|||
ThreadStatus status;
|
||||
Handle handle; // OS handle for this thread
|
||||
int index; // Index of the thread. 0 for the first thread, 1 for the second, and so on
|
||||
|
||||
|
||||
// The waiting address for threads that are waiting on an AddressArbiter
|
||||
u32 waitingAddress;
|
||||
|
||||
|
|
8
include/result/result.hpp
Normal file
8
include/result/result.hpp
Normal file
|
@ -0,0 +1,8 @@
|
|||
#pragma once
|
||||
|
||||
#include "result_common.hpp"
|
||||
#include "result_kernel.hpp"
|
||||
#include "result_os.hpp"
|
||||
#include "result_fnd.hpp"
|
||||
#include "result_fs.hpp"
|
||||
#include "result_gsp.hpp"
|
206
include/result/result_common.hpp
Normal file
206
include/result/result_common.hpp
Normal file
|
@ -0,0 +1,206 @@
|
|||
#pragma once
|
||||
|
||||
#include <climits>
|
||||
#include <cstdint>
|
||||
#include <type_traits>
|
||||
|
||||
namespace Result {
|
||||
enum class HorizonResultLevel : uint32_t {
|
||||
Success = 0,
|
||||
Info = 1,
|
||||
Status = 25,
|
||||
Temporary = 26,
|
||||
Permanent = 27,
|
||||
Usage = 28,
|
||||
Reinitialize = 29,
|
||||
Reset = 30,
|
||||
Fatal = 31,
|
||||
};
|
||||
|
||||
enum class HorizonResultSummary : uint32_t {
|
||||
Success = 0,
|
||||
NothingHappened = 1,
|
||||
WouldBlock = 2,
|
||||
OutOfResource = 3,
|
||||
NotFound = 4,
|
||||
InvalidState = 5,
|
||||
NotSupported = 6,
|
||||
InvalidArgument = 7,
|
||||
WrongArgument = 8,
|
||||
Canceled = 9,
|
||||
StatusChanged = 10,
|
||||
Internal = 11,
|
||||
};
|
||||
|
||||
enum class HorizonResultModule : uint32_t {
|
||||
Common = 0,
|
||||
Kernel = 1,
|
||||
Util = 2,
|
||||
FileServer = 3,
|
||||
LoaderServer = 4,
|
||||
TCB = 5,
|
||||
OS = 6,
|
||||
DBG = 7,
|
||||
DMNT = 8,
|
||||
PDN = 9 ,
|
||||
GSP = 10,
|
||||
I2C = 11,
|
||||
GPIO = 12,
|
||||
DD = 13,
|
||||
CODEC = 14,
|
||||
SPI = 15,
|
||||
PXI = 16,
|
||||
FS = 17,
|
||||
DI = 18,
|
||||
HID = 19,
|
||||
CAM = 20,
|
||||
PI = 21,
|
||||
PM = 22,
|
||||
PM_LOW = 23,
|
||||
FSI = 24,
|
||||
SRV = 25,
|
||||
NDM = 26,
|
||||
NWM = 27,
|
||||
SOC = 28,
|
||||
LDR = 29,
|
||||
ACC = 30,
|
||||
RomFS = 31,
|
||||
AM = 32,
|
||||
HIO = 33,
|
||||
Updater = 34,
|
||||
MIC = 35,
|
||||
FND = 36,
|
||||
MP = 37,
|
||||
MPWL = 38,
|
||||
AC = 39,
|
||||
HTTP = 40,
|
||||
DSP = 41,
|
||||
SND = 42,
|
||||
DLP = 43,
|
||||
HIO_LOW = 44,
|
||||
CSND = 45,
|
||||
SSL = 46,
|
||||
AM_LOW = 47,
|
||||
NEX = 48,
|
||||
Friends = 49,
|
||||
RDT = 50,
|
||||
Applet = 51,
|
||||
NIM = 52,
|
||||
PTM = 53,
|
||||
MIDI = 54,
|
||||
MC = 55,
|
||||
SWC = 56,
|
||||
FatFS = 57,
|
||||
NGC = 58,
|
||||
CARD = 59,
|
||||
CARDNOR = 60,
|
||||
SDMC = 61,
|
||||
BOSS = 62,
|
||||
DBM = 63,
|
||||
Config = 64,
|
||||
PS = 65,
|
||||
CEC = 66,
|
||||
IR = 67,
|
||||
UDS = 68,
|
||||
PL = 69,
|
||||
CUP = 70,
|
||||
Gyroscope = 71,
|
||||
MCU = 72,
|
||||
NS = 73,
|
||||
News = 74,
|
||||
RO = 75,
|
||||
GD = 76,
|
||||
CardSPI = 77,
|
||||
EC = 78,
|
||||
WebBrowser = 79,
|
||||
Test = 80,
|
||||
ENC = 81,
|
||||
PIA = 82,
|
||||
ACT = 83,
|
||||
VCTL = 84,
|
||||
OLV = 85,
|
||||
NEIA = 86,
|
||||
NPNS = 87,
|
||||
AVD = 90,
|
||||
L2B = 91,
|
||||
MVD = 92,
|
||||
NFC = 93,
|
||||
UART = 94,
|
||||
SPM = 95,
|
||||
QTM = 96,
|
||||
NFP = 97,
|
||||
};
|
||||
|
||||
class HorizonResult {
|
||||
private:
|
||||
static const uint32_t DescriptionBits = 10;
|
||||
static const uint32_t ModuleBits = 8;
|
||||
static const uint32_t ReservedBits = 3;
|
||||
static const uint32_t SummaryBits = 6;
|
||||
static const uint32_t LevelBits = 5;
|
||||
|
||||
static const uint32_t DescriptionOffset = 0;
|
||||
static const uint32_t ModuleOffset = DescriptionOffset + DescriptionBits;
|
||||
static const uint32_t SummaryOffset = ModuleOffset + ModuleBits + ReservedBits;
|
||||
static const uint32_t LevelOffset = SummaryOffset + SummaryBits;
|
||||
|
||||
static_assert(DescriptionBits + ModuleBits + SummaryBits + LevelBits + ReservedBits == sizeof(uint32_t) * CHAR_BIT, "Invalid Result size");
|
||||
|
||||
uint32_t m_value;
|
||||
|
||||
constexpr inline uint32_t getBitsValue(int offset, int amount) {
|
||||
return (m_value >> offset) & ~(~0 << amount);
|
||||
}
|
||||
|
||||
static constexpr inline uint32_t makeValue(uint32_t description, uint32_t module, uint32_t summary, uint32_t level) {
|
||||
return (description << DescriptionOffset) | (module << ModuleOffset) | (summary << SummaryOffset) | (level << LevelOffset);
|
||||
}
|
||||
|
||||
public:
|
||||
constexpr HorizonResult() {}
|
||||
constexpr HorizonResult(uint32_t value) : m_value(value) {}
|
||||
constexpr HorizonResult(uint32_t description, HorizonResultModule module, HorizonResultSummary summary, HorizonResultLevel level) : m_value(makeValue(description, static_cast<uint32_t>(module), static_cast<uint32_t>(summary), static_cast<uint32_t>(level))) {}
|
||||
constexpr operator uint32_t() const { return m_value; }
|
||||
|
||||
constexpr inline uint32_t getDescription() {
|
||||
return getBitsValue(DescriptionOffset, DescriptionBits);
|
||||
}
|
||||
|
||||
constexpr inline HorizonResultModule getModule() {
|
||||
return static_cast<HorizonResultModule>(getBitsValue(ModuleOffset, ModuleBits));
|
||||
}
|
||||
|
||||
constexpr inline HorizonResultSummary getSummary() {
|
||||
return static_cast<HorizonResultSummary>(getBitsValue(SummaryOffset, SummaryBits));
|
||||
}
|
||||
|
||||
constexpr inline HorizonResultLevel getLevel() {
|
||||
return static_cast<HorizonResultLevel>(getBitsValue(LevelOffset, LevelBits));
|
||||
}
|
||||
|
||||
constexpr inline uint32_t getRawValue() {
|
||||
return m_value;
|
||||
}
|
||||
|
||||
constexpr inline bool isSuccess() {
|
||||
return m_value == 0;
|
||||
}
|
||||
|
||||
constexpr inline bool isFailure() {
|
||||
return m_value != 0;
|
||||
}
|
||||
};
|
||||
|
||||
static_assert(std::is_trivially_destructible<HorizonResult>::value, "std::is_trivially_destructible<HorizonResult>::value");
|
||||
|
||||
#define DEFINE_HORIZON_RESULT_MODULE(ns, value) \
|
||||
namespace ns::Detail {\
|
||||
static constexpr HorizonResultModule ModuleId = HorizonResultModule::value; \
|
||||
}
|
||||
|
||||
#define DEFINE_HORIZON_RESULT(name, description, summary, level) \
|
||||
static constexpr HorizonResult name(description, Detail::ModuleId, HorizonResultSummary::summary, HorizonResultLevel::level);
|
||||
|
||||
static constexpr HorizonResult Success(0);
|
||||
static constexpr HorizonResult FailurePlaceholder(UINT32_MAX);
|
||||
};
|
8
include/result/result_fnd.hpp
Normal file
8
include/result/result_fnd.hpp
Normal file
|
@ -0,0 +1,8 @@
|
|||
#pragma once
|
||||
#include "result_common.hpp"
|
||||
|
||||
DEFINE_HORIZON_RESULT_MODULE(Result::FND, FND);
|
||||
|
||||
namespace Result::FND {
|
||||
DEFINE_HORIZON_RESULT(InvalidEnumValue, 1005, InvalidArgument, Permanent);
|
||||
};
|
18
include/result/result_fs.hpp
Normal file
18
include/result/result_fs.hpp
Normal file
|
@ -0,0 +1,18 @@
|
|||
#pragma once
|
||||
#include "result_common.hpp"
|
||||
|
||||
DEFINE_HORIZON_RESULT_MODULE(Result::FS, FS);
|
||||
|
||||
namespace Result::FS {
|
||||
// TODO: Verify this
|
||||
DEFINE_HORIZON_RESULT(FileNotFound, 100, NotFound, Status);
|
||||
// TODO: Verify this
|
||||
DEFINE_HORIZON_RESULT(FileNotFoundAlt, 112, NotFound, Status);
|
||||
// Also a not found error code used here and there in the FS module.
|
||||
DEFINE_HORIZON_RESULT(NotFoundInvalid, 120, InvalidState, Status);
|
||||
DEFINE_HORIZON_RESULT(AlreadyExists, 190, NothingHappened, Info);
|
||||
DEFINE_HORIZON_RESULT(FileTooLarge, 210, OutOfResource, Info);
|
||||
// Trying to access an archive that needs formatting and has not been formatted
|
||||
DEFINE_HORIZON_RESULT(NotFormatted, 340, InvalidState, Status);
|
||||
DEFINE_HORIZON_RESULT(UnexpectedFileOrDir, 770, NotSupported, Usage);
|
||||
};
|
8
include/result/result_gsp.hpp
Normal file
8
include/result/result_gsp.hpp
Normal file
|
@ -0,0 +1,8 @@
|
|||
#pragma once
|
||||
#include "result_common.hpp"
|
||||
|
||||
DEFINE_HORIZON_RESULT_MODULE(Result::GSP, GSP);
|
||||
|
||||
namespace Result::GSP {
|
||||
DEFINE_HORIZON_RESULT(SuccessRegisterIRQ, 519, Success, Success);
|
||||
};
|
15
include/result/result_kernel.hpp
Normal file
15
include/result/result_kernel.hpp
Normal file
|
@ -0,0 +1,15 @@
|
|||
#pragma once
|
||||
#include "result_common.hpp"
|
||||
|
||||
DEFINE_HORIZON_RESULT_MODULE(Result::Kernel, Kernel);
|
||||
|
||||
namespace Result::Kernel {
|
||||
// Returned when a thread releases a mutex it does not own
|
||||
DEFINE_HORIZON_RESULT(InvalidMutexRelease, 31, InvalidArgument, Permanent);
|
||||
DEFINE_HORIZON_RESULT(NotFound, 1018, NotFound, Permanent);
|
||||
DEFINE_HORIZON_RESULT(InvalidEnumValue, 1005, InvalidArgument, Permanent);
|
||||
DEFINE_HORIZON_RESULT(InvalidHandle, 1015, InvalidArgument, Permanent);
|
||||
|
||||
|
||||
static_assert(InvalidHandle == 0xD8E007F7, "conversion broken");
|
||||
};
|
14
include/result/result_os.hpp
Normal file
14
include/result/result_os.hpp
Normal file
|
@ -0,0 +1,14 @@
|
|||
#pragma once
|
||||
#include "result_common.hpp"
|
||||
|
||||
DEFINE_HORIZON_RESULT_MODULE(Result::OS, OS);
|
||||
|
||||
namespace Result::OS {
|
||||
DEFINE_HORIZON_RESULT(PortNameTooLong, 30, InvalidArgument, Usage);
|
||||
DEFINE_HORIZON_RESULT(InvalidHandle, 1015, WrongArgument, Permanent);
|
||||
DEFINE_HORIZON_RESULT(InvalidCombination, 1006, InvalidArgument, Usage);
|
||||
DEFINE_HORIZON_RESULT(MisalignedAddress, 1009, InvalidArgument, Usage);
|
||||
DEFINE_HORIZON_RESULT(MisalignedSize, 1010, InvalidArgument, Usage);
|
||||
DEFINE_HORIZON_RESULT(OutOfRange, 1021, InvalidArgument, Usage);
|
||||
DEFINE_HORIZON_RESULT(Timeout, 1022, StatusChanged, Info);
|
||||
};
|
|
@ -3,6 +3,7 @@
|
|||
#include "kernel_types.hpp"
|
||||
#include "logger.hpp"
|
||||
#include "memory.hpp"
|
||||
#include "result/result.hpp"
|
||||
|
||||
class ACService {
|
||||
Handle handle = KernelHandles::AC;
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include "kernel_types.hpp"
|
||||
#include "logger.hpp"
|
||||
#include "memory.hpp"
|
||||
#include "result/result.hpp"
|
||||
|
||||
class ACTService {
|
||||
Handle handle = KernelHandles::ACT;
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include "kernel_types.hpp"
|
||||
#include "logger.hpp"
|
||||
#include "memory.hpp"
|
||||
#include "result/result.hpp"
|
||||
|
||||
class AMService {
|
||||
Handle handle = KernelHandles::AM;
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include "kernel_types.hpp"
|
||||
#include "logger.hpp"
|
||||
#include "memory.hpp"
|
||||
#include "result/result.hpp"
|
||||
|
||||
// Yay, more circular dependencies
|
||||
class Kernel;
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include "kernel_types.hpp"
|
||||
#include "logger.hpp"
|
||||
#include "memory.hpp"
|
||||
#include "result/result.hpp"
|
||||
|
||||
class BOSSService {
|
||||
Handle handle = KernelHandles::BOSS;
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include "kernel_types.hpp"
|
||||
#include "logger.hpp"
|
||||
#include "memory.hpp"
|
||||
#include "result/result.hpp"
|
||||
|
||||
class CAMService {
|
||||
Handle handle = KernelHandles::CAM;
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include "kernel_types.hpp"
|
||||
#include "logger.hpp"
|
||||
#include "memory.hpp"
|
||||
#include "result/result.hpp"
|
||||
|
||||
class Kernel;
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include "logger.hpp"
|
||||
#include "memory.hpp"
|
||||
#include "region_codes.hpp"
|
||||
#include "result/result.hpp"
|
||||
|
||||
class CFGService {
|
||||
Handle handle = KernelHandles::CFG;
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include "kernel_types.hpp"
|
||||
#include "logger.hpp"
|
||||
#include "memory.hpp"
|
||||
#include "result/result.hpp"
|
||||
|
||||
// Please forgive me for how everything in this file is named
|
||||
// "dlp:SRVR" is not a nice name to work with
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include "helpers.hpp"
|
||||
#include "logger.hpp"
|
||||
#include "memory.hpp"
|
||||
#include "result/result.hpp"
|
||||
|
||||
namespace DSPPipeType {
|
||||
enum : u32 {
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include "kernel_types.hpp"
|
||||
#include "logger.hpp"
|
||||
#include "memory.hpp"
|
||||
#include "result/result.hpp"
|
||||
|
||||
// It's important to keep this struct to 16 bytes as we use its sizeof in the service functions in frd.cpp
|
||||
struct FriendKey {
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include "kernel_types.hpp"
|
||||
#include "logger.hpp"
|
||||
#include "memory.hpp"
|
||||
#include "result/result.hpp"
|
||||
|
||||
// Yay, more circular dependencies
|
||||
class Kernel;
|
||||
|
@ -29,8 +30,8 @@ class FSService {
|
|||
ExtSaveDataArchive sharedExtSaveData_nand;
|
||||
|
||||
ArchiveBase* getArchiveFromID(u32 id, const FSPath& archivePath);
|
||||
Rust::Result<Handle, FSResult> openArchiveHandle(u32 archiveID, const FSPath& path);
|
||||
Rust::Result<Handle, FSResult> openDirectoryHandle(ArchiveBase* archive, const FSPath& path);
|
||||
Rust::Result<Handle, HorizonResult> openArchiveHandle(u32 archiveID, const FSPath& path);
|
||||
Rust::Result<Handle, HorizonResult> openDirectoryHandle(ArchiveBase* archive, const FSPath& path);
|
||||
std::optional<Handle> openFileHandle(ArchiveBase* archive, const FSPath& path, const FSPath& archivePath, const FilePerms& perms);
|
||||
FSPath readPath(u32 type, u32 pointer, u32 size);
|
||||
|
||||
|
@ -62,7 +63,7 @@ public:
|
|||
sharedExtSaveData_nand(mem, "../SharedFiles/NAND", true), extSaveData_sdmc(mem, "SDMC"),
|
||||
sdmc(mem), selfNcch(mem), ncch(mem), kernel(kernel)
|
||||
{}
|
||||
|
||||
|
||||
void reset();
|
||||
void handleSyncRequest(u32 messagePointer);
|
||||
// Creates directories for NAND, ExtSaveData, etc if they don't already exist. Should be executed after loading a new ROM.
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#include "kernel_types.hpp"
|
||||
#include "logger.hpp"
|
||||
#include "memory.hpp"
|
||||
#include "result/result.hpp"
|
||||
|
||||
enum class GPUInterrupt : u8 {
|
||||
PSC0 = 0, // Memory fill completed
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include "kernel_types.hpp"
|
||||
#include "logger.hpp"
|
||||
#include "memory.hpp"
|
||||
#include "result/result.hpp"
|
||||
|
||||
class LCDService {
|
||||
Handle handle = KernelHandles::LCD;
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include "kernel_types.hpp"
|
||||
#include "logger.hpp"
|
||||
#include "memory.hpp"
|
||||
#include "result/result.hpp"
|
||||
|
||||
namespace HID::Keys {
|
||||
enum : u32 {
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include "kernel_types.hpp"
|
||||
#include "logger.hpp"
|
||||
#include "memory.hpp"
|
||||
#include "result/result.hpp"
|
||||
|
||||
class LDRService {
|
||||
Handle handle = KernelHandles::LDR_RO;
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include "kernel_types.hpp"
|
||||
#include "logger.hpp"
|
||||
#include "memory.hpp"
|
||||
#include "result/result.hpp"
|
||||
|
||||
class MICService {
|
||||
Handle handle = KernelHandles::MIC;
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include "kernel_types.hpp"
|
||||
#include "logger.hpp"
|
||||
#include "memory.hpp"
|
||||
#include "result/result.hpp"
|
||||
|
||||
class NDMService {
|
||||
Handle handle = KernelHandles::NDM;
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include "kernel_types.hpp"
|
||||
#include "logger.hpp"
|
||||
#include "memory.hpp"
|
||||
#include "result/result.hpp"
|
||||
|
||||
// You know the drill
|
||||
class Kernel;
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include "kernel_types.hpp"
|
||||
#include "logger.hpp"
|
||||
#include "memory.hpp"
|
||||
#include "result/result.hpp"
|
||||
|
||||
class NIMService {
|
||||
Handle handle = KernelHandles::NIM;
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include "kernel_types.hpp"
|
||||
#include "logger.hpp"
|
||||
#include "memory.hpp"
|
||||
#include "result/result.hpp"
|
||||
|
||||
class PTMService {
|
||||
Handle handle = KernelHandles::PTM;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue