diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | src/core/hle/hle.cpp | 3 | ||||
| -rw-r--r-- | src/core/hle/shared_page.cpp | 80 | ||||
| -rw-r--r-- | src/core/hle/shared_page.h | 26 | ||||
| -rw-r--r-- | src/core/mem_map_funcs.cpp | 5 |
5 files changed, 116 insertions, 0 deletions
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index b67226d8d..d248b454c 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt | |||
| @@ -69,6 +69,7 @@ set(SRCS | |||
| 69 | hle/service/y2r_u.cpp | 69 | hle/service/y2r_u.cpp |
| 70 | hle/config_mem.cpp | 70 | hle/config_mem.cpp |
| 71 | hle/hle.cpp | 71 | hle/hle.cpp |
| 72 | hle/shared_page.cpp | ||
| 72 | hle/svc.cpp | 73 | hle/svc.cpp |
| 73 | hw/gpu.cpp | 74 | hw/gpu.cpp |
| 74 | hw/hw.cpp | 75 | hw/hw.cpp |
| @@ -163,6 +164,7 @@ set(HEADERS | |||
| 163 | hle/result.h | 164 | hle/result.h |
| 164 | hle/function_wrappers.h | 165 | hle/function_wrappers.h |
| 165 | hle/hle.h | 166 | hle/hle.h |
| 167 | hle/shared_page.h | ||
| 166 | hle/svc.h | 168 | hle/svc.h |
| 167 | hw/gpu.h | 169 | hw/gpu.h |
| 168 | hw/hw.h | 170 | hw/hw.h |
diff --git a/src/core/hle/hle.cpp b/src/core/hle/hle.cpp index 33ac12507..f76048d14 100644 --- a/src/core/hle/hle.cpp +++ b/src/core/hle/hle.cpp | |||
| @@ -6,6 +6,7 @@ | |||
| 6 | 6 | ||
| 7 | #include "core/mem_map.h" | 7 | #include "core/mem_map.h" |
| 8 | #include "core/hle/hle.h" | 8 | #include "core/hle/hle.h" |
| 9 | #include "core/hle/shared_page.h" | ||
| 9 | #include "core/hle/kernel/thread.h" | 10 | #include "core/hle/kernel/thread.h" |
| 10 | #include "core/hle/service/service.h" | 11 | #include "core/hle/service/service.h" |
| 11 | #include "core/hle/service/fs/archive.h" | 12 | #include "core/hle/service/fs/archive.h" |
| @@ -71,6 +72,8 @@ void Init() { | |||
| 71 | 72 | ||
| 72 | RegisterAllModules(); | 73 | RegisterAllModules(); |
| 73 | 74 | ||
| 75 | SharedPage::Init(); | ||
| 76 | |||
| 74 | LOG_DEBUG(Kernel, "initialized OK"); | 77 | LOG_DEBUG(Kernel, "initialized OK"); |
| 75 | } | 78 | } |
| 76 | 79 | ||
diff --git a/src/core/hle/shared_page.cpp b/src/core/hle/shared_page.cpp new file mode 100644 index 000000000..6033a53b4 --- /dev/null +++ b/src/core/hle/shared_page.cpp | |||
| @@ -0,0 +1,80 @@ | |||
| 1 | // Copyright 2015 Citra Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #include "common/common_types.h" | ||
| 6 | #include "common/log.h" | ||
| 7 | |||
| 8 | #include "core/core.h" | ||
| 9 | #include "core/mem_map.h" | ||
| 10 | #include "core/hle/config_mem.h" | ||
| 11 | |||
| 12 | //////////////////////////////////////////////////////////////////////////////////////////////////// | ||
| 13 | |||
| 14 | namespace SharedPage { | ||
| 15 | |||
| 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 | ||
| 24 | |||
| 25 | #pragma pack(1) | ||
| 26 | struct DateTime { | ||
| 27 | u64 date_time; // 0x0 | ||
| 28 | u64 update_tick; // 0x8 | ||
| 29 | INSERT_PADDING_BYTES(0x20 - 0x10); // 0x10 | ||
| 30 | }; | ||
| 31 | |||
| 32 | struct SharedPageDef { | ||
| 33 | // most of these names are taken from the 3dbrew page linked above. | ||
| 34 | u32 date_time_selector; // 0x0 | ||
| 35 | u8 running_hw; // 0x4 | ||
| 36 | u8 mcu_hw_info; // 0x5: don't know what the acronyms mean | ||
| 37 | INSERT_PADDING_BYTES(0x20 - 0x6); // 0x6 | ||
| 38 | DateTime date_time_0; // 0x20 | ||
| 39 | DateTime date_time_1; // 0x40 | ||
| 40 | u8 wifi_macaddr[6]; // 0x60 | ||
| 41 | u8 wifi_unknown1; // 0x66: 3dbrew says these are "Likely wifi hardware related" | ||
| 42 | u8 wifi_unknown2; // 0x67 | ||
| 43 | INSERT_PADDING_BYTES(0x80 - 0x68); // 0x68 | ||
| 44 | float sliderstate_3d; // 0x80 | ||
| 45 | u8 ledstate_3d; // 0x84 | ||
| 46 | INSERT_PADDING_BYTES(0xA0 - 0x85); // 0x85 | ||
| 47 | u64 menu_title_id; // 0xA0 | ||
| 48 | u64 active_menu_title_id; // 0xA8 | ||
| 49 | INSERT_PADDING_BYTES(0x1000 - 0xB0); // 0xB0 | ||
| 50 | }; | ||
| 51 | #pragma pack() | ||
| 52 | |||
| 53 | static_assert(sizeof(DateTime) == 0x20, "Datetime size is wrong"); | ||
| 54 | static_assert(sizeof(SharedPageDef) == Memory::SHARED_PAGE_SIZE, "Shared page structure size is wrong"); | ||
| 55 | |||
| 56 | static SharedPageDef shared_page; | ||
| 57 | |||
| 58 | template <typename T> | ||
| 59 | inline void Read(T &var, const u32 addr) { | ||
| 60 | u32 offset = addr - Memory::SHARED_PAGE_VADDR; | ||
| 61 | var = *(reinterpret_cast<T*>(((uintptr_t)&shared_page) + offset)); | ||
| 62 | } | ||
| 63 | |||
| 64 | // Explicitly instantiate template functions because we aren't defining this in the header: | ||
| 65 | template void Read<u64>(u64 &var, const u32 addr); | ||
| 66 | template void Read<u32>(u32 &var, const u32 addr); | ||
| 67 | template void Read<u16>(u16 &var, const u32 addr); | ||
| 68 | template void Read<u8>(u8 &var, const u32 addr); | ||
| 69 | |||
| 70 | void Set3DSlider(float amount) { | ||
| 71 | shared_page.sliderstate_3d = amount; | ||
| 72 | shared_page.ledstate_3d = (amount == 0.0f); // off when non-zero | ||
| 73 | } | ||
| 74 | |||
| 75 | void Init() { | ||
| 76 | shared_page.running_hw = 0x1; // product | ||
| 77 | Set3DSlider(0.0f); | ||
| 78 | } | ||
| 79 | |||
| 80 | } // namespace | ||
diff --git a/src/core/hle/shared_page.h b/src/core/hle/shared_page.h new file mode 100644 index 000000000..8f93545ec --- /dev/null +++ b/src/core/hle/shared_page.h | |||
| @@ -0,0 +1,26 @@ | |||
| 1 | // Copyright 2015 Citra Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #pragma once | ||
| 6 | |||
| 7 | /** | ||
| 8 | * The shared page stores various runtime configuration settings. This memory page is | ||
| 9 | * read-only for user processes (there is a bit in the header that grants the process | ||
| 10 | * write access, according to 3dbrew; this is not emulated) | ||
| 11 | */ | ||
| 12 | |||
| 13 | #include "common/common_types.h" | ||
| 14 | |||
| 15 | //////////////////////////////////////////////////////////////////////////////////////////////////// | ||
| 16 | |||
| 17 | namespace SharedPage { | ||
| 18 | |||
| 19 | template <typename T> | ||
| 20 | void Read(T &var, const u32 addr); | ||
| 21 | |||
| 22 | void Set3DSlider(float amount); | ||
| 23 | |||
| 24 | void Init(); | ||
| 25 | |||
| 26 | } // namespace | ||
diff --git a/src/core/mem_map_funcs.cpp b/src/core/mem_map_funcs.cpp index 97ef1c5a3..0e3b81b28 100644 --- a/src/core/mem_map_funcs.cpp +++ b/src/core/mem_map_funcs.cpp | |||
| @@ -9,6 +9,7 @@ | |||
| 9 | #include "core/mem_map.h" | 9 | #include "core/mem_map.h" |
| 10 | #include "core/hw/hw.h" | 10 | #include "core/hw/hw.h" |
| 11 | #include "hle/config_mem.h" | 11 | #include "hle/config_mem.h" |
| 12 | #include "hle/shared_page.h" | ||
| 12 | 13 | ||
| 13 | namespace Memory { | 14 | namespace Memory { |
| 14 | 15 | ||
| @@ -82,6 +83,10 @@ inline void Read(T &var, const VAddr vaddr) { | |||
| 82 | } else if ((vaddr >= CONFIG_MEMORY_VADDR) && (vaddr < CONFIG_MEMORY_VADDR_END)) { | 83 | } else if ((vaddr >= CONFIG_MEMORY_VADDR) && (vaddr < CONFIG_MEMORY_VADDR_END)) { |
| 83 | ConfigMem::Read<T>(var, vaddr); | 84 | ConfigMem::Read<T>(var, vaddr); |
| 84 | 85 | ||
| 86 | // Shared page | ||
| 87 | } else if ((vaddr >= SHARED_PAGE_VADDR) && (vaddr < SHARED_PAGE_VADDR_END)) { | ||
| 88 | SharedPage::Read<T>(var, vaddr); | ||
| 89 | |||
| 85 | // DSP memory | 90 | // DSP memory |
| 86 | } else if ((vaddr >= DSP_MEMORY_VADDR) && (vaddr < DSP_MEMORY_VADDR_END)) { | 91 | } else if ((vaddr >= DSP_MEMORY_VADDR) && (vaddr < DSP_MEMORY_VADDR_END)) { |
| 87 | var = *((const T*)&g_dsp_mem[vaddr - DSP_MEMORY_VADDR]); | 92 | var = *((const T*)&g_dsp_mem[vaddr - DSP_MEMORY_VADDR]); |