diff options
| author | 2015-02-18 00:12:37 -0500 | |
|---|---|---|
| committer | 2015-02-18 00:12:37 -0500 | |
| commit | 745b42d236873522ee854aa7422f8330eaa86c0e (patch) | |
| tree | cd7be21255658b42e295b6df365c1a74cf70a3aa /src | |
| parent | Merge pull request #582 from lioncash/warnings (diff) | |
| parent | ConfigMem: Clean up the Config memory to be more like the shared page and moved (diff) | |
| download | yuzu-745b42d236873522ee854aa7422f8330eaa86c0e.tar.gz yuzu-745b42d236873522ee854aa7422f8330eaa86c0e.tar.xz yuzu-745b42d236873522ee854aa7422f8330eaa86c0e.zip | |
Merge pull request #570 from purpasmart96/config_mem
ConfigMem: Clean up the Config memory to be more like the shared page
Diffstat (limited to 'src')
| -rw-r--r-- | src/common/common_funcs.h | 7 | ||||
| -rw-r--r-- | src/core/hle/config_mem.cpp | 96 | ||||
| -rw-r--r-- | src/core/hle/config_mem.h | 2 | ||||
| -rw-r--r-- | src/core/hle/hle.cpp | 2 | ||||
| -rw-r--r-- | src/core/hle/shared_page.cpp | 8 |
5 files changed, 65 insertions, 50 deletions
diff --git a/src/common/common_funcs.h b/src/common/common_funcs.h index 44d8ae11f..4bbcc3571 100644 --- a/src/common/common_funcs.h +++ b/src/common/common_funcs.h | |||
| @@ -35,6 +35,13 @@ template<> struct CompileTimeAssert<true> {}; | |||
| 35 | #define CONCAT2(x, y) DO_CONCAT2(x, y) | 35 | #define CONCAT2(x, y) DO_CONCAT2(x, y) |
| 36 | #define DO_CONCAT2(x, y) x ## y | 36 | #define DO_CONCAT2(x, y) x ## y |
| 37 | 37 | ||
| 38 | // helper macro to properly align structure members. | ||
| 39 | // Calling INSERT_PADDING_BYTES will add a new member variable with a name like "pad121", | ||
| 40 | // depending on the current source line to make sure variable names are unique. | ||
| 41 | #define INSERT_PADDING_BYTES_HELPER1(x, y) x ## y | ||
| 42 | #define INSERT_PADDING_BYTES_HELPER2(x, y) INSERT_PADDING_BYTES_HELPER1(x, y) | ||
| 43 | #define INSERT_PADDING_BYTES(num_words) u8 INSERT_PADDING_BYTES_HELPER2(pad, __LINE__)[(num_words)] | ||
| 44 | |||
| 38 | #ifndef _MSC_VER | 45 | #ifndef _MSC_VER |
| 39 | 46 | ||
| 40 | #include <errno.h> | 47 | #include <errno.h> |
diff --git a/src/core/hle/config_mem.cpp b/src/core/hle/config_mem.cpp index 68d3071f5..b10c19d1d 100644 --- a/src/core/hle/config_mem.cpp +++ b/src/core/hle/config_mem.cpp | |||
| @@ -3,60 +3,54 @@ | |||
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include "common/common_types.h" | 5 | #include "common/common_types.h" |
| 6 | #include "common/logging/log.h" | 6 | #include "common/common_funcs.h" |
| 7 | 7 | ||
| 8 | #include "core/core.h" | ||
| 9 | #include "core/mem_map.h" | ||
| 8 | #include "core/hle/config_mem.h" | 10 | #include "core/hle/config_mem.h" |
| 9 | 11 | ||
| 10 | //////////////////////////////////////////////////////////////////////////////////////////////////// | 12 | //////////////////////////////////////////////////////////////////////////////////////////////////// |
| 11 | 13 | ||
| 12 | namespace ConfigMem { | 14 | namespace ConfigMem { |
| 13 | 15 | ||
| 14 | enum { | 16 | struct ConfigMemDef { |
| 15 | KERNEL_VERSIONREVISION = 0x1FF80001, | 17 | u8 kernel_unk; // 0 |
| 16 | KERNEL_VERSIONMINOR = 0x1FF80002, | 18 | u8 kernel_version_rev; // 1 |
| 17 | KERNEL_VERSIONMAJOR = 0x1FF80003, | 19 | u8 kernel_version_min; // 2 |
| 18 | UPDATEFLAG = 0x1FF80004, | 20 | u8 kernel_version_maj; // 3 |
| 19 | NSTID = 0x1FF80008, | 21 | u32 update_flag; // 4 |
| 20 | SYSCOREVER = 0x1FF80010, | 22 | u64 ns_tid; // 8 |
| 21 | UNITINFO = 0x1FF80014, | 23 | u32 sys_core_ver; // 10 |
| 22 | KERNEL_CTRSDKVERSION = 0x1FF80018, | 24 | u8 unit_info; // 14 |
| 23 | APPMEMTYPE = 0x1FF80030, | 25 | u8 boot_firm; // 15 |
| 24 | APPMEMALLOC = 0x1FF80040, | 26 | u8 prev_firm; // 16 |
| 25 | FIRM_VERSIONREVISION = 0x1FF80061, | 27 | INSERT_PADDING_BYTES(0x1); // 17 |
| 26 | FIRM_VERSIONMINOR = 0x1FF80062, | 28 | u32 ctr_sdk_ver; // 18 |
| 27 | FIRM_VERSIONMAJOR = 0x1FF80063, | 29 | INSERT_PADDING_BYTES(0x30 - 0x1C); // 1C |
| 28 | FIRM_SYSCOREVER = 0x1FF80064, | 30 | u32 app_mem_type; // 30 |
| 29 | FIRM_CTRSDKVERSION = 0x1FF80068, | 31 | INSERT_PADDING_BYTES(0x40 - 0x34); // 34 |
| 32 | u32 app_mem_alloc; // 40 | ||
| 33 | u32 sys_mem_alloc; // 44 | ||
| 34 | u32 base_mem_alloc; // 48 | ||
| 35 | INSERT_PADDING_BYTES(0x60 - 0x4C); // 4C | ||
| 36 | u8 firm_unk; // 60 | ||
| 37 | u8 firm_version_rev; // 61 | ||
| 38 | u8 firm_version_min; // 62 | ||
| 39 | u8 firm_version_maj; // 63 | ||
| 40 | u32 firm_sys_core_ver; // 64 | ||
| 41 | u32 firm_ctr_sdk_ver; // 68 | ||
| 42 | INSERT_PADDING_BYTES(0x1000 - 0x6C); // 6C | ||
| 30 | }; | 43 | }; |
| 31 | 44 | ||
| 32 | template <typename T> | 45 | static_assert(sizeof(ConfigMemDef) == Memory::CONFIG_MEMORY_SIZE, "Config Memory structure size is wrong"); |
| 33 | inline void Read(T &var, const u32 addr) { | ||
| 34 | switch (addr) { | ||
| 35 | |||
| 36 | // Bit 0 set for Retail | ||
| 37 | case UNITINFO: | ||
| 38 | var = 0x00000001; | ||
| 39 | break; | ||
| 40 | |||
| 41 | // Set app memory size to 64MB? | ||
| 42 | case APPMEMALLOC: | ||
| 43 | var = 0x04000000; | ||
| 44 | break; | ||
| 45 | 46 | ||
| 46 | // Unknown - normally set to: 0x08000000 - (APPMEMALLOC + *0x1FF80048) | 47 | static ConfigMemDef config_mem; |
| 47 | // (Total FCRAM size - APPMEMALLOC - *0x1FF80048) | ||
| 48 | case 0x1FF80044: | ||
| 49 | var = 0x08000000 - (0x04000000 + 0x1400000); | ||
| 50 | break; | ||
| 51 | 48 | ||
| 52 | // Unknown - normally set to: 0x1400000 (20MB) | 49 | template <typename T> |
| 53 | case 0x1FF80048: | 50 | inline void Read(T &var, const u32 addr) { |
| 54 | var = 0x1400000; | 51 | u32 offset = addr - Memory::CONFIG_MEMORY_VADDR; |
| 55 | break; | 52 | ASSERT(offset < Memory::CONFIG_MEMORY_SIZE); |
| 56 | 53 | var = *(reinterpret_cast<T*>(((uintptr_t)&config_mem) + offset)); | |
| 57 | default: | ||
| 58 | LOG_ERROR(Kernel, "unknown addr=0x%08X", addr); | ||
| 59 | } | ||
| 60 | } | 54 | } |
| 61 | 55 | ||
| 62 | // Explicitly instantiate template functions because we aren't defining this in the header: | 56 | // Explicitly instantiate template functions because we aren't defining this in the header: |
| @@ -66,5 +60,21 @@ template void Read<u32>(u32 &var, const u32 addr); | |||
| 66 | template void Read<u16>(u16 &var, const u32 addr); | 60 | template void Read<u16>(u16 &var, const u32 addr); |
| 67 | template void Read<u8>(u8 &var, const u32 addr); | 61 | template void Read<u8>(u8 &var, const u32 addr); |
| 68 | 62 | ||
| 63 | void Init() { | ||
| 64 | config_mem.update_flag = 0; // No update | ||
| 65 | config_mem.sys_core_ver = 0x2; | ||
| 66 | config_mem.unit_info = 0x1; // Bit 0 set for Retail | ||
| 67 | config_mem.prev_firm = 0; | ||
| 68 | config_mem.app_mem_type = 0; // Defualt app mem type | ||
| 69 | config_mem.unit_info = 0x1; // Bit 0 set for Retail | ||
| 70 | config_mem.app_mem_alloc = 0x04000000; // Default app memory size is 64MB | ||
| 71 | config_mem.base_mem_alloc = 0x01400000; // Default base memory is 20MB | ||
| 72 | config_mem.sys_mem_alloc = Memory::FCRAM_SIZE - (config_mem.app_mem_alloc + config_mem.base_mem_alloc); | ||
| 73 | config_mem.firm_unk = 0; | ||
| 74 | config_mem.firm_version_rev = 0; | ||
| 75 | config_mem.firm_version_min = 0x40; | ||
| 76 | config_mem.firm_version_maj = 0x2; | ||
| 77 | config_mem.firm_sys_core_ver = 0x2; | ||
| 78 | } | ||
| 69 | 79 | ||
| 70 | } // namespace | 80 | } // namespace |
diff --git a/src/core/hle/config_mem.h b/src/core/hle/config_mem.h index 3975af18f..94853901a 100644 --- a/src/core/hle/config_mem.h +++ b/src/core/hle/config_mem.h | |||
| @@ -18,4 +18,6 @@ namespace ConfigMem { | |||
| 18 | template <typename T> | 18 | template <typename T> |
| 19 | void Read(T &var, const u32 addr); | 19 | void Read(T &var, const u32 addr); |
| 20 | 20 | ||
| 21 | void Init(); | ||
| 22 | |||
| 21 | } // namespace | 23 | } // namespace |
diff --git a/src/core/hle/hle.cpp b/src/core/hle/hle.cpp index 529133ca7..b0066e15e 100644 --- a/src/core/hle/hle.cpp +++ b/src/core/hle/hle.cpp | |||
| @@ -7,6 +7,7 @@ | |||
| 7 | #include "core/arm/arm_interface.h" | 7 | #include "core/arm/arm_interface.h" |
| 8 | #include "core/mem_map.h" | 8 | #include "core/mem_map.h" |
| 9 | #include "core/hle/hle.h" | 9 | #include "core/hle/hle.h" |
| 10 | #include "core/hle/config_mem.h" | ||
| 10 | #include "core/hle/shared_page.h" | 11 | #include "core/hle/shared_page.h" |
| 11 | #include "core/hle/kernel/thread.h" | 12 | #include "core/hle/kernel/thread.h" |
| 12 | #include "core/hle/service/service.h" | 13 | #include "core/hle/service/service.h" |
| @@ -75,6 +76,7 @@ void Init() { | |||
| 75 | 76 | ||
| 76 | RegisterAllModules(); | 77 | RegisterAllModules(); |
| 77 | 78 | ||
| 79 | ConfigMem::Init(); | ||
| 78 | SharedPage::Init(); | 80 | SharedPage::Init(); |
| 79 | 81 | ||
| 80 | LOG_DEBUG(Kernel, "initialized OK"); | 82 | LOG_DEBUG(Kernel, "initialized OK"); |
diff --git a/src/core/hle/shared_page.cpp b/src/core/hle/shared_page.cpp index f0726ef09..568dad684 100644 --- a/src/core/hle/shared_page.cpp +++ b/src/core/hle/shared_page.cpp | |||
| @@ -3,6 +3,7 @@ | |||
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include "common/common_types.h" | 5 | #include "common/common_types.h" |
| 6 | #include "common/common_funcs.h" | ||
| 6 | 7 | ||
| 7 | #include "core/core.h" | 8 | #include "core/core.h" |
| 8 | #include "core/mem_map.h" | 9 | #include "core/mem_map.h" |
| @@ -13,13 +14,6 @@ | |||
| 13 | 14 | ||
| 14 | namespace SharedPage { | 15 | namespace SharedPage { |
| 15 | 16 | ||
| 16 | // helper macro to properly align structure members. | ||
| 17 | // Calling INSERT_PADDING_BYTES will add a new member variable with a name like "pad121", | ||
| 18 | // depending on the current source line to make sure variable names are unique. | ||
| 19 | #define INSERT_PADDING_BYTES_HELPER1(x, y) x ## y | ||
| 20 | #define INSERT_PADDING_BYTES_HELPER2(x, y) INSERT_PADDING_BYTES_HELPER1(x, y) | ||
| 21 | #define INSERT_PADDING_BYTES(num_words) u8 INSERT_PADDING_BYTES_HELPER2(pad, __LINE__)[(num_words)] | ||
| 22 | |||
| 23 | // see http://3dbrew.org/wiki/Configuration_Memory#Shared_Memory_Page_For_ARM11_Processes | 17 | // see http://3dbrew.org/wiki/Configuration_Memory#Shared_Memory_Page_For_ARM11_Processes |
| 24 | 18 | ||
| 25 | #pragma pack(1) | 19 | #pragma pack(1) |