diff options
| author | 2014-10-28 23:08:37 -0400 | |
|---|---|---|
| committer | 2014-10-29 15:55:51 -0400 | |
| commit | 38df9e96dd39604273a7a3508abb5e2b302b79cd (patch) | |
| tree | 56e092b84815ba02b3d6918524405f25f4c2f251 /src/core/hle/service/fs.cpp | |
| parent | Merge pull request #151 from archshift/dyncom-enabled (diff) | |
| download | yuzu-38df9e96dd39604273a7a3508abb5e2b302b79cd.tar.gz yuzu-38df9e96dd39604273a7a3508abb5e2b302b79cd.tar.xz yuzu-38df9e96dd39604273a7a3508abb5e2b302b79cd.zip | |
Renamed souce files of services to match port names
Diffstat (limited to 'src/core/hle/service/fs.cpp')
| -rw-r--r-- | src/core/hle/service/fs.cpp | 302 |
1 files changed, 0 insertions, 302 deletions
diff --git a/src/core/hle/service/fs.cpp b/src/core/hle/service/fs.cpp deleted file mode 100644 index 662c4f247..000000000 --- a/src/core/hle/service/fs.cpp +++ /dev/null | |||
| @@ -1,302 +0,0 @@ | |||
| 1 | // Copyright 2014 Citra Emulator Project | ||
| 2 | // Licensed under GPLv2 | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #include "common/common.h" | ||
| 6 | |||
| 7 | #include "core/hle/service/fs.h" | ||
| 8 | #include "core/hle/kernel/archive.h" | ||
| 9 | |||
| 10 | //////////////////////////////////////////////////////////////////////////////////////////////////// | ||
| 11 | // Namespace FS_User | ||
| 12 | |||
| 13 | namespace FS_User { | ||
| 14 | |||
| 15 | // Command to access archive file | ||
| 16 | enum class LowPathType : u32 { | ||
| 17 | Invalid = 0, | ||
| 18 | Empty = 1, | ||
| 19 | Binary = 2, | ||
| 20 | Char = 3, | ||
| 21 | Wchar = 4 | ||
| 22 | }; | ||
| 23 | |||
| 24 | std::string GetStringFromCmdBuff(const u32 pointer, const u32 size) { | ||
| 25 | auto data = reinterpret_cast<const char*>(Memory::GetPointer(pointer)); | ||
| 26 | return std::string(data, size - 1); | ||
| 27 | } | ||
| 28 | |||
| 29 | // We currently return 0 for success and -1 for failure in cmd_buff[1]. -1 was chosen because it | ||
| 30 | // puts all the sections of the http://3dbrew.org/wiki/Error_codes to something non-zero, to make | ||
| 31 | // sure we don't mislead the application into thinking something worked. | ||
| 32 | |||
| 33 | void Initialize(Service::Interface* self) { | ||
| 34 | u32* cmd_buff = Service::GetCommandBuffer(); | ||
| 35 | |||
| 36 | // TODO(Link Mauve): check the behavior when cmd_buff[1] isn't 32, as per | ||
| 37 | // http://3dbrew.org/wiki/FS:Initialize#Request | ||
| 38 | cmd_buff[1] = 0; | ||
| 39 | |||
| 40 | DEBUG_LOG(KERNEL, "called"); | ||
| 41 | } | ||
| 42 | |||
| 43 | void OpenFile(Service::Interface* self) { | ||
| 44 | u32* cmd_buff = Service::GetCommandBuffer(); | ||
| 45 | |||
| 46 | u32 transaction = cmd_buff[1]; | ||
| 47 | // TODO(Link Mauve): cmd_buff[2], aka archive handle lower word, isn't used according to | ||
| 48 | // 3dmoo's or ctrulib's implementations. Triple check if it's really the case. | ||
| 49 | Handle archive_handle = static_cast<Handle>(cmd_buff[3]); | ||
| 50 | LowPathType type = static_cast<LowPathType>(cmd_buff[4]); | ||
| 51 | u32 size = cmd_buff[5]; | ||
| 52 | FileSys::Mode mode; mode.hex = cmd_buff[6]; | ||
| 53 | u32 attributes = cmd_buff[7]; // TODO(Link Mauve): do something with those attributes. | ||
| 54 | u32 pointer = cmd_buff[9]; | ||
| 55 | |||
| 56 | if (type != LowPathType::Char) { | ||
| 57 | ERROR_LOG(KERNEL, "file LowPath type other than char is currently unsupported"); | ||
| 58 | cmd_buff[1] = -1; | ||
| 59 | return; | ||
| 60 | } | ||
| 61 | |||
| 62 | std::string file_name = GetStringFromCmdBuff(pointer, size); | ||
| 63 | |||
| 64 | DEBUG_LOG(KERNEL, "type=%d size=%d mode=%d attrs=%d data=%s", type, size, mode, attributes, file_name.c_str()); | ||
| 65 | |||
| 66 | Handle handle = Kernel::OpenFileFromArchive(archive_handle, file_name, mode); | ||
| 67 | if (handle) { | ||
| 68 | cmd_buff[1] = 0; | ||
| 69 | cmd_buff[3] = handle; | ||
| 70 | } else { | ||
| 71 | ERROR_LOG(KERNEL, "failed to get a handle for file %s", file_name.c_str()); | ||
| 72 | // TODO(Link Mauve): check for the actual error values, this one was just chosen arbitrarily. | ||
| 73 | cmd_buff[1] = -1; | ||
| 74 | } | ||
| 75 | |||
| 76 | DEBUG_LOG(KERNEL, "called"); | ||
| 77 | } | ||
| 78 | |||
| 79 | void OpenFileDirectly(Service::Interface* self) { | ||
| 80 | u32* cmd_buff = Service::GetCommandBuffer(); | ||
| 81 | |||
| 82 | u32 transaction = cmd_buff[1]; | ||
| 83 | auto archive_id = static_cast<FileSys::Archive::IdCode>(cmd_buff[2]); | ||
| 84 | LowPathType archive_type = static_cast<LowPathType>(cmd_buff[3]); | ||
| 85 | u32 archive_size = cmd_buff[4]; | ||
| 86 | LowPathType file_type = static_cast<LowPathType>(cmd_buff[5]); | ||
| 87 | u32 size = cmd_buff[6]; | ||
| 88 | FileSys::Mode mode; mode.hex = cmd_buff[7]; | ||
| 89 | u32 attributes = cmd_buff[8]; // TODO(Link Mauve): do something with those attributes. | ||
| 90 | u32 archive_pointer = cmd_buff[10]; | ||
| 91 | u32 pointer = cmd_buff[12]; | ||
| 92 | |||
| 93 | if (archive_type != LowPathType::Empty) { | ||
| 94 | ERROR_LOG(KERNEL, "archive LowPath type other than empty is currently unsupported"); | ||
| 95 | cmd_buff[1] = -1; | ||
| 96 | return; | ||
| 97 | } | ||
| 98 | |||
| 99 | std::string archive_name = GetStringFromCmdBuff(archive_pointer, archive_size); | ||
| 100 | std::string file_name = GetStringFromCmdBuff(pointer, size); | ||
| 101 | |||
| 102 | DEBUG_LOG(KERNEL, "archive_type=%d archive_size=%d archive_data=%s" | ||
| 103 | "file_type=%d file_size=%d file_mode=%d file_attrs=%d file_data=%s", | ||
| 104 | archive_type, archive_size, archive_name.c_str(), | ||
| 105 | file_type, size, mode, attributes, file_name.c_str()); | ||
| 106 | |||
| 107 | // TODO(Link Mauve): check if we should even get a handle for the archive, and don't leak it. | ||
| 108 | Handle archive_handle = Kernel::OpenArchive(archive_id); | ||
| 109 | if (archive_handle) { | ||
| 110 | cmd_buff[1] = 0; | ||
| 111 | // cmd_buff[2] isn't used according to 3dmoo's implementation. | ||
| 112 | cmd_buff[3] = archive_handle; | ||
| 113 | } else { | ||
| 114 | ERROR_LOG(KERNEL, "failed to get a handle for archive %s", archive_name.c_str()); | ||
| 115 | // TODO(Link Mauve): check for the actual error values, this one was just chosen arbitrarily. | ||
| 116 | cmd_buff[1] = -1; | ||
| 117 | return; | ||
| 118 | } | ||
| 119 | |||
| 120 | if (file_type != LowPathType::Char) { | ||
| 121 | WARN_LOG(KERNEL, "file LowPath type other than char is currently unsupported; returning archive handle instead"); | ||
| 122 | return; | ||
| 123 | } | ||
| 124 | |||
| 125 | Handle handle = Kernel::OpenFileFromArchive(archive_handle, file_name, mode); | ||
| 126 | if (handle) { | ||
| 127 | cmd_buff[1] = 0; | ||
| 128 | cmd_buff[3] = handle; | ||
| 129 | } else { | ||
| 130 | ERROR_LOG(KERNEL, "failed to get a handle for file %s", file_name.c_str()); | ||
| 131 | // TODO(Link Mauve): check for the actual error values, this one was just chosen arbitrarily. | ||
| 132 | cmd_buff[1] = -1; | ||
| 133 | } | ||
| 134 | |||
| 135 | DEBUG_LOG(KERNEL, "called"); | ||
| 136 | } | ||
| 137 | |||
| 138 | void OpenDirectory(Service::Interface* self) { | ||
| 139 | u32* cmd_buff = Service::GetCommandBuffer(); | ||
| 140 | |||
| 141 | // TODO(Link Mauve): cmd_buff[2], aka archive handle lower word, isn't used according to | ||
| 142 | // 3dmoo's or ctrulib's implementations. Triple check if it's really the case. | ||
| 143 | Handle archive_handle = static_cast<Handle>(cmd_buff[2]); | ||
| 144 | LowPathType type = static_cast<LowPathType>(cmd_buff[3]); | ||
| 145 | u32 size = cmd_buff[4]; | ||
| 146 | u32 pointer = cmd_buff[6]; | ||
| 147 | |||
| 148 | if (type != LowPathType::Char) { | ||
| 149 | ERROR_LOG(KERNEL, "directory LowPath type other than char is currently unsupported"); | ||
| 150 | cmd_buff[1] = -1; | ||
| 151 | return; | ||
| 152 | } | ||
| 153 | |||
| 154 | std::string dir_name = GetStringFromCmdBuff(pointer, size); | ||
| 155 | |||
| 156 | DEBUG_LOG(KERNEL, "type=%d size=%d data=%s", type, size, dir_name.c_str()); | ||
| 157 | |||
| 158 | Handle handle = Kernel::OpenDirectoryFromArchive(archive_handle, dir_name); | ||
| 159 | if (handle) { | ||
| 160 | cmd_buff[1] = 0; | ||
| 161 | cmd_buff[3] = handle; | ||
| 162 | } else { | ||
| 163 | ERROR_LOG(KERNEL, "failed to get a handle for directory %s", dir_name.c_str()); | ||
| 164 | // TODO(Link Mauve): check for the actual error values, this one was just chosen arbitrarily. | ||
| 165 | cmd_buff[1] = -1; | ||
| 166 | } | ||
| 167 | |||
| 168 | DEBUG_LOG(KERNEL, "called"); | ||
| 169 | } | ||
| 170 | |||
| 171 | void OpenArchive(Service::Interface* self) { | ||
| 172 | u32* cmd_buff = Service::GetCommandBuffer(); | ||
| 173 | |||
| 174 | auto arch_id = static_cast<FileSys::Archive::IdCode>(cmd_buff[1]); | ||
| 175 | LowPathType type = static_cast<LowPathType>(cmd_buff[2]); | ||
| 176 | u32 size = cmd_buff[3]; | ||
| 177 | u32 pointer = cmd_buff[5]; | ||
| 178 | |||
| 179 | if (type != LowPathType::Empty) { | ||
| 180 | ERROR_LOG(KERNEL, "archive LowPath type other than empty is currently unsupported"); | ||
| 181 | cmd_buff[1] = -1; | ||
| 182 | return; | ||
| 183 | } | ||
| 184 | |||
| 185 | std::string archive_name = GetStringFromCmdBuff(pointer, size); | ||
| 186 | |||
| 187 | DEBUG_LOG(KERNEL, "type=%d size=%d data=%s", type, size, archive_name.c_str()); | ||
| 188 | |||
| 189 | Handle handle = Kernel::OpenArchive(arch_id); | ||
| 190 | if (handle) { | ||
| 191 | cmd_buff[1] = 0; | ||
| 192 | // cmd_buff[2] isn't used according to 3dmoo's implementation. | ||
| 193 | cmd_buff[3] = handle; | ||
| 194 | } else { | ||
| 195 | ERROR_LOG(KERNEL, "failed to get a handle for archive %s", archive_name.c_str()); | ||
| 196 | // TODO(Link Mauve): check for the actual error values, this one was just chosen arbitrarily. | ||
| 197 | cmd_buff[1] = -1; | ||
| 198 | } | ||
| 199 | |||
| 200 | DEBUG_LOG(KERNEL, "called"); | ||
| 201 | } | ||
| 202 | |||
| 203 | const Interface::FunctionInfo FunctionTable[] = { | ||
| 204 | {0x000100C6, nullptr, "Dummy1"}, | ||
| 205 | {0x040100C4, nullptr, "Control"}, | ||
| 206 | {0x08010002, Initialize, "Initialize"}, | ||
| 207 | {0x080201C2, OpenFile, "OpenFile"}, | ||
| 208 | {0x08030204, OpenFileDirectly, "OpenFileDirectly"}, | ||
| 209 | {0x08040142, nullptr, "DeleteFile"}, | ||
| 210 | {0x08050244, nullptr, "RenameFile"}, | ||
| 211 | {0x08060142, nullptr, "DeleteDirectory"}, | ||
| 212 | {0x08070142, nullptr, "DeleteDirectoryRecursively"}, | ||
| 213 | {0x08080202, nullptr, "CreateFile"}, | ||
| 214 | {0x08090182, nullptr, "CreateDirectory"}, | ||
| 215 | {0x080A0244, nullptr, "RenameDirectory"}, | ||
| 216 | {0x080B0102, OpenDirectory, "OpenDirectory"}, | ||
| 217 | {0x080C00C2, OpenArchive, "OpenArchive"}, | ||
| 218 | {0x080D0144, nullptr, "ControlArchive"}, | ||
| 219 | {0x080E0080, nullptr, "CloseArchive"}, | ||
| 220 | {0x080F0180, nullptr, "FormatThisUserSaveData"}, | ||
| 221 | {0x08100200, nullptr, "CreateSystemSaveData"}, | ||
| 222 | {0x08110040, nullptr, "DeleteSystemSaveData"}, | ||
| 223 | {0x08120080, nullptr, "GetFreeBytes"}, | ||
| 224 | {0x08130000, nullptr, "GetCardType"}, | ||
| 225 | {0x08140000, nullptr, "GetSdmcArchiveResource"}, | ||
| 226 | {0x08150000, nullptr, "GetNandArchiveResource"}, | ||
| 227 | {0x08160000, nullptr, "GetSdmcFatfsErro"}, | ||
| 228 | {0x08170000, nullptr, "IsSdmcDetected"}, | ||
| 229 | {0x08180000, nullptr, "IsSdmcWritable"}, | ||
| 230 | {0x08190042, nullptr, "GetSdmcCid"}, | ||
| 231 | {0x081A0042, nullptr, "GetNandCid"}, | ||
| 232 | {0x081B0000, nullptr, "GetSdmcSpeedInfo"}, | ||
| 233 | {0x081C0000, nullptr, "GetNandSpeedInfo"}, | ||
| 234 | {0x081D0042, nullptr, "GetSdmcLog"}, | ||
| 235 | {0x081E0042, nullptr, "GetNandLog"}, | ||
| 236 | {0x081F0000, nullptr, "ClearSdmcLog"}, | ||
| 237 | {0x08200000, nullptr, "ClearNandLog"}, | ||
| 238 | {0x08210000, nullptr, "CardSlotIsInserted"}, | ||
| 239 | {0x08220000, nullptr, "CardSlotPowerOn"}, | ||
| 240 | {0x08230000, nullptr, "CardSlotPowerOff"}, | ||
| 241 | {0x08240000, nullptr, "CardSlotGetCardIFPowerStatus"}, | ||
| 242 | {0x08250040, nullptr, "CardNorDirectCommand"}, | ||
| 243 | {0x08260080, nullptr, "CardNorDirectCommandWithAddress"}, | ||
| 244 | {0x08270082, nullptr, "CardNorDirectRead"}, | ||
| 245 | {0x082800C2, nullptr, "CardNorDirectReadWithAddress"}, | ||
| 246 | {0x08290082, nullptr, "CardNorDirectWrite"}, | ||
| 247 | {0x082A00C2, nullptr, "CardNorDirectWriteWithAddress"}, | ||
| 248 | {0x082B00C2, nullptr, "CardNorDirectRead_4xIO"}, | ||
| 249 | {0x082C0082, nullptr, "CardNorDirectCpuWriteWithoutVerify"}, | ||
| 250 | {0x082D0040, nullptr, "CardNorDirectSectorEraseWithoutVerify"}, | ||
| 251 | {0x082E0040, nullptr, "GetProductInfo"}, | ||
| 252 | {0x082F0040, nullptr, "GetProgramLaunchInfo"}, | ||
| 253 | {0x08300182, nullptr, "CreateExtSaveData"}, | ||
| 254 | {0x08310180, nullptr, "CreateSharedExtSaveData"}, | ||
| 255 | {0x08320102, nullptr, "ReadExtSaveDataIcon"}, | ||
| 256 | {0x08330082, nullptr, "EnumerateExtSaveData"}, | ||
| 257 | {0x08340082, nullptr, "EnumerateSharedExtSaveData"}, | ||
| 258 | {0x08350080, nullptr, "DeleteExtSaveData"}, | ||
| 259 | {0x08360080, nullptr, "DeleteSharedExtSaveData"}, | ||
| 260 | {0x08370040, nullptr, "SetCardSpiBaudRate"}, | ||
| 261 | {0x08380040, nullptr, "SetCardSpiBusMode"}, | ||
| 262 | {0x08390000, nullptr, "SendInitializeInfoTo9"}, | ||
| 263 | {0x083A0100, nullptr, "GetSpecialContentIndex"}, | ||
| 264 | {0x083B00C2, nullptr, "GetLegacyRomHeader"}, | ||
| 265 | {0x083C00C2, nullptr, "GetLegacyBannerData"}, | ||
| 266 | {0x083D0100, nullptr, "CheckAuthorityToAccessExtSaveData"}, | ||
| 267 | {0x083E00C2, nullptr, "QueryTotalQuotaSize"}, | ||
| 268 | {0x083F00C0, nullptr, "GetExtDataBlockSize"}, | ||
| 269 | {0x08400040, nullptr, "AbnegateAccessRight"}, | ||
| 270 | {0x08410000, nullptr, "DeleteSdmcRoot"}, | ||
| 271 | {0x08420040, nullptr, "DeleteAllExtSaveDataOnNand"}, | ||
| 272 | {0x08430000, nullptr, "InitializeCtrFileSystem"}, | ||
| 273 | {0x08440000, nullptr, "CreateSeed"}, | ||
| 274 | {0x084500C2, nullptr, "GetFormatInfo"}, | ||
| 275 | {0x08460102, nullptr, "GetLegacyRomHeader2"}, | ||
| 276 | {0x08470180, nullptr, "FormatCtrCardUserSaveData"}, | ||
| 277 | {0x08480042, nullptr, "GetSdmcCtrRootPath"}, | ||
| 278 | {0x08490040, nullptr, "GetArchiveResource"}, | ||
| 279 | {0x084A0002, nullptr, "ExportIntegrityVerificationSeed"}, | ||
| 280 | {0x084B0002, nullptr, "ImportIntegrityVerificationSeed"}, | ||
| 281 | {0x084C0242, nullptr, "FormatSaveData"}, | ||
| 282 | {0x084D0102, nullptr, "GetLegacySubBannerData"}, | ||
| 283 | {0x084E0342, nullptr, "UpdateSha256Context"}, | ||
| 284 | {0x084F0102, nullptr, "ReadSpecialFile"}, | ||
| 285 | {0x08500040, nullptr, "GetSpecialFileSize"}, | ||
| 286 | {0x08580000, nullptr, "GetMovableSedHashedKeyYRandomData"}, | ||
| 287 | {0x08610042, nullptr, "InitializeWithSdkVersion"}, | ||
| 288 | {0x08620040, nullptr, "SetPriority"}, | ||
| 289 | {0x08630000, nullptr, "GetPriority"}, | ||
| 290 | }; | ||
| 291 | |||
| 292 | //////////////////////////////////////////////////////////////////////////////////////////////////// | ||
| 293 | // Interface class | ||
| 294 | |||
| 295 | Interface::Interface() { | ||
| 296 | Register(FunctionTable, ARRAY_SIZE(FunctionTable)); | ||
| 297 | } | ||
| 298 | |||
| 299 | Interface::~Interface() { | ||
| 300 | } | ||
| 301 | |||
| 302 | } // namespace | ||