mrc.cpp 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. // Copyright 2014 Citra Emulator Project
  2. // Licensed under GPLv2
  3. // Refer to the license.txt file included.
  4. #include "core/hle/mrc.h"
  5. #include "core/hle/hle.h"
  6. #include "core/mem_map.h"
  7. #include "core/core.h"
  8. namespace HLE {
  9. enum {
  10. CMD_GX_REQUEST_DMA = 0x00000000,
  11. };
  12. /// Data synchronization barrier
  13. u32 DataSynchronizationBarrier(u32* command_buffer) {
  14. u32 command = command_buffer[0];
  15. switch (command) {
  16. case CMD_GX_REQUEST_DMA:
  17. {
  18. u32* src = (u32*)Memory::GetPointer(command_buffer[1]);
  19. u32* dst = (u32*)Memory::GetPointer(command_buffer[2]);
  20. u32 size = command_buffer[3];
  21. memcpy(dst, src, size);
  22. }
  23. break;
  24. default:
  25. ERROR_LOG(OSHLE, "MRC::DataSynchronizationBarrier unknown command 0x%08X", command);
  26. return -1;
  27. }
  28. return 0;
  29. }
  30. /// Returns the coprocessor (in this case, syscore) command buffer pointer
  31. Addr GetThreadCommandBuffer() {
  32. // Called on insruction: mrc p15, 0, r0, c13, c0, 3
  33. // Returns an address in OSHLE memory for the CPU to read/write to
  34. RETURN(CMD_BUFFER_ADDR);
  35. return CMD_BUFFER_ADDR;
  36. }
  37. /// Call an MRC operation in HLE
  38. u32 CallMRC(ARM11_MRC_OPERATION operation) {
  39. switch (operation) {
  40. case DATA_SYNCHRONIZATION_BARRIER:
  41. return DataSynchronizationBarrier((u32*)Memory::GetPointer(PARAM(0)));
  42. case CALL_GET_THREAD_COMMAND_BUFFER:
  43. return GetThreadCommandBuffer();
  44. default:
  45. ERROR_LOG(OSHLE, "unimplemented MRC operation 0x%02X", operation);
  46. break;
  47. }
  48. return -1;
  49. }
  50. } // namespace