2014-12-17 11:08:14 +05:30
|
|
|
// Copyright 2014 Citra Emulator Project
|
|
|
|
// Licensed under GPLv2 or any later version
|
2014-04-09 04:45:46 +05:30
|
|
|
// Refer to the license.txt file included.
|
2013-09-06 04:03:46 +05:30
|
|
|
|
2015-05-06 12:36:12 +05:30
|
|
|
#include "common/common_types.h"
|
|
|
|
#include "common/logging/log.h"
|
2013-09-06 08:34:04 +05:30
|
|
|
|
2014-04-09 05:45:08 +05:30
|
|
|
#include "core/mem_map.h"
|
2013-09-06 08:34:04 +05:30
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
2013-09-06 04:03:46 +05:30
|
|
|
|
|
|
|
namespace Memory {
|
|
|
|
|
2015-05-08 03:31:09 +05:30
|
|
|
u8* g_exefs_code; ///< ExeFS:/.code is loaded here
|
|
|
|
u8* g_heap; ///< Application heap (main memory)
|
|
|
|
u8* g_heap_linear; ///< Linear heap
|
|
|
|
u8* g_vram; ///< Video memory (VRAM) pointer
|
|
|
|
u8* g_shared_mem; ///< Shared memory
|
|
|
|
u8* g_dsp_mem; ///< DSP memory
|
2015-05-09 09:09:56 +05:30
|
|
|
u8* g_tls_mem; ///< TLS memory
|
2015-04-28 07:29:06 +05:30
|
|
|
|
2015-05-08 03:31:09 +05:30
|
|
|
namespace {
|
2015-04-28 07:29:06 +05:30
|
|
|
|
2015-05-08 03:31:09 +05:30
|
|
|
struct MemoryArea {
|
|
|
|
u8** ptr;
|
|
|
|
size_t size;
|
2013-09-06 08:34:04 +05:30
|
|
|
};
|
|
|
|
|
2015-05-08 03:31:09 +05:30
|
|
|
// We don't declare the IO regions in here since its handled by other means.
|
|
|
|
static MemoryArea memory_areas[] = {
|
2015-05-09 09:09:56 +05:30
|
|
|
{&g_exefs_code, PROCESS_IMAGE_MAX_SIZE},
|
|
|
|
{&g_vram, VRAM_SIZE },
|
|
|
|
{&g_heap, HEAP_SIZE },
|
|
|
|
{&g_shared_mem, SHARED_MEMORY_SIZE },
|
|
|
|
{&g_dsp_mem, DSP_RAM_SIZE },
|
|
|
|
{&g_tls_mem, TLS_AREA_SIZE },
|
|
|
|
{&g_heap_linear, LINEAR_HEAP_SIZE },
|
2015-05-08 03:31:09 +05:30
|
|
|
};
|
2013-09-19 08:06:39 +05:30
|
|
|
|
2015-05-08 03:31:09 +05:30
|
|
|
}
|
2013-09-06 08:34:04 +05:30
|
|
|
|
|
|
|
void Init() {
|
2015-05-08 03:31:09 +05:30
|
|
|
for (MemoryArea& area : memory_areas) {
|
|
|
|
*area.ptr = new u8[area.size];
|
2014-04-02 03:48:02 +05:30
|
|
|
}
|
2015-04-28 07:29:06 +05:30
|
|
|
MemBlock_Init();
|
2014-03-30 07:23:41 +05:30
|
|
|
|
2015-05-08 03:31:09 +05:30
|
|
|
LOG_DEBUG(HW_Memory, "initialized OK, RAM at %p", g_heap);
|
2013-09-06 08:34:04 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
void Shutdown() {
|
2015-04-28 07:29:06 +05:30
|
|
|
MemBlock_Shutdown();
|
2015-05-08 03:31:09 +05:30
|
|
|
for (MemoryArea& area : memory_areas) {
|
|
|
|
delete[] *area.ptr;
|
|
|
|
*area.ptr = nullptr;
|
|
|
|
}
|
2014-04-02 03:48:02 +05:30
|
|
|
|
2014-12-06 07:23:49 +05:30
|
|
|
LOG_DEBUG(HW_Memory, "shutdown OK");
|
2013-09-06 08:34:04 +05:30
|
|
|
}
|
|
|
|
|
2013-09-06 04:03:46 +05:30
|
|
|
} // namespace
|