fs_user.cpp 38 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040
  1. // Copyright 2014 Citra Emulator Project
  2. // Licensed under GPLv2 or any later version
  3. // Refer to the license.txt file included.
  4. #include "common/assert.h"
  5. #include "common/common_types.h"
  6. #include "common/file_util.h"
  7. #include "common/logging/log.h"
  8. #include "common/scope_exit.h"
  9. #include "common/string_util.h"
  10. #include "core/core.h"
  11. #include "core/file_sys/errors.h"
  12. #include "core/hle/kernel/client_session.h"
  13. #include "core/hle/result.h"
  14. #include "core/hle/service/fs/archive.h"
  15. #include "core/hle/service/fs/fs_user.h"
  16. #include "core/settings.h"
  17. ////////////////////////////////////////////////////////////////////////////////////////////////////
  18. // Namespace FS_User
  19. using Kernel::SharedPtr;
  20. using Kernel::ServerSession;
  21. namespace Service {
  22. namespace FS {
  23. static u32 priority = -1; ///< For SetPriority and GetPriority service functions
  24. static ArchiveHandle MakeArchiveHandle(u32 low_word, u32 high_word) {
  25. return (u64)low_word | ((u64)high_word << 32);
  26. }
  27. static void Initialize(Service::Interface* self) {
  28. u32* cmd_buff = Kernel::GetCommandBuffer();
  29. // TODO(Link Mauve): check the behavior when cmd_buff[1] isn't 32, as per
  30. // http://3dbrew.org/wiki/FS:Initialize#Request
  31. cmd_buff[1] = RESULT_SUCCESS.raw;
  32. }
  33. /**
  34. * FS_User::OpenFile service function
  35. * Inputs:
  36. * 1 : Transaction
  37. * 2 : Archive handle lower word
  38. * 3 : Archive handle upper word
  39. * 4 : Low path type
  40. * 5 : Low path size
  41. * 6 : Open flags
  42. * 7 : Attributes
  43. * 8 : (LowPathSize << 14) | 2
  44. * 9 : Low path data pointer
  45. * Outputs:
  46. * 1 : Result of function, 0 on success, otherwise error code
  47. * 3 : File handle
  48. */
  49. static void OpenFile(Service::Interface* self) {
  50. // The helper should be passed by argument to the function
  51. IPC::RequestParser rp(Kernel::GetCommandBuffer(), {0x080201C2});
  52. rp.Pop<u32>(); // Always 0 ?
  53. ArchiveHandle archive_handle = rp.Pop<u64>();
  54. auto filename_type = static_cast<FileSys::LowPathType>(rp.Pop<u32>());
  55. u32 filename_size = rp.Pop<u32>();
  56. FileSys::Mode mode;
  57. mode.hex = rp.Pop<u32>();
  58. u32 attributes = rp.Pop<u32>(); // TODO(Link Mauve): do something with those attributes.
  59. VAddr filename_ptr = rp.PopStaticBuffer();
  60. FileSys::Path file_path(filename_type, filename_size, filename_ptr);
  61. LOG_DEBUG(Service_FS, "path=%s, mode=%u attrs=%u", file_path.DebugStr().c_str(), mode.hex,
  62. attributes);
  63. ResultVal<std::shared_ptr<File>> file_res =
  64. OpenFileFromArchive(archive_handle, file_path, mode);
  65. IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
  66. rb.Push(file_res.Code());
  67. if (file_res.Succeeded()) {
  68. std::shared_ptr<File> file = *file_res;
  69. auto sessions = ServerSession::CreateSessionPair(file->GetName(), file);
  70. file->ClientConnected(std::get<Kernel::SharedPtr<Kernel::ServerSession>>(sessions));
  71. rb.PushMoveHandles(Kernel::g_handle_table
  72. .Create(std::get<Kernel::SharedPtr<Kernel::ClientSession>>(sessions))
  73. .MoveFrom());
  74. } else {
  75. rb.PushMoveHandles(0);
  76. LOG_ERROR(Service_FS, "failed to get a handle for file %s", file_path.DebugStr().c_str());
  77. }
  78. }
  79. /**
  80. * FS_User::OpenFileDirectly service function
  81. * Inputs:
  82. * 1 : Transaction
  83. * 2 : Archive ID
  84. * 3 : Archive low path type
  85. * 4 : Archive low path size
  86. * 5 : File low path type
  87. * 6 : File low path size
  88. * 7 : Flags
  89. * 8 : Attributes
  90. * 9 : (ArchiveLowPathSize << 14) | 0x802
  91. * 10 : Archive low path
  92. * 11 : (FileLowPathSize << 14) | 2
  93. * 12 : File low path
  94. * Outputs:
  95. * 1 : Result of function, 0 on success, otherwise error code
  96. * 3 : File handle
  97. */
  98. static void OpenFileDirectly(Service::Interface* self) {
  99. u32* cmd_buff = Kernel::GetCommandBuffer();
  100. auto archive_id = static_cast<FS::ArchiveIdCode>(cmd_buff[2]);
  101. auto archivename_type = static_cast<FileSys::LowPathType>(cmd_buff[3]);
  102. u32 archivename_size = cmd_buff[4];
  103. auto filename_type = static_cast<FileSys::LowPathType>(cmd_buff[5]);
  104. u32 filename_size = cmd_buff[6];
  105. FileSys::Mode mode;
  106. mode.hex = cmd_buff[7];
  107. u32 attributes = cmd_buff[8]; // TODO(Link Mauve): do something with those attributes.
  108. u32 archivename_ptr = cmd_buff[10];
  109. u32 filename_ptr = cmd_buff[12];
  110. FileSys::Path archive_path(archivename_type, archivename_size, archivename_ptr);
  111. FileSys::Path file_path(filename_type, filename_size, filename_ptr);
  112. LOG_DEBUG(Service_FS, "archive_id=0x%08X archive_path=%s file_path=%s, mode=%u attributes=%u",
  113. static_cast<u32>(archive_id), archive_path.DebugStr().c_str(),
  114. file_path.DebugStr().c_str(), mode.hex, attributes);
  115. ResultVal<ArchiveHandle> archive_handle = OpenArchive(archive_id, archive_path);
  116. if (archive_handle.Failed()) {
  117. LOG_ERROR(Service_FS,
  118. "Failed to get a handle for archive archive_id=0x%08X archive_path=%s",
  119. static_cast<u32>(archive_id), archive_path.DebugStr().c_str());
  120. cmd_buff[1] = archive_handle.Code().raw;
  121. cmd_buff[3] = 0;
  122. return;
  123. }
  124. SCOPE_EXIT({ CloseArchive(*archive_handle); });
  125. ResultVal<std::shared_ptr<File>> file_res =
  126. OpenFileFromArchive(*archive_handle, file_path, mode);
  127. cmd_buff[1] = file_res.Code().raw;
  128. if (file_res.Succeeded()) {
  129. std::shared_ptr<File> file = *file_res;
  130. auto sessions = ServerSession::CreateSessionPair(file->GetName(), file);
  131. file->ClientConnected(std::get<Kernel::SharedPtr<Kernel::ServerSession>>(sessions));
  132. cmd_buff[3] = Kernel::g_handle_table
  133. .Create(std::get<Kernel::SharedPtr<Kernel::ClientSession>>(sessions))
  134. .MoveFrom();
  135. } else {
  136. cmd_buff[3] = 0;
  137. LOG_ERROR(Service_FS, "failed to get a handle for file %s mode=%u attributes=%u",
  138. file_path.DebugStr().c_str(), mode.hex, attributes);
  139. }
  140. }
  141. /*
  142. * FS_User::DeleteFile service function
  143. * Inputs:
  144. * 2 : Archive handle lower word
  145. * 3 : Archive handle upper word
  146. * 4 : File path string type
  147. * 5 : File path string size
  148. * 7 : File path string data
  149. * Outputs:
  150. * 1 : Result of function, 0 on success, otherwise error code
  151. */
  152. static void DeleteFile(Service::Interface* self) {
  153. u32* cmd_buff = Kernel::GetCommandBuffer();
  154. ArchiveHandle archive_handle = MakeArchiveHandle(cmd_buff[2], cmd_buff[3]);
  155. auto filename_type = static_cast<FileSys::LowPathType>(cmd_buff[4]);
  156. u32 filename_size = cmd_buff[5];
  157. u32 filename_ptr = cmd_buff[7];
  158. FileSys::Path file_path(filename_type, filename_size, filename_ptr);
  159. LOG_DEBUG(Service_FS, "type=%u size=%u data=%s", static_cast<u32>(filename_type), filename_size,
  160. file_path.DebugStr().c_str());
  161. cmd_buff[1] = DeleteFileFromArchive(archive_handle, file_path).raw;
  162. }
  163. /*
  164. * FS_User::RenameFile service function
  165. * Inputs:
  166. * 2 : Source archive handle lower word
  167. * 3 : Source archive handle upper word
  168. * 4 : Source file path type
  169. * 5 : Source file path size
  170. * 6 : Dest archive handle lower word
  171. * 7 : Dest archive handle upper word
  172. * 8 : Dest file path type
  173. * 9 : Dest file path size
  174. * 11: Source file path string data
  175. * 13: Dest file path string
  176. * Outputs:
  177. * 1 : Result of function, 0 on success, otherwise error code
  178. */
  179. static void RenameFile(Service::Interface* self) {
  180. u32* cmd_buff = Kernel::GetCommandBuffer();
  181. ArchiveHandle src_archive_handle = MakeArchiveHandle(cmd_buff[2], cmd_buff[3]);
  182. auto src_filename_type = static_cast<FileSys::LowPathType>(cmd_buff[4]);
  183. u32 src_filename_size = cmd_buff[5];
  184. ArchiveHandle dest_archive_handle = MakeArchiveHandle(cmd_buff[6], cmd_buff[7]);
  185. ;
  186. auto dest_filename_type = static_cast<FileSys::LowPathType>(cmd_buff[8]);
  187. u32 dest_filename_size = cmd_buff[9];
  188. u32 src_filename_ptr = cmd_buff[11];
  189. u32 dest_filename_ptr = cmd_buff[13];
  190. FileSys::Path src_file_path(src_filename_type, src_filename_size, src_filename_ptr);
  191. FileSys::Path dest_file_path(dest_filename_type, dest_filename_size, dest_filename_ptr);
  192. LOG_DEBUG(Service_FS,
  193. "src_type=%u src_size=%u src_data=%s dest_type=%u dest_size=%u dest_data=%s",
  194. static_cast<u32>(src_filename_type), src_filename_size,
  195. src_file_path.DebugStr().c_str(), static_cast<u32>(dest_filename_type),
  196. dest_filename_size, dest_file_path.DebugStr().c_str());
  197. cmd_buff[1] = RenameFileBetweenArchives(src_archive_handle, src_file_path, dest_archive_handle,
  198. dest_file_path)
  199. .raw;
  200. }
  201. /*
  202. * FS_User::DeleteDirectory service function
  203. * Inputs:
  204. * 2 : Archive handle lower word
  205. * 3 : Archive handle upper word
  206. * 4 : Directory path string type
  207. * 5 : Directory path string size
  208. * 7 : Directory path string data
  209. * Outputs:
  210. * 1 : Result of function, 0 on success, otherwise error code
  211. */
  212. static void DeleteDirectory(Service::Interface* self) {
  213. u32* cmd_buff = Kernel::GetCommandBuffer();
  214. ArchiveHandle archive_handle = MakeArchiveHandle(cmd_buff[2], cmd_buff[3]);
  215. auto dirname_type = static_cast<FileSys::LowPathType>(cmd_buff[4]);
  216. u32 dirname_size = cmd_buff[5];
  217. u32 dirname_ptr = cmd_buff[7];
  218. FileSys::Path dir_path(dirname_type, dirname_size, dirname_ptr);
  219. LOG_DEBUG(Service_FS, "type=%u size=%u data=%s", static_cast<u32>(dirname_type), dirname_size,
  220. dir_path.DebugStr().c_str());
  221. cmd_buff[1] = DeleteDirectoryFromArchive(archive_handle, dir_path).raw;
  222. }
  223. /*
  224. * FS_User::DeleteDirectoryRecursively service function
  225. * Inputs:
  226. * 0 : Command header 0x08070142
  227. * 1 : Transaction
  228. * 2 : Archive handle lower word
  229. * 3 : Archive handle upper word
  230. * 4 : Directory path string type
  231. * 5 : Directory path string size
  232. * 7 : Directory path string data
  233. * Outputs:
  234. * 1 : Result of function, 0 on success, otherwise error code
  235. */
  236. static void DeleteDirectoryRecursively(Service::Interface* self) {
  237. u32* cmd_buff = Kernel::GetCommandBuffer();
  238. ArchiveHandle archive_handle = MakeArchiveHandle(cmd_buff[2], cmd_buff[3]);
  239. auto dirname_type = static_cast<FileSys::LowPathType>(cmd_buff[4]);
  240. u32 dirname_size = cmd_buff[5];
  241. u32 dirname_ptr = cmd_buff[7];
  242. FileSys::Path dir_path(dirname_type, dirname_size, dirname_ptr);
  243. LOG_DEBUG(Service_FS, "type=%u size=%u data=%s", static_cast<u32>(dirname_type), dirname_size,
  244. dir_path.DebugStr().c_str());
  245. cmd_buff[1] = DeleteDirectoryRecursivelyFromArchive(archive_handle, dir_path).raw;
  246. }
  247. /*
  248. * FS_User::CreateFile service function
  249. * Inputs:
  250. * 0 : Command header 0x08080202
  251. * 2 : Archive handle lower word
  252. * 3 : Archive handle upper word
  253. * 4 : File path string type
  254. * 5 : File path string size
  255. * 7-8 : File size
  256. * 10: File path string data
  257. * Outputs:
  258. * 1 : Result of function, 0 on success, otherwise error code
  259. */
  260. static void CreateFile(Service::Interface* self) {
  261. u32* cmd_buff = Kernel::GetCommandBuffer();
  262. ArchiveHandle archive_handle = MakeArchiveHandle(cmd_buff[2], cmd_buff[3]);
  263. auto filename_type = static_cast<FileSys::LowPathType>(cmd_buff[4]);
  264. u32 filename_size = cmd_buff[5];
  265. u64 file_size = ((u64)cmd_buff[8] << 32) | cmd_buff[7];
  266. u32 filename_ptr = cmd_buff[10];
  267. FileSys::Path file_path(filename_type, filename_size, filename_ptr);
  268. LOG_DEBUG(Service_FS, "type=%u size=%llu data=%s", static_cast<u32>(filename_type), file_size,
  269. file_path.DebugStr().c_str());
  270. cmd_buff[1] = CreateFileInArchive(archive_handle, file_path, file_size).raw;
  271. }
  272. /*
  273. * FS_User::CreateDirectory service function
  274. * Inputs:
  275. * 2 : Archive handle lower word
  276. * 3 : Archive handle upper word
  277. * 4 : Directory path string type
  278. * 5 : Directory path string size
  279. * 8 : Directory path string data
  280. * Outputs:
  281. * 1 : Result of function, 0 on success, otherwise error code
  282. */
  283. static void CreateDirectory(Service::Interface* self) {
  284. u32* cmd_buff = Kernel::GetCommandBuffer();
  285. ArchiveHandle archive_handle = MakeArchiveHandle(cmd_buff[2], cmd_buff[3]);
  286. auto dirname_type = static_cast<FileSys::LowPathType>(cmd_buff[4]);
  287. u32 dirname_size = cmd_buff[5];
  288. u32 dirname_ptr = cmd_buff[8];
  289. FileSys::Path dir_path(dirname_type, dirname_size, dirname_ptr);
  290. LOG_DEBUG(Service_FS, "type=%u size=%d data=%s", static_cast<u32>(dirname_type), dirname_size,
  291. dir_path.DebugStr().c_str());
  292. cmd_buff[1] = CreateDirectoryFromArchive(archive_handle, dir_path).raw;
  293. }
  294. /*
  295. * FS_User::RenameDirectory service function
  296. * Inputs:
  297. * 2 : Source archive handle lower word
  298. * 3 : Source archive handle upper word
  299. * 4 : Source dir path type
  300. * 5 : Source dir path size
  301. * 6 : Dest archive handle lower word
  302. * 7 : Dest archive handle upper word
  303. * 8 : Dest dir path type
  304. * 9 : Dest dir path size
  305. * 11: Source dir path string data
  306. * 13: Dest dir path string
  307. * Outputs:
  308. * 1 : Result of function, 0 on success, otherwise error code
  309. */
  310. static void RenameDirectory(Service::Interface* self) {
  311. u32* cmd_buff = Kernel::GetCommandBuffer();
  312. ArchiveHandle src_archive_handle = MakeArchiveHandle(cmd_buff[2], cmd_buff[3]);
  313. auto src_dirname_type = static_cast<FileSys::LowPathType>(cmd_buff[4]);
  314. u32 src_dirname_size = cmd_buff[5];
  315. ArchiveHandle dest_archive_handle = MakeArchiveHandle(cmd_buff[6], cmd_buff[7]);
  316. auto dest_dirname_type = static_cast<FileSys::LowPathType>(cmd_buff[8]);
  317. u32 dest_dirname_size = cmd_buff[9];
  318. u32 src_dirname_ptr = cmd_buff[11];
  319. u32 dest_dirname_ptr = cmd_buff[13];
  320. FileSys::Path src_dir_path(src_dirname_type, src_dirname_size, src_dirname_ptr);
  321. FileSys::Path dest_dir_path(dest_dirname_type, dest_dirname_size, dest_dirname_ptr);
  322. LOG_DEBUG(
  323. Service_FS, "src_type=%u src_size=%u src_data=%s dest_type=%u dest_size=%u dest_data=%s",
  324. static_cast<u32>(src_dirname_type), src_dirname_size, src_dir_path.DebugStr().c_str(),
  325. static_cast<u32>(dest_dirname_type), dest_dirname_size, dest_dir_path.DebugStr().c_str());
  326. cmd_buff[1] = RenameDirectoryBetweenArchives(src_archive_handle, src_dir_path,
  327. dest_archive_handle, dest_dir_path)
  328. .raw;
  329. }
  330. /**
  331. * FS_User::OpenDirectory service function
  332. * Inputs:
  333. * 1 : Archive handle low word
  334. * 2 : Archive handle high word
  335. * 3 : Low path type
  336. * 4 : Low path size
  337. * 7 : (LowPathSize << 14) | 2
  338. * 8 : Low path data pointer
  339. * Outputs:
  340. * 1 : Result of function, 0 on success, otherwise error code
  341. * 3 : Directory handle
  342. */
  343. static void OpenDirectory(Service::Interface* self) {
  344. u32* cmd_buff = Kernel::GetCommandBuffer();
  345. ArchiveHandle archive_handle = MakeArchiveHandle(cmd_buff[1], cmd_buff[2]);
  346. auto dirname_type = static_cast<FileSys::LowPathType>(cmd_buff[3]);
  347. u32 dirname_size = cmd_buff[4];
  348. u32 dirname_ptr = cmd_buff[6];
  349. FileSys::Path dir_path(dirname_type, dirname_size, dirname_ptr);
  350. LOG_DEBUG(Service_FS, "type=%u size=%u data=%s", static_cast<u32>(dirname_type), dirname_size,
  351. dir_path.DebugStr().c_str());
  352. ResultVal<std::shared_ptr<Directory>> dir_res =
  353. OpenDirectoryFromArchive(archive_handle, dir_path);
  354. cmd_buff[1] = dir_res.Code().raw;
  355. if (dir_res.Succeeded()) {
  356. std::shared_ptr<Directory> directory = *dir_res;
  357. auto sessions = ServerSession::CreateSessionPair(directory->GetName(), directory);
  358. directory->ClientConnected(std::get<Kernel::SharedPtr<Kernel::ServerSession>>(sessions));
  359. cmd_buff[3] = Kernel::g_handle_table
  360. .Create(std::get<Kernel::SharedPtr<Kernel::ClientSession>>(sessions))
  361. .MoveFrom();
  362. } else {
  363. LOG_ERROR(Service_FS, "failed to get a handle for directory type=%d size=%d data=%s",
  364. dirname_type, dirname_size, dir_path.DebugStr().c_str());
  365. }
  366. }
  367. /**
  368. * FS_User::OpenArchive service function
  369. * Inputs:
  370. * 1 : Archive ID
  371. * 2 : Archive low path type
  372. * 3 : Archive low path size
  373. * 4 : (LowPathSize << 14) | 2
  374. * 5 : Archive low path
  375. * Outputs:
  376. * 1 : Result of function, 0 on success, otherwise error code
  377. * 2 : Archive handle lower word (unused)
  378. * 3 : Archive handle upper word (same as file handle)
  379. */
  380. static void OpenArchive(Service::Interface* self) {
  381. u32* cmd_buff = Kernel::GetCommandBuffer();
  382. auto archive_id = static_cast<FS::ArchiveIdCode>(cmd_buff[1]);
  383. auto archivename_type = static_cast<FileSys::LowPathType>(cmd_buff[2]);
  384. u32 archivename_size = cmd_buff[3];
  385. u32 archivename_ptr = cmd_buff[5];
  386. FileSys::Path archive_path(archivename_type, archivename_size, archivename_ptr);
  387. LOG_DEBUG(Service_FS, "archive_id=0x%08X archive_path=%s", static_cast<u32>(archive_id),
  388. archive_path.DebugStr().c_str());
  389. ResultVal<ArchiveHandle> handle = OpenArchive(archive_id, archive_path);
  390. cmd_buff[1] = handle.Code().raw;
  391. if (handle.Succeeded()) {
  392. cmd_buff[2] = *handle & 0xFFFFFFFF;
  393. cmd_buff[3] = (*handle >> 32) & 0xFFFFFFFF;
  394. } else {
  395. cmd_buff[2] = cmd_buff[3] = 0;
  396. LOG_ERROR(Service_FS,
  397. "failed to get a handle for archive archive_id=0x%08X archive_path=%s",
  398. static_cast<u32>(archive_id), archive_path.DebugStr().c_str());
  399. }
  400. }
  401. /**
  402. * FS_User::CloseArchive service function
  403. * Inputs:
  404. * 0 : 0x080E0080
  405. * 1 : Archive handle low word
  406. * 2 : Archive handle high word
  407. * Outputs:
  408. * 0 : ??? TODO(yuriks): Verify return header
  409. * 1 : Result of function, 0 on success, otherwise error code
  410. */
  411. static void CloseArchive(Service::Interface* self) {
  412. u32* cmd_buff = Kernel::GetCommandBuffer();
  413. ArchiveHandle archive_handle = MakeArchiveHandle(cmd_buff[1], cmd_buff[2]);
  414. cmd_buff[1] = CloseArchive(archive_handle).raw;
  415. }
  416. /*
  417. * FS_User::IsSdmcDetected service function
  418. * Outputs:
  419. * 1 : Result of function, 0 on success, otherwise error code
  420. * 2 : Whether the Sdmc could be detected
  421. */
  422. static void IsSdmcDetected(Service::Interface* self) {
  423. u32* cmd_buff = Kernel::GetCommandBuffer();
  424. cmd_buff[1] = 0;
  425. cmd_buff[2] = Settings::values.use_virtual_sd ? 1 : 0;
  426. }
  427. /**
  428. * FS_User::IsSdmcWriteable service function
  429. * Outputs:
  430. * 0 : Command header 0x08180000
  431. * 1 : Result of function, 0 on success, otherwise error code
  432. * 2 : Whether the Sdmc is currently writeable
  433. */
  434. static void IsSdmcWriteable(Service::Interface* self) {
  435. u32* cmd_buff = Kernel::GetCommandBuffer();
  436. cmd_buff[1] = RESULT_SUCCESS.raw;
  437. // If the SD isn't enabled, it can't be writeable...else, stubbed true
  438. cmd_buff[2] = Settings::values.use_virtual_sd ? 1 : 0;
  439. LOG_DEBUG(Service_FS, " (STUBBED)");
  440. }
  441. /**
  442. * FS_User::FormatSaveData service function,
  443. * formats the SaveData specified by the input path.
  444. * Inputs:
  445. * 0 : 0x084C0242
  446. * 1 : Archive ID
  447. * 2 : Archive path type
  448. * 3 : Archive path size
  449. * 4 : Size in Blocks (1 block = 512 bytes)
  450. * 5 : Number of directories
  451. * 6 : Number of files
  452. * 7 : Directory bucket count
  453. * 8 : File bucket count
  454. * 9 : Duplicate data
  455. * 10 : (PathSize << 14) | 2
  456. * 11 : Archive low path
  457. * Outputs:
  458. * 1 : Result of function, 0 on success, otherwise error code
  459. */
  460. static void FormatSaveData(Service::Interface* self) {
  461. u32* cmd_buff = Kernel::GetCommandBuffer();
  462. LOG_WARNING(Service_FS, "(STUBBED)");
  463. auto archive_id = static_cast<FS::ArchiveIdCode>(cmd_buff[1]);
  464. auto archivename_type = static_cast<FileSys::LowPathType>(cmd_buff[2]);
  465. u32 archivename_size = cmd_buff[3];
  466. u32 archivename_ptr = cmd_buff[11];
  467. FileSys::Path archive_path(archivename_type, archivename_size, archivename_ptr);
  468. LOG_DEBUG(Service_FS, "archive_path=%s", archive_path.DebugStr().c_str());
  469. if (archive_id != FS::ArchiveIdCode::SaveData) {
  470. LOG_ERROR(Service_FS, "tried to format an archive different than SaveData, %u",
  471. static_cast<u32>(archive_id));
  472. cmd_buff[1] = FileSys::ERROR_INVALID_PATH.raw;
  473. return;
  474. }
  475. if (archive_path.GetType() != FileSys::LowPathType::Empty) {
  476. // TODO(Subv): Implement formatting the SaveData of other games
  477. LOG_ERROR(Service_FS, "archive LowPath type other than empty is currently unsupported");
  478. cmd_buff[1] = UnimplementedFunction(ErrorModule::FS).raw;
  479. return;
  480. }
  481. FileSys::ArchiveFormatInfo format_info;
  482. format_info.duplicate_data = cmd_buff[9] & 0xFF;
  483. format_info.number_directories = cmd_buff[5];
  484. format_info.number_files = cmd_buff[6];
  485. format_info.total_size = cmd_buff[4] * 512;
  486. cmd_buff[1] = FormatArchive(ArchiveIdCode::SaveData, format_info).raw;
  487. }
  488. /**
  489. * FS_User::FormatThisUserSaveData service function
  490. * Inputs:
  491. * 0: 0x080F0180
  492. * 1 : Size in Blocks (1 block = 512 bytes)
  493. * 2 : Number of directories
  494. * 3 : Number of files
  495. * 4 : Directory bucket count
  496. * 5 : File bucket count
  497. * 6 : Duplicate data
  498. * Outputs:
  499. * 1 : Result of function, 0 on success, otherwise error code
  500. */
  501. static void FormatThisUserSaveData(Service::Interface* self) {
  502. u32* cmd_buff = Kernel::GetCommandBuffer();
  503. FileSys::ArchiveFormatInfo format_info;
  504. format_info.duplicate_data = cmd_buff[6] & 0xFF;
  505. format_info.number_directories = cmd_buff[2];
  506. format_info.number_files = cmd_buff[3];
  507. format_info.total_size = cmd_buff[1] * 512;
  508. cmd_buff[1] = FormatArchive(ArchiveIdCode::SaveData, format_info).raw;
  509. LOG_TRACE(Service_FS, "called");
  510. }
  511. /**
  512. * FS_User::GetFreeBytes service function
  513. * Inputs:
  514. * 0: 0x08120080
  515. * 1: Archive handle low word
  516. * 2: Archive handle high word
  517. * Outputs:
  518. * 1: Result of function, 0 on success, otherwise error code
  519. * 2: Free byte count low word
  520. * 3: Free byte count high word
  521. */
  522. static void GetFreeBytes(Service::Interface* self) {
  523. u32* cmd_buff = Kernel::GetCommandBuffer();
  524. ArchiveHandle archive_handle = MakeArchiveHandle(cmd_buff[1], cmd_buff[2]);
  525. ResultVal<u64> bytes_res = GetFreeBytesInArchive(archive_handle);
  526. cmd_buff[1] = bytes_res.Code().raw;
  527. if (bytes_res.Succeeded()) {
  528. cmd_buff[2] = (u32)*bytes_res;
  529. cmd_buff[3] = *bytes_res >> 32;
  530. } else {
  531. cmd_buff[2] = 0;
  532. cmd_buff[3] = 0;
  533. }
  534. }
  535. /**
  536. * FS_User::CreateExtSaveData service function
  537. * Inputs:
  538. * 0 : 0x08510242
  539. * 1 : Media type (NAND / SDMC)
  540. * 2 : Low word of the saveid to create
  541. * 3 : High word of the saveid to create
  542. * 4 : Unknown
  543. * 5 : Number of directories
  544. * 6 : Number of files
  545. * 7-8 : Size limit
  546. * 9 : Size of the SMDH icon
  547. * 10: (SMDH Size << 4) | 0x0000000A
  548. * 11: Pointer to the SMDH icon for the new ExtSaveData
  549. * Outputs:
  550. * 1 : Result of function, 0 on success, otherwise error code
  551. */
  552. static void CreateExtSaveData(Service::Interface* self) {
  553. // TODO(Subv): Figure out the other parameters.
  554. u32* cmd_buff = Kernel::GetCommandBuffer();
  555. MediaType media_type = static_cast<MediaType>(cmd_buff[1] & 0xFF);
  556. u32 save_low = cmd_buff[2];
  557. u32 save_high = cmd_buff[3];
  558. u32 icon_size = cmd_buff[9];
  559. VAddr icon_buffer = cmd_buff[11];
  560. LOG_WARNING(
  561. Service_FS,
  562. "(STUBBED) savedata_high=%08X savedata_low=%08X cmd_buff[3]=%08X "
  563. "cmd_buff[4]=%08X cmd_buff[5]=%08X cmd_buff[6]=%08X cmd_buff[7]=%08X cmd_buff[8]=%08X "
  564. "icon_size=%08X icon_descriptor=%08X icon_buffer=%08X",
  565. save_high, save_low, cmd_buff[3], cmd_buff[4], cmd_buff[5], cmd_buff[6], cmd_buff[7],
  566. cmd_buff[8], icon_size, cmd_buff[10], icon_buffer);
  567. FileSys::ArchiveFormatInfo format_info;
  568. format_info.number_directories = cmd_buff[5];
  569. format_info.number_files = cmd_buff[6];
  570. format_info.duplicate_data = false;
  571. format_info.total_size = 0;
  572. cmd_buff[1] =
  573. CreateExtSaveData(media_type, save_high, save_low, icon_buffer, icon_size, format_info).raw;
  574. }
  575. /**
  576. * FS_User::DeleteExtSaveData service function
  577. * Inputs:
  578. * 0 : 0x08520100
  579. * 1 : Media type (NAND / SDMC)
  580. * 2 : Low word of the saveid to create
  581. * 3 : High word of the saveid to create
  582. * 4 : Unknown
  583. * Outputs:
  584. * 1 : Result of function, 0 on success, otherwise error code
  585. */
  586. static void DeleteExtSaveData(Service::Interface* self) {
  587. u32* cmd_buff = Kernel::GetCommandBuffer();
  588. MediaType media_type = static_cast<MediaType>(cmd_buff[1] & 0xFF);
  589. u32 save_low = cmd_buff[2];
  590. u32 save_high = cmd_buff[3];
  591. u32 unknown = cmd_buff[4]; // TODO(Subv): Figure out what this is
  592. LOG_WARNING(Service_FS, "(STUBBED) save_low=%08X save_high=%08X media_type=%08X unknown=%08X",
  593. save_low, save_high, cmd_buff[1] & 0xFF, unknown);
  594. cmd_buff[1] = DeleteExtSaveData(media_type, save_high, save_low).raw;
  595. }
  596. /**
  597. * FS_User::CardSlotIsInserted service function.
  598. * Inputs:
  599. * 0 : 0x08210000
  600. * Outputs:
  601. * 1 : Result of function, 0 on success, otherwise error code
  602. * 2 : Whether there is a game card inserted into the slot or not.
  603. */
  604. static void CardSlotIsInserted(Service::Interface* self) {
  605. u32* cmd_buff = Kernel::GetCommandBuffer();
  606. cmd_buff[1] = RESULT_SUCCESS.raw;
  607. cmd_buff[2] = 0;
  608. LOG_WARNING(Service_FS, "(STUBBED) called");
  609. }
  610. /**
  611. * FS_User::DeleteSystemSaveData service function.
  612. * Inputs:
  613. * 0 : 0x08570080
  614. * 1 : High word of the SystemSaveData id to delete
  615. * 2 : Low word of the SystemSaveData id to delete
  616. * Outputs:
  617. * 1 : Result of function, 0 on success, otherwise error code
  618. */
  619. static void DeleteSystemSaveData(Service::Interface* self) {
  620. u32* cmd_buff = Kernel::GetCommandBuffer();
  621. u32 savedata_high = cmd_buff[1];
  622. u32 savedata_low = cmd_buff[2];
  623. cmd_buff[1] = DeleteSystemSaveData(savedata_high, savedata_low).raw;
  624. }
  625. /**
  626. * FS_User::CreateSystemSaveData service function.
  627. * Inputs:
  628. * 0 : 0x08560240
  629. * 1 : u8 MediaType of the system save data
  630. * 2 : SystemSaveData id to create
  631. * 3 : Total size
  632. * 4 : Block size
  633. * 5 : Number of directories
  634. * 6 : Number of files
  635. * 7 : Directory bucket count
  636. * 8 : File bucket count
  637. * 9 : u8 Whether to duplicate data or not
  638. * Outputs:
  639. * 1 : Result of function, 0 on success, otherwise error code
  640. */
  641. static void CreateSystemSaveData(Service::Interface* self) {
  642. u32* cmd_buff = Kernel::GetCommandBuffer();
  643. u32 savedata_high = cmd_buff[1];
  644. u32 savedata_low = cmd_buff[2];
  645. LOG_WARNING(
  646. Service_FS,
  647. "(STUBBED) savedata_high=%08X savedata_low=%08X cmd_buff[3]=%08X "
  648. "cmd_buff[4]=%08X cmd_buff[5]=%08X cmd_buff[6]=%08X cmd_buff[7]=%08X cmd_buff[8]=%08X "
  649. "cmd_buff[9]=%08X",
  650. savedata_high, savedata_low, cmd_buff[3], cmd_buff[4], cmd_buff[5], cmd_buff[6],
  651. cmd_buff[7], cmd_buff[8], cmd_buff[9]);
  652. cmd_buff[1] = CreateSystemSaveData(savedata_high, savedata_low).raw;
  653. }
  654. /**
  655. * FS_User::CreateLegacySystemSaveData service function.
  656. * This function appears to be obsolete and seems to have been replaced by
  657. * command 0x08560240 (CreateSystemSaveData).
  658. *
  659. * Inputs:
  660. * 0 : 0x08100200
  661. * 1 : SystemSaveData id to create
  662. * 2 : Total size
  663. * 3 : Block size
  664. * 4 : Number of directories
  665. * 5 : Number of files
  666. * 6 : Directory bucket count
  667. * 7 : File bucket count
  668. * 8 : u8 Duplicate data
  669. * Outputs:
  670. * 1 : Result of function, 0 on success, otherwise error code
  671. */
  672. static void CreateLegacySystemSaveData(Service::Interface* self) {
  673. u32* cmd_buff = Kernel::GetCommandBuffer();
  674. u32 savedata_id = cmd_buff[1];
  675. LOG_WARNING(
  676. Service_FS,
  677. "(STUBBED) savedata_id=%08X cmd_buff[3]=%08X "
  678. "cmd_buff[4]=%08X cmd_buff[5]=%08X cmd_buff[6]=%08X cmd_buff[7]=%08X cmd_buff[8]=%08X "
  679. "cmd_buff[9]=%08X",
  680. savedata_id, cmd_buff[3], cmd_buff[4], cmd_buff[5], cmd_buff[6], cmd_buff[7], cmd_buff[8],
  681. cmd_buff[9]);
  682. cmd_buff[0] = IPC::MakeHeader(0x810, 0x1, 0);
  683. // With this command, the SystemSaveData always has save_high = 0 (Always created in the NAND)
  684. cmd_buff[1] = CreateSystemSaveData(0, savedata_id).raw;
  685. }
  686. /**
  687. * FS_User::InitializeWithSdkVersion service function.
  688. * Inputs:
  689. * 0 : 0x08610042
  690. * 1 : Used SDK Version
  691. * 2 : ProcessId Header
  692. * 3 : placeholder for ProcessId
  693. * Outputs:
  694. * 1 : Result of function, 0 on success, otherwise error code
  695. */
  696. static void InitializeWithSdkVersion(Service::Interface* self) {
  697. u32* cmd_buff = Kernel::GetCommandBuffer();
  698. const u32 version = cmd_buff[1];
  699. self->SetVersion(version);
  700. if (cmd_buff[2] == IPC::CallingPidDesc()) {
  701. LOG_WARNING(Service_FS, "(STUBBED) called, version: 0x%08X", version);
  702. cmd_buff[1] = RESULT_SUCCESS.raw;
  703. } else {
  704. LOG_ERROR(Service_FS, "ProcessId Header must be 0x20");
  705. cmd_buff[1] = IPC::ERR_INVALID_BUFFER_DESCRIPTOR.raw;
  706. }
  707. }
  708. /**
  709. * FS_User::SetPriority service function.
  710. * Inputs:
  711. * 0 : 0x08620040
  712. * 1 : priority
  713. * Outputs:
  714. * 1 : Result of function, 0 on success, otherwise error code
  715. */
  716. static void SetPriority(Service::Interface* self) {
  717. u32* cmd_buff = Kernel::GetCommandBuffer();
  718. priority = cmd_buff[1];
  719. cmd_buff[1] = RESULT_SUCCESS.raw;
  720. LOG_DEBUG(Service_FS, "called priority=0x%X", priority);
  721. }
  722. /**
  723. * FS_User::GetPriority service function.
  724. * Inputs:
  725. * 0 : 0x08630000
  726. * Outputs:
  727. * 1 : Result of function, 0 on success, otherwise error code
  728. * 2 : priority
  729. */
  730. static void GetPriority(Service::Interface* self) {
  731. u32* cmd_buff = Kernel::GetCommandBuffer();
  732. if (priority == -1) {
  733. LOG_INFO(Service_FS, "priority was not set, priority=0x%X", priority);
  734. }
  735. cmd_buff[1] = RESULT_SUCCESS.raw;
  736. cmd_buff[2] = priority;
  737. LOG_DEBUG(Service_FS, "called priority=0x%X", priority);
  738. }
  739. /**
  740. * FS_User::GetArchiveResource service function.
  741. * Inputs:
  742. * 0 : 0x08490040
  743. * 1 : Media type
  744. * Outputs:
  745. * 1 : Result of function, 0 on success, otherwise error code
  746. * 2 : Sector byte-size
  747. * 3 : Cluster byte-size
  748. * 4 : Partition capacity in clusters
  749. * 5 : Available free space in clusters
  750. */
  751. static void GetArchiveResource(Service::Interface* self) {
  752. u32* cmd_buff = Kernel::GetCommandBuffer();
  753. LOG_WARNING(Service_FS, "(STUBBED) called Media type=0x%08X", cmd_buff[1]);
  754. cmd_buff[1] = RESULT_SUCCESS.raw;
  755. cmd_buff[2] = 512;
  756. cmd_buff[3] = 16384;
  757. cmd_buff[4] = 0x80000; // 8GiB capacity
  758. cmd_buff[5] = 0x80000; // 8GiB free
  759. }
  760. /**
  761. * FS_User::GetFormatInfo service function.
  762. * Inputs:
  763. * 0 : 0x084500C2
  764. * 1 : Archive ID
  765. * 2 : Archive path type
  766. * 3 : Archive path size
  767. * 4 : (PathSize << 14) | 2
  768. * 5 : Archive low path
  769. * Outputs:
  770. * 0 : 0x08450140
  771. * 1 : Result of function, 0 on success, otherwise error code
  772. * 2 : Total size
  773. * 3 : Number of directories
  774. * 4 : Number of files
  775. * 5 : Duplicate data
  776. */
  777. static void GetFormatInfo(Service::Interface* self) {
  778. u32* cmd_buff = Kernel::GetCommandBuffer();
  779. auto archive_id = static_cast<FS::ArchiveIdCode>(cmd_buff[1]);
  780. auto archivename_type = static_cast<FileSys::LowPathType>(cmd_buff[2]);
  781. u32 archivename_size = cmd_buff[3];
  782. u32 archivename_ptr = cmd_buff[5];
  783. FileSys::Path archive_path(archivename_type, archivename_size, archivename_ptr);
  784. LOG_DEBUG(Service_FS, "archive_path=%s", archive_path.DebugStr().c_str());
  785. cmd_buff[0] = IPC::MakeHeader(0x0845, 5, 0);
  786. auto format_info = GetArchiveFormatInfo(archive_id, archive_path);
  787. if (format_info.Failed()) {
  788. LOG_ERROR(Service_FS, "Failed to retrieve the format info");
  789. cmd_buff[1] = format_info.Code().raw;
  790. return;
  791. }
  792. cmd_buff[1] = RESULT_SUCCESS.raw;
  793. cmd_buff[2] = format_info->total_size;
  794. cmd_buff[3] = format_info->number_directories;
  795. cmd_buff[4] = format_info->number_files;
  796. cmd_buff[5] = format_info->duplicate_data;
  797. }
  798. const Interface::FunctionInfo FunctionTable[] = {
  799. {0x000100C6, nullptr, "Dummy1"},
  800. {0x040100C4, nullptr, "Control"},
  801. {0x08010002, Initialize, "Initialize"},
  802. {0x080201C2, OpenFile, "OpenFile"},
  803. {0x08030204, OpenFileDirectly, "OpenFileDirectly"},
  804. {0x08040142, DeleteFile, "DeleteFile"},
  805. {0x08050244, RenameFile, "RenameFile"},
  806. {0x08060142, DeleteDirectory, "DeleteDirectory"},
  807. {0x08070142, DeleteDirectoryRecursively, "DeleteDirectoryRecursively"},
  808. {0x08080202, CreateFile, "CreateFile"},
  809. {0x08090182, CreateDirectory, "CreateDirectory"},
  810. {0x080A0244, RenameDirectory, "RenameDirectory"},
  811. {0x080B0102, OpenDirectory, "OpenDirectory"},
  812. {0x080C00C2, OpenArchive, "OpenArchive"},
  813. {0x080D0144, nullptr, "ControlArchive"},
  814. {0x080E0080, CloseArchive, "CloseArchive"},
  815. {0x080F0180, FormatThisUserSaveData, "FormatThisUserSaveData"},
  816. {0x08100200, CreateLegacySystemSaveData, "CreateLegacySystemSaveData"},
  817. {0x08110040, nullptr, "DeleteSystemSaveData"},
  818. {0x08120080, GetFreeBytes, "GetFreeBytes"},
  819. {0x08130000, nullptr, "GetCardType"},
  820. {0x08140000, nullptr, "GetSdmcArchiveResource"},
  821. {0x08150000, nullptr, "GetNandArchiveResource"},
  822. {0x08160000, nullptr, "GetSdmcFatfsError"},
  823. {0x08170000, IsSdmcDetected, "IsSdmcDetected"},
  824. {0x08180000, IsSdmcWriteable, "IsSdmcWritable"},
  825. {0x08190042, nullptr, "GetSdmcCid"},
  826. {0x081A0042, nullptr, "GetNandCid"},
  827. {0x081B0000, nullptr, "GetSdmcSpeedInfo"},
  828. {0x081C0000, nullptr, "GetNandSpeedInfo"},
  829. {0x081D0042, nullptr, "GetSdmcLog"},
  830. {0x081E0042, nullptr, "GetNandLog"},
  831. {0x081F0000, nullptr, "ClearSdmcLog"},
  832. {0x08200000, nullptr, "ClearNandLog"},
  833. {0x08210000, CardSlotIsInserted, "CardSlotIsInserted"},
  834. {0x08220000, nullptr, "CardSlotPowerOn"},
  835. {0x08230000, nullptr, "CardSlotPowerOff"},
  836. {0x08240000, nullptr, "CardSlotGetCardIFPowerStatus"},
  837. {0x08250040, nullptr, "CardNorDirectCommand"},
  838. {0x08260080, nullptr, "CardNorDirectCommandWithAddress"},
  839. {0x08270082, nullptr, "CardNorDirectRead"},
  840. {0x082800C2, nullptr, "CardNorDirectReadWithAddress"},
  841. {0x08290082, nullptr, "CardNorDirectWrite"},
  842. {0x082A00C2, nullptr, "CardNorDirectWriteWithAddress"},
  843. {0x082B00C2, nullptr, "CardNorDirectRead_4xIO"},
  844. {0x082C0082, nullptr, "CardNorDirectCpuWriteWithoutVerify"},
  845. {0x082D0040, nullptr, "CardNorDirectSectorEraseWithoutVerify"},
  846. {0x082E0040, nullptr, "GetProductInfo"},
  847. {0x082F0040, nullptr, "GetProgramLaunchInfo"},
  848. {0x08300182, nullptr, "CreateExtSaveData"},
  849. {0x08310180, nullptr, "CreateSharedExtSaveData"},
  850. {0x08320102, nullptr, "ReadExtSaveDataIcon"},
  851. {0x08330082, nullptr, "EnumerateExtSaveData"},
  852. {0x08340082, nullptr, "EnumerateSharedExtSaveData"},
  853. {0x08350080, nullptr, "DeleteExtSaveData"},
  854. {0x08360080, nullptr, "DeleteSharedExtSaveData"},
  855. {0x08370040, nullptr, "SetCardSpiBaudRate"},
  856. {0x08380040, nullptr, "SetCardSpiBusMode"},
  857. {0x08390000, nullptr, "SendInitializeInfoTo9"},
  858. {0x083A0100, nullptr, "GetSpecialContentIndex"},
  859. {0x083B00C2, nullptr, "GetLegacyRomHeader"},
  860. {0x083C00C2, nullptr, "GetLegacyBannerData"},
  861. {0x083D0100, nullptr, "CheckAuthorityToAccessExtSaveData"},
  862. {0x083E00C2, nullptr, "QueryTotalQuotaSize"},
  863. {0x083F00C0, nullptr, "GetExtDataBlockSize"},
  864. {0x08400040, nullptr, "AbnegateAccessRight"},
  865. {0x08410000, nullptr, "DeleteSdmcRoot"},
  866. {0x08420040, nullptr, "DeleteAllExtSaveDataOnNand"},
  867. {0x08430000, nullptr, "InitializeCtrFileSystem"},
  868. {0x08440000, nullptr, "CreateSeed"},
  869. {0x084500C2, GetFormatInfo, "GetFormatInfo"},
  870. {0x08460102, nullptr, "GetLegacyRomHeader2"},
  871. {0x08470180, nullptr, "FormatCtrCardUserSaveData"},
  872. {0x08480042, nullptr, "GetSdmcCtrRootPath"},
  873. {0x08490040, GetArchiveResource, "GetArchiveResource"},
  874. {0x084A0002, nullptr, "ExportIntegrityVerificationSeed"},
  875. {0x084B0002, nullptr, "ImportIntegrityVerificationSeed"},
  876. {0x084C0242, FormatSaveData, "FormatSaveData"},
  877. {0x084D0102, nullptr, "GetLegacySubBannerData"},
  878. {0x084E0342, nullptr, "UpdateSha256Context"},
  879. {0x084F0102, nullptr, "ReadSpecialFile"},
  880. {0x08500040, nullptr, "GetSpecialFileSize"},
  881. {0x08510242, CreateExtSaveData, "CreateExtSaveData"},
  882. {0x08520100, DeleteExtSaveData, "DeleteExtSaveData"},
  883. {0x08530142, nullptr, "ReadExtSaveDataIcon"},
  884. {0x085400C0, nullptr, "GetExtDataBlockSize"},
  885. {0x08550102, nullptr, "EnumerateExtSaveData"},
  886. {0x08560240, CreateSystemSaveData, "CreateSystemSaveData"},
  887. {0x08570080, DeleteSystemSaveData, "DeleteSystemSaveData"},
  888. {0x08580000, nullptr, "StartDeviceMoveAsSource"},
  889. {0x08590200, nullptr, "StartDeviceMoveAsDestination"},
  890. {0x085A00C0, nullptr, "SetArchivePriority"},
  891. {0x085B0080, nullptr, "GetArchivePriority"},
  892. {0x085C00C0, nullptr, "SetCtrCardLatencyParameter"},
  893. {0x085D01C0, nullptr, "SetFsCompatibilityInfo"},
  894. {0x085E0040, nullptr, "ResetCardCompatibilityParameter"},
  895. {0x085F0040, nullptr, "SwitchCleanupInvalidSaveData"},
  896. {0x08600042, nullptr, "EnumerateSystemSaveData"},
  897. {0x08610042, InitializeWithSdkVersion, "InitializeWithSdkVersion"},
  898. {0x08620040, SetPriority, "SetPriority"},
  899. {0x08630000, GetPriority, "GetPriority"},
  900. {0x08640000, nullptr, "GetNandInfo"},
  901. {0x08650140, nullptr, "SetSaveDataSecureValue"},
  902. {0x086600C0, nullptr, "GetSaveDataSecureValue"},
  903. {0x086700C4, nullptr, "ControlSecureSave"},
  904. {0x08680000, nullptr, "GetMediaType"},
  905. {0x08690000, nullptr, "GetNandEraseCount"},
  906. {0x086A0082, nullptr, "ReadNandReport"},
  907. {0x087A0180, nullptr, "AddSeed"},
  908. {0x088600C0, nullptr, "CheckUpdatedDat"},
  909. };
  910. ////////////////////////////////////////////////////////////////////////////////////////////////////
  911. // Interface class
  912. Interface::Interface() {
  913. priority = -1;
  914. Register(FunctionTable);
  915. }
  916. } // namespace FS
  917. } // namespace Service