ldr_ro.cpp 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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/logging/log.h"
  5. #include "core/hle/hle.h"
  6. #include "core/hle/service/ldr_ro.h"
  7. ////////////////////////////////////////////////////////////////////////////////////////////////////
  8. // Namespace LDR_RO
  9. namespace LDR_RO {
  10. /**
  11. * LDR_RO::Initialize service function
  12. * Inputs:
  13. * 1 : CRS buffer pointer
  14. * 2 : CRS Size
  15. * 3 : Process memory address where the CRS will be mapped
  16. * 4 : Value, must be zero
  17. * 5 : KProcess handle
  18. * Outputs:
  19. * 0 : Return header
  20. * 1 : Result of function, 0 on success, otherwise error code
  21. */
  22. static void Initialize(Service::Interface* self) {
  23. u32* cmd_buff = Kernel::GetCommandBuffer();
  24. u32 crs_buffer_ptr = cmd_buff[1];
  25. u32 crs_size = cmd_buff[2];
  26. u32 address = cmd_buff[3];
  27. u32 value = cmd_buff[4];
  28. u32 process = cmd_buff[5];
  29. if (value != 0) {
  30. LOG_ERROR(Service_LDR, "This value should be zero, but is actually %u!", value);
  31. }
  32. // TODO(purpasmart96): Verify return header on HW
  33. cmd_buff[1] = RESULT_SUCCESS.raw; // No error
  34. LOG_WARNING(Service_LDR, "(STUBBED) called");
  35. }
  36. /**
  37. * LDR_RO::LoadCRR service function
  38. * Inputs:
  39. * 1 : CRS buffer pointer
  40. * 2 : CRS Size
  41. * 3 : Value, must be zero
  42. * 4 : KProcess handle
  43. * Outputs:
  44. * 0 : Return header
  45. * 1 : Result of function, 0 on success, otherwise error code
  46. */
  47. static void LoadCRR(Service::Interface* self) {
  48. u32* cmd_buff = Kernel::GetCommandBuffer();
  49. u32 crs_buffer_ptr = cmd_buff[1];
  50. u32 crs_size = cmd_buff[2];
  51. u32 value = cmd_buff[3];
  52. u32 process = cmd_buff[4];
  53. if (value != 0) {
  54. LOG_ERROR(Service_LDR, "This value should be zero, but is actually %u!", value);
  55. }
  56. // TODO(purpasmart96): Verify return header on HW
  57. cmd_buff[1] = RESULT_SUCCESS.raw; // No error
  58. LOG_WARNING(Service_LDR, "(STUBBED) called");
  59. }
  60. const Interface::FunctionInfo FunctionTable[] = {
  61. {0x000100C2, Initialize, "Initialize"},
  62. {0x00020082, LoadCRR, "LoadCRR"},
  63. {0x00030042, nullptr, "UnloadCCR"},
  64. {0x000402C2, nullptr, "LoadExeCRO"},
  65. {0x000500C2, nullptr, "LoadCROSymbols"},
  66. {0x00060042, nullptr, "CRO_Load?"},
  67. {0x00070042, nullptr, "LoadCROSymbols"},
  68. {0x00080042, nullptr, "Shutdown"},
  69. {0x000902C2, nullptr, "LoadExeCRO_New?"},
  70. };
  71. ////////////////////////////////////////////////////////////////////////////////////////////////////
  72. // Interface class
  73. Interface::Interface() {
  74. Register(FunctionTable);
  75. }
  76. } // namespace