From 7418c80e7f9fa5cb423939856b83bea61ac7e32b Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Wed, 25 Nov 2020 21:19:27 -0800 Subject: [PATCH] ceci n'est pas une prfile2 --- libraries/libvapours/include/vapours.hpp | 3 +- .../libvapours/include/vapours/prfile2.hpp | 24 +++++ .../prfile2/pf/prfile2_pf_api_common.hpp | 24 +++++ .../vapours/prfile2/pf/prfile2_pf_config.hpp | 24 +++++ .../vapours/prfile2/pf/prfile2_pf_types.hpp | 71 +++++++++++++ .../vapours/prfile2/prfile2_build_config.hpp | 38 +++++++ .../vapours/prfile2/prfile2_common.hpp | 99 +++++++++++++++++++ 7 files changed, 282 insertions(+), 1 deletion(-) create mode 100644 libraries/libvapours/include/vapours/prfile2.hpp create mode 100644 libraries/libvapours/include/vapours/prfile2/pf/prfile2_pf_api_common.hpp create mode 100644 libraries/libvapours/include/vapours/prfile2/pf/prfile2_pf_config.hpp create mode 100644 libraries/libvapours/include/vapours/prfile2/pf/prfile2_pf_types.hpp create mode 100644 libraries/libvapours/include/vapours/prfile2/prfile2_build_config.hpp create mode 100644 libraries/libvapours/include/vapours/prfile2/prfile2_common.hpp diff --git a/libraries/libvapours/include/vapours.hpp b/libraries/libvapours/include/vapours.hpp index a47ec53bc..c9570fe30 100644 --- a/libraries/libvapours/include/vapours.hpp +++ b/libraries/libvapours/include/vapours.hpp @@ -38,4 +38,5 @@ #include #include -#include \ No newline at end of file +#include +#include diff --git a/libraries/libvapours/include/vapours/prfile2.hpp b/libraries/libvapours/include/vapours/prfile2.hpp new file mode 100644 index 000000000..e01bcd523 --- /dev/null +++ b/libraries/libvapours/include/vapours/prfile2.hpp @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2018-2020 Atmosphère-NX + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#pragma once +#include +#include +#include +#include +#include + +#include diff --git a/libraries/libvapours/include/vapours/prfile2/pf/prfile2_pf_api_common.hpp b/libraries/libvapours/include/vapours/prfile2/pf/prfile2_pf_api_common.hpp new file mode 100644 index 000000000..41d54424e --- /dev/null +++ b/libraries/libvapours/include/vapours/prfile2/pf/prfile2_pf_api_common.hpp @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2018-2020 Atmosphère-NX + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +#pragma once +#include +#include + +namespace ams::prfile2::pf { + + int Initialize(u32 config, void *param); + +} diff --git a/libraries/libvapours/include/vapours/prfile2/pf/prfile2_pf_config.hpp b/libraries/libvapours/include/vapours/prfile2/pf/prfile2_pf_config.hpp new file mode 100644 index 000000000..cce025a12 --- /dev/null +++ b/libraries/libvapours/include/vapours/prfile2/pf/prfile2_pf_config.hpp @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2018-2020 Atmosphère-NX + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +#pragma once +#include + +namespace ams::prfile2::pf { + + constexpr inline const auto MaximumFileCount = 256; + constexpr inline const auto MaximumDirectoryCount = 32; + +} diff --git a/libraries/libvapours/include/vapours/prfile2/pf/prfile2_pf_types.hpp b/libraries/libvapours/include/vapours/prfile2/pf/prfile2_pf_types.hpp new file mode 100644 index 000000000..870d254fb --- /dev/null +++ b/libraries/libvapours/include/vapours/prfile2/pf/prfile2_pf_types.hpp @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2018-2020 Atmosphère-NX + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +#pragma once +#include + +namespace ams::prfile2::pf { + + enum Error { + Error_NoError = 0, + Error_Ok = Error_NoError, + + Error_EPERM = 1, + Error_ENOENT = 2, + Error_ESRCH = 3, + Error_EIO = 5, + Error_ENOEXEC = 8, + Error_EBADF = 9, + Error_ENOMEM = 12, + Error_EACCES = 13, + Error_EBUSY = 16, + Error_EEXIST = 17, + Error_ENODEV = 19, + Error_EISDIR = 21, + Error_EINVAL = 22, + Error_ENFILE = 23, + Error_EMFILE = 24, + Error_EFBIG = 27, + Error_ENOSPC = 28, + Error_ENOLCK = 46, + Error_ENOSYS = 88, + Error_ENOTEMPTY = 90, + + Error_EMOD_NOTREG = 100, + Error_EMOD_NOTSPRT = 101, + Error_EMOD_FCS = 102, + Error_EMOD_SAFE = 103, + + Error_ENOMEDIUM = 123, + + Error_EEXFAT_NOTSPRT = 200, + + Error_DFNC = 0x1000, + + Error_SYSTEM = -1, + }; + + constexpr inline const int ReturnValueNoError = 0; + constexpr inline const int ReturnValueError = -1; + + constexpr inline int ConvertReturnValue(Error err) { + if (AMS_LIKELY(err == Error_NoError)) { + return ReturnValueNoError; + } else { + return ReturnValueError; + } + } + +} diff --git a/libraries/libvapours/include/vapours/prfile2/prfile2_build_config.hpp b/libraries/libvapours/include/vapours/prfile2/prfile2_build_config.hpp new file mode 100644 index 000000000..c6bc5359d --- /dev/null +++ b/libraries/libvapours/include/vapours/prfile2/prfile2_build_config.hpp @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2018-2020 Atmosphère-NX + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +#pragma once +#include +#include +#include +#include +#include +#include + +#if defined(ATMOSPHERE_IS_EXOSPHERE) || defined(ATMOSPHERE_IS_MESOSPHERE) + + //#define AMS_PRFILE2_THREAD_SAFE + +#elif defined(ATMOSPHERE_IS_MESOSPHERE) + + //#define AMS_PRFILE2_THREAD_SAFE + +#elif defined(ATMOSPHERE_IS_STRATOSPHERE) + + #define AMS_PRFILE2_THREAD_SAFE + +#else + #error "Unknown execution context for ams::prfile2!" +#endif diff --git a/libraries/libvapours/include/vapours/prfile2/prfile2_common.hpp b/libraries/libvapours/include/vapours/prfile2/prfile2_common.hpp new file mode 100644 index 000000000..c9a1bf9a6 --- /dev/null +++ b/libraries/libvapours/include/vapours/prfile2/prfile2_common.hpp @@ -0,0 +1,99 @@ +/* + * Copyright (c) 2018-2020 Atmosphère-NX + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +#pragma once +#include +#include +#include + +namespace ams::prfile2 { + + constexpr inline const auto MaximumOpenFileCountSystem = pf::MaximumFileCount; + constexpr inline const auto MaximumOpenFileCountUser = pf::MaximumFileCount; + constexpr inline const auto MaximumOpenDirectoryCountSystem = pf::MaximumDirectoryCount; + constexpr inline const auto MaximumOpenDirectoryCountUser = pf::MaximumDirectoryCount; + + enum InternalError { + InternalError_NoError = 0, + InternalError_Ok = InternalError_NoError, + + InternalError_Generic = -1, + + InternalError_InvalidFileName = 1, + InternalError_InvalidPathName = 2, + InternalError_FileNotFound = 3, + InternalError_TooManyVolumesAttached = 4, + InternalError_DirectoryFull = 5, + InternalError_VolumeFull = 6, + InternalError_InvalidDiskFormat = 7, + InternalError_FileAlreadyExists = 8, + InternalError_VolumeNotMounted = 9, + InternalError_InvalidParameter = 10, + InternalError_WriteProtected = 11, + InternalError_UnsupportedFormat = 12, + InternalError_BrokenClusterChain = 13, + InternalError_InvalidClusterNum = 14, + InternalError_InvalidBpb = 15, + InternalError_AccessOutOfVolume = 16, + InternalError_DriverError = 17, + InternalError_InvalidVolumeLabel = 18, + InternalError_FileOpened = 19, + InternalError_NotADirectory = 20, + InternalError_TooManyFilesOpenedS = 21, + InternalError_TooManyFilesOpenedU = 22, + InternalError_NotAFile = 23, + InternalError_ReadOnly = 24, + InternalError_LockError = 25, + InternalError_InternalError = 26, + InternalError_EndOfFile = 27, + InternalError_AccessNotAllowed = 28, + InternalError_DirectoryNotEmpty = 29, + InternalError_NotEnoughCachePages = 30, + InternalError_DifferentDrive = 31, + InternalError_DifferentEntry = 32, + InternalError_InvalidEntry = 33, + InternalError_InvalidSector = 34, + InternalError_BrokenVolume = 35, + InternalError_NotEffective = 36, + InternalError_FileSizeOver = 37, + InternalError_InvalidFileDiscriptor = 38, + InternalError_InvalidLockFile = 39, + InternalError_ExtensionNotRegistered = 40, + InternalError_ExtensionError = 41, + }; + + constexpr inline const u32 InvalidSector = std::numeric_limits::max(); + + enum OpenMode { + OpenMode_None = 0, + OpenMode_Write = (1u << 0), + OpenMode_Read = (1u << 1), + OpenMode_Append = (1u << 2), + OpenMode_Plus = (1u << 3), + OpenMode_NoOverwrite = (1u << 4), + OpenMode_V = (1u << 5), + OpenMode_ContCluster = (1u << 6), + }; + + enum FatFormat { + FatFormat_Fat12 = 0, + FatFormat_Fat16 = 1, + FatFormat_Fat32 = 2, + FatFormat_ExFat = 3, + + FatFormat_Invalid = -1, + }; + +}