mem_map.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. // Copyright 2014 Citra Emulator Project
  2. // Licensed under GPLv2
  3. // Refer to the license.txt file included.
  4. #pragma once
  5. ////////////////////////////////////////////////////////////////////////////////////////////////////
  6. #include "common/common.h"
  7. #include "common/common_types.h"
  8. ////////////////////////////////////////////////////////////////////////////////////////////////////
  9. enum {
  10. MEM_BOOTROM_SIZE = 0x00010000, ///< Bootrom (super secret code/data @ 0x8000) size
  11. MEM_MPCORE_PRIV_SIZE = 0x00002000, ///< MPCore private memory region size
  12. MEM_VRAM_SIZE = 0x00600000, ///< VRAM size
  13. MEM_DSP_SIZE = 0x00080000, ///< DSP memory size
  14. MEM_AXI_WRAM_SIZE = 0x00080000, ///< AXI WRAM size
  15. MEM_FCRAM_SIZE = 0x08000000, ///< FCRAM size
  16. MEM_SCRATCHPAD_SIZE = 0x00004000, ///< Typical stack size - TODO: Read from exheader
  17. MEM_VRAM_MASK = 0x007FFFFF,
  18. MEM_FCRAM_MASK = (MEM_FCRAM_SIZE - 1), ///< FCRAM mask
  19. MEM_SCRATCHPAD_MASK = (MEM_SCRATCHPAD_SIZE - 1), ///< Scratchpad memory mask
  20. MEM_FCRAM_PADDR = 0x20000000, ///< FCRAM physical address
  21. MEM_FCRAM_PADDR_END = (MEM_FCRAM_PADDR + MEM_FCRAM_SIZE), ///< FCRAM end of physical space
  22. MEM_FCRAM_VADDR = 0x08000000, ///< FCRAM virtual address
  23. MEM_FCRAM_VADDR_END = (MEM_FCRAM_VADDR + MEM_FCRAM_SIZE), ///< FCRAM end of virtual space
  24. MEM_VRAM_VADDR = 0x1F000000,
  25. MEM_SCRATCHPAD_VADDR = (0x10000000 - MEM_SCRATCHPAD_SIZE), ///< Scratchpad virtual address
  26. };
  27. ////////////////////////////////////////////////////////////////////////////////////////////////////
  28. namespace Memory {
  29. // Base is a pointer to the base of the memory map. Yes, some MMU tricks
  30. // are used to set up a full GC or Wii memory map in process memory. on
  31. // 32-bit, you have to mask your offsets with 0x3FFFFFFF. This means that
  32. // some things are mirrored too many times, but eh... it works.
  33. // In 64-bit, this might point to "high memory" (above the 32-bit limit),
  34. // so be sure to load it into a 64-bit register.
  35. extern u8 *g_base;
  36. // These are guaranteed to point to "low memory" addresses (sub-32-bit).
  37. // 64-bit: Pointers to low-mem (sub-0x10000000) mirror
  38. // 32-bit: Same as the corresponding physical/virtual pointers.
  39. extern u8* g_fcram; ///< Main memory
  40. extern u8* g_vram; ///< Video memory (VRAM)
  41. void Init();
  42. void Shutdown();
  43. u8 Read8(const u32 addr);
  44. u16 Read16(const u32 addr);
  45. u32 Read32(const u32 addr);
  46. u32 Read8_ZX(const u32 addr);
  47. u32 Read16_ZX(const u32 addr);
  48. void Write8(const u32 addr, const u8 data);
  49. void Write16(const u32 addr, const u16 data);
  50. void Write32(const u32 addr, const u32 data);
  51. u8* GetPointer(const u32 Address);
  52. inline const char* GetCharPointer(const u32 address) {
  53. return (const char *)GetPointer(address);
  54. }
  55. } // namespace