summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar bunnei2018-02-10 01:14:40 -0500
committerGravatar GitHub2018-02-10 01:14:40 -0500
commitb26cdf1fe5e07d161bdb8542744b26c8e50f94c9 (patch)
tree6eab1f6c8f726fca18468ad883a2ca3c010898d0 /src
parentMerge pull request #171 from bunnei/libnx-fixes (diff)
parentfsp_srv: Stub MountSdCard. (diff)
downloadyuzu-b26cdf1fe5e07d161bdb8542744b26c8e50f94c9.tar.gz
yuzu-b26cdf1fe5e07d161bdb8542744b26c8e50f94c9.tar.xz
yuzu-b26cdf1fe5e07d161bdb8542744b26c8e50f94c9.zip
Merge pull request #175 from bunnei/libnx-fixes-2
More fixes for Libnx
Diffstat (limited to 'src')
-rw-r--r--src/core/CMakeLists.txt2
-rw-r--r--src/core/hle/service/apm/apm.cpp56
-rw-r--r--src/core/hle/service/apm/apm.h9
-rw-r--r--src/core/hle/service/apm/interface.cpp66
-rw-r--r--src/core/hle/service/apm/interface.h27
-rw-r--r--src/core/hle/service/filesystem/fsp_srv.cpp8
-rw-r--r--src/core/hle/service/filesystem/fsp_srv.h1
-rw-r--r--src/core/hle/service/nvflinger/buffer_queue.cpp6
-rw-r--r--src/core/hle/service/vi/vi.cpp90
9 files changed, 166 insertions, 99 deletions
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt
index eab08207d..a78d6d888 100644
--- a/src/core/CMakeLists.txt
+++ b/src/core/CMakeLists.txt
@@ -92,6 +92,8 @@ add_library(core STATIC
92 hle/service/aoc/aoc_u.h 92 hle/service/aoc/aoc_u.h
93 hle/service/apm/apm.cpp 93 hle/service/apm/apm.cpp
94 hle/service/apm/apm.h 94 hle/service/apm/apm.h
95 hle/service/apm/interface.cpp
96 hle/service/apm/interface.h
95 hle/service/audio/audio.cpp 97 hle/service/audio/audio.cpp
96 hle/service/audio/audio.h 98 hle/service/audio/audio.h
97 hle/service/audio/audin_u.cpp 99 hle/service/audio/audin_u.cpp
diff --git a/src/core/hle/service/apm/apm.cpp b/src/core/hle/service/apm/apm.cpp
index a7495d0a0..c4b09b435 100644
--- a/src/core/hle/service/apm/apm.cpp
+++ b/src/core/hle/service/apm/apm.cpp
@@ -5,63 +5,15 @@
5#include "common/logging/log.h" 5#include "common/logging/log.h"
6#include "core/hle/ipc_helpers.h" 6#include "core/hle/ipc_helpers.h"
7#include "core/hle/service/apm/apm.h" 7#include "core/hle/service/apm/apm.h"
8#include "core/hle/service/apm/interface.h"
8 9
9namespace Service { 10namespace Service {
10namespace APM { 11namespace APM {
11 12
12void InstallInterfaces(SM::ServiceManager& service_manager) { 13void InstallInterfaces(SM::ServiceManager& service_manager) {
13 std::make_shared<APM>()->InstallAsService(service_manager); 14 auto module_ = std::make_shared<Module>();
14} 15 std::make_shared<APM>(module_, "apm")->InstallAsService(service_manager);
15 16 std::make_shared<APM>(module_, "apm:p")->InstallAsService(service_manager);
16class ISession final : public ServiceFramework<ISession> {
17public:
18 ISession() : ServiceFramework("ISession") {
19 static const FunctionInfo functions[] = {
20 {0, &ISession::SetPerformanceConfiguration, "SetPerformanceConfiguration"},
21 {1, &ISession::GetPerformanceConfiguration, "GetPerformanceConfiguration"},
22 };
23 RegisterHandlers(functions);
24 }
25
26private:
27 void SetPerformanceConfiguration(Kernel::HLERequestContext& ctx) {
28 IPC::RequestParser rp{ctx};
29
30 auto mode = static_cast<PerformanceMode>(rp.Pop<u32>());
31 u32 config = rp.Pop<u32>();
32
33 IPC::ResponseBuilder rb{ctx, 2};
34 rb.Push(RESULT_SUCCESS);
35
36 LOG_WARNING(Service_APM, "(STUBBED) called mode=%u config=%u", static_cast<u32>(mode),
37 config);
38 }
39
40 void GetPerformanceConfiguration(Kernel::HLERequestContext& ctx) {
41 IPC::RequestParser rp{ctx};
42
43 auto mode = static_cast<PerformanceMode>(rp.Pop<u32>());
44
45 IPC::ResponseBuilder rb{ctx, 3};
46 rb.Push(RESULT_SUCCESS);
47 rb.Push<u32>(0); // Performance configuration
48
49 LOG_WARNING(Service_APM, "(STUBBED) called mode=%u", static_cast<u32>(mode));
50 }
51};
52
53APM::APM() : ServiceFramework("apm") {
54 static const FunctionInfo functions[] = {
55 {0x00000000, &APM::OpenSession, "OpenSession"},
56 {0x00000001, nullptr, "GetPerformanceMode"},
57 };
58 RegisterHandlers(functions);
59}
60
61void APM::OpenSession(Kernel::HLERequestContext& ctx) {
62 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
63 rb.Push(RESULT_SUCCESS);
64 rb.PushIpcInterface<ISession>();
65} 17}
66 18
67} // namespace APM 19} // namespace APM
diff --git a/src/core/hle/service/apm/apm.h b/src/core/hle/service/apm/apm.h
index 90a1afbbc..070ab21f8 100644
--- a/src/core/hle/service/apm/apm.h
+++ b/src/core/hle/service/apm/apm.h
@@ -14,13 +14,10 @@ enum class PerformanceMode : u8 {
14 Docked = 1, 14 Docked = 1,
15}; 15};
16 16
17class APM final : public ServiceFramework<APM> { 17class Module final {
18public: 18public:
19 APM(); 19 Module() = default;
20 ~APM() = default; 20 ~Module() = default;
21
22private:
23 void OpenSession(Kernel::HLERequestContext& ctx);
24}; 21};
25 22
26/// Registers all AM services with the specified service manager. 23/// Registers all AM services with the specified service manager.
diff --git a/src/core/hle/service/apm/interface.cpp b/src/core/hle/service/apm/interface.cpp
new file mode 100644
index 000000000..0179351ba
--- /dev/null
+++ b/src/core/hle/service/apm/interface.cpp
@@ -0,0 +1,66 @@
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/logging/log.h"
6#include "core/hle/ipc_helpers.h"
7#include "core/hle/service/apm/apm.h"
8#include "core/hle/service/apm/interface.h"
9
10namespace Service {
11namespace APM {
12
13class ISession final : public ServiceFramework<ISession> {
14public:
15 ISession() : ServiceFramework("ISession") {
16 static const FunctionInfo functions[] = {
17 {0, &ISession::SetPerformanceConfiguration, "SetPerformanceConfiguration"},
18 {1, &ISession::GetPerformanceConfiguration, "GetPerformanceConfiguration"},
19 };
20 RegisterHandlers(functions);
21 }
22
23private:
24 void SetPerformanceConfiguration(Kernel::HLERequestContext& ctx) {
25 IPC::RequestParser rp{ctx};
26
27 auto mode = static_cast<PerformanceMode>(rp.Pop<u32>());
28 u32 config = rp.Pop<u32>();
29
30 IPC::ResponseBuilder rb{ctx, 2};
31 rb.Push(RESULT_SUCCESS);
32
33 LOG_WARNING(Service_APM, "(STUBBED) called mode=%u config=%u", static_cast<u32>(mode),
34 config);
35 }
36
37 void GetPerformanceConfiguration(Kernel::HLERequestContext& ctx) {
38 IPC::RequestParser rp{ctx};
39
40 auto mode = static_cast<PerformanceMode>(rp.Pop<u32>());
41
42 IPC::ResponseBuilder rb{ctx, 3};
43 rb.Push(RESULT_SUCCESS);
44 rb.Push<u32>(0); // Performance configuration
45
46 LOG_WARNING(Service_APM, "(STUBBED) called mode=%u", static_cast<u32>(mode));
47 }
48};
49
50APM::APM(std::shared_ptr<Module> apm, const char* name)
51 : ServiceFramework(name), apm(std::move(apm)) {
52 static const FunctionInfo functions[] = {
53 {0, &APM::OpenSession, "OpenSession"},
54 {1, nullptr, "GetPerformanceMode"},
55 };
56 RegisterHandlers(functions);
57}
58
59void APM::OpenSession(Kernel::HLERequestContext& ctx) {
60 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
61 rb.Push(RESULT_SUCCESS);
62 rb.PushIpcInterface<ISession>();
63}
64
65} // namespace APM
66} // namespace Service
diff --git a/src/core/hle/service/apm/interface.h b/src/core/hle/service/apm/interface.h
new file mode 100644
index 000000000..7d53721de
--- /dev/null
+++ b/src/core/hle/service/apm/interface.h
@@ -0,0 +1,27 @@
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 APM {
11
12class APM final : public ServiceFramework<APM> {
13public:
14 APM(std::shared_ptr<Module> apm, const char* name);
15 ~APM() = default;
16
17private:
18 void OpenSession(Kernel::HLERequestContext& ctx);
19
20 std::shared_ptr<Module> apm;
21};
22
23/// Registers all AM services with the specified service manager.
24void InstallInterfaces(SM::ServiceManager& service_manager);
25
26} // namespace APM
27} // namespace Service
diff --git a/src/core/hle/service/filesystem/fsp_srv.cpp b/src/core/hle/service/filesystem/fsp_srv.cpp
index aa5a3d631..34d4fd035 100644
--- a/src/core/hle/service/filesystem/fsp_srv.cpp
+++ b/src/core/hle/service/filesystem/fsp_srv.cpp
@@ -70,6 +70,7 @@ private:
70FSP_SRV::FSP_SRV() : ServiceFramework("fsp-srv") { 70FSP_SRV::FSP_SRV() : ServiceFramework("fsp-srv") {
71 static const FunctionInfo functions[] = { 71 static const FunctionInfo functions[] = {
72 {1, &FSP_SRV::Initalize, "Initalize"}, 72 {1, &FSP_SRV::Initalize, "Initalize"},
73 {18, &FSP_SRV::MountSdCard, "MountSdCard"},
73 {200, &FSP_SRV::OpenDataStorageByCurrentProcess, "OpenDataStorageByCurrentProcess"}, 74 {200, &FSP_SRV::OpenDataStorageByCurrentProcess, "OpenDataStorageByCurrentProcess"},
74 {202, nullptr, "OpenDataStorageByDataId"}, 75 {202, nullptr, "OpenDataStorageByDataId"},
75 {203, &FSP_SRV::OpenRomStorage, "OpenRomStorage"}, 76 {203, &FSP_SRV::OpenRomStorage, "OpenRomStorage"},
@@ -96,6 +97,13 @@ void FSP_SRV::Initalize(Kernel::HLERequestContext& ctx) {
96 rb.Push(RESULT_SUCCESS); 97 rb.Push(RESULT_SUCCESS);
97} 98}
98 99
100void FSP_SRV::MountSdCard(Kernel::HLERequestContext& ctx) {
101 LOG_WARNING(Service_FS, "(STUBBED) called");
102
103 IPC::ResponseBuilder rb{ctx, 2};
104 rb.Push(RESULT_SUCCESS);
105}
106
99void FSP_SRV::GetGlobalAccessLogMode(Kernel::HLERequestContext& ctx) { 107void FSP_SRV::GetGlobalAccessLogMode(Kernel::HLERequestContext& ctx) {
100 LOG_WARNING(Service_FS, "(STUBBED) called"); 108 LOG_WARNING(Service_FS, "(STUBBED) called");
101 109
diff --git a/src/core/hle/service/filesystem/fsp_srv.h b/src/core/hle/service/filesystem/fsp_srv.h
index 15be8edc1..56afc4b90 100644
--- a/src/core/hle/service/filesystem/fsp_srv.h
+++ b/src/core/hle/service/filesystem/fsp_srv.h
@@ -23,6 +23,7 @@ private:
23 void TryLoadRomFS(); 23 void TryLoadRomFS();
24 24
25 void Initalize(Kernel::HLERequestContext& ctx); 25 void Initalize(Kernel::HLERequestContext& ctx);
26 void MountSdCard(Kernel::HLERequestContext& ctx);
26 void GetGlobalAccessLogMode(Kernel::HLERequestContext& ctx); 27 void GetGlobalAccessLogMode(Kernel::HLERequestContext& ctx);
27 void OpenDataStorageByCurrentProcess(Kernel::HLERequestContext& ctx); 28 void OpenDataStorageByCurrentProcess(Kernel::HLERequestContext& ctx);
28 void OpenRomStorage(Kernel::HLERequestContext& ctx); 29 void OpenRomStorage(Kernel::HLERequestContext& ctx);
diff --git a/src/core/hle/service/nvflinger/buffer_queue.cpp b/src/core/hle/service/nvflinger/buffer_queue.cpp
index c7206a683..f90c7ca51 100644
--- a/src/core/hle/service/nvflinger/buffer_queue.cpp
+++ b/src/core/hle/service/nvflinger/buffer_queue.cpp
@@ -40,7 +40,11 @@ u32 BufferQueue::DequeueBuffer(u32 pixel_format, u32 width, u32 height) {
40 return igbp_buffer.format == pixel_format && igbp_buffer.width == width && 40 return igbp_buffer.format == pixel_format && igbp_buffer.width == width &&
41 igbp_buffer.height == height; 41 igbp_buffer.height == height;
42 }); 42 });
43 ASSERT(itr != queue.end()); 43 if (itr == queue.end()) {
44 LOG_CRITICAL(Service_NVDRV, "no free buffers for pixel_format=%d, width=%d, height=%d",
45 pixel_format, width, height);
46 itr = queue.begin();
47 }
44 48
45 itr->status = Buffer::Status::Dequeued; 49 itr->status = Buffer::Status::Dequeued;
46 return itr->slot; 50 return itr->slot;
diff --git a/src/core/hle/service/vi/vi.cpp b/src/core/hle/service/vi/vi.cpp
index 7508443a8..69ac2fe07 100644
--- a/src/core/hle/service/vi/vi.cpp
+++ b/src/core/hle/service/vi/vi.cpp
@@ -211,7 +211,6 @@ public:
211 void DeserializeData() override { 211 void DeserializeData() override {
212 std::u16string token = ReadInterfaceToken(); 212 std::u16string token = ReadInterfaceToken();
213 data = Read<Data>(); 213 data = Read<Data>();
214 ASSERT(data.graphic_buffer_length == sizeof(NVFlinger::IGBPBuffer));
215 buffer = Read<NVFlinger::IGBPBuffer>(); 214 buffer = Read<NVFlinger::IGBPBuffer>();
216 } 215 }
217 216
@@ -301,14 +300,11 @@ public:
301 300
302protected: 301protected:
303 void SerializeData() override { 302 void SerializeData() override {
304 // TODO(Subv): Find out what this all means 303 // TODO(bunnei): Find out what this all means. Writing anything non-zero here breaks libnx.
305 Write<u32_le>(1); 304 Write<u32_le>(0);
306 305 Write<u32_le>(0);
307 Write<u32_le>(sizeof(NVFlinger::IGBPBuffer)); 306 Write<u32_le>(0);
308 Write<u32_le>(0); // Unknown
309
310 Write(buffer); 307 Write(buffer);
311
312 Write<u32_le>(0); 308 Write<u32_le>(0);
313 } 309 }
314 310
@@ -401,7 +397,7 @@ public:
401 {0, &IHOSBinderDriver::TransactParcel, "TransactParcel"}, 397 {0, &IHOSBinderDriver::TransactParcel, "TransactParcel"},
402 {1, &IHOSBinderDriver::AdjustRefcount, "AdjustRefcount"}, 398 {1, &IHOSBinderDriver::AdjustRefcount, "AdjustRefcount"},
403 {2, &IHOSBinderDriver::GetNativeHandle, "GetNativeHandle"}, 399 {2, &IHOSBinderDriver::GetNativeHandle, "GetNativeHandle"},
404 {3, nullptr, "TransactParcelAuto"}, 400 {3, &IHOSBinderDriver::TransactParcelAuto, "TransactParcelAuto"},
405 }; 401 };
406 RegisterHandlers(functions); 402 RegisterHandlers(functions);
407 } 403 }
@@ -425,35 +421,21 @@ private:
425 SetPreallocatedBuffer = 14 421 SetPreallocatedBuffer = 14
426 }; 422 };
427 423
428 void TransactParcel(Kernel::HLERequestContext& ctx) { 424 void TransactParcel(u32 id, TransactionId transaction, const std::vector<u8>& input_data,
429 IPC::RequestParser rp{ctx}; 425 VAddr output_addr, u64 output_size) {
430 u32 id = rp.Pop<u32>();
431 auto transaction = static_cast<TransactionId>(rp.Pop<u32>());
432 u32 flags = rp.Pop<u32>();
433
434 auto& input_buffer = ctx.BufferDescriptorA()[0];
435 std::vector<u8> input_data(input_buffer.Size());
436 Memory::ReadBlock(input_buffer.Address(), input_data.data(), input_buffer.Size());
437
438 auto& output_buffer = ctx.BufferDescriptorB()[0];
439
440 auto buffer_queue = nv_flinger->GetBufferQueue(id); 426 auto buffer_queue = nv_flinger->GetBufferQueue(id);
441 LOG_WARNING(Service_VI, "(STUBBED) called, transaction=%x", transaction); 427 std::vector<u8> response_buffer;
442 if (transaction == TransactionId::Connect) { 428 if (transaction == TransactionId::Connect) {
443 IGBPConnectRequestParcel request{input_data}; 429 IGBPConnectRequestParcel request{input_data};
444 IGBPConnectResponseParcel response{1280, 720}; 430 IGBPConnectResponseParcel response{1280, 720};
445 auto response_buffer = response.Serialize(); 431 response_buffer = response.Serialize();
446 Memory::WriteBlock(output_buffer.Address(), response_buffer.data(),
447 output_buffer.Size());
448 } else if (transaction == TransactionId::SetPreallocatedBuffer) { 432 } else if (transaction == TransactionId::SetPreallocatedBuffer) {
449 IGBPSetPreallocatedBufferRequestParcel request{input_data}; 433 IGBPSetPreallocatedBufferRequestParcel request{input_data};
450 434
451 buffer_queue->SetPreallocatedBuffer(request.data.slot, request.buffer); 435 buffer_queue->SetPreallocatedBuffer(request.data.slot, request.buffer);
452 436
453 IGBPSetPreallocatedBufferResponseParcel response{}; 437 IGBPSetPreallocatedBufferResponseParcel response{};
454 auto response_buffer = response.Serialize(); 438 response_buffer = response.Serialize();
455 Memory::WriteBlock(output_buffer.Address(), response_buffer.data(),
456 output_buffer.Size());
457 } else if (transaction == TransactionId::DequeueBuffer) { 439 } else if (transaction == TransactionId::DequeueBuffer) {
458 IGBPDequeueBufferRequestParcel request{input_data}; 440 IGBPDequeueBufferRequestParcel request{input_data};
459 441
@@ -461,27 +443,21 @@ private:
461 request.data.height); 443 request.data.height);
462 444
463 IGBPDequeueBufferResponseParcel response{slot}; 445 IGBPDequeueBufferResponseParcel response{slot};
464 auto response_buffer = response.Serialize(); 446 response_buffer = response.Serialize();
465 Memory::WriteBlock(output_buffer.Address(), response_buffer.data(),
466 output_buffer.Size());
467 } else if (transaction == TransactionId::RequestBuffer) { 447 } else if (transaction == TransactionId::RequestBuffer) {
468 IGBPRequestBufferRequestParcel request{input_data}; 448 IGBPRequestBufferRequestParcel request{input_data};
469 449
470 auto& buffer = buffer_queue->RequestBuffer(request.slot); 450 auto& buffer = buffer_queue->RequestBuffer(request.slot);
471 451
472 IGBPRequestBufferResponseParcel response{buffer}; 452 IGBPRequestBufferResponseParcel response{buffer};
473 auto response_buffer = response.Serialize(); 453 response_buffer = response.Serialize();
474 Memory::WriteBlock(output_buffer.Address(), response_buffer.data(),
475 output_buffer.Size());
476 } else if (transaction == TransactionId::QueueBuffer) { 454 } else if (transaction == TransactionId::QueueBuffer) {
477 IGBPQueueBufferRequestParcel request{input_data}; 455 IGBPQueueBufferRequestParcel request{input_data};
478 456
479 buffer_queue->QueueBuffer(request.data.slot); 457 buffer_queue->QueueBuffer(request.data.slot);
480 458
481 IGBPQueueBufferResponseParcel response{1280, 720}; 459 IGBPQueueBufferResponseParcel response{1280, 720};
482 auto response_buffer = response.Serialize(); 460 response_buffer = response.Serialize();
483 Memory::WriteBlock(output_buffer.Address(), response_buffer.data(),
484 output_buffer.Size());
485 } else if (transaction == TransactionId::Query) { 461 } else if (transaction == TransactionId::Query) {
486 IGBPQueryRequestParcel request{input_data}; 462 IGBPQueryRequestParcel request{input_data};
487 463
@@ -489,13 +465,47 @@ private:
489 buffer_queue->Query(static_cast<NVFlinger::BufferQueue::QueryType>(request.type)); 465 buffer_queue->Query(static_cast<NVFlinger::BufferQueue::QueryType>(request.type));
490 466
491 IGBPQueryResponseParcel response{value}; 467 IGBPQueryResponseParcel response{value};
492 auto response_buffer = response.Serialize(); 468 response_buffer = response.Serialize();
493 Memory::WriteBlock(output_buffer.Address(), response_buffer.data(), 469
494 output_buffer.Size());
495 } else { 470 } else {
496 ASSERT_MSG(false, "Unimplemented"); 471 ASSERT_MSG(false, "Unimplemented");
497 } 472 }
498 473
474 Memory::WriteBlock(output_addr, response_buffer.data(), output_size);
475 }
476
477 void TransactParcel(Kernel::HLERequestContext& ctx) {
478 IPC::RequestParser rp{ctx};
479 u32 id = rp.Pop<u32>();
480 auto transaction = static_cast<TransactionId>(rp.Pop<u32>());
481 u32 flags = rp.Pop<u32>();
482 LOG_DEBUG(Service_VI, "called, transaction=%x", transaction);
483
484 auto& input_buffer = ctx.BufferDescriptorA()[0];
485 auto& output_buffer = ctx.BufferDescriptorB()[0];
486 std::vector<u8> input_data(input_buffer.Size());
487 Memory::ReadBlock(input_buffer.Address(), input_data.data(), input_buffer.Size());
488
489 TransactParcel(id, transaction, input_data, output_buffer.Address(), output_buffer.Size());
490
491 IPC::ResponseBuilder rb{ctx, 2};
492 rb.Push(RESULT_SUCCESS);
493 }
494
495 void TransactParcelAuto(Kernel::HLERequestContext& ctx) {
496 IPC::RequestParser rp{ctx};
497 u32 id = rp.Pop<u32>();
498 auto transaction = static_cast<TransactionId>(rp.Pop<u32>());
499 u32 flags = rp.Pop<u32>();
500 LOG_DEBUG(Service_VI, "called, transaction=%x", transaction);
501
502 auto& input_buffer = ctx.BufferDescriptorX()[0];
503 auto& output_buffer = ctx.BufferDescriptorC()[0];
504 std::vector<u8> input_data(input_buffer.size);
505 Memory::ReadBlock(input_buffer.Address(), input_data.data(), input_buffer.size);
506
507 TransactParcel(id, transaction, input_data, output_buffer.Address(), output_buffer.Size());
508
499 IPC::ResponseBuilder rb{ctx, 2}; 509 IPC::ResponseBuilder rb{ctx, 2};
500 rb.Push(RESULT_SUCCESS); 510 rb.Push(RESULT_SUCCESS);
501 } 511 }