diff options
Diffstat (limited to 'src/core/hle/shared_page.cpp')
| -rw-r--r-- | src/core/hle/shared_page.cpp | 80 |
1 files changed, 80 insertions, 0 deletions
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 | ||