cfg_s.cpp 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. // Copyright 2015 Citra Emulator Project
  2. // Licensed under GPLv2 or any later version
  3. // Refer to the license.txt file included.
  4. #include "core/hle/hle.h"
  5. #include "core/hle/service/cfg/cfg.h"
  6. #include "core/hle/service/cfg/cfg_s.h"
  7. ////////////////////////////////////////////////////////////////////////////////////////////////////
  8. // Namespace CFG_S
  9. namespace CFG_S {
  10. /**
  11. * CFG_S::GetConfigInfoBlk2 service function
  12. * Inputs:
  13. * 0 : 0x00010082
  14. * 1 : Size
  15. * 2 : Block ID
  16. * 3 : Descriptor for the output buffer
  17. * 4 : Output buffer pointer
  18. * Outputs:
  19. * 1 : Result of function, 0 on success, otherwise error code
  20. */
  21. static void GetConfigInfoBlk2(Service::Interface* self) {
  22. u32* cmd_buffer = Kernel::GetCommandBuffer();
  23. u32 size = cmd_buffer[1];
  24. u32 block_id = cmd_buffer[2];
  25. u8* data_pointer = Memory::GetPointer(cmd_buffer[4]);
  26. if (data_pointer == nullptr) {
  27. cmd_buffer[1] = -1; // TODO(Subv): Find the right error code
  28. return;
  29. }
  30. cmd_buffer[1] = Service::CFG::GetConfigInfoBlock(block_id, size, 0x2, data_pointer).raw;
  31. }
  32. /**
  33. * CFG_S::GetConfigInfoBlk8 service function
  34. * Inputs:
  35. * 0 : 0x04010082
  36. * 1 : Size
  37. * 2 : Block ID
  38. * 3 : Descriptor for the output buffer
  39. * 4 : Output buffer pointer
  40. * Outputs:
  41. * 1 : Result of function, 0 on success, otherwise error code
  42. */
  43. static void GetConfigInfoBlk8(Service::Interface* self) {
  44. u32* cmd_buffer = Kernel::GetCommandBuffer();
  45. u32 size = cmd_buffer[1];
  46. u32 block_id = cmd_buffer[2];
  47. u8* data_pointer = Memory::GetPointer(cmd_buffer[4]);
  48. if (data_pointer == nullptr) {
  49. cmd_buffer[1] = -1; // TODO(Subv): Find the right error code
  50. return;
  51. }
  52. cmd_buffer[1] = Service::CFG::GetConfigInfoBlock(block_id, size, 0x8, data_pointer).raw;
  53. }
  54. /**
  55. * CFG_S::UpdateConfigNANDSavegame service function
  56. * Inputs:
  57. * 0 : 0x04030000
  58. * Outputs:
  59. * 1 : Result of function, 0 on success, otherwise error code
  60. */
  61. static void UpdateConfigNANDSavegame(Service::Interface* self) {
  62. u32* cmd_buffer = Kernel::GetCommandBuffer();
  63. cmd_buffer[1] = Service::CFG::UpdateConfigNANDSavegame().raw;
  64. }
  65. const Interface::FunctionInfo FunctionTable[] = {
  66. {0x00010082, GetConfigInfoBlk2, "GetConfigInfoBlk2"},
  67. {0x00020000, nullptr, "SecureInfoGetRegion"},
  68. {0x04010082, GetConfigInfoBlk8, "GetConfigInfoBlk8"},
  69. {0x04020082, nullptr, "SetConfigInfoBlk4"},
  70. {0x04030000, UpdateConfigNANDSavegame, "UpdateConfigNANDSavegame"},
  71. {0x04040042, nullptr, "GetLocalFriendCodeSeedData"},
  72. {0x04050000, nullptr, "GetLocalFriendCodeSeed"},
  73. {0x04060000, nullptr, "SecureInfoGetRegion"},
  74. {0x04070000, nullptr, "SecureInfoGetByte101"},
  75. {0x04080042, nullptr, "SecureInfoGetSerialNo"},
  76. {0x04090000, nullptr, "UpdateConfigBlk00040003"},
  77. };
  78. ////////////////////////////////////////////////////////////////////////////////////////////////////
  79. // Interface class
  80. Interface::Interface() {
  81. Register(FunctionTable);
  82. }
  83. } // namespace