hle.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. // Copyright 2014 Citra Emulator Project
  2. // Licensed under GPLv2
  3. // Refer to the license.txt file included.
  4. #pragma once
  5. #include "common/common_types.h"
  6. #include "core/core.h"
  7. ////////////////////////////////////////////////////////////////////////////////////////////////////
  8. #define PARAM(n) Core::g_app_core->GetReg(n)
  9. #define PARAM64(n) (Core::g_app_core->GetReg(n) | ((u64)Core::g_app_core->GetReg(n + 1) << 32))
  10. #define RETURN(n) Core::g_app_core->SetReg(0, n)
  11. ////////////////////////////////////////////////////////////////////////////////////////////////////
  12. namespace HLE {
  13. enum {
  14. CMD_BUFFER_ADDR = 0xA0010000, ///< Totally arbitrary unused address space
  15. CMD_BUFFER_SIZE = 0x10000,
  16. CMD_BUFFER_MASK = (CMD_BUFFER_SIZE - 1),
  17. CMD_BUFFER_ADDR_END = (CMD_BUFFER_ADDR + CMD_BUFFER_SIZE),
  18. };
  19. typedef u32 Addr;
  20. typedef void (*Func)();
  21. struct FunctionDef {
  22. u32 id;
  23. Func func;
  24. std::string name;
  25. };
  26. struct ModuleDef {
  27. std::string name;
  28. int num_funcs;
  29. const FunctionDef* func_table;
  30. };
  31. // Read from memory used by CTROS HLE functions
  32. template <typename T>
  33. inline void Read(T &var, const u32 addr);
  34. // Write to memory used by CTROS HLE functions
  35. template <typename T>
  36. inline void Write(u32 addr, const T data);
  37. u8* GetPointer(const u32 Address);
  38. inline const char* GetCharPointer(const u32 address) {
  39. return (const char *)GetPointer(address);
  40. }
  41. void RegisterModule(std::string name, int num_functions, const FunctionDef *func_table);
  42. void CallSyscall(u32 opcode);
  43. Addr CallGetThreadCommandBuffer();
  44. void Init();
  45. void Shutdown();
  46. } // namespace