summaryrefslogtreecommitdiff
path: root/src/core/hle
diff options
context:
space:
mode:
authorGravatar Zhuowei Zhang2015-01-01 21:41:34 -0800
committerGravatar Zhuowei Zhang2015-01-15 22:16:13 -0500
commitedb8450420149cc5fa11dfd2fd2c0c3cd20beffa (patch)
tree00f7e56449ae0a64f80b9573a2f2e2ade7457ff5 /src/core/hle
parentMerge pull request #441 from Kingcom/CallStack (diff)
downloadyuzu-edb8450420149cc5fa11dfd2fd2c0c3cd20beffa.tar.gz
yuzu-edb8450420149cc5fa11dfd2fd2c0c3cd20beffa.tar.xz
yuzu-edb8450420149cc5fa11dfd2fd2c0c3cd20beffa.zip
Add some support for the shared page (currently 3d slider is implemented)
Diffstat (limited to 'src/core/hle')
-rw-r--r--src/core/hle/hle.cpp3
-rw-r--r--src/core/hle/shared_page.cpp80
-rw-r--r--src/core/hle/shared_page.h26
3 files changed, 109 insertions, 0 deletions
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
14namespace 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)
26struct DateTime {
27 u64 date_time; // 0x0
28 u64 update_tick; // 0x8
29 INSERT_PADDING_BYTES(0x20 - 0x10); // 0x10
30};
31
32struct 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
53static_assert(sizeof(DateTime) == 0x20, "Datetime size is wrong");
54static_assert(sizeof(SharedPageDef) == Memory::SHARED_PAGE_SIZE, "Shared page structure size is wrong");
55
56static SharedPageDef shared_page;
57
58template <typename T>
59inline 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:
65template void Read<u64>(u64 &var, const u32 addr);
66template void Read<u32>(u32 &var, const u32 addr);
67template void Read<u16>(u16 &var, const u32 addr);
68template void Read<u8>(u8 &var, const u32 addr);
69
70void Set3DSlider(float amount) {
71 shared_page.sliderstate_3d = amount;
72 shared_page.ledstate_3d = (amount == 0.0f); // off when non-zero
73}
74
75void 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
17namespace SharedPage {
18
19template <typename T>
20void Read(T &var, const u32 addr);
21
22void Set3DSlider(float amount);
23
24void Init();
25
26} // namespace