mem_map.cpp 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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/common_types.h"
  5. #include "common/logging/log.h"
  6. #include "core/mem_map.h"
  7. ////////////////////////////////////////////////////////////////////////////////////////////////////
  8. namespace Memory {
  9. u8* g_exefs_code; ///< ExeFS:/.code is loaded here
  10. u8* g_heap; ///< Application heap (main memory)
  11. u8* g_heap_linear; ///< Linear heap
  12. u8* g_vram; ///< Video memory (VRAM) pointer
  13. u8* g_shared_mem; ///< Shared memory
  14. u8* g_dsp_mem; ///< DSP memory
  15. u8* g_tls_mem; ///< TLS memory
  16. namespace {
  17. struct MemoryArea {
  18. u8** ptr;
  19. size_t size;
  20. };
  21. // We don't declare the IO regions in here since its handled by other means.
  22. static MemoryArea memory_areas[] = {
  23. {&g_exefs_code, PROCESS_IMAGE_MAX_SIZE},
  24. {&g_vram, VRAM_SIZE },
  25. {&g_heap, HEAP_SIZE },
  26. {&g_shared_mem, SHARED_MEMORY_SIZE },
  27. {&g_dsp_mem, DSP_RAM_SIZE },
  28. {&g_tls_mem, TLS_AREA_SIZE },
  29. {&g_heap_linear, LINEAR_HEAP_SIZE },
  30. };
  31. }
  32. void Init() {
  33. for (MemoryArea& area : memory_areas) {
  34. *area.ptr = new u8[area.size];
  35. }
  36. MemBlock_Init();
  37. LOG_DEBUG(HW_Memory, "initialized OK, RAM at %p", g_heap);
  38. }
  39. void Shutdown() {
  40. MemBlock_Shutdown();
  41. for (MemoryArea& area : memory_areas) {
  42. delete[] *area.ptr;
  43. *area.ptr = nullptr;
  44. }
  45. LOG_DEBUG(HW_Memory, "shutdown OK");
  46. }
  47. } // namespace