summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/common/logging/backend.cpp1
-rw-r--r--src/common/logging/log.h1
-rw-r--r--src/core/CMakeLists.txt4
-rw-r--r--src/core/hle/kernel/shared_memory.cpp13
-rw-r--r--src/core/hle/service/hid/hid.cpp15
-rw-r--r--src/core/hle/service/ns/ns.cpp16
-rw-r--r--src/core/hle/service/ns/ns.h16
-rw-r--r--src/core/hle/service/ns/pl_u.cpp111
-rw-r--r--src/core/hle/service/ns/pl_u.h33
-rw-r--r--src/core/hle/service/service.cpp2
10 files changed, 199 insertions, 13 deletions
diff --git a/src/common/logging/backend.cpp b/src/common/logging/backend.cpp
index 2bbc5bb16..8274b2388 100644
--- a/src/common/logging/backend.cpp
+++ b/src/common/logging/backend.cpp
@@ -40,6 +40,7 @@ namespace Log {
40 SUB(Service, HID) \ 40 SUB(Service, HID) \
41 SUB(Service, LM) \ 41 SUB(Service, LM) \
42 SUB(Service, NIFM) \ 42 SUB(Service, NIFM) \
43 SUB(Service, NS) \
43 SUB(Service, NVDRV) \ 44 SUB(Service, NVDRV) \
44 SUB(Service, PCTL) \ 45 SUB(Service, PCTL) \
45 SUB(Service, SET) \ 46 SUB(Service, SET) \
diff --git a/src/common/logging/log.h b/src/common/logging/log.h
index 0d79b8498..69472ef1a 100644
--- a/src/common/logging/log.h
+++ b/src/common/logging/log.h
@@ -57,6 +57,7 @@ enum class Class : ClassType {
57 Service_HID, ///< The HID (Human interface device) service 57 Service_HID, ///< The HID (Human interface device) service
58 Service_LM, ///< The LM (Logger) service 58 Service_LM, ///< The LM (Logger) service
59 Service_NIFM, ///< The NIFM (Network interface) service 59 Service_NIFM, ///< The NIFM (Network interface) service
60 Service_NS, ///< The NS services
60 Service_NVDRV, ///< The NVDRV (Nvidia driver) service 61 Service_NVDRV, ///< The NVDRV (Nvidia driver) service
61 Service_PCTL, ///< The PCTL (Parental control) service 62 Service_PCTL, ///< The PCTL (Parental control) service
62 Service_SET, ///< The SET (Settings) service 63 Service_SET, ///< The SET (Settings) service
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt
index fc6cb67c7..ce68194c5 100644
--- a/src/core/CMakeLists.txt
+++ b/src/core/CMakeLists.txt
@@ -124,6 +124,10 @@ add_library(core STATIC
124 hle/service/nifm/nifm_s.h 124 hle/service/nifm/nifm_s.h
125 hle/service/nifm/nifm_u.cpp 125 hle/service/nifm/nifm_u.cpp
126 hle/service/nifm/nifm_u.h 126 hle/service/nifm/nifm_u.h
127 hle/service/ns/ns.cpp
128 hle/service/ns/ns.h
129 hle/service/ns/pl_u.cpp
130 hle/service/ns/pl_u.h
127 hle/service/nvdrv/devices/nvdevice.h 131 hle/service/nvdrv/devices/nvdevice.h
128 hle/service/nvdrv/devices/nvdisp_disp0.cpp 132 hle/service/nvdrv/devices/nvdisp_disp0.cpp
129 hle/service/nvdrv/devices/nvdisp_disp0.h 133 hle/service/nvdrv/devices/nvdisp_disp0.h
diff --git a/src/core/hle/kernel/shared_memory.cpp b/src/core/hle/kernel/shared_memory.cpp
index 835fc710b..d4505061e 100644
--- a/src/core/hle/kernel/shared_memory.cpp
+++ b/src/core/hle/kernel/shared_memory.cpp
@@ -111,13 +111,6 @@ ResultCode SharedMemory::Map(Process* target_process, VAddr address, MemoryPermi
111 return ERR_INVALID_COMBINATION; 111 return ERR_INVALID_COMBINATION;
112 } 112 }
113 113
114 // Heap-backed memory blocks can not be mapped with other_permissions = DontCare
115 if (base_address != 0 && other_permissions == MemoryPermission::DontCare) {
116 LOG_ERROR(Kernel, "cannot map id=%u, address=0x%llx name=%s, permissions don't match",
117 GetObjectId(), address, name.c_str());
118 return ERR_INVALID_COMBINATION;
119 }
120
121 // Error out if the provided permissions are not compatible with what the creator process needs. 114 // Error out if the provided permissions are not compatible with what the creator process needs.
122 if (other_permissions != MemoryPermission::DontCare && 115 if (other_permissions != MemoryPermission::DontCare &&
123 static_cast<u32>(this->permissions) & ~static_cast<u32>(other_permissions)) { 116 static_cast<u32>(this->permissions) & ~static_cast<u32>(other_permissions)) {
@@ -126,12 +119,6 @@ ResultCode SharedMemory::Map(Process* target_process, VAddr address, MemoryPermi
126 return ERR_WRONG_PERMISSION; 119 return ERR_WRONG_PERMISSION;
127 } 120 }
128 121
129 // TODO(Subv): Check for the Shared Device Mem flag in the creator process.
130 /*if (was_created_with_shared_device_mem && address != 0) {
131 return ResultCode(ErrorDescription::InvalidCombination, ErrorModule::OS,
132 ErrorSummary::InvalidArgument, ErrorLevel::Usage);
133 }*/
134
135 // TODO(Subv): The same process that created a SharedMemory object 122 // TODO(Subv): The same process that created a SharedMemory object
136 // can not map it in its own address space unless it was created with addr=0, result 0xD900182C. 123 // can not map it in its own address space unless it was created with addr=0, result 0xD900182C.
137 124
diff --git a/src/core/hle/service/hid/hid.cpp b/src/core/hle/service/hid/hid.cpp
index d757d2eae..3f1c18505 100644
--- a/src/core/hle/service/hid/hid.cpp
+++ b/src/core/hle/service/hid/hid.cpp
@@ -186,7 +186,9 @@ public:
186 {121, &Hid::GetNpadJoyHoldType, "GetNpadJoyHoldType"}, 186 {121, &Hid::GetNpadJoyHoldType, "GetNpadJoyHoldType"},
187 {124, nullptr, "SetNpadJoyAssignmentModeDual"}, 187 {124, nullptr, "SetNpadJoyAssignmentModeDual"},
188 {128, &Hid::SetNpadHandheldActivationMode, "SetNpadHandheldActivationMode"}, 188 {128, &Hid::SetNpadHandheldActivationMode, "SetNpadHandheldActivationMode"},
189 {200, &Hid::GetVibrationDeviceInfo, "GetVibrationDeviceInfo"},
189 {203, &Hid::CreateActiveVibrationDeviceList, "CreateActiveVibrationDeviceList"}, 190 {203, &Hid::CreateActiveVibrationDeviceList, "CreateActiveVibrationDeviceList"},
191 {206, &Hid::SendVibrationValues, "SendVibrationValues"},
190 }; 192 };
191 RegisterHandlers(functions); 193 RegisterHandlers(functions);
192 194
@@ -272,12 +274,25 @@ private:
272 LOG_WARNING(Service_HID, "(STUBBED) called"); 274 LOG_WARNING(Service_HID, "(STUBBED) called");
273 } 275 }
274 276
277 void GetVibrationDeviceInfo(Kernel::HLERequestContext& ctx) {
278 IPC::ResponseBuilder rb{ctx, 4};
279 rb.Push(RESULT_SUCCESS);
280 rb.Push<u64>(0);
281 LOG_WARNING(Service_HID, "(STUBBED) called");
282 }
283
275 void CreateActiveVibrationDeviceList(Kernel::HLERequestContext& ctx) { 284 void CreateActiveVibrationDeviceList(Kernel::HLERequestContext& ctx) {
276 IPC::ResponseBuilder rb{ctx, 2, 0, 1}; 285 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
277 rb.Push(RESULT_SUCCESS); 286 rb.Push(RESULT_SUCCESS);
278 rb.PushIpcInterface<IActiveVibrationDeviceList>(); 287 rb.PushIpcInterface<IActiveVibrationDeviceList>();
279 LOG_DEBUG(Service_HID, "called"); 288 LOG_DEBUG(Service_HID, "called");
280 } 289 }
290
291 void SendVibrationValues(Kernel::HLERequestContext& ctx) {
292 IPC::ResponseBuilder rb{ctx, 2};
293 rb.Push(RESULT_SUCCESS);
294 LOG_WARNING(Service_HID, "(STUBBED) called");
295 }
281}; 296};
282 297
283void ReloadInputDevices() {} 298void ReloadInputDevices() {}
diff --git a/src/core/hle/service/ns/ns.cpp b/src/core/hle/service/ns/ns.cpp
new file mode 100644
index 000000000..45681c50f
--- /dev/null
+++ b/src/core/hle/service/ns/ns.cpp
@@ -0,0 +1,16 @@
1// Copyright 2018 yuzu emulator team
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#include "core/hle/service/ns/ns.h"
6#include "core/hle/service/ns/pl_u.h"
7
8namespace Service {
9namespace NS {
10
11void InstallInterfaces(SM::ServiceManager& service_manager) {
12 std::make_shared<PL_U>()->InstallAsService(service_manager);
13}
14
15} // namespace NS
16} // namespace Service
diff --git a/src/core/hle/service/ns/ns.h b/src/core/hle/service/ns/ns.h
new file mode 100644
index 000000000..a4b7e3ded
--- /dev/null
+++ b/src/core/hle/service/ns/ns.h
@@ -0,0 +1,16 @@
1// Copyright 2018 yuzu emulator team
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#pragma once
6
7#include "core/hle/service/service.h"
8
9namespace Service {
10namespace NS {
11
12/// Registers all NS services with the specified service manager.
13void InstallInterfaces(SM::ServiceManager& service_manager);
14
15} // namespace NS
16} // namespace Service
diff --git a/src/core/hle/service/ns/pl_u.cpp b/src/core/hle/service/ns/pl_u.cpp
new file mode 100644
index 000000000..cc9d03a7c
--- /dev/null
+++ b/src/core/hle/service/ns/pl_u.cpp
@@ -0,0 +1,111 @@
1// Copyright 2018 yuzu emulator team
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#include "common/common_paths.h"
6#include "common/file_util.h"
7#include "core/hle/ipc_helpers.h"
8#include "core/hle/service/ns/pl_u.h"
9
10namespace Service {
11namespace NS {
12
13struct FontRegion {
14 u32 offset;
15 u32 size;
16};
17
18// The below data is specific to shared font data dumped from Switch on f/w 2.2
19// Virtual address and offsets/sizes likely will vary by dump
20static constexpr VAddr SHARED_FONT_MEM_VADDR{0x00000009d3016000ULL};
21static constexpr u64 SHARED_FONT_MEM_SIZE{0x1100000};
22static constexpr std::array<FontRegion, 6> SHARED_FONT_REGIONS{
23 FontRegion{0x00000008, 0x001fe764}, FontRegion{0x001fe774, 0x00773e58},
24 FontRegion{0x009725d4, 0x0001aca8}, FontRegion{0x0098d284, 0x00369cec},
25 FontRegion{0x00cf6f78, 0x0039b858}, FontRegion{0x010927d8, 0x00019e80},
26};
27
28enum class LoadState : u32 {
29 Loading = 0,
30 Done = 1,
31};
32
33PL_U::PL_U() : ServiceFramework("pl:u") {
34 static const FunctionInfo functions[] = {
35 {1, &PL_U::GetLoadState, "GetLoadState"},
36 {2, &PL_U::GetSize, "GetSize"},
37 {3, &PL_U::GetSharedMemoryAddressOffset, "GetSharedMemoryAddressOffset"},
38 {4, &PL_U::GetSharedMemoryNativeHandle, "GetSharedMemoryNativeHandle"}};
39 RegisterHandlers(functions);
40
41 // Attempt to load shared font data from disk
42 const std::string filepath{FileUtil::GetUserPath(D_SYSDATA_IDX) + SHARED_FONT};
43 FileUtil::CreateFullPath(filepath); // Create path if not already created
44 FileUtil::IOFile file(filepath, "rb");
45
46 if (file.IsOpen()) {
47 // Read shared font data
48 ASSERT(file.GetSize() == SHARED_FONT_MEM_SIZE);
49 shared_font = std::make_shared<std::vector<u8>>(static_cast<size_t>(file.GetSize()));
50 file.ReadBytes(shared_font->data(), shared_font->size());
51 } else {
52 LOG_WARNING(Service_NS, "Unable to load shared font: %s", filepath.c_str());
53 }
54}
55
56void PL_U::GetLoadState(Kernel::HLERequestContext& ctx) {
57 IPC::RequestParser rp{ctx};
58 const u32 font_id{rp.Pop<u32>()};
59
60 LOG_DEBUG(Service_NS, "called, font_id=%d", font_id);
61 IPC::ResponseBuilder rb{ctx, 3};
62 rb.Push(RESULT_SUCCESS);
63 rb.Push<u32>(static_cast<u32>(LoadState::Done));
64}
65
66void PL_U::GetSize(Kernel::HLERequestContext& ctx) {
67 IPC::RequestParser rp{ctx};
68 const u32 font_id{rp.Pop<u32>()};
69
70 LOG_DEBUG(Service_NS, "called, font_id=%d", font_id);
71 IPC::ResponseBuilder rb{ctx, 3};
72 rb.Push(RESULT_SUCCESS);
73 rb.Push<u32>(SHARED_FONT_REGIONS[font_id].size);
74}
75
76void PL_U::GetSharedMemoryAddressOffset(Kernel::HLERequestContext& ctx) {
77 IPC::RequestParser rp{ctx};
78 const u32 font_id{rp.Pop<u32>()};
79
80 LOG_DEBUG(Service_NS, "called, font_id=%d", font_id);
81 IPC::ResponseBuilder rb{ctx, 3};
82 rb.Push(RESULT_SUCCESS);
83 rb.Push<u32>(SHARED_FONT_REGIONS[font_id].offset);
84}
85
86void PL_U::GetSharedMemoryNativeHandle(Kernel::HLERequestContext& ctx) {
87 if (shared_font != nullptr) {
88 // TODO(bunnei): This is a less-than-ideal solution to load a RAM dump of the Switch shared
89 // font data. This (likely) relies on exact address, size, and offsets from the original
90 // dump. In the future, we need to replace this with a more robust solution.
91
92 // Map backing memory for the font data
93 Kernel::g_current_process->vm_manager.MapMemoryBlock(SHARED_FONT_MEM_VADDR, shared_font, 0,
94 SHARED_FONT_MEM_SIZE,
95 Kernel::MemoryState::Shared);
96
97 // Create shared font memory object
98 shared_font_mem = Kernel::SharedMemory::Create(
99 Kernel::g_current_process, SHARED_FONT_MEM_SIZE, Kernel::MemoryPermission::ReadWrite,
100 Kernel::MemoryPermission::Read, SHARED_FONT_MEM_VADDR, Kernel::MemoryRegion::BASE,
101 "PL_U:shared_font_mem");
102 }
103
104 LOG_DEBUG(Service_NS, "called");
105 IPC::ResponseBuilder rb{ctx, 2, 1};
106 rb.Push(RESULT_SUCCESS);
107 rb.PushCopyObjects(shared_font_mem);
108}
109
110} // namespace NS
111} // namespace Service
diff --git a/src/core/hle/service/ns/pl_u.h b/src/core/hle/service/ns/pl_u.h
new file mode 100644
index 000000000..7a4766338
--- /dev/null
+++ b/src/core/hle/service/ns/pl_u.h
@@ -0,0 +1,33 @@
1// Copyright 2018 yuzu emulator team
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#pragma once
6
7#include <memory>
8#include "core/hle/kernel/shared_memory.h"
9#include "core/hle/service/service.h"
10
11namespace Service {
12namespace NS {
13
14class PL_U final : public ServiceFramework<PL_U> {
15public:
16 PL_U();
17 ~PL_U() = default;
18
19private:
20 void GetLoadState(Kernel::HLERequestContext& ctx);
21 void GetSize(Kernel::HLERequestContext& ctx);
22 void GetSharedMemoryAddressOffset(Kernel::HLERequestContext& ctx);
23 void GetSharedMemoryNativeHandle(Kernel::HLERequestContext& ctx);
24
25 /// Handle to shared memory region designated for a shared font
26 Kernel::SharedPtr<Kernel::SharedMemory> shared_font_mem;
27
28 /// Backing memory for the shared font data
29 std::shared_ptr<std::vector<u8>> shared_font;
30};
31
32} // namespace NS
33} // namespace Service
diff --git a/src/core/hle/service/service.cpp b/src/core/hle/service/service.cpp
index 1dd04a12f..5e6d83729 100644
--- a/src/core/hle/service/service.cpp
+++ b/src/core/hle/service/service.cpp
@@ -23,6 +23,7 @@
23#include "core/hle/service/hid/hid.h" 23#include "core/hle/service/hid/hid.h"
24#include "core/hle/service/lm/lm.h" 24#include "core/hle/service/lm/lm.h"
25#include "core/hle/service/nifm/nifm.h" 25#include "core/hle/service/nifm/nifm.h"
26#include "core/hle/service/ns/ns.h"
26#include "core/hle/service/nvdrv/nvdrv.h" 27#include "core/hle/service/nvdrv/nvdrv.h"
27#include "core/hle/service/pctl/pctl.h" 28#include "core/hle/service/pctl/pctl.h"
28#include "core/hle/service/service.h" 29#include "core/hle/service/service.h"
@@ -182,6 +183,7 @@ void Init() {
182 HID::InstallInterfaces(*SM::g_service_manager); 183 HID::InstallInterfaces(*SM::g_service_manager);
183 LM::InstallInterfaces(*SM::g_service_manager); 184 LM::InstallInterfaces(*SM::g_service_manager);
184 NIFM::InstallInterfaces(*SM::g_service_manager); 185 NIFM::InstallInterfaces(*SM::g_service_manager);
186 NS::InstallInterfaces(*SM::g_service_manager);
185 Nvidia::InstallInterfaces(*SM::g_service_manager); 187 Nvidia::InstallInterfaces(*SM::g_service_manager);
186 PCTL::InstallInterfaces(*SM::g_service_manager); 188 PCTL::InstallInterfaces(*SM::g_service_manager);
187 Sockets::InstallInterfaces(*SM::g_service_manager); 189 Sockets::InstallInterfaces(*SM::g_service_manager);