cfg_s.cpp 3.3 KB

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